Compare commits

...

5 commits

6 changed files with 36 additions and 34 deletions

View file

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

View file

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

View file

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

View file

@ -336,23 +336,20 @@ public class ClientEvents {
stack.popPose(); stack.popPose();
if (!ClientEvents.heldOcular.isEmpty()) { if (!ClientEvents.heldOcular.isEmpty()) {
var scale = 0.75F;
stack.pushPose(); stack.pushPose();
stack.scale(scale, scale, scale); //stack.scale(scale, scale, scale);
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22; 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 : ClientEvents.SHOWING_EFFECTS.values()) { for (var effect : ClientEvents.SHOWING_EFFECTS.values()) {
var theX = (int) (stackX / scale);
var theY = (int) (stackY / scale);
var itemStack = effect.getA(); var itemStack = effect.getA();
Helper.renderItemInGui(itemStack, theX, theY, 1F); Helper.renderItemInGui(itemStack, stackX, stackY, 1F);
if (effect.getB()) { if (effect.getB()) {
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); RenderSystem.setShaderTexture(0, ClientEvents.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(); RenderSystem.enableDepthTest();
} }
stackY += 8; stackY += 12;
} }
stack.popPose(); stack.popPose();
} }

View file

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

View file

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