Compare commits

..

5 commits

6 changed files with 37 additions and 35 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '36.2'
version = '36.3'
group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'NaturesAura'

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.api.misc.WeatherType;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
@ -52,7 +53,7 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka
if (this.processTime > 0) {
if (this.processTime % 20 == 0) {
var spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * this.itemAmount);
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * Mth.ceil(this.itemAmount * 0.75F));
}
this.processTime--;

View file

@ -62,8 +62,8 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
@Override
public void onRemovedFromWorld() {
super.onRemovedFromWorld();
this.setInhibitedEffect(null);
this.updatePowderListStatus();
// we pass a null effect because we want to remove our effect from the world
this.updatePowderListStatus(null);
}
@Override
@ -92,7 +92,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
super.tick();
if (this.powderListDirty)
this.updatePowderListStatus();
this.updatePowderListStatus(this.getInhibitedEffect());
if (this.level.isClientSide) {
if (this.level.getGameTime() % 5 == 0) {
@ -199,18 +199,17 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
return this.getColor();
}
private void updatePowderListStatus() {
private void updatePowderListStatus(ResourceLocation inhibitedEffect) {
var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders;
if (this.lastEffect != null) {
var oldList = powders.get(this.lastEffect);
oldList.removeIf(t -> this.getEyePosition().equals(t.getA()));
}
var effect = this.getInhibitedEffect();
if (effect != null) {
var newList = powders.get(effect);
if (inhibitedEffect != null) {
var newList = powders.get(inhibitedEffect);
newList.add(new Tuple<>(this.getEyePosition(), this.getAmount()));
}
this.powderListDirty = false;
this.lastEffect = effect;
this.lastEffect = inhibitedEffect;
}
}

View file

@ -326,23 +326,20 @@ public class ClientEvents {
stack.popPose();
if (!heldOcular.isEmpty()) {
var scale = 0.75F;
stack.pushPose();
stack.scale(scale, scale, scale);
//stack.scale(scale, scale, scale);
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55;
var stackY = conf < 2 ? 10 : res.getGuiScaledHeight() - 60;
for (var effect : SHOWING_EFFECTS.values()) {
var theX = (int) (stackX / scale);
var theY = (int) (stackY / scale);
var itemStack = effect.getA();
Helper.renderItemInGui(itemStack, theX, theY, 1F);
Helper.renderItemInGui(itemStack, stackX, stackY, 1F);
if (effect.getB()) {
RenderSystem.disableDepthTest();
RenderSystem.setShaderTexture(0, OVERLAYS);
Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
Screen.blit(stack, stackX, stackY, 240, 0, 16, 16, 256, 256);
RenderSystem.enableDepthTest();
}
stackY += 8;
stackY += 12;
}
stack.popPose();
}

View file

@ -2,8 +2,9 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
import de.ellpeck.naturesaura.entities.ModEntities;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
@ -15,13 +16,13 @@ import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
public class ItemStructureFinder extends ItemImpl {
private final Holder<ConfiguredStructureFeature<?, ?>> structureName;
private final ResourceKey<ConfiguredStructureFeature<?, ?>> structure;
private final int color;
private final int radius;
public ItemStructureFinder(String baseName, Holder<ConfiguredStructureFeature<?, ?>> structureName, int color, int radius) {
public ItemStructureFinder(String baseName, ResourceKey<ConfiguredStructureFeature<?, ?>> structure, int color, int radius) {
super(baseName);
this.structureName = structureName;
this.structure = structure;
this.color = color;
this.radius = radius;
}
@ -30,17 +31,20 @@ public class ItemStructureFinder extends ItemImpl {
public InteractionResultHolder<ItemStack> use(Level levelIn, Player playerIn, InteractionHand handIn) {
var stack = playerIn.getItemInHand(handIn);
if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) {
var holderSet = HolderSet.direct(this.structureName);
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false);
if (pos != null) {
var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());
entity.setItem(stack);
entity.getEntityData().set(EntityStructureFinder.COLOR, this.color);
entity.signalTo(pos.getFirst().above(64));
levelIn.addFreshEntity(entity);
var registry = levelIn.registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY);
var holderSet = registry.getHolder(this.structure).map(HolderSet::direct).orElse(null);
if (holderSet != null) {
var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false);
if (pos != null) {
var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn);
entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ());
entity.setItem(stack);
entity.getEntityData().set(EntityStructureFinder.COLOR, this.color);
entity.signalTo(pos.getFirst().above(64));
levelIn.addFreshEntity(entity);
stack.shrink(1);
stack.shrink(1);
}
}
}
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);

View file

@ -48,6 +48,7 @@ import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.extensions.IForgeMenuType;
@ -219,9 +220,9 @@ public final class ModRegistry {
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST),
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS),
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET),
new ItemStructureFinder("fortress_finder", StructureFeatures.FORTRESS, 0xba2800, 1024),
new ItemStructureFinder("end_city_finder", StructureFeatures.END_CITY, 0xca5cd6, 1024),
new ItemStructureFinder("outpost_finder", StructureFeatures.PILLAGER_OUTPOST, 0xab9f98, 2048),
new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024),
new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024),
new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048),
new ItemBreakPrevention(),
new ItemPetReviver(),
new ItemNetheriteFinder()