From cd328cab6ae666349ba387f74aaabe9798806002 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 4 Dec 2021 15:40:09 +0100 Subject: [PATCH] some more work?? --- README.md | 2 +- .../java/de/ellpeck/naturesaura/Helper.java | 78 +-- .../de/ellpeck/naturesaura/InternalHooks.java | 50 +- .../de/ellpeck/naturesaura/ModConfig.java | 12 +- .../de/ellpeck/naturesaura/NaturesAura.java | 4 +- .../naturesaura/api/NaturesAuraAPI.java | 132 ++-- .../api/aura/chunk/IAuraChunk.java | 85 ++- .../api/aura/chunk/IDrainSpotEffect.java | 18 +- .../aura/container/BasicAuraContainer.java | 6 +- .../api/aura/container/ItemAuraContainer.java | 4 +- .../api/aura/type/BasicAuraType.java | 15 +- .../naturesaura/api/aura/type/IAuraType.java | 10 +- .../naturesaura/api/misc/ILevelData.java | 25 + .../naturesaura/api/misc/IWorldData.java | 25 - .../api/multiblock/IMultiblock.java | 8 +- .../naturesaura/api/multiblock/Matcher.java | 6 +- .../naturesaura/api/render/ITrinketItem.java | 4 +- .../naturesaura/api/render/IVisualizable.java | 6 +- .../blocks/BlockAncientLeaves.java | 46 +- .../blocks/BlockAncientSapling.java | 34 +- .../blocks/BlockAnimalContainer.java | 22 +- .../blocks/BlockAnimalGenerator.java | 28 +- .../blocks/BlockAnimalSpawner.java | 4 +- .../naturesaura/blocks/BlockAuraBloom.java | 28 +- .../naturesaura/blocks/BlockAuraDetector.java | 16 +- .../naturesaura/blocks/BlockAuraTimer.java | 36 +- .../naturesaura/blocks/BlockAutoCrafter.java | 4 +- .../blocks/BlockBlastFurnaceBooster.java | 12 +- .../naturesaura/blocks/BlockCatalyst.java | 4 +- .../blocks/BlockChorusGenerator.java | 4 +- .../naturesaura/blocks/BlockChunkLoader.java | 40 +- .../blocks/BlockContainerImpl.java | 100 +-- .../blocks/BlockDecayedLeaves.java | 12 +- .../blocks/BlockDimensionRail.java | 74 +-- .../naturesaura/blocks/BlockEndFlower.java | 60 +- .../naturesaura/blocks/BlockEnderCrate.java | 62 +- .../naturesaura/blocks/BlockFieldCreator.java | 44 +- .../blocks/BlockFireworkGenerator.java | 10 +- .../blocks/BlockFlowerGenerator.java | 10 +- .../blocks/BlockFurnaceHeater.java | 18 +- .../blocks/BlockGeneratorLimitRemover.java | 14 +- .../naturesaura/blocks/BlockGoldPowder.java | 110 ++-- .../naturesaura/blocks/BlockGoldenLeaves.java | 34 +- .../naturesaura/blocks/BlockGratedChute.java | 66 +- .../blocks/BlockHopperUpgrade.java | 10 +- .../ellpeck/naturesaura/blocks/BlockImpl.java | 2 +- .../blocks/BlockItemDistributor.java | 28 +- .../naturesaura/blocks/BlockLight.java | 8 +- .../blocks/BlockMossGenerator.java | 10 +- .../naturesaura/blocks/BlockNatureAltar.java | 44 +- .../naturesaura/blocks/BlockNetherGrass.java | 32 +- .../naturesaura/blocks/BlockOakGenerator.java | 26 +- .../blocks/BlockOfferingTable.java | 30 +- .../blocks/BlockPickupStopper.java | 32 +- .../naturesaura/blocks/BlockPlacer.java | 10 +- .../blocks/BlockPotionGenerator.java | 4 +- .../naturesaura/blocks/BlockPowderPlacer.java | 12 +- .../blocks/BlockProjectileGenerator.java | 38 +- .../naturesaura/blocks/BlockRFConverter.java | 4 +- .../blocks/BlockSlimeSplitGenerator.java | 18 +- .../naturesaura/blocks/BlockSnowCreator.java | 18 +- .../naturesaura/blocks/BlockSpawnLamp.java | 50 +- .../naturesaura/blocks/BlockSpring.java | 26 +- .../naturesaura/blocks/BlockTimeChanger.java | 4 +- .../blocks/BlockWeatherChanger.java | 4 +- .../naturesaura/blocks/BlockWoodStand.java | 56 +- .../ellpeck/naturesaura/blocks/ModBlocks.java | 2 +- .../naturesaura/blocks/multi/Multiblock.java | 10 +- .../naturesaura/blocks/multi/Multiblocks.java | 10 +- ...ves.java => BlockEntityAncientLeaves.java} | 16 +- .../blocks/tiles/ItemStackHandlerNA.java | 6 +- .../blocks/tiles/ModTileEntities.java | 79 +-- .../tiles/TileEntityAnimalContainer.java | 34 +- .../tiles/TileEntityAnimalGenerator.java | 14 +- .../blocks/tiles/TileEntityAnimalSpawner.java | 74 +-- .../blocks/tiles/TileEntityAuraBloom.java | 18 +- .../blocks/tiles/TileEntityAuraDetector.java | 12 +- .../blocks/tiles/TileEntityAuraTimer.java | 32 +- .../blocks/tiles/TileEntityAutoCrafter.java | 36 +- .../tiles/TileEntityBlastFurnaceBooster.java | 40 +- .../tiles/TileEntityChorusGenerator.java | 32 +- .../blocks/tiles/TileEntityChunkLoader.java | 38 +- .../blocks/tiles/TileEntityEndFlower.java | 46 +- .../blocks/tiles/TileEntityEnderCrate.java | 30 +- .../blocks/tiles/TileEntityFieldCreator.java | 82 +-- .../tiles/TileEntityFireworkGenerator.java | 38 +- .../tiles/TileEntityFlowerGenerator.java | 52 +- .../blocks/tiles/TileEntityFurnaceHeater.java | 60 +- .../TileEntityGeneratorLimitRemover.java | 6 +- .../blocks/tiles/TileEntityGratedChute.java | 34 +- .../blocks/tiles/TileEntityHopperUpgrade.java | 36 +- .../blocks/tiles/TileEntityImpl.java | 110 ++-- .../tiles/TileEntityItemDistributor.java | 22 +- .../blocks/tiles/TileEntityMossGenerator.java | 30 +- .../blocks/tiles/TileEntityNatureAltar.java | 82 +-- .../blocks/tiles/TileEntityOakGenerator.java | 14 +- .../blocks/tiles/TileEntityOfferingTable.java | 46 +- .../blocks/tiles/TileEntityPickupStopper.java | 6 +- .../blocks/tiles/TileEntityPlacer.java | 38 +- .../tiles/TileEntityPotionGenerator.java | 16 +- .../blocks/tiles/TileEntityPowderPlacer.java | 14 +- .../tiles/TileEntityProjectileGenerator.java | 10 +- .../blocks/tiles/TileEntityRFConverter.java | 34 +- .../tiles/TileEntitySlimeSplitGenerator.java | 20 +- .../blocks/tiles/TileEntitySnowCreator.java | 66 +- .../blocks/tiles/TileEntitySpawnLamp.java | 18 +- .../blocks/tiles/TileEntitySpring.java | 64 +- .../blocks/tiles/TileEntityTimeChanger.java | 64 +- .../tiles/TileEntityWeatherChanger.java | 46 +- .../blocks/tiles/TileEntityWoodStand.java | 84 +-- .../blocks/tiles/render/RenderAuraTimer.java | 12 +- .../blocks/tiles/render/RenderEnderCrate.java | 12 +- .../render/RenderGeneratorLimitRemover.java | 20 +- .../tiles/render/RenderNatureAltar.java | 12 +- .../tiles/render/RenderOfferingTable.java | 12 +- .../render/RenderProjectileGenerator.java | 12 +- .../blocks/tiles/render/RenderWoodStand.java | 12 +- .../ellpeck/naturesaura/chunk/AuraChunk.java | 64 +- .../naturesaura/chunk/AuraChunkProvider.java | 12 +- .../naturesaura/chunk/effect/AngerEffect.java | 24 +- .../chunk/effect/AnimalEffect.java | 60 +- .../chunk/effect/BalanceEffect.java | 14 +- .../chunk/effect/BreathlessEffect.java | 22 +- .../chunk/effect/CacheRechargeEffect.java | 26 +- .../chunk/effect/ExplosionEffect.java | 36 +- .../chunk/effect/GrassDieEffect.java | 32 +- .../chunk/effect/NetherDecayEffect.java | 42 +- .../chunk/effect/NetherGrassEffect.java | 46 +- .../chunk/effect/OreSpawnEffect.java | 50 +- .../chunk/effect/PlantBoostEffect.java | 50 +- .../chunk/effect/ReplenishingEffect.java | 14 +- .../chunk/effect/SpreadEffect.java | 18 +- .../naturesaura/commands/CommandAura.java | 12 +- .../naturesaura/compat/CuriosCompat.java | 2 +- .../EnchantibilityAuraMending.java | 6 +- .../compat/jei/AnimalSpawnerCategory.java | 2 +- .../compat/jei/JEINaturesAuraPlugin.java | 2 +- .../compat/patchouli/PatchouliCompat.java | 2 +- .../entities/EntityEffectInhibitor.java | 54 +- .../entities/EntityLightProjectile.java | 18 +- .../entities/EntityMoverMinecart.java | 44 +- .../entities/EntityStructureFinder.java | 26 +- .../naturesaura/events/ClientEvents.java | 120 ++-- .../naturesaura/events/CommonEvents.java | 64 +- .../ellpeck/naturesaura/gen/ModFeatures.java | 6 +- .../naturesaura/gen/WorldGenAncientTree.java | 48 +- .../naturesaura/gen/WorldGenAuraBloom.java | 40 +- .../gen/WorldGenNetherWartMushroom.java | 36 +- .../naturesaura/gui/ContainerEnderCrate.java | 8 +- .../naturesaura/gui/GuiEnderCrate.java | 4 +- .../naturesaura/items/ItemAuraBottle.java | 36 +- .../naturesaura/items/ItemAuraCache.java | 16 +- .../naturesaura/items/ItemBirthSpirit.java | 14 +- .../items/ItemBreakPrevention.java | 4 +- .../naturesaura/items/ItemCaveFinder.java | 30 +- .../naturesaura/items/ItemColorChanger.java | 40 +- .../naturesaura/items/ItemCrimsonMeal.java | 44 +- .../naturesaura/items/ItemDeathRing.java | 12 +- .../naturesaura/items/ItemEffectPowder.java | 14 +- .../naturesaura/items/ItemEnderAccess.java | 28 +- .../de/ellpeck/naturesaura/items/ItemEye.java | 4 +- .../naturesaura/items/ItemGoldFiber.java | 12 +- .../naturesaura/items/ItemLightStaff.java | 16 +- .../naturesaura/items/ItemLootFinder.java | 22 +- .../naturesaura/items/ItemMoverMinecart.java | 20 +- .../items/ItemMultiblockMaker.java | 28 +- .../items/ItemNetheriteFinder.java | 16 +- .../naturesaura/items/ItemPetReviver.java | 62 +- .../items/ItemRangeVisualizer.java | 34 +- .../items/ItemShockwaveCreator.java | 34 +- .../items/ItemStructureFinder.java | 24 +- .../naturesaura/items/tools/ItemArmor.java | 12 +- .../naturesaura/items/tools/ItemAxe.java | 14 +- .../naturesaura/items/tools/ItemHoe.java | 38 +- .../naturesaura/items/tools/ItemPickaxe.java | 46 +- .../naturesaura/items/tools/ItemShovel.java | 46 +- .../naturesaura/items/tools/ItemSword.java | 4 +- .../ellpeck/naturesaura/misc/WorldData.java | 25 +- .../naturesaura/packet/PacketAuraChunk.java | 19 +- .../naturesaura/packet/PacketClient.java | 12 +- .../naturesaura/packet/PacketHandler.java | 27 +- .../packet/PacketParticleStream.java | 8 +- .../naturesaura/packet/PacketParticles.java | 582 +++++++++--------- .../particles/ParticleHandler.java | 6 +- .../naturesaura/particles/ParticleMagic.java | 8 +- .../naturesaura/proxy/ClientProxy.java | 18 +- .../recipes/AnimalSpawnerRecipe.java | 10 +- .../naturesaura/recipes/ModRecipe.java | 4 +- .../naturesaura/recipes/ModRecipes.java | 6 +- .../de/ellpeck/naturesaura/reg/IModItem.java | 4 +- .../naturesaura/reg/ITESRProvider.java | 12 +- .../ellpeck/naturesaura/reg/ModRegistry.java | 66 +- .../ellpeck/naturesaura/reg/ModTileType.java | 19 +- .../renderers/PlayerLayerTrinkets.java | 14 +- .../renderers/SupporterFancyHandler.java | 12 +- 195 files changed, 3046 insertions(+), 3041 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java delete mode 100644 src/main/java/de/ellpeck/naturesaura/api/misc/IWorldData.java rename src/main/java/de/ellpeck/naturesaura/blocks/tiles/{TileEntityAncientLeaves.java => BlockEntityAncientLeaves.java} (68%) diff --git a/README.md b/README.md index 663649ee..80faa46a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # NaturesAura Nature's Aura is a mod about collecting, using and replenishing the Aura -naturally present in the world to create useful devices and unique mechanics. +naturally present in the level to create useful devices and unique mechanics. ## Maven diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 302cc913..cf4df498 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -5,34 +5,34 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; -import de.ellpeck.naturesaura.api.misc.IWorldData; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import de.ellpeck.naturesaura.api.misc.ILevelData; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.compat.Compat; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.misc.LevelData; import net.minecraft.advancements.Advancement; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemFrameEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.Player; +import net.minecraft.entity.player.ServerPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.INBT; import net.minecraft.state.Property; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.ILevel; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.AbstractChunkProvider; +import net.minecraft.level.chunk.Chunk; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -61,14 +61,14 @@ import java.util.function.Predicate; public final class Helper { - public static boolean getTileEntitiesInArea(IWorld world, BlockPos pos, int radius, Function consumer) { + public static boolean getTileEntitiesInArea(ILevel level, BlockPos pos, int radius, Function consumer) { for (int x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) { for (int z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) { - Chunk chunk = getLoadedChunk(world, x, z); + Chunk chunk = getLoadedChunk(level, x, z); if (chunk != null) { for (BlockPos tilePos : chunk.getTileEntitiesPos()) { if (tilePos.distanceSq(pos) <= radius * radius) - if (consumer.apply(chunk.getTileEntity(tilePos))) + if (consumer.apply(chunk.getBlockEntity(tilePos))) return true; } } @@ -77,8 +77,8 @@ public final class Helper { return false; } - public static void getAuraChunksWithSpotsInArea(World world, BlockPos pos, int radius, Consumer consumer) { - WorldData data = (WorldData) IWorldData.getWorldData(world); + public static void getAuraChunksWithSpotsInArea(Level level, BlockPos pos, int radius, Consumer consumer) { + LevelData data = (LevelData) ILevelData.getLevelData(level); for (int x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) { for (int z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) { AuraChunk chunk = data.auraChunksWithSpots.get(ChunkPos.asLong(x, z)); @@ -88,8 +88,8 @@ public final class Helper { } } - public static List getAttachedItemFrames(World world, BlockPos pos) { - List frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25)); + public static List getAttachedItemFrames(Level level, BlockPos pos) { + List frames = level.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25)); for (int i = frames.size() - 1; i >= 0; i--) { ItemFrameEntity frame = frames.get(i); BlockPos framePos = frame.getHangingPosition().offset(frame.getHorizontalFacing().getOpposite()); @@ -99,10 +99,10 @@ public final class Helper { return frames; } - public static Chunk getLoadedChunk(IWorld world, int x, int z) { + public static Chunk getLoadedChunk(ILevel level, int x, int z) { // DO NOT EDIT PLEASE FOR THE LOVE OF GOD // This is very finicky and easily causes the game to hang for some reason - AbstractChunkProvider provider = world.getChunkProvider(); + AbstractChunkProvider provider = level.getChunkProvider(); if (provider.isChunkLoaded(new ChunkPos(x, z))) return provider.getChunk(x, z, false); return null; @@ -135,41 +135,41 @@ public final class Helper { RenderSystem.popMatrix(); } - public static ActionResultType putStackOnTile(PlayerEntity player, Hand hand, BlockPos pos, int slot, boolean sound) { - TileEntity tile = player.world.getTileEntity(pos); - if (tile instanceof TileEntityImpl) { - IItemHandlerModifiable handler = ((TileEntityImpl) tile).getItemHandler(); + public static InteractionResult putStackOnTile(Player player, Hand hand, BlockPos pos, int slot, boolean sound) { + BlockEntity tile = player.level.getBlockEntity(pos); + if (tile instanceof BlockEntityImpl) { + IItemHandlerModifiable handler = ((BlockEntityImpl) tile).getItemHandler(); if (handler != null) { ItemStack handStack = player.getHeldItem(hand); if (!handStack.isEmpty()) { - ItemStack remain = handler.insertItem(slot, handStack, player.world.isRemote); + ItemStack remain = handler.insertItem(slot, handStack, player.level.isClientSide); if (!ItemStack.areItemStacksEqual(remain, handStack)) { if (sound) - player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.PLAYERS, 0.75F, 1F); - if (!player.world.isRemote) + if (!player.level.isClientSide) player.setHeldItem(hand, remain); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } if (!handler.getStackInSlot(slot).isEmpty()) { if (sound) - player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ENTITY_ITEM_FRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 0.75F, 1F); - if (!player.world.isRemote) { + if (!player.level.isClientSide) { ItemStack stack = handler.getStackInSlot(slot); if (!player.addItemStackToInventory(stack)) { - ItemEntity item = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), stack); - player.world.addEntity(item); + ItemEntity item = new ItemEntity(player.level, player.getPosX(), player.getPosY(), player.getPosZ(), stack); + player.level.addEntity(item); } handler.setStackInSlot(slot, ItemStack.EMPTY); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } } - return ActionResultType.CONSUME; + return InteractionResult.CONSUME; } public static ICapabilityProvider makeRechargeProvider(ItemStack stack, boolean needsSelected) { @@ -244,11 +244,11 @@ public final class Helper { }, () -> null); } - public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) { - if (!(player instanceof ServerPlayerEntity)) + public static void addAdvancement(Player player, ResourceLocation advancement, String criterion) { + if (!(player instanceof ServerPlayer)) return; - ServerPlayerEntity playerMp = (ServerPlayerEntity) player; - Advancement adv = playerMp.getServerWorld().getServer().getAdvancementManager().getAdvancement(advancement); + ServerPlayer playerMp = (ServerPlayer) player; + Advancement adv = playerMp.getServerLevel().getServer().getAdvancementManager().getAdvancement(advancement); if (adv != null) playerMp.getAdvancements().grantCriterion(adv, criterion); } @@ -289,7 +289,7 @@ public final class Helper { GL11.glVertex3d(x, y, z); } - public static boolean isHoldingItem(PlayerEntity player, Item item) { + public static boolean isHoldingItem(Player player, Item item) { for (Hand hand : Hand.values()) { ItemStack stack = player.getHeldItem(hand); if (!stack.isEmpty() && stack.getItem() == item) @@ -327,7 +327,7 @@ public final class Helper { } } - public static ItemStack getEquippedItem(Predicate predicate, PlayerEntity player) { + public static ItemStack getEquippedItem(Predicate predicate, Player player) { if (Compat.hasCompat("curios")) { Optional stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight); if (stack.isPresent()) diff --git a/src/main/java/de/ellpeck/naturesaura/InternalHooks.java b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java index 743c5fc4..0a0287e1 100644 --- a/src/main/java/de/ellpeck/naturesaura/InternalHooks.java +++ b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java @@ -3,18 +3,18 @@ package de.ellpeck.naturesaura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.multiblock.IMultiblock; import de.ellpeck.naturesaura.blocks.multi.Multiblock; -import de.ellpeck.naturesaura.misc.WorldData; -import net.minecraft.entity.player.PlayerEntity; +import de.ellpeck.naturesaura.misc.LevelData; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.level.Level; import org.apache.commons.lang3.mutable.MutableFloat; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableObject; @@ -27,16 +27,16 @@ import java.util.function.BiConsumer; public class InternalHooks implements NaturesAuraAPI.IInternalHooks { @Override - public boolean extractAuraFromPlayer(PlayerEntity player, int amount, boolean simulate) { + public boolean extractAuraFromPlayer(Player player, int amount, boolean simulate) { return this.auraPlayerInteraction(player, amount, true, simulate); } @Override - public boolean insertAuraIntoPlayer(PlayerEntity player, int amount, boolean simulate) { + public boolean insertAuraIntoPlayer(Player player, int amount, boolean simulate) { return this.auraPlayerInteraction(player, amount, false, simulate); } - private boolean auraPlayerInteraction(PlayerEntity player, int amount, boolean extract, boolean simulate) { + private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) { if (extract && player.isCreative()) return true; ItemStack stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player); @@ -90,18 +90,18 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { } @Override - public List> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name) { + public List> getActiveEffectPowders(Level level, AxisAlignedBB area, ResourceLocation name) { List> found = new ArrayList<>(); - for (Tuple powder : ((WorldData) IWorldData.getWorldData(world)).effectPowders.get(name)) + for (Tuple powder : ((LevelData) ILevelData.getLevelData(level)).effectPowders.get(name)) if (area.contains(powder.getA())) found.add(powder); return found; } @Override - public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name) { + public boolean isEffectPowderActive(Level level, BlockPos pos, ResourceLocation name) { Vector3d posVec = new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - List> powders = this.getActiveEffectPowders(world, new AxisAlignedBB(pos).grow(64), name); + List> powders = this.getActiveEffectPowders(level, new AxisAlignedBB(pos).grow(64), name); for (Tuple powder : powders) { AxisAlignedBB bounds = Helper.aabb(powder.getA()).grow(powder.getB()); if (bounds.contains(posVec)) @@ -111,29 +111,29 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { } @Override - public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer) { - Helper.getAuraChunksWithSpotsInArea(world, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer)); + public void getAuraSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer consumer) { + Helper.getAuraChunksWithSpotsInArea(level, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer)); } @Override - public int getSpotAmountInArea(World world, BlockPos pos, int radius) { + public int getSpotAmountInArea(Level level, BlockPos pos, int radius) { MutableInt result = new MutableInt(); - this.getAuraSpotsInArea(world, pos, radius, (blockpos, drainSpot) -> result.increment()); + this.getAuraSpotsInArea(level, pos, radius, (blockpos, drainSpot) -> result.increment()); return result.intValue(); } @Override - public int getAuraInArea(World world, BlockPos pos, int radius) { + public int getAuraInArea(Level level, BlockPos pos, int radius) { MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA); - this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot)); + this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot)); return result.intValue(); } @Override - public Pair getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius) { + public Pair getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius) { MutableInt spots = new MutableInt(); MutableInt aura = new MutableInt(IAuraChunk.DEFAULT_AURA); - this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { + this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> { aura.add(drainSpot); spots.increment(); }); @@ -141,9 +141,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { } @Override - public int triangulateAuraInArea(World world, BlockPos pos, int radius) { + public int triangulateAuraInArea(Level level, BlockPos pos, int radius) { MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA); - IAuraChunk.getSpotsInArea(world, pos, radius, (blockPos, spot) -> { + IAuraChunk.getSpotsInArea(level, pos, radius, (blockPos, spot) -> { float percentage = 1F - (float) Math.sqrt(pos.distanceSq(blockPos)) / radius; result.add(spot * percentage); }); @@ -151,10 +151,10 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { } @Override - public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + public BlockPos getLowestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) { MutableInt lowestAmount = new MutableInt(Integer.MAX_VALUE); MutableObject lowestSpot = new MutableObject<>(); - this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { + this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> { if (drainSpot < lowestAmount.intValue()) { lowestAmount.setValue(drainSpot); lowestSpot.setValue(blockPos); @@ -167,10 +167,10 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { } @Override - public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + public BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) { MutableInt highestAmount = new MutableInt(Integer.MIN_VALUE); MutableObject highestSpot = new MutableObject<>(); - this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { + this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> { if (drainSpot > highestAmount.intValue()) { highestAmount.setValue(drainSpot); highestSpot.setValue(blockPos); diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index 5cbc0734..657348e7 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -46,7 +46,7 @@ public final class ModConfig { public ConfigValue auraBarLocation; public ConfigValue cacheBarLocation; public ConfigValue debugText; - public ConfigValue debugWorld; + public ConfigValue debugLevel; public ConfigValue renderItemsOnPlayer; public ModConfig(ForgeConfigSpec.Builder builder) { @@ -131,7 +131,7 @@ public final class ModConfig { .translation("config." + NaturesAura.MOD_ID + ".oreEffect") .define("oreEffect", true); this.auraBlooms = builder - .comment("If Aura Blooms and Aura Cacti should generate in the world") + .comment("If Aura Blooms and Aura Cacti should generate in the level") .translation("config." + NaturesAura.MOD_ID + ".auraBlooms") .define("auraBlooms", true); this.netherGrassEffect = builder @@ -165,10 +165,10 @@ public final class ModConfig { .comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode") .translation("config." + NaturesAura.MOD_ID + ".debugText") .define("debugText", true); - this.debugWorld = builder - .comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes") - .translation("config." + NaturesAura.MOD_ID + ".debugWorld") - .define("debugWorld", false); + this.debugLevel = builder + .comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes") + .translation("config." + NaturesAura.MOD_ID + ".debugLevel") + .define("debugLevel", false); this.renderItemsOnPlayer = builder .comment("If certain equippable items, like the Environmental Eye, should be rendered on the player") .translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer") diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index b40e1982..5af10c78 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects; import de.ellpeck.naturesaura.compat.Compat; @@ -65,7 +65,7 @@ public final class NaturesAura { Helper.registerCap(IAuraContainer.class); Helper.registerCap(IAuraRecharge.class); Helper.registerCap(IAuraChunk.class); - Helper.registerCap(IWorldData.class); + Helper.registerCap(ILevelData.class); Compat.setup(event); PacketHandler.init(); diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index 9204d809..eeac89cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -8,24 +8,24 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.type.BasicAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.misc.WeatherType; import de.ellpeck.naturesaura.api.misc.WeightedOre; import de.ellpeck.naturesaura.api.multiblock.IMultiblock; import de.ellpeck.naturesaura.api.multiblock.Matcher; -import net.minecraft.block.BlockState; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.CapabilityToken; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; @@ -46,34 +46,34 @@ public final class NaturesAuraAPI { public static final String API_ID = MOD_ID + "api"; public static final String VERSION = "9"; /** - * A map of all of the block states that the Botanist's Pickaxe can convert + * A map of all the block states that the Botanist's Pickaxe can convert * into their mossy variations. Contains mossy brick and mossy cobblestone * by default, along with all blocks specified in the config file */ public static final BiMap BOTANIST_PICKAXE_CONVERSIONS = HashBiMap.create(); /** * A map of all {@link IAuraType} instances which are types of Aura present - * in different types of worlds. {@link BasicAuraType} instances can be + * in different types of levels. {@link BasicAuraType} instances can be * easily registered using {@link BasicAuraType#register()}. */ public static final Map AURA_TYPES = new HashMap<>(); - public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), World.field_234918_g_, 0x89cc37, 0).register(); - public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), World.field_234919_h_, 0x871c0c, 0).register(); - public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), World.field_234920_i_, 0x302624, 0).register(); + public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register(); + public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register(); + public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), Level.END, 0x302624, 0).register(); public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register(); /** * A map of all {@link IDrainSpotEffect} suppliers which are effects that * happen passively at every spot that Aura has been drained from in the - * world. These effects include things like vegetational increase and + * level. These effects include things like vegetational increase and * natural decay. To register your own drain spot effects, just add a - * supplier for them to this map and they will automatically be executed + * supplier for them to this map, and they will automatically be executed * once a second for every drain spot currently loaded. */ public static final Map> DRAIN_SPOT_EFFECTS = new HashMap<>(); /** * A map of all effect powder type. The integer the effect is registered to * is the color that the powder and its effect should have. To check if a - * powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(World, + * powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(Level, * BlockPos, ResourceLocation)} */ public static final Map EFFECT_POWDERS = new HashMap<>(); @@ -90,48 +90,50 @@ public final class NaturesAuraAPI { public static final List OVERWORLD_ORES = new ArrayList<>(); /** * A list of all {@link WeightedOre} objects that represent ores that can - * spawn inside of netherrack blocks in the nether + * spawn inside netherrack blocks in the nether */ public static final List NETHER_ORES = new ArrayList<>(); /** - * A map of all of the entities' registry names to the amounts of aura they + * A map of all the entities' registry names to the amounts of aura they * each generate in the projectile generator */ - public static final Map PROJECTILE_GENERATIONS = new HashMap<>(); + public static final Map, Integer> PROJECTILE_GENERATIONS = new HashMap<>(); /** - * A map of all of the items that cause the {@link WeatherType} to be - * changed using the weather changer + * A map of all the items that cause the {@link WeatherType} to be changed + * using the weather changer */ public static final Map WEATHER_CHANGER_CONVERSIONS = new HashMap<>(); /** * The capability for any item or block that stores Aura in the form of an * {@link IAuraContainer} */ - @CapabilityInject(IAuraContainer.class) - public static Capability capAuraContainer; + public static Capability capAuraContainer = CapabilityManager.get(new CapabilityToken<>() { + }); /** * The capability for any item that can be recharged from an Aura storage * container like the Aura Cache in the form of {@link IAuraRecharge} by a * player holding it in their hand */ - @CapabilityInject(IAuraRecharge.class) - public static Capability capAuraRecharge; + public static Capability capAuraRecharge = CapabilityManager.get(new CapabilityToken<>() { + }); /** - * The capability that any chunk in a world has to store Aura in it. As this - * is only applicable to chunks and all chunks in the world automatically + * The capability that any chunk in a level has to store Aura in it. As this + * is only applicable to chunks and all chunks in the level automatically * get assigned this capability, using it directly is not necessary for * addon developers. To retrieve this capability from any chunk, use the - * helper method {@link IAuraChunk#getAuraChunk(IWorld, BlockPos)}. + * helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, + * BlockPos)}. */ - @CapabilityInject(IAuraChunk.class) - public static Capability capAuraChunk; + public static Capability capAuraChunk = CapabilityManager.get(new CapabilityToken<>() { + }); /** - * The capability that any world has to store Nature's Aura specific data in - * it. To retrieve this capability from any world, use the helper methods - * {@link IWorldData#getWorldData(World)} or {@link IWorldData#getOverworldData(World)}. + * The capability that any level has to store Nature's Aura specific data in + * it. To retrieve this capability from any level, use the helper methods + * {@link ILevelData#getLevelData(net.minecraft.world.level.Level)} or + * {@link ILevelData#getOverworldData(net.minecraft.world.level.Level)}. */ - @CapabilityInject(IWorldData.class) - public static Capability capWorldData; + public static Capability capLevelData = CapabilityManager.get(new CapabilityToken<>() { + }); private static final IInternalHooks INSTANCE; static { @@ -169,7 +171,7 @@ public final class NaturesAuraAPI { * @param simulate If the extraction should be simulated * @return If the extraction was successful */ - boolean extractAuraFromPlayer(PlayerEntity player, int amount, boolean simulate); + boolean extractAuraFromPlayer(Player player, int amount, boolean simulate); /** * Helper method to insert aura into an {@link IAuraContainer} in the @@ -181,7 +183,7 @@ public final class NaturesAuraAPI { * @param simulate If the insertion should be simulated * @return If the insertion was successful */ - boolean insertAuraIntoPlayer(PlayerEntity player, int amount, boolean simulate); + boolean insertAuraIntoPlayer(Player player, int amount, boolean simulate); /** * This method can be used to spawn the magic particle effect used by @@ -262,65 +264,65 @@ public final class NaturesAuraAPI { IMultiblock createMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers); /** - * Get all of the active effect powders in the given area and consume - * the position and the range that they have. To register a powder with - * the supplied name, use {@link #EFFECT_POWDERS} + * Get all the active effect powders in the given area and consume the + * position and the range that they have. To register a powder with the + * supplied name, use {@link #EFFECT_POWDERS} * - * @param world The world + * @param level The level * @param area The area to find powders in * @param name The registry name of the powder * @return A list of powders' positions and ranges */ - List> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name); + List> getActiveEffectPowders(Level level, AABB area, ResourceLocation name); /** * Returns true if there is an effect powder entity active anywhere * around the given position based on the radius it has. This is a - * shorthand function of {@link #getActiveEffectPowders(World, - * AxisAlignedBB, ResourceLocation)} that returns true if the list is - * non-empty + * shorthand function of {@link #getActiveEffectPowders(Level, + * net.minecraft.world.phys.AABB, ResourceLocation)} that returns true + * if the list is non-empty * - * @param world The world + * @param level The level * @param pos The center position * @param name The registry name of the powder * @return If the effect is currently inhibited by any inhibitors */ - boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name); + boolean isEffectPowderActive(Level level, BlockPos pos, ResourceLocation name); /** - * @see IAuraChunk#getSpotsInArea(IWorld, BlockPos, int, BiConsumer) + * @see IAuraChunk#getSpotsInArea(Level, BlockPos, int, BiConsumer) */ - void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer); + void getAuraSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer consumer); /** - * @see IAuraChunk#getSpotAmountInArea(IWorld, BlockPos, int) + * @see IAuraChunk#getSpotAmountInArea(Level, BlockPos, int) */ - int getSpotAmountInArea(World world, BlockPos pos, int radius); + int getSpotAmountInArea(Level level, BlockPos pos, int radius); /** - * @see IAuraChunk#getAuraInArea(IWorld, BlockPos, int) + * @see IAuraChunk#getAuraInArea(Level, BlockPos, int) */ - int getAuraInArea(World world, BlockPos pos, int radius); + int getAuraInArea(Level level, BlockPos pos, int radius); /** - * @see IAuraChunk#getAuraAndSpotAmountInArea(World, BlockPos, int) + * @see IAuraChunk#getAuraAndSpotAmountInArea(Level, BlockPos, int) */ - Pair getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius); + Pair getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius); /** - * @see IAuraChunk#triangulateAuraInArea(IWorld, BlockPos, int) + * @see IAuraChunk#triangulateAuraInArea(Level, BlockPos, int) */ - int triangulateAuraInArea(World world, BlockPos pos, int radius); + int triangulateAuraInArea(Level level, BlockPos pos, int radius); /** - * @see IAuraChunk#getLowestSpot(IWorld, BlockPos, int, BlockPos) + * @see IAuraChunk#getLowestSpot(Level, BlockPos, int, BlockPos) */ - BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot); + BlockPos getLowestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot); /** - * @see IAuraChunk#getHighestSpot(IWorld, BlockPos, int, BlockPos) + * @see IAuraChunk#getHighestSpot(Level, BlockPos, int, BlockPos) */ - BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot); + BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot); } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java index 9a50dcc7..ea1a9c7a 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java @@ -2,11 +2,10 @@ package de.ellpeck.naturesaura.api.aura.chunk; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.util.INBTSerializable; import org.apache.commons.lang3.tuple.Pair; @@ -14,13 +13,13 @@ import java.util.function.BiConsumer; /** * A class whose instances hold information about the aura present in any given - * {@link Chunk}. To get an instance for a chunk, use {@link - * #getAuraChunk(IWorld, BlockPos)}. + * {@link net.minecraft.world.level.chunk.LevelChunk}. To get an instance for a + * chunk, use {@link #getAuraChunk(Level, BlockPos)}. *

* It is not intended for API users to create custom implementation of this * class. */ -public interface IAuraChunk extends INBTSerializable { +public interface IAuraChunk extends INBTSerializable { /** * The default amount of Aura that a chunk has stored @@ -31,12 +30,12 @@ public interface IAuraChunk extends INBTSerializable { * This method is used to get information about the Aura in any given chunk. * This is a convenience method. * - * @param world The world + * @param level The level * @param pos A position that the chunk contains * @return The {@link IAuraChunk} instance belonging to the chunk */ - static IAuraChunk getAuraChunk(IWorld world, BlockPos pos) { - Chunk chunk = (Chunk) world.getChunk(pos); + static IAuraChunk getAuraChunk(Level level, BlockPos pos) { + LevelChunk chunk = (LevelChunk) level.getChunk(pos); return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); } @@ -45,78 +44,78 @@ public interface IAuraChunk extends INBTSerializable { * spots, represented as a position and the number of Aura in them, in any * given area. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @param consumer A consumer that gets given the position and amount of * aura in each drain spot found */ - static void getSpotsInArea(IWorld world, BlockPos pos, int radius, BiConsumer consumer) { - NaturesAuraAPI.instance().getAuraSpotsInArea((World) world, pos, radius, consumer); + static void getSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer consumer) { + NaturesAuraAPI.instance().getAuraSpotsInArea(level, pos, radius, consumer); } /** * Convenience method that adds up the amount of aura spots from {@link - * #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and returns it. + * #getSpotsInArea(Level, BlockPos, int, BiConsumer)} and returns it. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @return The amount of spots found in the area */ - static int getSpotAmountInArea(IWorld world, BlockPos pos, int radius) { - return NaturesAuraAPI.instance().getSpotAmountInArea((World) world, pos, radius); + static int getSpotAmountInArea(Level level, BlockPos pos, int radius) { + return NaturesAuraAPI.instance().getSpotAmountInArea(level, pos, radius); } /** * Convenience method that adds up all of the aura from each drain spot from - * {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and + * {@link #getSpotsInArea(Level, BlockPos, int, BiConsumer)} and * conveniently returns it. For a better visual display with a more gradual - * increase, use {@link #triangulateAuraInArea(IWorld, BlockPos, int)}. + * increase, use {@link #triangulateAuraInArea(Level, BlockPos, int)}. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @return The amount of Aura present in that area, based on the drain spots * that are found */ - static int getAuraInArea(IWorld world, BlockPos pos, int radius) { - return NaturesAuraAPI.instance().getAuraInArea((World) world, pos, radius); + static int getAuraInArea(Level level, BlockPos pos, int radius) { + return NaturesAuraAPI.instance().getAuraInArea(level, pos, radius); } /** - * Convenience method that combines {@link #getAuraInArea(IWorld, BlockPos, - * int)} and {@link #getSpotAmountInArea(IWorld, BlockPos, int)} to increase + * Convenience method that combines {@link #getAuraInArea(Level, BlockPos, + * int)} and {@link #getSpotAmountInArea(Level, BlockPos, int)} to increase * performance. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @return A pair of the amount of aura in the area as the {@link * Pair#getLeft()} entry, and the amount of aura spots in the area as the * {@link Pair#getRight()} entry */ - static Pair getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius) { - return NaturesAuraAPI.instance().getAuraAndSpotAmountInArea(world, pos, radius); + static Pair getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius) { + return NaturesAuraAPI.instance().getAuraAndSpotAmountInArea(level, pos, radius); } /** * Convenience method that adds up all of the aura from each drain spot from - * {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)}, but - * multiplies their amount by the percentual distance to the supplied - * position. This will cause for a lot more gradual of an increase and - * decrease of Aura when moving closer to actual spots. This should be used - * for visual purposes as it is more performance intensive than {@link - * #getAuraInArea(IWorld, BlockPos, int)}. + * {@link #getSpotsInArea(Level, BlockPos, int, BiConsumer)}, but multiplies + * their amount by the percentual distance to the supplied position. This + * will cause for a lot more gradual of an increase and decrease of Aura + * when moving closer to actual spots. This should be used for visual + * purposes as it is more performance intensive than {@link + * #getAuraInArea(Level, BlockPos, int)}. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @return The amount of Aura presetn in that area, based on the drain spots * that are found and their distance to the center */ - static int triangulateAuraInArea(IWorld world, BlockPos pos, int radius) { - return NaturesAuraAPI.instance().triangulateAuraInArea((World) world, pos, radius); + static int triangulateAuraInArea(Level level, BlockPos pos, int radius) { + return NaturesAuraAPI.instance().triangulateAuraInArea(level, pos, radius); } /** @@ -126,15 +125,15 @@ public interface IAuraChunk extends INBTSerializable { * drained spots get selected first. Note that, when there is no drain spot * with an amount lower than 0, the default will always be returned. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @param defaultSpot A position that will be used to create a new drain * spot when none are found * @return The position of the lowest drain spot */ - static BlockPos getLowestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) { - return NaturesAuraAPI.instance().getLowestAuraDrainSpot((World) world, pos, radius, defaultSpot); + static BlockPos getLowestSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) { + return NaturesAuraAPI.instance().getLowestAuraDrainSpot(level, pos, radius, defaultSpot); } /** @@ -144,15 +143,15 @@ public interface IAuraChunk extends INBTSerializable { * amount are drained first. Note that, when there is no drain spot with an * amount greater than 0, the defautl will always be returned. * - * @param world The world + * @param level The level * @param pos The center position * @param radius The radius around the center to search for spots in * @param defaultSpot A position that will be used to create a new drain * spot when none are found * @return The position of the highest drain spot */ - static BlockPos getHighestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) { - return NaturesAuraAPI.instance().getHighestAuraDrainSpot((World) world, pos, radius, defaultSpot); + static BlockPos getHighestSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) { + return NaturesAuraAPI.instance().getHighestAuraDrainSpot(level, pos, radius, defaultSpot); } /** diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java index be06ee39..4a353052 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java @@ -1,22 +1,22 @@ package de.ellpeck.naturesaura.api.aura.chunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; public interface IDrainSpotEffect { - void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot); + void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot); - boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type); + boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type); ResourceLocation getName(); - default ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + default ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { return ActiveType.INACTIVE; } diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java index c51531b0..8150fab9 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.api.aura.container; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; public class BasicAuraContainer implements IAuraContainer { @@ -52,11 +52,11 @@ public class BasicAuraContainer implements IAuraContainer { return this.type == null || type.isSimilar(this.type); } - public void writeNBT(CompoundNBT compound) { + public void writeNBT(CompoundTag compound) { compound.putInt("aura", this.aura); } - public void readNBT(CompoundNBT compound) { + public void readNBT(CompoundTag compound) { this.aura = compound.getInt("aura"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java index b71c870d..cf467165 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.api.aura.container; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; public class ItemAuraContainer implements IAuraContainer { @@ -38,7 +38,7 @@ public class ItemAuraContainer implements IAuraContainer { private void setAura(int amount) { if (!this.stack.hasTag()) { - this.stack.setTag(new CompoundNBT()); + this.stack.setTag(new CompoundTag()); } this.stack.getTag().putInt("aura", amount); } diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/type/BasicAuraType.java b/src/main/java/de/ellpeck/naturesaura/api/aura/type/BasicAuraType.java index 730c0a3e..c7a0cdb7 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/type/BasicAuraType.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/type/BasicAuraType.java @@ -1,10 +1,9 @@ package de.ellpeck.naturesaura.api.aura.type; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.util.RegistryKey; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import java.util.HashSet; import java.util.Set; @@ -16,12 +15,12 @@ public class BasicAuraType implements IAuraType { private final int priority; private final Set dimensions = new HashSet<>(); - public BasicAuraType(ResourceLocation name, RegistryKey dimension, int color, int priority) { + public BasicAuraType(ResourceLocation name, ResourceKey dimension, int color, int priority) { this.name = name; this.color = color; this.priority = priority; if (dimension != null) - this.dimensions.add(dimension.func_240901_a_()); + this.dimensions.add(dimension.location()); } public BasicAuraType register() { @@ -35,8 +34,8 @@ public class BasicAuraType implements IAuraType { } @Override - public boolean isPresentInWorld(IWorld world) { - return this.dimensions.isEmpty() || this.dimensions.contains(((World) world).func_234923_W_().func_240901_a_()); + public boolean isPresentInLevel(Level level) { + return this.dimensions.isEmpty() || this.dimensions.contains(level.dimension().location()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java b/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java index d45117ea..ad4a795c 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java @@ -1,22 +1,22 @@ package de.ellpeck.naturesaura.api.aura.type; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.IWorld; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; public interface IAuraType { - static IAuraType forWorld(IWorld world) { + static IAuraType forLevel(Level level) { IAuraType highestType = NaturesAuraAPI.TYPE_OTHER; for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values()) - if (type.isPresentInWorld(world) && type.getPriority() > highestType.getPriority()) + if (type.isPresentInLevel(level) && type.getPriority() > highestType.getPriority()) highestType = type; return highestType; } ResourceLocation getName(); - boolean isPresentInWorld(IWorld world); + boolean isPresentInLevel(Level level); int getColor(); diff --git a/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java b/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java new file mode 100644 index 00000000..72f55d51 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java @@ -0,0 +1,25 @@ +package de.ellpeck.naturesaura.api.misc; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.Level; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.INBTSerializable; +import net.minecraftforge.items.IItemHandlerModifiable; + +public interface ILevelData extends ICapabilityProvider, INBTSerializable { + + static ILevelData getLevelData(Level level) { + return level.getCapability(NaturesAuraAPI.capLevelData, null).orElse(null); + } + + static ILevelData getOverworldData(Level level) { + if (!level.isClientSide) + return getLevelData(level.getServer().getLevel(Level.OVERWORLD)); + return getLevelData(level); + } + + IItemHandlerModifiable getEnderStorage(String name); + + boolean isEnderStorageLocked(String name); +} diff --git a/src/main/java/de/ellpeck/naturesaura/api/misc/IWorldData.java b/src/main/java/de/ellpeck/naturesaura/api/misc/IWorldData.java deleted file mode 100644 index c05c6e45..00000000 --- a/src/main/java/de/ellpeck/naturesaura/api/misc/IWorldData.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.ellpeck.naturesaura.api.misc; - -import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.common.util.INBTSerializable; -import net.minecraftforge.items.IItemHandlerModifiable; - -public interface IWorldData extends ICapabilityProvider, INBTSerializable { - - static IWorldData getWorldData(World world) { - return world.getCapability(NaturesAuraAPI.capWorldData, null).orElse(null); - } - - static IWorldData getOverworldData(World world) { - if (!world.isRemote) - return getWorldData(world.getServer().getWorld(World.field_234918_g_)); - return getWorldData(world); - } - - IItemHandlerModifiable getEnderStorage(String name); - - boolean isEnderStorageLocked(String name); -} diff --git a/src/main/java/de/ellpeck/naturesaura/api/multiblock/IMultiblock.java b/src/main/java/de/ellpeck/naturesaura/api/multiblock/IMultiblock.java index 0415357a..75c19253 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/multiblock/IMultiblock.java +++ b/src/main/java/de/ellpeck/naturesaura/api/multiblock/IMultiblock.java @@ -1,15 +1,15 @@ package de.ellpeck.naturesaura.api.multiblock; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import java.util.Map; import java.util.function.BiFunction; public interface IMultiblock { - boolean isComplete(World world, BlockPos center); + boolean isComplete(Level level, BlockPos center); boolean forEach(BlockPos center, char c, BiFunction function); diff --git a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java index ee25f1a3..67a47748 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java +++ b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java @@ -5,7 +5,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.tags.ITag; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; public class Matcher { @@ -22,7 +22,7 @@ public class Matcher { } public static Matcher tag(Block defaultBlock, ITag.INamedTag tag) { - return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName())); + return new Matcher(defaultBlock.getDefaultState(), (level, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName())); } public BlockState getDefaultState() { @@ -34,6 +34,6 @@ public class Matcher { } public interface ICheck { - boolean matches(World world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c); + boolean matches(Level level, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c); } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java b/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java index ec22f64d..6c95b485 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java +++ b/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java @@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.api.render; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public interface ITrinketItem { @OnlyIn(Dist.CLIENT) - void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding); + void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding); enum RenderType { HEAD, BODY diff --git a/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizable.java b/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizable.java index c0b2416b..41d512ff 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizable.java +++ b/src/main/java/de/ellpeck/naturesaura/api/render/IVisualizable.java @@ -2,15 +2,15 @@ package de.ellpeck.naturesaura.api.render; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public interface IVisualizable { @OnlyIn(Dist.CLIENT) - AxisAlignedBB getVisualizationBounds(World world, BlockPos pos); + AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos); @OnlyIn(Dist.CLIENT) - int getVisualizationColor(World world, BlockPos pos); + int getVisualizationColor(Level level, BlockPos pos); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java index 63f2f921..a1438d72 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAncientLeaves; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.*; import net.minecraft.block.BlockState; @@ -11,11 +11,11 @@ import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -27,7 +27,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP public BlockAncientLeaves() { super(Properties.create(Material.LEAVES, MaterialColor.PINK).hardnessAndResistance(0.2F).tickRandomly().notSolid().sound(SoundType.PLANT)); ModRegistry.add(this); - ModRegistry.add(new ModTileType<>(TileEntityAncientLeaves::new, this)); + ModRegistry.add(new ModTileType<>(BlockEntityAncientLeaves::new, this)); } @Override @@ -37,19 +37,19 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP @Nullable @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new TileEntityAncientLeaves(); + public BlockEntity createBlockEntity(BlockState state, IBlockReader level) { + return new BlockEntityAncientLeaves(); } @Override - public boolean hasTileEntity(BlockState state) { + public boolean hasBlockEntity(BlockState state) { return true; } @Override @OnlyIn(Dist.CLIENT) public IBlockColor getBlockColor() { - return (state, worldIn, pos, tintIndex) -> 0xE55B97; + return (state, levelIn, pos, tintIndex) -> 0xE55B97; } @Override @@ -60,12 +60,12 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { - super.animateTick(stateIn, worldIn, pos, rand); - if (rand.nextFloat() >= 0.95F && !worldIn.getBlockState(pos.down()).isOpaqueCube(worldIn, pos)) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityAncientLeaves) { - if (((TileEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + super.animateTick(stateIn, levelIn, pos, rand); + if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.down()).isOpaqueCube(levelIn, pos)) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityAncientLeaves) { + if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) { NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(), 0F, 0F, 0F, 0xCC4780, @@ -79,13 +79,13 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP } @Override - public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - super.randomTick(state, worldIn, pos, random); - if (!worldIn.isRemote) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityAncientLeaves) { - if (((TileEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) { - worldIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState()); + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + super.randomTick(state, levelIn, pos, random); + if (!levelIn.isClientSide) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityAncientLeaves) { + if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) { + levelIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState()); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 5902ee26..405b1cb0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.gen.ModFeatures; -import de.ellpeck.naturesaura.gen.WorldGenAncientTree; +import de.ellpeck.naturesaura.gen.LevelGenAncientTree; import de.ellpeck.naturesaura.reg.*; import net.minecraft.block.*; import net.minecraft.block.material.Material; @@ -12,9 +12,9 @@ import net.minecraft.state.StateContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.event.ForgeEventFactory; import java.util.Random; @@ -29,17 +29,17 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override - public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!world.isRemote) { - super.randomTick(state, world, pos, random); + public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) { + if (!level.isClientSide) { + super.randomTick(state, level, pos, random); - if (world.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) { - this.grow(world, random, pos, state); + if (level.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) { + this.grow(level, random, pos, state); } } } @@ -55,21 +55,21 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte } @Override - public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) { + public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) { return true; } @Override - public boolean canUseBonemeal(World world, Random rand, BlockPos pos, BlockState state) { - return world.rand.nextFloat() < 0.45F; + public boolean canUseBonemeal(Level level, Random rand, BlockPos pos, BlockState state) { + return level.rand.nextFloat() < 0.45F; } @Override - public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) { + public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) { if (state.get(SaplingBlock.STAGE) == 0) { - world.setBlockState(pos, state.func_235896_a_(SaplingBlock.STAGE), 4); - } else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) { - ModFeatures.ANCIENT_TREE.func_241855_a(world, world.getChunkProvider().getChunkGenerator(), rand, pos, WorldGenAncientTree.CONFIG); + level.setBlockState(pos, state.func_235896_a_(SaplingBlock.STAGE), 4); + } else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) { + ModFeatures.ANCIENT_TREE.func_241855_a(level, level.getChunkProvider().getChunkGenerator(), rand, pos, LevelGenAncientTree.CONFIG); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java index a28ec844..abe8ea8a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java @@ -1,18 +1,18 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalContainer; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalContainer; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -21,7 +21,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11); public BlockAnimalContainer() { - super("animal_container", TileEntityAnimalContainer::new, Properties.from(Blocks.STONE)); + super("animal_container", BlockEntityAnimalContainer::new, Properties.from(Blocks.STONE)); } @Override @@ -30,16 +30,16 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityAnimalContainer) { - int radius = ((TileEntityAnimalContainer) tile).getRadius(); + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntityAnimalContainer) { + int radius = ((BlockEntityAnimalContainer) tile).getRadius(); if (radius > 0) return new AxisAlignedBB(pos).grow(radius); } @@ -48,7 +48,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x42ddf5; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java index 1ea09176..78754c0a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -14,11 +14,11 @@ import net.minecraft.entity.INPC; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -30,7 +30,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockAnimalGenerator() { - super("animal_generator", TileEntityAnimalGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); + super("animal_generator", BlockEntityAnimalGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @@ -38,9 +38,9 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @SubscribeEvent public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { LivingEntity entity = event.getEntityLiving(); - if (entity.world.isRemote || entity.world.getGameTime() % 40 != 0 || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC) + if (entity.level.isClientSide || entity.level.getGameTime() % 40 != 0 || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC) return; - CompoundNBT data = entity.getPersistentData(); + CompoundTag data = entity.getPersistentData(); int timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive"); data.putInt(NaturesAura.MOD_ID + ":time_alive", timeAlive + 40); } @@ -48,15 +48,15 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @SubscribeEvent public void onEntityDeath(LivingDeathEvent event) { LivingEntity entity = event.getEntityLiving(); - if (entity.world.isRemote || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC) + if (entity.level.isClientSide || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC) return; BlockPos pos = entity.getPosition(); - Helper.getTileEntitiesInArea(entity.world, pos, 5, tile -> { - if (!(tile instanceof TileEntityAnimalGenerator)) + Helper.getTileEntitiesInArea(entity.level, pos, 5, tile -> { + if (!(tile instanceof BlockEntityAnimalGenerator)) return false; - TileEntityAnimalGenerator gen = (TileEntityAnimalGenerator) tile; + BlockEntityAnimalGenerator gen = (BlockEntityAnimalGenerator) tile; - CompoundNBT data = entity.getPersistentData(); + CompoundTag data = entity.getPersistentData(); data.putBoolean(NaturesAura.MOD_ID + ":no_drops", true); if (gen.isBusy()) @@ -74,7 +74,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali gen.setGenerationValues(time, amount); BlockPos genPos = gen.getPos(); - PacketHandler.sendToAllAround(entity.world, pos, 32, new PacketParticles( + PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles( (float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME, child ? 1 : 0, (int) (entity.getEyeHeight() * 10F), @@ -100,13 +100,13 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(5); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x11377a; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java index d7d9bd4e..1a101026 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java @@ -1,11 +1,11 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalSpawner; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalSpawner; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; public class BlockAnimalSpawner extends BlockContainerImpl { public BlockAnimalSpawner() { - super("animal_spawner", TileEntityAnimalSpawner::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); + super("animal_spawner", BlockEntityAnimalSpawner::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java index 4d7ab820..fef74d5f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.reg.*; @@ -11,15 +11,15 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevelReader; +import net.minecraft.level.Level; import javax.annotation.Nullable; import java.util.Arrays; @@ -39,25 +39,25 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) { BlockPos down = pos.down(); - return this.isValidGround(worldIn.getBlockState(down), worldIn, down); + return this.isValidGround(levelIn.getBlockState(down), levelIn, down); } @Override - protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) { + protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) { return Arrays.stream(this.allowedGround).anyMatch(state::isIn); } @Override - public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + public void onEntityCollision(BlockState state, Level levelIn, BlockPos pos, Entity entityIn) { if (this == ModBlocks.AURA_CACTUS) entityIn.attackEntityFrom(DamageSource.CACTUS, 1); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - Vector3d vec3d = state.getOffset(worldIn, pos); + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { + Vector3d vec3d = state.getOffset(levelIn, pos); return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z); } @@ -83,12 +83,12 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS @Nullable @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new TileEntityAuraBloom(); + public BlockEntity createBlockEntity(BlockState state, IBlockReader level) { + return new BlockEntityAuraBloom(); } @Override - public boolean hasTileEntity(BlockState state) { + public boolean hasBlockEntity(BlockState state) { return true; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java index be955cf5..c93806bc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java @@ -1,17 +1,17 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraDetector; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; public class BlockAuraDetector extends BlockContainerImpl { public BlockAuraDetector() { - super("aura_detector", TileEntityAuraDetector::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); + super("aura_detector", BlockEntityAuraDetector::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); } @Override @@ -20,10 +20,10 @@ public class BlockAuraDetector extends BlockContainerImpl { } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityAuraDetector) - return ((TileEntityAuraDetector) tile).redstonePower; + public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityAuraDetector) + return ((BlockEntityAuraDetector) tile).redstonePower; else return 0; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java index 57c5946b..22846081 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraTimer; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer; import de.ellpeck.naturesaura.blocks.tiles.render.RenderAuraTimer; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; @@ -12,13 +12,13 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.entity.player.Player; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ActionResultType; +import net.minecraft.tileentity.BlockEntityType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.Tuple; @@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -36,12 +36,12 @@ import java.util.Random; import java.util.function.Function; import java.util.function.Supplier; -public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider, ICustomRenderType { +public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider, ICustomRenderType { private static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 15, 15); public BlockAuraTimer() { - super("aura_timer", TileEntityAuraTimer::new, Properties.from(Blocks.SMOOTH_STONE)); + super("aura_timer", BlockEntityAuraTimer::new, Properties.from(Blocks.SMOOTH_STONE)); this.setDefaultState(this.getDefaultState().with(BlockStateProperties.POWERED, false)); } @@ -51,13 +51,13 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override @OnlyIn(Dist.CLIENT) - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.AURA_TIMER, () -> RenderAuraTimer::new); } @@ -72,7 +72,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) { return Helper.putStackOnTile(player, handIn, pos, 0, true); } @@ -82,15 +82,15 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt } @Override - public int getWeakPower(BlockState state, IBlockReader world, BlockPos pos, Direction side) { + public int getWeakPower(BlockState state, IBlockReader level, BlockPos pos, Direction side) { return state.get(BlockStateProperties.POWERED) ? 15 : 0; } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - super.tick(state, worldIn, pos, random); + public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + super.tick(state, levelIn, pos, random); if (state.get(BlockStateProperties.POWERED)) - worldIn.setBlockState(pos, state.with(BlockStateProperties.POWERED, false)); + levelIn.setBlockState(pos, state.with(BlockStateProperties.POWERED, false)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java index f9dcd4d4..b0f57193 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAutoCrafter; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAutoCrafter; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Block; @@ -16,7 +16,7 @@ public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlock public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public BlockAutoCrafter() { - super("auto_crafter", TileEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD)); + super("auto_crafter", BlockEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java index 4c290806..0c688e34 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityBlastFurnaceBooster; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityBlastFurnaceBooster; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Block; @@ -13,15 +13,15 @@ import net.minecraft.state.StateContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICustomBlockState { public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; - private static final VoxelShape SHAPE = VoxelShapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F); + private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F); public BlockBlastFurnaceBooster() { - super("blast_furnace_booster", TileEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE).setLightLevel(s -> 0)); + super("blast_furnace_booster", BlockEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE).setLightLevel(s -> 0)); } @Override @@ -30,7 +30,7 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java index 33861159..e42b929a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java @@ -7,8 +7,8 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; +import net.minecraft.world.level.block.state.properties.BooleanProperty; public class BlockCatalyst extends BlockImpl implements ICustomBlockState { public static final BooleanProperty NETHER = BlockNatureAltar.NETHER; @@ -20,7 +20,7 @@ public class BlockCatalyst extends BlockImpl implements ICustomBlockState { @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - boolean nether = IAuraType.forWorld(context.getWorld()).isSimilar(NaturesAuraAPI.TYPE_NETHER); + boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); return super.getStateForPlacement(context).with(NETHER, nether); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChorusGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChorusGenerator.java index 7264b37c..375af757 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChorusGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChorusGenerator.java @@ -1,13 +1,13 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityChorusGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChorusGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Blocks; public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState { public BlockChorusGenerator() { - super("chorus_generator", TileEntityChorusGenerator::new, Properties.from(Blocks.END_STONE)); + super("chorus_generator", BlockEntityChorusGenerator::new, Properties.from(Blocks.END_STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java index 37ad4940..eebf2a30 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java @@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChunkLoader; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.BlockState; @@ -12,15 +12,15 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.text.ITextComponent; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -33,7 +33,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12); public BlockChunkLoader() { - super("chunk_loader", TileEntityChunkLoader::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); + super("chunk_loader", BlockEntityChunkLoader::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); } @Override @@ -43,17 +43,17 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityChunkLoader) { - int range = ((TileEntityChunkLoader) tile).range(); + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntityChunkLoader) { + int range = ((BlockEntityChunkLoader) tile).range(); if (range > 0) { return new AxisAlignedBB( (pos.getX() - range) >> 4 << 4, 0, (pos.getZ() - range) >> 4 << 4, ((pos.getX() + range) >> 4 << 4) + 16, - world.getHeight(), + level.getHeight(), ((pos.getZ() + range) >> 4 << 4) + 16); } } @@ -62,28 +62,28 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { if (!ModConfig.instance.chunkLoader.get()) return; - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityChunkLoader) { - int range = ((TileEntityChunkLoader) tile).range(); + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityChunkLoader) { + int range = ((BlockEntityChunkLoader) tile).range(); for (int i = MathHelper.ceil(range / 8F); i > 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + worldIn.rand.nextFloat(), pos.getY() + worldIn.rand.nextFloat(), pos.getZ() + worldIn.rand.nextFloat(), - 0, 0, 0, 0xa12dff, 1F + worldIn.rand.nextFloat(), 100, 0, false, true); + pos.getX() + levelIn.rand.nextFloat(), pos.getY() + levelIn.rand.nextFloat(), pos.getZ() + levelIn.rand.nextFloat(), + 0, 0, 0, 0xa12dff, 1F + levelIn.rand.nextFloat(), 100, 0, false, true); } } } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0xc159f9; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @@ -93,8 +93,8 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl } @Override - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { - super.addInformation(stack, worldIn, tooltip, flagIn); + public void addInformation(ItemStack stack, @Nullable IBlockReader levelIn, List tooltip, ITooltipFlag flagIn) { + super.addInformation(stack, levelIn, tooltip, flagIn); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index b52d5387..37a39f25 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -1,40 +1,42 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModTileType; import net.minecraft.block.*; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevel; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraft.loot.LootContext; import net.minecraft.loot.LootParameters; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import javax.annotation.Nullable; import java.util.List; import java.util.Random; import java.util.function.Supplier; -public class BlockContainerImpl extends ContainerBlock implements IModItem { +public class BlockContainerImpl extends BaseEntityBlock implements IModItem { private final String baseName; - private final ModTileType tileType; + private final ModTileType tileType; - public BlockContainerImpl(String baseName, Supplier tileSupplier, Block.Properties properties) { + public BlockContainerImpl(String baseName, Supplier tileSupplier, Block.Properties properties) { super(properties); this.baseName = baseName; @@ -63,17 +65,17 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem { } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { + public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, ILevel levelIn, BlockPos currentPos, BlockPos facingPos) { if (this.hasWaterlogging() && stateIn.get(BlockStateProperties.WATERLOGGED)) - worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); - return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos); + levelIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(levelIn)); + return super.updatePostPlacement(stateIn, facing, facingState, levelIn, currentPos, facingPos); } @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) { if (this.hasWaterlogging()) { - FluidState state = context.getWorld().getFluidState(context.getPos()); + FluidState state = context.getLevel().getFluidState(context.getPos()); return this.getDefaultState().with(BlockStateProperties.WATERLOGGED, state.isTagged(FluidTags.WATER) && state.getLevel() == 8); } return super.getStateForPlacement(context); @@ -81,7 +83,7 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem { @Nullable @Override - public TileEntity createNewTileEntity(IBlockReader worldIn) { + public BlockEntity createNewBlockEntity(IBlockReader levelIn) { return this.tileType.type.create(); } @@ -96,20 +98,20 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem { } @Override - public void onPlayerDestroy(IWorld worldIn, BlockPos pos, BlockState state) { - super.onPlayerDestroy(worldIn, pos, state); + public void onPlayerDestroy(ILevel levelIn, BlockPos pos, BlockState state) { + super.onPlayerDestroy(levelIn, pos, state); } @Override public List getDrops(BlockState state, LootContext.Builder builder) { List drops = super.getDrops(state, builder); - TileEntity tile = builder.get(LootParameters.BLOCK_ENTITY); - if (tile instanceof TileEntityImpl) { + BlockEntity tile = builder.get(LootParameters.BLOCK_ENTITY); + if (tile instanceof BlockEntityImpl) { for (ItemStack stack : drops) { if (stack.getItem() != this.asItem()) continue; - ((TileEntityImpl) tile).modifyDrop(stack); + ((BlockEntityImpl) tile).modifyDrop(stack); break; } } @@ -117,57 +119,57 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem { } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onReplaced(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityImpl) - ((TileEntityImpl) tile).dropInventory(); + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityImpl) + ((BlockEntityImpl) tile).dropInventory(); } - super.onReplaced(state, worldIn, pos, newState, isMoving); + super.onReplaced(state, levelIn, pos, newState, isMoving); } @Override - public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) { - super.harvestBlock(worldIn, player, pos, state, te, stack); - worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); + public void harvestBlock(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) { + super.harvestBlock(levelIn, player, pos, state, te, stack); + levelIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityImpl) - ((TileEntityImpl) tile).loadDataOnPlace(stack); + public void onBlockPlacedBy(Level levelIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityImpl) + ((BlockEntityImpl) tile).loadDataOnPlace(stack); } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { - this.updateRedstoneState(worldIn, pos); + public void onBlockAdded(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) { + this.updateRedstoneState(levelIn, pos); } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - this.updateRedstoneState(worldIn, pos); + public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { + this.updateRedstoneState(levelIn, pos); } - private void updateRedstoneState(World world, BlockPos pos) { - if (!world.isRemote) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityImpl) { - TileEntityImpl impl = (TileEntityImpl) tile; - int newPower = world.getRedstonePowerFromNeighbors(pos); + private void updateRedstoneState(Level level, BlockPos pos) { + if (!level.isClientSide) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntityImpl) { + BlockEntityImpl impl = (BlockEntityImpl) tile; + int newPower = level.getRedstonePowerFromNeighbors(pos); if (impl.redstonePower != newPower) - world.getPendingBlockTicks().scheduleTick(pos, this, 4); + level.getPendingBlockTicks().scheduleTick(pos, this, 4); } } } @Override - public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - if (!worldIn.isRemote) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityImpl) { - TileEntityImpl impl = (TileEntityImpl) tile; - int newPower = worldIn.getRedstonePowerFromNeighbors(pos); + public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + if (!levelIn.isClientSide) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityImpl) { + BlockEntityImpl impl = (BlockEntityImpl) tile; + int newPower = levelIn.getRedstonePowerFromNeighbors(pos); if (impl.redstonePower != newPower) impl.onRedstonePowerChange(newPower); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java index 63283ad6..11da8b7a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java @@ -9,8 +9,8 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.server.ServerLevel; import java.util.Random; import java.util.function.Supplier; @@ -22,9 +22,9 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState, } @Override - public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (!world.isRemote) { - world.setBlockState(pos, Blocks.AIR.getDefaultState()); + public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { + if (!level.isClientSide) { + level.setBlockState(pos, Blocks.AIR.getDefaultState()); } } @@ -34,7 +34,7 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState, } @Override - public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) { + public int getOpacity(BlockState state, IBlockReader levelIn, BlockPos pos) { return 1; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java index b5b906e7..b2817bcf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java @@ -15,9 +15,9 @@ import net.minecraft.block.Blocks; import net.minecraft.client.renderer.RenderType; import net.minecraft.entity.Entity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.server.MinecraftServer; import net.minecraft.state.EnumProperty; import net.minecraft.state.Property; @@ -28,10 +28,10 @@ import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; +import net.minecraft.level.gen.Heightmap; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.util.ITeleporter; import java.util.function.Function; @@ -42,10 +42,10 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I public static final EnumProperty SHAPE = BlockStateProperties.RAIL_SHAPE; private final String name; - private final RegistryKey goalDim; - private final RegistryKey[] canUseDims; + private final RegistryKey goalDim; + private final RegistryKey[] canUseDims; - public BlockDimensionRail(String name, RegistryKey goalDim, RegistryKey... canUseDims) { + public BlockDimensionRail(String name, RegistryKey goalDim, RegistryKey... canUseDims) { super(false, Properties.from(Blocks.RAIL)); this.name = name; this.goalDim = goalDim; @@ -54,77 +54,77 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I ModRegistry.add(this); } - private boolean canUseHere(RegistryKey dimension) { - for (RegistryKey dim : this.canUseDims) + private boolean canUseHere(RegistryKey dimension) { + for (RegistryKey dim : this.canUseDims) if (dim == dimension) return true; return false; } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand hand, BlockRayTraceResult hit) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() == ModItems.RANGE_VISUALIZER) { - if (!worldIn.isRemote) { - BlockPos goalPos = this.getGoalCoords(worldIn, pos); - CompoundNBT data = new CompoundNBT(); + if (!levelIn.isClientSide) { + BlockPos goalPos = this.getGoalCoords(levelIn, pos); + CompoundTag data = new CompoundTag(); data.putString("dim", this.goalDim.func_240901_a_().toString()); data.putLong("pos", goalPos.toLong()); PacketHandler.sendTo(player, new PacketClient(0, data)); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.FAIL; + return InteractionResult.FAIL; } @Override - public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) { - if (world.isRemote) + public void onMinecartPass(BlockState state, Level level, BlockPos pos, AbstractMinecartEntity cart) { + if (level.isClientSide) return; if (cart.isBeingRidden()) return; - if (!this.canUseHere(world.func_234923_W_())) + if (!this.canUseHere(level.func_234923_W_())) return; AxisAlignedBB box = cart.getBoundingBox(); - PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F))); - world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F); + PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F))); + level.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F); - BlockPos goalCoords = this.getGoalCoords(world, pos); - cart.changeDimension(world.getServer().getWorld(this.goalDim), new ITeleporter() { + BlockPos goalCoords = this.getGoalCoords(level, pos); + cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() { @Override - public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function repositionEntity) { + public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function repositionEntity) { // repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy - entity.world.getProfiler().endStartSection("reloading"); - Entity result = entity.getType().create(destWorld); + entity.level.getProfiler().endStartSection("reloading"); + Entity result = entity.getType().create(destLevel); if (result != null) { result.copyDataFromOld(entity); - destWorld.addFromAnotherDimension(result); + destLevel.addFromAnotherDimension(result); result.moveToBlockPosAndAngles(goalCoords, yaw, result.rotationPitch); } return result; } }); - BlockPos spot = IAuraChunk.getHighestSpot(world, pos, 35, pos); - IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 50000); + BlockPos spot = IAuraChunk.getHighestSpot(level, pos, 35, pos); + IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000); } - private BlockPos getGoalCoords(World world, BlockPos pos) { - MinecraftServer server = world.getServer(); + private BlockPos getGoalCoords(Level level, BlockPos pos) { + MinecraftServer server = level.getServer(); if (this == ModBlocks.DIMENSION_RAIL_NETHER) { // travel to the nether from the overworld return new BlockPos(pos.getX() / 8, pos.getY() / 2, pos.getZ() / 8); } else if (this == ModBlocks.DIMENSION_RAIL_END) { // travel to the end from the overworld - return ServerWorld.field_241108_a_.up(8); + return ServerLevel.field_241108_a_.up(8); } else { - if (world.func_234923_W_() == World.field_234919_h_) { + if (level.func_234923_W_() == Level.field_234919_h_) { // travel to the overworld from the nether return new BlockPos(pos.getX() * 8, pos.getY() * 2, pos.getZ() * 8); } else { // travel to the overworld from the end - ServerWorld overworld = server.getWorld(this.goalDim); + ServerLevel overworld = server.getLevel(this.goalDim); BlockPos spawn = overworld.func_241135_u_(); BlockPos ret = new BlockPos(spawn.getX(), 0, spawn.getZ()); return ret.up(overworld.getHeight(Heightmap.Type.WORLD_SURFACE, spawn.getX(), spawn.getZ())); @@ -138,12 +138,12 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I } @Override - public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) { + public boolean isFlexibleRail(BlockState state, IBlockReader level, BlockPos pos) { return false; } @Override - public boolean canMakeSlopes(BlockState state, IBlockReader world, BlockPos pos) { + public boolean canMakeSlopes(BlockState state, IBlockReader level, BlockPos pos) { return false; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java index 6f95259b..cfc8af29 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityEndFlower; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.reg.*; @@ -9,21 +9,21 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.boss.dragon.EnderDragonEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.fluid.FluidState; import net.minecraft.item.ItemStack; import net.minecraft.loot.LootContext; import net.minecraft.loot.LootParameters; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevelReader; +import net.minecraft.level.Level; +import net.minecraft.level.gen.Heightmap; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -40,44 +40,44 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS super(Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0.5F).sound(SoundType.PLANT)); MinecraftForge.EVENT_BUS.register(this); ModRegistry.add(this); - ModRegistry.add(new ModTileType<>(TileEntityEndFlower::new, this)); + ModRegistry.add(new ModTileType<>(BlockEntityEndFlower::new, this)); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - Vector3d vec3d = state.getOffset(worldIn, pos); + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { + Vector3d vec3d = state.getOffset(levelIn, pos); return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z); } @SubscribeEvent public void onDragonTick(LivingUpdateEvent event) { LivingEntity living = event.getEntityLiving(); - if (living.world.isRemote || !(living instanceof EnderDragonEntity)) + if (living.level.isClientSide || !(living instanceof EnderDragonEntity)) return; EnderDragonEntity dragon = (EnderDragonEntity) living; if (dragon.deathTicks < 150 || dragon.deathTicks % 10 != 0) return; for (int i = 0; i < 6; i++) { - int x = dragon.world.rand.nextInt(256) - 128; - int z = dragon.world.rand.nextInt(256) - 128; - BlockPos pos = new BlockPos(x, dragon.world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z); - if (!dragon.world.isBlockLoaded(pos)) + int x = dragon.level.rand.nextInt(256) - 128; + int z = dragon.level.rand.nextInt(256) - 128; + BlockPos pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z); + if (!dragon.level.isBlockLoaded(pos)) continue; - if (dragon.world.getBlockState(pos.down()).getBlock() != Blocks.END_STONE) + if (dragon.level.getBlockState(pos.down()).getBlock() != Blocks.END_STONE) continue; - dragon.world.setBlockState(pos, this.getDefaultState()); + dragon.level.setBlockState(pos, this.getDefaultState()); } } @Override - protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) { + protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) { return state.getBlock() == Blocks.END_STONE; } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { - return worldIn.getBlockState(pos.down()).getBlock() == Blocks.END_STONE; + public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) { + return levelIn.getBlockState(pos.down()).getBlock() == Blocks.END_STONE; } @Override @@ -87,30 +87,30 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS @Nullable @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new TileEntityEndFlower(); + public BlockEntity createBlockEntity(BlockState state, IBlockReader level) { + return new BlockEntityEndFlower(); } @Override - public boolean hasTileEntity(BlockState state) { + public boolean hasBlockEntity(BlockState state) { return true; } @Override - public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) { - return willHarvest || super.removedByPlayer(state, world, pos, player, willHarvest, fluid); + public boolean removedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { + return willHarvest || super.removedByPlayer(state, level, pos, player, willHarvest, fluid); } @Override - public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) { - super.harvestBlock(worldIn, player, pos, state, te, stack); - worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); + public void harvestBlock(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) { + super.harvestBlock(levelIn, player, pos, state, te, stack); + levelIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } @Override public List getDrops(BlockState state, LootContext.Builder builder) { - TileEntity tile = builder.get(LootParameters.BLOCK_ENTITY); - if (tile instanceof TileEntityEndFlower && ((TileEntityEndFlower) tile).isDrainMode) + BlockEntity tile = builder.get(LootParameters.BLOCK_ENTITY); + if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode) return NonNullList.create(); return super.getDrops(state, builder); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java index 7119b6d5..e8f4e321 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java @@ -1,9 +1,9 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.items.ModItems; @@ -13,19 +13,19 @@ import net.minecraft.block.AnvilBlock; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.Player; +import net.minecraft.entity.player.ServerPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ActionResultType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.tileentity.BlockEntityType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; @@ -33,8 +33,8 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -50,13 +50,13 @@ import java.util.Random; import java.util.function.Function; import java.util.function.Supplier; -public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { // This is terrible but I can't see a better solution right now so oh well - private static final ThreadLocal> CACHED_WORLD = new ThreadLocal<>(); + private static final ThreadLocal> CACHED_WORLD = new ThreadLocal<>(); public BlockEnderCrate() { - super("ender_crate", TileEntityEnderCrate::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).setLightLevel(s -> 7).sound(SoundType.STONE)); + super("ender_crate", BlockEntityEnderCrate::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).setLightLevel(s -> 7).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @@ -79,18 +79,18 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider @SubscribeEvent public void onRightClick(PlayerInteractEvent.RightClickBlock event) { - World world = event.getWorld(); + Level level = event.getLevel(); BlockPos pos = event.getPos(); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); if (state.getBlock() instanceof AnvilBlock) { - CACHED_WORLD.set(new WeakReference<>(world)); + CACHED_WORLD.set(new WeakReference<>(level)); } } @SubscribeEvent public void onAnvilUpdate(AnvilUpdateEvent event) { - WeakReference world = CACHED_WORLD.get(); - if (world == null || world.get() == null) + WeakReference level = CACHED_WORLD.get(); + if (level == null || level.get() == null) return; ItemStack stack = event.getLeft(); if (stack.getItem() != Item.getItemFromBlock(this) && stack.getItem() != ModItems.ENDER_ACCESS) @@ -101,7 +101,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider String name = event.getName(); if (name == null || name.isEmpty()) return; - if (IWorldData.getOverworldData(world.get()).isEnderStorageLocked(name)) + if (ILevelData.getOverworldData(level.get()).isEnderStorageLocked(name)) return; ItemStack output = stack.copy(); output.getOrCreateTag().putString(NaturesAura.MOD_ID + ":ender_name", name); @@ -111,29 +111,29 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!worldIn.isRemote) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityEnderCrate) { - TileEntityEnderCrate crate = (TileEntityEnderCrate) tile; + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { + if (!levelIn.isClientSide) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityEnderCrate) { + BlockEntityEnderCrate crate = (BlockEntityEnderCrate) tile; if (crate.canOpen()) { crate.drainAura(2500); - NetworkHooks.openGui((ServerPlayerEntity) player, crate, pos); + NetworkHooks.openGui((ServerPlayer) player, crate, pos); } } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + public void addInformation(ItemStack stack, @Nullable IBlockReader levelIn, List tooltip, ITooltipFlag flagIn) { addEnderNameInfo(stack, tooltip); } @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { for (int i = 0; i < 3; ++i) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; @@ -143,12 +143,12 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider double d3 = rand.nextFloat() * (float) j; double d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D; double d5 = rand.nextFloat() * (float) k; - worldIn.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); + levelIn.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); } } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.ENDER_CRATE, () -> RenderEnderCrate::new); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java index cc8c4113..2d0537f8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityFieldCreator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFieldCreator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomRenderType; @@ -10,15 +10,15 @@ import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; +import net.minecraft.entity.player.Player; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -27,28 +27,28 @@ import java.util.function.Supplier; public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState, ICustomRenderType { public BlockFieldCreator() { - super("field_creator", TileEntityFieldCreator::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).notSolid().sound(SoundType.STONE)); + super("field_creator", BlockEntityFieldCreator::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).notSolid().sound(SoundType.STONE)); } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityFieldCreator) { - if (!worldIn.isRemote) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityFieldCreator) { + if (!levelIn.isClientSide) { String key = NaturesAura.MOD_ID + ":field_creator_pos"; - CompoundNBT compound = player.getPersistentData(); + CompoundTag compound = player.getPersistentData(); if (!player.isSneaking() && compound.contains(key)) { BlockPos stored = BlockPos.fromLong(compound.getLong(key)); - TileEntityFieldCreator creator = (TileEntityFieldCreator) tile; + BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile; if (!pos.equals(stored)) { if (creator.isCloseEnough(stored)) { - TileEntity otherTile = worldIn.getTileEntity(stored); - if (otherTile instanceof TileEntityFieldCreator) { + BlockEntity otherTile = levelIn.getBlockEntity(stored); + if (otherTile instanceof BlockEntityFieldCreator) { creator.connectionOffset = stored.subtract(pos); creator.isMain = true; creator.sendToClients(); - TileEntityFieldCreator otherCreator = (TileEntityFieldCreator) otherTile; + BlockEntityFieldCreator otherCreator = (BlockEntityFieldCreator) otherTile; otherCreator.connectionOffset = pos.subtract(stored); otherCreator.isMain = false; otherCreator.sendToClients(); @@ -66,17 +66,17 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true); } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } else - return ActionResultType.FAIL; + return InteractionResult.FAIL; } @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityFieldCreator) { - TileEntityFieldCreator creator = (TileEntityFieldCreator) tile; + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityFieldCreator) { + BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile; if (creator.isCharged) { BlockPos connected = creator.getConnectedPos(); if (connected != null) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java index 1b28bcb3..2ddb5bad 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java @@ -1,31 +1,31 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityFireworkGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFireworkGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockFireworkGenerator() { - super("firework_generator", TileEntityFireworkGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); + super("firework_generator", BlockEntityFireworkGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(4); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0xa442f4; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java index b06d2e4b..787efa15 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java @@ -1,32 +1,32 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityFlowerGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFlowerGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockFlowerGenerator() { - super("flower_generator", TileEntityFlowerGenerator::new, Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F)); + super("flower_generator", BlockEntityFlowerGenerator::new, Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(3, 1, 3); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0xffed2b; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java index 13985f11..c4869744 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFurnaceHeater; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Block; @@ -11,13 +11,13 @@ import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; @@ -38,7 +38,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo }; public BlockFurnaceHeater() { - super("furnace_heater", TileEntityFurnaceHeater::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); + super("furnace_heater", BlockEntityFurnaceHeater::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); } @Override @@ -48,9 +48,9 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityFurnaceHeater && ((BlockEntityFurnaceHeater) tile).isActive) { Direction facing = stateIn.get(FACING); float x; @@ -80,7 +80,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPES[state.get(FACING).getIndex()]; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java index a2f06d69..5707dff0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java @@ -1,29 +1,29 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.tileentity.BlockEntityType; import net.minecraft.util.Tuple; import java.util.function.Function; import java.util.function.Supplier; -public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { public BlockGeneratorLimitRemover() { - super("generator_limit_remover", TileEntityGeneratorLimitRemover::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); + super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.GENERATOR_LIMIT_REMOVER, () -> RenderGeneratorLimitRemover::new); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java index c1bc407e..21815777 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java @@ -21,11 +21,11 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevel; +import net.minecraft.level.ILevelReader; +import net.minecraft.level.Level; import java.util.function.Supplier; @@ -71,39 +71,39 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, @Override public IBlockColor getBlockColor() { - return (state, worldIn, pos, tintIndex) -> 0xf4cb42; + return (state, levelIn, pos, tintIndex) -> 0xf4cb42; } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPES[getShapeIndex(state)]; } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - IBlockReader iblockreader = context.getWorld(); + IBlockReader iblockreader = context.getLevel(); BlockPos blockpos = context.getPos(); return this.getDefaultState().with(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).with(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).with(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).with(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH)); } @Override - public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { + public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, ILevel levelIn, BlockPos currentPos, BlockPos facingPos) { if (facing == Direction.DOWN) { return stateIn; } else { - return facing == Direction.UP ? stateIn.with(WEST, this.getSide(worldIn, currentPos, Direction.WEST)).with(EAST, this.getSide(worldIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(worldIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(worldIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(worldIn, currentPos, facing)); + return facing == Direction.UP ? stateIn.with(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).with(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(levelIn, currentPos, facing)); } } - private RedstoneSide getSide(IBlockReader worldIn, BlockPos pos, Direction face) { + private RedstoneSide getSide(IBlockReader levelIn, BlockPos pos, Direction face) { BlockPos blockpos = pos.offset(face); - BlockState blockstate = worldIn.getBlockState(blockpos); + BlockState blockstate = levelIn.getBlockState(blockpos); BlockPos blockpos1 = pos.up(); - BlockState blockstate1 = worldIn.getBlockState(blockpos1); - if (!blockstate1.isNormalCube(worldIn, blockpos1)) { - boolean flag = blockstate.isSolidSide(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER; - if (flag && this.canConnectTo(worldIn.getBlockState(blockpos.up()))) { - if (blockstate.hasOpaqueCollisionShape(worldIn, blockpos)) { + BlockState blockstate1 = levelIn.getBlockState(blockpos1); + if (!blockstate1.isNormalCube(levelIn, blockpos1)) { + boolean flag = blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER; + if (flag && this.canConnectTo(levelIn.getBlockState(blockpos.up()))) { + if (blockstate.hasOpaqueCollisionShape(levelIn, blockpos)) { return RedstoneSide.UP; } @@ -111,7 +111,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, } } - return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(worldIn, blockpos) || !this.canConnectTo(worldIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE; + return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(levelIn, blockpos) || !this.canConnectTo(levelIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE; } protected boolean canConnectTo(BlockState blockState) { @@ -120,32 +120,32 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, } @Override - public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) { BlockPos blockpos = pos.down(); - BlockState blockstate = worldIn.getBlockState(blockpos); - return blockstate.isSolidSide(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER; + BlockState blockstate = levelIn.getBlockState(blockpos); + return blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER; } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return VoxelShapes.empty(); + public VoxelShape getCollisionShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { + return Shapes.empty(); } @Override - public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { - if (oldState.getBlock() != state.getBlock() && !worldIn.isRemote) { + public void onBlockAdded(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) { + if (oldState.getBlock() != state.getBlock() && !levelIn.isClientSide) { for (Direction direction : Direction.Plane.VERTICAL) { - worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this); + levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this); } for (Direction direction1 : Direction.Plane.HORIZONTAL) { - this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1)); + this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1)); } for (Direction direction2 : Direction.Plane.HORIZONTAL) { BlockPos blockpos = pos.offset(direction2); - if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) { - this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up()); + if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) { + this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up()); } else { - this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down()); + this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down()); } } @@ -153,22 +153,22 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onReplaced(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) { if (!isMoving && state.getBlock() != newState.getBlock()) { - super.onReplaced(state, worldIn, pos, newState, isMoving); - if (!worldIn.isRemote) { + super.onReplaced(state, levelIn, pos, newState, isMoving); + if (!levelIn.isClientSide) { for (Direction direction : Direction.values()) { - worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this); + levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this); } for (Direction direction1 : Direction.Plane.HORIZONTAL) { - this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1)); + this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1)); } for (Direction direction2 : Direction.Plane.HORIZONTAL) { BlockPos blockpos = pos.offset(direction2); - if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) { - this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up()); + if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) { + this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up()); } else { - this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down()); + this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down()); } } @@ -177,47 +177,47 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, } @Override - public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if (!worldIn.isRemote) { - if (!state.isValidPosition(worldIn, pos)) { - spawnDrops(state, worldIn, pos); - worldIn.removeBlock(pos, false); + public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { + if (!levelIn.isClientSide) { + if (!state.isValidPosition(levelIn, pos)) { + spawnDrops(state, levelIn, pos); + levelIn.removeBlock(pos, false); } } } @Override - public void updateDiagonalNeighbors(BlockState state, IWorld worldIn, BlockPos pos, int flags, int recursionLeft) { + public void updateDiagonalNeighbors(BlockState state, ILevel levelIn, BlockPos pos, int flags, int recursionLeft) { BlockPos.Mutable pool = new BlockPos.Mutable(); for (Direction direction : Direction.Plane.HORIZONTAL) { RedstoneSide redstoneside = state.get(RedstoneWireBlock.FACING_PROPERTY_MAP.get(direction)); - if (redstoneside != RedstoneSide.NONE && worldIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) { + if (redstoneside != RedstoneSide.NONE && levelIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) { pool.move(Direction.DOWN); - BlockState blockstate = worldIn.getBlockState(pool); + BlockState blockstate = levelIn.getBlockState(pool); if (blockstate.getBlock() != Blocks.OBSERVER) { BlockPos blockpos = pool.offset(direction.getOpposite()); - BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos), worldIn, pool, blockpos); - replaceBlock(blockstate, blockstate1, worldIn, pool, flags); + BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos); + replaceBlock(blockstate, blockstate1, levelIn, pool, flags); } pool.setPos(pos).move(direction).move(Direction.UP); - BlockState blockstate3 = worldIn.getBlockState(pool); + BlockState blockstate3 = levelIn.getBlockState(pool); if (blockstate3.getBlock() != Blocks.OBSERVER) { BlockPos blockpos1 = pool.offset(direction.getOpposite()); - BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos1), worldIn, pool, blockpos1); - replaceBlock(blockstate3, blockstate2, worldIn, pool, flags); + BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1); + replaceBlock(blockstate3, blockstate2, levelIn, pool, flags); } } } } - private void notifyWireNeighborsOfStateChange(World worldIn, BlockPos pos) { - if (worldIn.getBlockState(pos).getBlock() == this) { - worldIn.notifyNeighborsOfStateChange(pos, this); + private void notifyWireNeighborsOfStateChange(Level levelIn, BlockPos pos) { + if (levelIn.getBlockState(pos).getBlock() == this) { + levelIn.notifyNeighborsOfStateChange(pos, this); for (Direction direction : Direction.values()) { - worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this); + levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java index 5677f64e..387ced5f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java @@ -16,9 +16,9 @@ import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeColors; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.biome.BiomeColors; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -34,11 +34,11 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr ModRegistry.add(this); } - public static boolean convert(World world, BlockPos pos) { - BlockState state = world.getBlockState(pos); + public static boolean convert(Level level, BlockPos pos) { + BlockState state = level.getBlockState(pos); if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) { - if (!world.isRemote) { - world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState() + if (!level.isClientSide) { + level.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState() .with(DISTANCE, state.hasProperty(DISTANCE) ? state.get(DISTANCE) : 1) .with(PERSISTENT, state.hasProperty(PERSISTENT) ? state.get(PERSISTENT) : false)); } @@ -54,7 +54,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { if (stateIn.get(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F) NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + rand.nextFloat(), @@ -73,10 +73,10 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr @Override @OnlyIn(Dist.CLIENT) public IBlockColor getBlockColor() { - return (state, worldIn, pos, tintIndex) -> { + return (state, levelIn, pos, tintIndex) -> { int color = 0xF2FF00; - if (state != null && worldIn != null && pos != null) { - int foliage = BiomeColors.getFoliageColor(worldIn, pos); + if (state != null && levelIn != null && pos != null) { + int foliage = BiomeColors.getFoliageColor(levelIn, pos); return Helper.blendColors(color, foliage, state.get(STAGE) / (float) HIGHEST_STAGE); } else { return color; @@ -91,18 +91,18 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr } @Override - public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { - super.randomTick(state, worldIn, pos, random); - if (!worldIn.isRemote) { + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + super.randomTick(state, levelIn, pos, random); + if (!levelIn.isClientSide) { int stage = state.get(STAGE); if (stage < HIGHEST_STAGE) { - worldIn.setBlockState(pos, state.with(STAGE, stage + 1)); + levelIn.setBlockState(pos, state.with(STAGE, stage + 1)); } if (stage > 1) { BlockPos offset = pos.offset(Direction.func_239631_a_(random)); - if (worldIn.isBlockLoaded(offset)) - convert(worldIn, offset); + if (levelIn.isBlockLoaded(offset)) + convert(levelIn, offset); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java index 7eae6a95..8fa1d3c4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java @@ -1,20 +1,20 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGratedChute; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomItemModel; import net.minecraft.block.*; import net.minecraft.block.material.Material; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.IHopper; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; @@ -23,9 +23,9 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.items.IItemHandler; import javax.annotation.Nullable; @@ -35,21 +35,21 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock public static final DirectionProperty FACING = HopperBlock.FACING; private static final VoxelShape INPUT_SHAPE = Block.makeCuboidShape(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D); private static final VoxelShape MIDDLE_SHAPE = Block.makeCuboidShape(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D); - private static final VoxelShape INPUT_MIDDLE_SHAPE = VoxelShapes.or(MIDDLE_SHAPE, INPUT_SHAPE); - private static final VoxelShape COMBINED_SHAPE = VoxelShapes.combineAndSimplify(INPUT_MIDDLE_SHAPE, IHopper.INSIDE_BOWL_SHAPE, IBooleanFunction.ONLY_FIRST); - private static final VoxelShape DOWN_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D)); - private static final VoxelShape EAST_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D)); - private static final VoxelShape NORTH_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D)); - private static final VoxelShape SOUTH_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D)); - private static final VoxelShape WEST_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D)); + private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(MIDDLE_SHAPE, INPUT_SHAPE); + private static final VoxelShape COMBINED_SHAPE = Shapes.combineAndSimplify(INPUT_MIDDLE_SHAPE, IHopper.INSIDE_BOWL_SHAPE, IBooleanFunction.ONLY_FIRST); + private static final VoxelShape DOWN_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D)); + private static final VoxelShape EAST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D)); + private static final VoxelShape NORTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D)); + private static final VoxelShape SOUTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D)); + private static final VoxelShape WEST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D)); private static final VoxelShape DOWN_RAYTRACE_SHAPE = IHopper.INSIDE_BOWL_SHAPE; - private static final VoxelShape EAST_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); - private static final VoxelShape NORTH_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); - private static final VoxelShape SOUTH_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); - private static final VoxelShape WEST_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); + private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); + private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); + private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); + private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); public BlockGratedChute() { - super("grated_chute", TileEntityGratedChute::new, Properties.create(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL)); + super("grated_chute", BlockEntityGratedChute::new, Properties.create(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL)); } @Override @@ -58,7 +58,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { switch (state.get(FACING)) { case DOWN: return DOWN_SHAPE; @@ -76,7 +76,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock } @Override - public VoxelShape getRaytraceShape(BlockState state, IBlockReader worldIn, BlockPos pos) { + public VoxelShape getRaytraceShape(BlockState state, IBlockReader levelIn, BlockPos pos) { switch (state.get(FACING)) { case DOWN: return DOWN_RAYTRACE_SHAPE; @@ -94,18 +94,18 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { if (!player.isSneaking()) - return ActionResultType.FAIL; - TileEntity tile = worldIn.getTileEntity(pos); - if (!(tile instanceof TileEntityGratedChute)) - return ActionResultType.FAIL; - if (!worldIn.isRemote) { - TileEntityGratedChute chute = (TileEntityGratedChute) tile; + return InteractionResult.FAIL; + BlockEntity tile = levelIn.getBlockEntity(pos); + if (!(tile instanceof BlockEntityGratedChute)) + return InteractionResult.FAIL; + if (!levelIn.isClientSide) { + BlockEntityGratedChute chute = (BlockEntityGratedChute) tile; chute.isBlacklist = !chute.isBlacklist; chute.sendToClients(); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Nullable @@ -128,10 +128,10 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock } @Override - public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntityGratedChute) { - IItemHandler handler = ((TileEntityGratedChute) tile).getItemHandler(); + public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntityGratedChute) { + IItemHandler handler = ((BlockEntityGratedChute) tile).getItemHandler(); ItemStack stack = handler.getStackInSlot(0); if (stack.isEmpty()) return 0; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java index 3a572f53..c05aa5cb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java @@ -1,29 +1,29 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityHopperUpgrade; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable { public BlockHopperUpgrade() { - super("hopper_upgrade", TileEntityHopperUpgrade::new, Properties.create(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL)); + super("hopper_upgrade", BlockEntityHopperUpgrade::new, Properties.create(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(7); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x434f3f; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java index 89cf56fc..c6f42267 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; public class BlockImpl extends Block implements IModItem { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java index d7acb0f7..3e488cfe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java @@ -1,37 +1,37 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityItemDistributor; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; +import net.minecraft.entity.player.Player; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.level.Level; public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState { public BlockItemDistributor() { - super("item_distributor", TileEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS)); + super("item_distributor", BlockEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS)); } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { if (!player.isSneaking()) - return ActionResultType.FAIL; - TileEntity tile = worldIn.getTileEntity(pos); - if (!(tile instanceof TileEntityItemDistributor)) - return ActionResultType.FAIL; - if (!worldIn.isRemote) { - TileEntityItemDistributor distributor = (TileEntityItemDistributor) tile; + return InteractionResult.FAIL; + BlockEntity tile = levelIn.getBlockEntity(pos); + if (!(tile instanceof BlockEntityItemDistributor)) + return InteractionResult.FAIL; + if (!levelIn.isClientSide) { + BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile; distributor.isRandomMode = !distributor.isRandomMode; distributor.sendToClients(); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java index 3d867b2b..09acc405 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java @@ -12,8 +12,8 @@ import net.minecraft.item.BlockItemUseContext; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -30,7 +30,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { for (int i = 0; i < 2; i++) NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, @@ -39,7 +39,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java index 16f2bfc3..480df6d9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java @@ -1,29 +1,29 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable { public BlockMossGenerator() { - super("moss_generator", TileEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); + super("moss_generator", BlockEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(2); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x15702d; } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index a13c466c..23a488cb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -3,45 +3,46 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.core.BlockPos; +import net.minecraft.entity.player.Player; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ActionResultType; +import net.minecraft.tileentity.BlockEntityType; import net.minecraft.util.Hand; import net.minecraft.util.Tuple; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.ToolType; import javax.annotation.Nullable; import java.util.function.Function; import java.util.function.Supplier; -public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { - private static final VoxelShape SHAPE = VoxelShapes.create(0, 0, 0, 1, 12 / 16F, 1); + private static final VoxelShape SHAPE = Shapes.create(0, 0, 0, 1, 12 / 16F, 1); public static final BooleanProperty NETHER = BooleanProperty.create("nether"); public BlockNatureAltar() { - super("nature_altar", TileEntityNatureAltar::new, Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); + super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); this.setDefaultState(this.getDefaultState().with(NETHER, false)); } @@ -51,17 +52,18 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { return SHAPE; } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { return Helper.putStackOnTile(player, handIn, pos, 0, true); } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.NATURE_ALTAR, () -> RenderNatureAltar::new); } @@ -79,7 +81,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { - boolean nether = IAuraType.forWorld(context.getWorld()).isSimilar(NaturesAuraAPI.TYPE_NETHER); + boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); return super.getStateForPlacement(context).with(NETHER, nether); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java index d0c062da..f0b91cb1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java @@ -7,9 +7,9 @@ import net.minecraft.block.Blocks; import net.minecraft.block.IGrowable; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import java.util.Random; @@ -20,11 +20,11 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG } @Override - public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { BlockPos up = pos.up(); - BlockState upState = worldIn.getBlockState(up); - if (upState.isSolidSide(worldIn, up, Direction.DOWN)) - worldIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); + BlockState upState = levelIn.getBlockState(up); + if (upState.isSolidSide(levelIn, up, Direction.DOWN)) + levelIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState()); } @Override @@ -36,17 +36,17 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG } @Override - public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) { - return worldIn.getBlockState(pos.up()).isAir(worldIn, pos.up()); + public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) { + return levelIn.getBlockState(pos.up()).isAir(levelIn, pos.up()); } @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state) { + public boolean canUseBonemeal(Level levelIn, Random rand, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) { + public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) { BlockPos blockpos = pos.up(); BlockState blockstate = Blocks.GRASS.getDefaultState(); @@ -56,23 +56,23 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG while (true) { if (j >= i / 16) { - BlockState blockstate2 = world.getBlockState(blockpos1); + BlockState blockstate2 = level.getBlockState(blockpos1); if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) { - ((IGrowable) blockstate.getBlock()).grow(world, rand, blockpos1, blockstate2); + ((IGrowable) blockstate.getBlock()).grow(level, rand, blockpos1, blockstate2); } if (!blockstate2.isAir()) { break; } - if (blockstate.isValidPosition(world, blockpos1)) { - world.setBlockState(blockpos1, blockstate, 3); + if (blockstate.isValidPosition(level, blockpos1)) { + level.setBlockState(blockpos1, blockstate, 3); } break; } blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1); - if (world.getBlockState(blockpos1.down()).getBlock() != this || world.getBlockState(blockpos1).hasOpaqueCollisionShape(world, blockpos1)) { + if (level.getBlockState(blockpos1.down()).getBlock() != this || level.getBlockState(blockpos1).hasOpaqueCollisionShape(level, blockpos1)) { break; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index 5d650bf4..e1867dc3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SaplingBlock; @@ -12,12 +12,12 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.level.ILevel; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.SaplingGrowTreeEvent; +import net.minecraftforge.event.level.SaplingGrowTreeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import java.util.Random; @@ -25,24 +25,24 @@ import java.util.Random; public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockOakGenerator() { - super("oak_generator", TileEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); + super("oak_generator", BlockEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onTreeGrow(SaplingGrowTreeEvent event) { - IWorld world = event.getWorld(); + ILevel level = event.getLevel(); BlockPos pos = event.getPos(); - if (world instanceof World && !world.isRemote() && IAuraType.forWorld(world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) - && world.getBlockState(pos).getBlock() instanceof SaplingBlock) { - Helper.getTileEntitiesInArea(world, pos, 10, tile -> { - if (!(tile instanceof TileEntityOakGenerator)) + if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel(level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) + && level.getBlockState(pos).getBlock() instanceof SaplingBlock) { + Helper.getTileEntitiesInArea(level, pos, 10, tile -> { + if (!(tile instanceof BlockEntityOakGenerator)) return false; Random rand = event.getRand(); if (rand.nextInt(10) == 0) - ((TileEntityOakGenerator) tile).scheduledBigTrees.add(pos); + ((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos); long seed; do { @@ -59,13 +59,13 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(10); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x2e7a11; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java index 2aca69aa..c0a3ca47 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; @@ -10,30 +10,30 @@ import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ActionResultType; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.entity.player.Player; +import net.minecraft.tileentity.BlockEntityType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.Level; import java.util.function.Function; import java.util.function.Supplier; -public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { - private static final VoxelShape SHAPE = VoxelShapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); + private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); public BlockOfferingTable() { - super("offering_table", TileEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); + super("offering_table", BlockEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); } @Override @@ -42,17 +42,17 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { return Helper.putStackOnTile(player, handIn, pos, 0, true); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.OFFERING_TABLE, () -> RenderOfferingTable::new); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java index c07c86aa..8db8dd79 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPickupStopper; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -10,11 +10,11 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.entity.player.Player; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -23,21 +23,21 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockPickupStopper() { - super("pickup_stopper", TileEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); + super("pickup_stopper", BlockEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onPickup(EntityItemPickupEvent event) { - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); if (player != null && !player.isSneaking()) { ItemEntity item = event.getItem(); BlockPos pos = item.getPosition(); - Helper.getTileEntitiesInArea(item.world, pos, 8, tile -> { - if (!(tile instanceof TileEntityPickupStopper)) + Helper.getTileEntitiesInArea(item.level, pos, 8, tile -> { + if (!(tile instanceof BlockEntityPickupStopper)) return false; - TileEntityPickupStopper stopper = (TileEntityPickupStopper) tile; + BlockEntityPickupStopper stopper = (BlockEntityPickupStopper) tile; float radius = stopper.getRadius(); if (radius <= 0F) return false; @@ -47,8 +47,8 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza event.setCanceled(true); - if (item.world.getGameTime() % 3 == 0) - PacketHandler.sendToAllAround(item.world, pos, 32, + if (item.level.getGameTime() % 3 == 0) + PacketHandler.sendToAllAround(item.level, pos, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.PICKUP_STOPPER)); return true; }); @@ -57,10 +57,10 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityPickupStopper) { - double radius = ((TileEntityPickupStopper) tile).getRadius(); + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntityPickupStopper) { + double radius = ((BlockEntityPickupStopper) tile).getRadius(); if (radius > 0) return new AxisAlignedBB(pos).grow(radius); } @@ -69,7 +69,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0xf4aa42; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java index 62417f03..d84d4d5d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java @@ -1,32 +1,32 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityPlacer; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPlacer; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockPlacer() { - super("placer", TileEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); + super("placer", BlockEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(5); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x078a93; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java index 9ad653a5..4cd77412 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityPotionGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.material.Material; @@ -8,7 +8,7 @@ import net.minecraftforge.common.ToolType; public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState { public BlockPotionGenerator() { - super("potion_generator", TileEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1)); + super("potion_generator", BlockEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java index 08a12f1f..79559538 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPowderPlacer; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.BlockState; @@ -9,15 +9,15 @@ import net.minecraft.block.material.Material; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBlockState { - private static final VoxelShape SHAPE = VoxelShapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F); + private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F); public BlockPowderPlacer() { - super("powder_placer", TileEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE)); + super("powder_placer", BlockEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE)); } @Override @@ -26,7 +26,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java index 6843e3e7..98ffc4dd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -13,8 +13,8 @@ import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.DispenserBlock; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.dispenser.IPosition; import net.minecraft.dispenser.ProjectileDispenseBehavior; import net.minecraft.entity.Entity; @@ -25,15 +25,15 @@ import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.entity.projectile.TridentEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.tileentity.BlockEntityType; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -42,24 +42,24 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.util.function.Function; import java.util.function.Supplier; -public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { public BlockProjectileGenerator() { - super("projectile_generator", TileEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); + super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); DispenserBlock.registerDispenseBehavior(Items.ENDER_PEARL, new ProjectileDispenseBehavior() { @Override - protected ProjectileEntity getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) { - EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, worldIn); + protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) { + EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, levelIn); ret.setPosition(position.getX(), position.getY(), position.getZ()); return ret; } }); DispenserBlock.registerDispenseBehavior(Items.TRIDENT, new ProjectileDispenseBehavior() { @Override - protected ProjectileEntity getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) { - TridentEntity ret = new TridentEntity(EntityType.TRIDENT, worldIn); + protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) { + TridentEntity ret = new TridentEntity(EntityType.TRIDENT, levelIn); ret.setPosition(position.getX(), position.getY(), position.getZ()); // set thrownStack ObfuscationReflectionHelper.setPrivateValue(TridentEntity.class, ret, stackIn.copy(), "field_203054_h"); @@ -72,7 +72,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES @SubscribeEvent public void onProjectileImpact(ProjectileImpactEvent event) { Entity entity = event.getEntity(); - if (entity.world.isRemote) + if (entity.level.isClientSide) return; RayTraceResult ray = event.getRayTraceResult(); if (!(ray instanceof BlockRayTraceResult)) @@ -81,10 +81,10 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES BlockPos pos = blockRay.getPos(); if (pos == null) return; - TileEntity tile = entity.world.getTileEntity(pos); - if (!(tile instanceof TileEntityProjectileGenerator)) + BlockEntity tile = entity.level.getBlockEntity(pos); + if (!(tile instanceof BlockEntityProjectileGenerator)) return; - TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile; + BlockEntityProjectileGenerator generator = (BlockEntityProjectileGenerator) tile; if (generator.nextSide != blockRay.getFace()) return; Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType()); @@ -94,9 +94,9 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES return; generator.generateAura(amount); - PacketHandler.sendToAllAround(entity.world, pos, 32, + PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles((float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ())); - entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F); + entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F); generator.nextSide = generator.nextSide.rotateY(); generator.sendToClients(); @@ -106,7 +106,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.PROJECTILE_GENERATOR, () -> RenderProjectileGenerator::new); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java index d320a981..9526efc5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java @@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; public class BlockRFConverter extends BlockContainerImpl { public BlockRFConverter() { - super("rf_converter", TileEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3)); + super("rf_converter", BlockEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java index 7aa75cee..706674b3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntitySlimeSplitGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Blocks; @@ -10,7 +10,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -19,7 +19,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockSlimeSplitGenerator() { - super("slime_split_generator", TileEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2)); + super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2)); MinecraftForge.EVENT_BUS.register(new Events()); } @@ -33,13 +33,13 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return new AxisAlignedBB(pos).grow(8); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x4da84f; } @@ -48,16 +48,16 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis @SubscribeEvent public void onLivingDeath(LivingDeathEvent event) { LivingEntity entity = event.getEntityLiving(); - if (!(entity instanceof SlimeEntity) || entity.world.isRemote) + if (!(entity instanceof SlimeEntity) || entity.level.isClientSide) return; SlimeEntity slime = (SlimeEntity) entity; int size = slime.getSlimeSize(); if (size <= 1) return; - Helper.getTileEntitiesInArea(entity.world, entity.getPosition(), 8, tile -> { - if (!(tile instanceof TileEntitySlimeSplitGenerator)) + Helper.getTileEntitiesInArea(entity.level, entity.getPosition(), 8, tile -> { + if (!(tile instanceof BlockEntitySlimeSplitGenerator)) return false; - TileEntitySlimeSplitGenerator gen = (TileEntitySlimeSplitGenerator) tile; + BlockEntitySlimeSplitGenerator gen = (BlockEntitySlimeSplitGenerator) tile; if (gen.isBusy()) return false; gen.startGenerating(slime); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSnowCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSnowCreator.java index c8bfa45b..833c3a6f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSnowCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSnowCreator.java @@ -1,28 +1,28 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntitySnowCreator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySnowCreator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Blocks; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockSnowCreator() { - super("snow_creator", TileEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS)); + super("snow_creator", BlockEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS)); } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntitySnowCreator) { - int radius = ((TileEntitySnowCreator) tile).getRange(); + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntitySnowCreator) { + int radius = ((BlockEntitySnowCreator) tile).getRange(); if (radius > 0) return new AxisAlignedBB(pos).grow(radius); } @@ -30,7 +30,7 @@ public class BlockSnowCreator extends BlockContainerImpl implements IVisualizabl } @Override - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0xdbe9ff; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java index 189575e4..d693e25b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java @@ -1,11 +1,11 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpawnLamp; import de.ellpeck.naturesaura.data.BlockStateGenerator; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.reg.ICustomBlockState; @@ -15,17 +15,17 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.RenderType; import net.minecraft.entity.MobEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.Shapes; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevel; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -37,10 +37,10 @@ import java.util.function.Supplier; public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, ICustomBlockState, ICustomRenderType { - private static final VoxelShape SHAPE = VoxelShapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); + private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); public BlockSpawnLamp() { - super("spawn_lamp", TileEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL)); + super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL)); MinecraftForge.EVENT_BUS.register(this); } @@ -53,12 +53,12 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, public void onSpawn(LivingSpawnEvent.CheckSpawn event) { if (event.getSpawner() != null) return; - IWorld world = event.getWorld(); + ILevel level = event.getLevel(); BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ()); - if (!(world instanceof World)) + if (!(level instanceof Level)) return; - WorldData data = (WorldData) IWorldData.getWorldData((World) world); - for (TileEntitySpawnLamp lamp : data.spawnLamps) { + LevelData data = (LevelData) ILevelData.getLevelData((Level) level); + for (BlockEntitySpawnLamp lamp : data.spawnLamps) { if (lamp.isRemoved()) continue; @@ -71,11 +71,11 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, continue; MobEntity entity = (MobEntity) event.getEntityLiving(); - if (entity.canSpawn(world, event.getSpawnReason()) && entity.isNotColliding(world)) { - BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos); - IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200); + if (entity.canSpawn(level, event.getSpawnReason()) && entity.isNotColliding(level)) { + BlockPos spot = IAuraChunk.getHighestSpot(level, lampPos, 32, lampPos); + IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 200); - PacketHandler.sendToAllAround((ServerWorld) world, lampPos, 32, + PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32, new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP)); } @@ -85,16 +85,16 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntitySpawnLamp) { - int radius = ((TileEntitySpawnLamp) tile).getRadius(); + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntitySpawnLamp) { + int radius = ((BlockEntitySpawnLamp) tile).getRadius(); if (radius > 0) return new AxisAlignedBB(pos).grow(radius); } @@ -103,7 +103,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return 0x825ee5; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java index 654470df..b4d904e1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpring; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpring; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.IColorProvidingBlock; import de.ellpeck.naturesaura.reg.IColorProvidingItem; @@ -13,14 +13,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorld; -import net.minecraft.world.biome.BiomeColors; +import net.minecraft.level.ILevel; +import net.minecraft.level.biome.BiomeColors; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -28,13 +28,13 @@ import java.util.function.Supplier; public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, IBucketPickupHandler, ICustomRenderType { public BlockSpring() { - super("spring", TileEntitySpring::new, Properties.from(Blocks.STONE_BRICKS)); + super("spring", BlockEntitySpring::new, Properties.from(Blocks.STONE_BRICKS)); } @Override @OnlyIn(Dist.CLIENT) public IBlockColor getBlockColor() { - return (state, world, pos, i) -> BiomeColors.getWaterColor(world, pos); + return (state, level, pos, i) -> BiomeColors.getWaterColor(level, pos); } @Override @@ -44,8 +44,8 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState return new IItemColor() { @Override public int getColor(ItemStack stack, int i) { - PlayerEntity player = Minecraft.getInstance().player; - return BiomeColors.getWaterColor(player.world, player.getPosition()); + Player player = Minecraft.getInstance().player; + return BiomeColors.getWaterColor(player.level, player.getPosition()); } }; } @@ -56,10 +56,10 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState } @Override - public Fluid pickupFluid(IWorld worldIn, BlockPos pos, BlockState state) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileEntitySpring) - ((TileEntitySpring) tile).consumeAura(2500); + public Fluid pickupFluid(ILevel levelIn, BlockPos pos, BlockState state) { + BlockEntity tile = levelIn.getBlockEntity(pos); + if (tile instanceof BlockEntitySpring) + ((BlockEntitySpring) tile).consumeAura(2500); return Fluids.WATER; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java index 27deb0ab..1c558fda 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityTimeChanger; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.SoundType; @@ -8,7 +8,7 @@ import net.minecraft.block.material.Material; public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState { public BlockTimeChanger() { - super("time_changer", TileEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); + super("time_changer", BlockEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWeatherChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWeatherChanger.java index 1389cd33..38aa86ad 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWeatherChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWeatherChanger.java @@ -1,13 +1,13 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityWeatherChanger; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWeatherChanger; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.Blocks; public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState { public BlockWeatherChanger() { - super("weather_changer", TileEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS)); + super("weather_changer", BlockEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index 7683e407..746fcee8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand; import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.recipes.ModRecipes; @@ -13,27 +13,27 @@ import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.ActionResultType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.tileentity.BlockEntityType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.util.math.shapes.Shapes; +import net.minecraft.level.IBlockReader; +import net.minecraft.level.ILevel; +import net.minecraft.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolType; -import net.minecraftforge.event.world.SaplingGrowTreeEvent; +import net.minecraftforge.event.level.SaplingGrowTreeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.commons.lang3.mutable.MutableObject; @@ -43,12 +43,12 @@ import java.util.List; import java.util.function.Function; import java.util.function.Supplier; -public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { +public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { - private static final VoxelShape SHAPE = VoxelShapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F); + private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F); public BlockWoodStand() { - super("wood_stand", TileEntityWoodStand::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE)); + super("wood_stand", BlockEntityWoodStand::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE)); MinecraftForge.EVENT_BUS.register(this); } @@ -58,28 +58,28 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider< } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @SubscribeEvent public void onTreeGrow(SaplingGrowTreeEvent event) { - IWorld world = event.getWorld(); + ILevel level = event.getLevel(); BlockPos pos = event.getPos(); - if (!world.isRemote() && world instanceof World) { - if (Multiblocks.TREE_RITUAL.isComplete((World) world, pos)) { - BlockState sapling = world.getBlockState(pos); - ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling); + if (!level.isClientSide() && level instanceof Level) { + if (Multiblocks.TREE_RITUAL.isComplete((Level) level, pos)) { + BlockState sapling = level.getBlockState(pos); + ItemStack saplingStack = sapling.getBlock().getItem(level, pos, sapling); if (!saplingStack.isEmpty()) { - for (TreeRitualRecipe recipe : ((World) world).getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null)) { + for (TreeRitualRecipe recipe : ((Level) level).getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null)) { if (recipe.saplingType.test(saplingStack)) { List required = new ArrayList<>(Arrays.asList(recipe.ingredients)); - MutableObject toPick = new MutableObject<>(); + MutableObject toPick = new MutableObject<>(); boolean fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> { - TileEntity tile = world.getTileEntity(tilePos); - if (tile instanceof TileEntityWoodStand) { - TileEntityWoodStand stand = (TileEntityWoodStand) tile; + BlockEntity tile = level.getBlockEntity(tilePos); + if (tile instanceof BlockEntityWoodStand) { + BlockEntityWoodStand stand = (BlockEntityWoodStand) tile; ItemStack stack = stand.items.getStackInSlot(0); if (!stack.isEmpty()) { for (int i = required.size() - 1; i >= 0; i--) { @@ -111,12 +111,12 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider< } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { + public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) { return Helper.putStackOnTile(player, handIn, pos, 0, true); } @Override - public Tuple, Supplier>>> getTESR() { + public Tuple, Supplier>>> getTESR() { return new Tuple<>(ModTileEntities.WOOD_STAND, () -> RenderWoodStand::new); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 8dc1ffd8..d2288316 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import net.minecraft.block.Block; +import net.minecraft.world.level.block.Block; @SuppressWarnings("FieldNamingConvention") public final class ModBlocks { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblock.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblock.java index 85cc75e7..49207874 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblock.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblock.java @@ -8,7 +8,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import java.util.HashMap; import java.util.Map; @@ -83,11 +83,11 @@ public class Multiblock implements IMultiblock { if (value instanceof BlockState) { BlockState state = (BlockState) value; matchers.put(c, new Matcher(state, - (world, start, offset, pos, other, otherC) -> other == state)); + (level, start, offset, pos, other, otherC) -> other == state)); } else if (value instanceof Block) { Block block = (Block) value; matchers.put(c, new Matcher(block.getDefaultState(), - (world, start, offset, pos, state, otherC) -> state.getBlock() == block)); + (level, start, offset, pos, state, otherC) -> state.getBlock() == block)); } else matchers.put(c, (Matcher) value); } @@ -107,11 +107,11 @@ public class Multiblock implements IMultiblock { } @Override - public boolean isComplete(World world, BlockPos center) { + public boolean isComplete(Level level, BlockPos center) { BlockPos start = this.getStart(center); return this.forEach(center, (char) 0, (pos, matcher) -> { BlockPos offset = pos.subtract(start); - return matcher.getCheck().matches(world, start, offset, pos, world.getBlockState(pos), this.getChar(offset)); + return matcher.getCheck().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset)); }); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java index e7344e27..aa37f60a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -45,16 +45,16 @@ public final class Multiblocks { new String[][]{ {" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}}, 'W', new Matcher(ModBlocks.WOOD_STAND.getDefaultState(), - (world, start, offset, pos, state, c) -> world != null || state.getBlock() == ModBlocks.WOOD_STAND), + (level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND), 'G', ModBlocks.GOLD_POWDER, '0', new Matcher(Blocks.OAK_SAPLING.getDefaultState(), - (world, start, offset, pos, state, c) -> { + (level, start, offset, pos, state, c) -> { if (state.getBlock() instanceof SaplingBlock || state.getMaterial() == Material.WOOD) return true; // try-catch to prevent blocks that need to have been placed crashing here try { - ItemStack stack = state.getBlock().getItem(world, pos, state); - return !stack.isEmpty() && world.getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack)); + ItemStack stack = state.getBlock().getItem(level, pos, state); + return !stack.isEmpty() && level.getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack)); } catch (Exception e) { return false; } @@ -77,7 +77,7 @@ public final class Multiblocks { new String[][]{ {" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}}, 'R', new Matcher(Blocks.POPPY.getDefaultState(), - (world, start, offset, pos, state, c) -> BlockTags.SMALL_FLOWERS.contains(state.getBlock())), + (level, start, offset, pos, state, c) -> BlockTags.SMALL_FLOWERS.contains(state.getBlock())), '0', ModBlocks.OFFERING_TABLE, ' ', Matcher.wildcard()); public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock( diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java similarity index 68% rename from src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java rename to src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java index ecfae8b1..32b8b4c3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java @@ -3,9 +3,11 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.level.block.state.BlockState; -public class TileEntityAncientLeaves extends TileEntityImpl { +public class BlockEntityAncientLeaves extends BlockEntityImpl { private final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 2000, 500) { @Override @@ -17,14 +19,14 @@ public class TileEntityAncientLeaves extends TileEntityImpl { public int drainAura(int amountToDrain, boolean simulate) { int amount = super.drainAura(amountToDrain, simulate); if (amount > 0 && !simulate) { - TileEntityAncientLeaves.this.sendToClients(); + BlockEntityAncientLeaves.this.sendToClients(); } return amount; } }; - public TileEntityAncientLeaves() { - super(ModTileEntities.ANCIENT_LEAVES); + public BlockEntityAncientLeaves(BlockPos pos, BlockState state) { + super(ModTileEntities.ANCIENT_LEAVES, pos, state); } @Override @@ -33,14 +35,14 @@ public class TileEntityAncientLeaves extends TileEntityImpl { } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) this.container.writeNBT(compound); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) this.container.readNBT(compound); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java index 63992713..3ed95213 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ItemStackHandlerNA.java @@ -7,14 +7,14 @@ import javax.annotation.Nonnull; public class ItemStackHandlerNA extends ItemStackHandler { - private final TileEntityImpl tile; + private final BlockEntityImpl tile; private final boolean sendToClients; public ItemStackHandlerNA(int size) { this(size, null, false); } - public ItemStackHandlerNA(int size, TileEntityImpl tile, boolean sendToClients) { + public ItemStackHandlerNA(int size, BlockEntityImpl tile, boolean sendToClients) { super(size); this.tile = tile; this.sendToClients = sendToClients; @@ -24,7 +24,7 @@ public class ItemStackHandlerNA extends ItemStackHandler { protected void onContentsChanged(int slot) { if (this.tile != null) { this.tile.markDirty(); - if (this.sendToClients && !this.tile.getWorld().isRemote) + if (this.sendToClients && !this.tile.getLevel().isClientSide) this.tile.sendToClients(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java index 2346b4cc..13c91c30 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/ModTileEntities.java @@ -1,45 +1,46 @@ package de.ellpeck.naturesaura.blocks.tiles; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.entity.BlockEntityType; @SuppressWarnings("FieldNamingConvention") public final class ModTileEntities { - public static TileEntityType ANCIENT_LEAVES; - public static TileEntityType ANIMAL_GENERATOR; - public static TileEntityType ANIMAL_SPAWNER; - public static TileEntityType AURA_DETECTOR; - public static TileEntityType AUTO_CRAFTER; - public static TileEntityType CHUNK_LOADER; - public static TileEntityType ENDER_CRATE; - public static TileEntityType END_FLOWER; - public static TileEntityType FIELD_CREATOR; - public static TileEntityType FIREWORK_GENERATOR; - public static TileEntityType FLOWER_GENERATOR; - public static TileEntityType FURNACE_HEATER; - public static TileEntityType GENERATOR_LIMIT_REMOVER; - public static TileEntityType GRATED_CHUTE; - public static TileEntityType HOPPER_UPGRADE; - public static TileEntityType MOSS_GENERATOR; - public static TileEntityType NATURE_ALTAR; - public static TileEntityType OAK_GENERATOR; - public static TileEntityType OFFERING_TABLE; - public static TileEntityType PICKUP_STOPPER; - public static TileEntityType PLACER; - public static TileEntityType POTION_GENERATOR; - public static TileEntityType POWDER_PLACER; - public static TileEntityType PROJECTILE_GENERATOR; - public static TileEntityType RF_CONVERTER; - public static TileEntityType SPAWN_LAMP; - public static TileEntityType TIME_CHANGER; - public static TileEntityType WOOD_STAND; - public static TileEntityType BLAST_FURNACE_BOOSTER; - public static TileEntityType ANIMAL_CONTAINER; - public static TileEntityType SNOW_CREATOR; - public static TileEntityType ITEM_DISTRIBUTOR; - public static TileEntityType AURA_BLOOM; - public static TileEntityType CHORUS_GENERATOR; - public static TileEntityType AURA_TIMER; - public static TileEntityType SLIME_SPLIT_GENERATOR; - public static TileEntityType SPRING; - public static TileEntityType WEATHER_CHANGER; + + public static BlockEntityType ANCIENT_LEAVES; + public static BlockEntityType ANIMAL_GENERATOR; + public static BlockEntityType ANIMAL_SPAWNER; + public static BlockEntityType AURA_DETECTOR; + public static BlockEntityType AUTO_CRAFTER; + public static BlockEntityType CHUNK_LOADER; + public static BlockEntityType ENDER_CRATE; + public static BlockEntityType END_FLOWER; + public static BlockEntityType FIELD_CREATOR; + public static BlockEntityType FIREWORK_GENERATOR; + public static BlockEntityType FLOWER_GENERATOR; + public static BlockEntityType FURNACE_HEATER; + public static BlockEntityType GENERATOR_LIMIT_REMOVER; + public static BlockEntityType GRATED_CHUTE; + public static BlockEntityType HOPPER_UPGRADE; + public static BlockEntityType MOSS_GENERATOR; + public static BlockEntityType NATURE_ALTAR; + public static BlockEntityType OAK_GENERATOR; + public static BlockEntityType OFFERING_TABLE; + public static BlockEntityType PICKUP_STOPPER; + public static BlockEntityType PLACER; + public static BlockEntityType POTION_GENERATOR; + public static BlockEntityType POWDER_PLACER; + public static BlockEntityType PROJECTILE_GENERATOR; + public static BlockEntityType RF_CONVERTER; + public static BlockEntityType SPAWN_LAMP; + public static BlockEntityType TIME_CHANGER; + public static BlockEntityType WOOD_STAND; + public static BlockEntityType BLAST_FURNACE_BOOSTER; + public static BlockEntityType ANIMAL_CONTAINER; + public static BlockEntityType SNOW_CREATOR; + public static BlockEntityType ITEM_DISTRIBUTOR; + public static BlockEntityType AURA_BLOOM; + public static BlockEntityType CHORUS_GENERATOR; + public static BlockEntityType AURA_TIMER; + public static BlockEntityType SLIME_SPLIT_GENERATOR; + public static BlockEntityType SPRING; + public static BlockEntityType WEATHER_CHANGER; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java index e01003f1..b3bfea6e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java @@ -2,19 +2,23 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.entity.passive.Animal; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; import java.util.HashSet; import java.util.List; import java.util.Set; -public class TileEntityAnimalContainer extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAnimalContainer extends BlockEntityImpl implements ITickableBlockEntity { - public TileEntityAnimalContainer() { - super(ModTileEntities.ANIMAL_CONTAINER); + public BlockEntityAnimalContainer(BlockPos pos, BlockState state) { + super(ModTileEntities.ANIMAL_CONTAINER, pos, state); } public int getRadius() { @@ -29,23 +33,23 @@ public class TileEntityAnimalContainer extends TileEntityImpl implements ITickab @Override public void tick() { - if (this.world.isRemote) + if (this.level.isClientSide) return; int radius = this.getRadius(); - Set animalsInRange = new HashSet<>(this.world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(this.pos).grow(radius - 1))); - List animalsOutRange = this.world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(this.pos).grow(radius + 1)); - for (AnimalEntity animal : animalsOutRange) { + Set animalsInRange = new HashSet<>(this.level.getEntitiesWithinAABB(Animal.class, new AxisAlignedBB(this.worldPosition).grow(radius - 1))); + List animalsOutRange = this.level.getEntitiesWithinAABB(Animal.class, new AxisAlignedBB(this.worldPosition).grow(radius + 1)); + for (Animal animal : animalsOutRange) { if (animalsInRange.contains(animal)) continue; - Vector3d pos = animal.getPositionVec(); - Vector3d distance = pos.subtract(this.pos.getX(), pos.getY(), this.pos.getZ()); + Vec3 pos = animal.position(); + Vec3 distance = pos.subtract(this.worldPosition.getX(), pos.y, this.worldPosition.getZ()); distance = distance.normalize().scale(-0.15F); animal.setMotion(distance); - if (this.world.rand.nextBoolean()) { - Vector3d eye = animal.getEyePosition(1).add(animal.getLookVec()); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles((float) eye.getX(), (float) eye.getY(), (float) eye.getZ(), PacketParticles.Type.ANIMAL_CONTAINER)); + if (this.level.rand.nextBoolean()) { + Vec3 eye = animal.getEyePosition(1).add(animal.getLookAngle()); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles((float) eye.x, (float) eye.y, (float) eye.z, PacketParticles.Type.ANIMAL_CONTAINER)); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java index ee23295a..527e1a59 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalGenerator.java @@ -3,22 +3,22 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; -public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAnimalGenerator extends BlockEntityImpl implements ITickableBlockEntity { private int timeRemaining; private int amountToRelease; - public TileEntityAnimalGenerator() { + public BlockEntityAnimalGenerator() { super(ModTileEntities.ANIMAL_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 10 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 10 != 0) return; if (this.timeRemaining <= 0) return; @@ -26,8 +26,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab int remain = this.amountToRelease; if (this.canGenerateRightNow(remain)) { this.generateAura(remain); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.ANIMAL_GEN_CREATE)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.ANIMAL_GEN_CREATE)); } this.timeRemaining -= 10; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java index 71cb167e..5bf61d35 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java @@ -13,8 +13,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity { private AnimalSpawnerRecipe currentRecipe; private double spawnX; @@ -32,16 +32,16 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable private int time; private Entity entityClient; - public TileEntityAnimalSpawner() { + public BlockEntityAnimalSpawner() { super(ModTileEntities.ANIMAL_SPAWNER); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 10 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 10 != 0) return; - if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.world, this.pos)) { + if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.level, this.worldPosition)) { if (this.currentRecipe != null) { this.currentRecipe = null; this.time = 0; @@ -52,23 +52,23 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable if (this.currentRecipe != null) { int drain = MathHelper.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F); - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, drain); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, drain); this.time += 10; if (this.time >= this.currentRecipe.time) { - Entity entity = this.currentRecipe.makeEntity(this.world, new BlockPos(this.spawnX, this.pos.getY() + 1, this.spawnZ)); - this.world.addEntity(entity); + Entity entity = this.currentRecipe.makeEntity(this.level, new BlockPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ)); + this.level.addEntity(entity); this.currentRecipe = null; this.time = 0; this.sendToClients(); } } else { - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(this.pos).grow(2)); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(this.worldPosition).grow(2)); - for (AnimalSpawnerRecipe recipe : this.world.getRecipeManager().getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) { + for (AnimalSpawnerRecipe recipe : this.level.getRecipeManager().getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) { if (recipe.ingredients.length != items.size()) continue; List required = new ArrayList<>(Arrays.asList(recipe.ingredients)); @@ -90,19 +90,19 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable for (ItemEntity item : items) { item.remove(); - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.ANIMAL_SPAWNER)); } this.currentRecipe = recipe; - this.spawnX = this.pos.getX() + 0.5 + this.world.rand.nextFloat() * 4 - 2; - this.spawnZ = this.pos.getZ() + 0.5 + this.world.rand.nextFloat() * 4 - 2; + this.spawnX = this.worldPosition.getX() + 0.5 + this.level.rand.nextFloat() * 4 - 2; + this.spawnZ = this.worldPosition.getZ() + 0.5 + this.level.rand.nextFloat() * 4 - 2; this.sendToClients(); break; } } } else { - if (this.world.getGameTime() % 5 != 0) + if (this.level.getGameTime() % 5 != 0) return; if (this.currentRecipe == null) { this.entityClient = null; @@ -110,32 +110,32 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable } NaturesAuraAPI.instance().spawnParticleStream( - this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F, - this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F, - this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F, - this.pos.getX() + this.world.rand.nextFloat(), - this.pos.getY() + this.world.rand.nextFloat(), - this.pos.getZ() + this.world.rand.nextFloat(), - this.world.rand.nextFloat() * 0.07F + 0.07F, - IAuraType.forWorld(this.world).getColor(), - this.world.rand.nextFloat() + 0.5F); + this.worldPosition.getX() + (float) this.level.rand.nextGaussian() * 5F, + this.worldPosition.getY() + 1 + this.level.rand.nextFloat() * 5F, + this.worldPosition.getZ() + (float) this.level.rand.nextGaussian() * 5F, + this.worldPosition.getX() + this.level.rand.nextFloat(), + this.worldPosition.getY() + this.level.rand.nextFloat(), + this.worldPosition.getZ() + this.level.rand.nextFloat(), + this.level.rand.nextFloat() * 0.07F + 0.07F, + IAuraType.forLevel(this.level).getColor(), + this.level.rand.nextFloat() + 0.5F); if (this.entityClient == null) { - this.entityClient = this.currentRecipe.makeEntity(this.world, BlockPos.ZERO); - this.entityClient.setPosition(this.spawnX, this.pos.getY() + 1, this.spawnZ); + this.entityClient = this.currentRecipe.makeEntity(this.level, BlockPos.ZERO); + this.entityClient.setPosition(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ); } AxisAlignedBB bounds = this.entityClient.getBoundingBox(); - for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--) + for (int i = this.level.rand.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - bounds.minX + this.world.rand.nextFloat() * (bounds.maxX - bounds.minX), - bounds.minY + this.world.rand.nextFloat() * (bounds.maxY - bounds.minY), - bounds.minZ + this.world.rand.nextFloat() * (bounds.maxZ - bounds.minZ), + bounds.minX + this.level.rand.nextFloat() * (bounds.maxX - bounds.minX), + bounds.minY + this.level.rand.nextFloat() * (bounds.maxY - bounds.minY), + bounds.minZ + this.level.rand.nextFloat() * (bounds.maxZ - bounds.minZ), 0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true); } } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { if (this.currentRecipe != null) { @@ -148,13 +148,13 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { if (compound.contains("recipe")) { - if (this.hasWorld()) { + if (this.hasLevel()) { ResourceLocation name = new ResourceLocation(compound.getString("recipe")); - this.currentRecipe = (AnimalSpawnerRecipe) this.world.getRecipeManager().getRecipe(name).orElse(null); + this.currentRecipe = (AnimalSpawnerRecipe) this.level.getRecipeManager().getRecipe(name).orElse(null); } this.spawnX = compound.getDouble("spawn_x"); this.spawnZ = compound.getDouble("spawn_z"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java index 69639b5b..1519136d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraBloom.java @@ -1,40 +1,40 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntityType; -public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBlockEntity { public boolean justGenerated; - public TileEntityAuraBloom() { + public BlockEntityAuraBloom() { this(ModTileEntities.AURA_BLOOM); } - protected TileEntityAuraBloom(TileEntityType type) { + protected BlockEntityAuraBloom(BlockEntityType type) { super(type); } // Doing this in validate() creates a loading deadlock for some reason... @Override public void tick() { - if (this.world.isRemote || !this.justGenerated) + if (this.level.isClientSide || !this.justGenerated) return; this.generateAura(150000); this.justGenerated = false; } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) compound.putBoolean("just_generated", this.justGenerated); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) this.justGenerated = compound.getBoolean("just_generated"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java index c9cdf656..f108f7d0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java @@ -1,25 +1,25 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.MathHelper; -public class TileEntityAuraDetector extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAuraDetector extends BlockEntityImpl implements ITickableBlockEntity { public int redstonePower; - public TileEntityAuraDetector() { + public BlockEntityAuraDetector() { super(ModTileEntities.AURA_DETECTOR); } @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 20 == 0) { - int totalAmount = IAuraChunk.triangulateAuraInArea(this.world, this.pos, 25); + if (!this.level.isClientSide && this.level.getGameTime() % 20 == 0) { + int totalAmount = IAuraChunk.triangulateAuraInArea(this.level, this.worldPosition, 25); int power = MathHelper.clamp(MathHelper.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15); if (this.redstonePower != power) { this.redstonePower = power; - this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock()); + this.level.updateComparatorOutputLevel(this.worldPosition, this.getBlockState().getBlock()); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraTimer.java index b7db90ee..453aa2fa 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraTimer.java @@ -9,14 +9,14 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraftforge.items.IItemHandlerModifiable; import java.util.Map; -public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBlockEntity { private static final Map TIMES = ImmutableMap.builder() .put(NaturesAuraAPI.TYPE_OVERWORLD, 20) @@ -30,7 +30,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile }; private int timer; - public TileEntityAuraTimer() { + public BlockEntityAuraTimer() { super(ModTileEntities.AURA_TIMER); } @@ -39,7 +39,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile if (this.redstonePower <= 0 && newPower > 0) { this.timer = 0; int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor(); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.TIMER_RESET, color)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color)); this.sendToClients(); } super.onRedstonePowerChange(newPower); @@ -53,14 +53,14 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile return; } - if (this.world.isRemote) { - if (this.world.getGameTime() % 8 == 0) { + if (this.level.isClientSide) { + if (this.level.getGameTime() % 8 == 0) { int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor(); NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F, - this.pos.getY() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F, - this.pos.getZ() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F, - 0, 0, 0, color, 1, 80 + this.world.rand.nextInt(50), 0, false, true); + this.worldPosition.getX() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F, + this.worldPosition.getY() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F, + this.worldPosition.getZ() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F, + 0, 0, 0, color, 1, 80 + this.level.rand.nextInt(50), 0, false, true); } return; } @@ -70,11 +70,11 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile this.timer = 0; BlockState state = this.getBlockState(); - this.world.setBlockState(this.pos, state.with(BlockStateProperties.POWERED, true), 1); - this.world.getPendingBlockTicks().scheduleTick(this.pos, state.getBlock(), 4); + this.level.setBlockState(this.worldPosition, state.with(BlockStateProperties.POWERED, true), 1); + this.level.getPendingBlockTicks().scheduleTick(this.worldPosition, state.getBlock(), 4); int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor(); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.TIMER_RESET, color)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color)); } if (this.timer % 2 == 0) this.sendToClients(); @@ -104,7 +104,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.put("items", this.itemHandler.serializeNBT()); @@ -113,7 +113,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.itemHandler.deserializeNBT(compound.getCompound("items")); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java index b02b5cd1..7968f2d0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java @@ -6,13 +6,13 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.BlockState; import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.EntityPredicates; import net.minecraft.util.NonNullList; @@ -21,30 +21,30 @@ import net.minecraft.util.math.BlockPos; import java.util.List; -public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity { public final CraftingInventory crafting = new CraftingInventory(new Container(null, 0) { @Override - public boolean canInteractWith(PlayerEntity playerIn) { + public boolean canInteractWith(Player playerIn) { return false; } }, 3, 3); - public TileEntityAutoCrafter() { + public BlockEntityAutoCrafter() { super(ModTileEntities.AUTO_CRAFTER); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 60 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 60 != 0) return; - if (!Multiblocks.AUTO_CRAFTER.isComplete(this.world, this.pos)) + if (!Multiblocks.AUTO_CRAFTER.isComplete(this.level, this.worldPosition)) return; this.crafting.clear(); - BlockState state = this.world.getBlockState(this.pos); + BlockState state = this.level.getBlockState(this.worldPosition); Direction facing = state.get(BlockAutoCrafter.FACING); - BlockPos middlePos = this.pos.up(); + BlockPos middlePos = this.worldPosition.up(); BlockPos topPos = middlePos.offset(facing, 2); BlockPos bottomPos = middlePos.offset(facing.getOpposite(), 2); BlockPos[] poses = new BlockPos[]{ @@ -61,7 +61,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi ItemEntity[] items = new ItemEntity[9]; for (int i = 0; i < poses.length; i++) { - List entities = this.world.getEntitiesWithinAABB( + List entities = this.level.getEntitiesWithinAABB( ItemEntity.class, new AxisAlignedBB(poses[i]).grow(0.25), EntityPredicates.IS_ALIVE); if (entities.size() > 1) return; @@ -77,17 +77,17 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi this.crafting.setInventorySlotContents(i, stack.copy()); } - IRecipe recipe = this.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, this.world).orElse(null); + IRecipe recipe = this.level.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, this.level).orElse(null); if (recipe == null) return; ItemStack result = recipe.getCraftingResult(this.crafting); if (result.isEmpty()) return; - ItemEntity resultItem = new ItemEntity(this.world, - this.pos.getX() + 0.5F, this.pos.getY() - 0.35F, this.pos.getZ() + 0.5F, result.copy()); + ItemEntity resultItem = new ItemEntity(this.level, + this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy()); resultItem.setMotion(0, 0, 0); - this.world.addEntity(resultItem); + this.level.addEntity(resultItem); NonNullList remainingItems = recipe.getRemainingItems(this.crafting); for (int i = 0; i < items.length; i++) { @@ -104,12 +104,12 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi ItemStack remain = remainingItems.get(i); if (!remain.isEmpty()) { - ItemEntity remItem = new ItemEntity(this.world, item.getPosX(), item.getPosY(), item.getPosZ(), remain.copy()); + ItemEntity remItem = new ItemEntity(this.level, item.getPosX(), item.getPosY(), item.getPosZ(), remain.copy()); remItem.setMotion(0, 0, 0); - this.world.addEntity(remItem); + this.level.addEntity(remItem); } - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.ANIMAL_SPAWNER)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java index 6481a79e..d22ae26c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityBlastFurnaceBooster.java @@ -6,9 +6,9 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.tileentity.BlastFurnaceTileEntity; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlastFurnaceBlockEntity; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.IIntArray; import net.minecraft.util.math.BlockPos; @@ -19,35 +19,35 @@ import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nonnull; import java.util.List; -public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements ITickableBlockEntity { - public TileEntityBlastFurnaceBooster() { + public BlockEntityBlastFurnaceBooster() { super(ModTileEntities.BLAST_FURNACE_BOOSTER); } @Override public void tick() { - if (this.world.isRemote) + if (this.level.isClientSide) return; - TileEntity below = this.world.getTileEntity(this.pos.down()); - if (!(below instanceof BlastFurnaceTileEntity)) + BlockEntity below = this.level.getBlockEntity(this.worldPosition.down()); + if (!(below instanceof BlastFurnaceBlockEntity)) return; - BlastFurnaceTileEntity tile = (BlastFurnaceTileEntity) below; - IRecipe recipe = this.world.getRecipeManager().getRecipe(TileEntityFurnaceHeater.getRecipeType(tile), tile, this.world).orElse(null); + BlastFurnaceBlockEntity tile = (BlastFurnaceBlockEntity) below; + IRecipe recipe = this.level.getRecipeManager().getRecipe(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null); if (recipe == null) return; if (!this.isApplicable(recipe.getIngredients())) return; - IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile); + IIntArray data = BlockEntityFurnaceHeater.getFurnaceData(tile); int doneDiff = data.get(3) - data.get(2); if (doneDiff > 1) return; - if (this.world.rand.nextFloat() > 0.45F) { - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0)); + if (this.level.rand.nextFloat() > 0.45F) { + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0)); return; } @@ -62,11 +62,11 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi output.grow(1); } - BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 30, this.pos); - IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, 6500); + BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, 6500); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); } private boolean isApplicable(List ingredients) { @@ -81,8 +81,8 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi @Override public IItemHandlerModifiable getItemHandler() { - TileEntity below = this.world.getTileEntity(this.pos.down()); - if (!(below instanceof BlastFurnaceTileEntity)) + BlockEntity below = this.level.getBlockEntity(this.worldPosition.down()); + if (!(below instanceof BlastFurnaceBlockEntity)) return null; IItemHandler handler = below.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null); if (handler == null) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChorusGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChorusGenerator.java index 859478cf..c888e429 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChorusGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChorusGenerator.java @@ -5,10 +5,10 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -19,32 +19,32 @@ import java.util.ArrayList; import java.util.Deque; import java.util.List; -public class TileEntityChorusGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITickableBlockEntity { private final Deque currentlyBreaking = new ArrayDeque<>(); private int auraPerBlock; - public TileEntityChorusGenerator() { + public BlockEntityChorusGenerator() { super(ModTileEntities.CHORUS_GENERATOR); } @Override public void tick() { - if (this.world.isRemote) + if (this.level.isClientSide) return; - if (this.world.getGameTime() % 5 != 0) + if (this.level.getGameTime() % 5 != 0) return; if (this.currentlyBreaking.isEmpty()) return; BlockPos pos = this.currentlyBreaking.removeLast(); - BlockState state = this.world.getBlockState(pos); + BlockState state = this.level.getBlockState(pos); if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER) { this.currentlyBreaking.clear(); return; } - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ())); - this.world.removeBlock(pos, false); - this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ())); + this.level.removeBlock(pos, false); + this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.BLOCKS, 0.5F, 1F); this.generateAura(this.auraPerBlock); } @@ -57,11 +57,11 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab for (int x = -range; x <= range; x++) { for (int y = -range; y <= range; y++) { for (int z = -range; z <= range; z++) { - BlockPos offset = this.pos.add(x, y, z); - BlockState below = this.world.getBlockState(offset.down()); + BlockPos offset = this.worldPosition.add(x, y, z); + BlockState below = this.level.getBlockState(offset.down()); if (below.getBlock() != Blocks.END_STONE) continue; - BlockState state = this.world.getBlockState(offset); + BlockState state = this.level.getBlockState(offset); if (state.getBlock() != Blocks.CHORUS_PLANT) continue; @@ -90,7 +90,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab BlockPos offset = pos.offset(dir); if (blocks.contains(offset)) continue; - BlockState state = this.world.getBlockState(offset); + BlockState state = this.level.getBlockState(offset); if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER) continue; blocks.add(offset); @@ -99,7 +99,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) { ListNBT list = new ListNBT(); @@ -111,7 +111,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) { this.currentlyBreaking.clear(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChunkLoader.java index 918a6448..e6bb3f2e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityChunkLoader.java @@ -2,24 +2,24 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.server.ServerLevel; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickableBlockEntity { private final List forcedChunks = new ArrayList<>(); private boolean firstTick = true; - public TileEntityChunkLoader() { + public BlockEntityChunkLoader() { super(ModTileEntities.CHUNK_LOADER); } @@ -32,7 +32,7 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi @Override public void onRedstonePowerChange(int newPower) { super.onRedstonePowerChange(newPower); - if (!this.world.isRemote) { + if (!this.level.isClientSide) { this.loadChunks(false); this.sendToClients(); } @@ -43,19 +43,19 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi } private void loadChunks(boolean unload) { - if (this.world.isRemote || !ModConfig.instance.chunkLoader.get()) + if (this.level.isClientSide || !ModConfig.instance.chunkLoader.get()) return; - ServerWorld world = (ServerWorld) this.world; + ServerLevel level = (ServerLevel) this.level; List shouldBeForced = new ArrayList<>(); if (!unload) { int range = this.range(); if (range > 0) { - for (int x = (this.pos.getX() - range) >> 4; x <= (this.pos.getX() + range) >> 4; x++) { - for (int z = (this.pos.getZ() - range) >> 4; z <= (this.pos.getZ() + range) >> 4; z++) { + for (int x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) { + for (int z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) { ChunkPos pos = new ChunkPos(x, z); // Only force chunks that we're already forcing or that nobody else is forcing - if (this.forcedChunks.contains(pos) || !world.getForcedChunks().contains(pos.asLong())) + if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.asLong())) shouldBeForced.add(pos); } } @@ -65,20 +65,20 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi // Unforce all of the chunks that shouldn't be forced anymore for (ChunkPos pos : this.forcedChunks) { if (!shouldBeForced.contains(pos)) - world.forceChunk(pos.x, pos.z, false); + level.forceChunk(pos.x, pos.z, false); } this.forcedChunks.clear(); // Force all chunks that should be forced for (ChunkPos pos : shouldBeForced) { - world.forceChunk(pos.x, pos.z, true); + level.forceChunk(pos.x, pos.z, true); this.forcedChunks.add(pos); } } @Override public void tick() { - if (!this.world.isRemote && ModConfig.instance.chunkLoader.get()) { + if (!this.level.isClientSide && ModConfig.instance.chunkLoader.get()) { // defer loading chunks on load to here since, otherwise, deadlocks happen oof // since forced chunks are saved to disk by the game, this is only necessary for when the chunk loader config changes if (this.firstTick) { @@ -86,25 +86,25 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi this.firstTick = false; } - if (this.world.getGameTime() % 20 != 0) + if (this.level.getGameTime() % 20 != 0) return; int toUse = MathHelper.ceil(this.range() / 2F); if (toUse > 0) { - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, toUse); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, toUse); } } } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) compound.putLongArray("forced_chunks", this.forcedChunks.stream().map(ChunkPos::asLong).collect(Collectors.toList())); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEndFlower.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEndFlower.java index 60487fe0..a63cf436 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEndFlower.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEndFlower.java @@ -10,15 +10,15 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import java.util.List; -public class TileEntityEndFlower extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBlockEntity { private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) { { @@ -34,7 +34,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile public int drainAura(int amountToDrain, boolean simulate) { int amount = super.drainAura(amountToDrain, simulate); if (amount > 0 && !simulate) - TileEntityEndFlower.this.sendToClients(); + BlockEntityEndFlower.this.sendToClients(); return amount; } @@ -46,19 +46,19 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile public boolean isDrainMode; - public TileEntityEndFlower() { + public BlockEntityEndFlower() { super(ModTileEntities.END_FLOWER); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 10 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 10 != 0) return; if (!this.isDrainMode) { - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(this.pos).grow(1), EntityPredicates.IS_ALIVE); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(this.worldPosition).grow(1), EntityPredicates.IS_ALIVE); for (ItemEntity item : items) { if (item.cannotPickup()) continue; @@ -71,7 +71,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile this.isDrainMode = true; item.remove(); - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.END_FLOWER_CONSUME, this.container.getAuraColor())); break; } @@ -81,21 +81,21 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile this.generateAura(toDrain); if (this.container.getStoredAura() <= 0) { - this.world.setBlockState(this.pos, Blocks.DEAD_BUSH.getDefaultState()); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.END_FLOWER_DECAY, this.container.getAuraColor())); + this.level.setBlockState(this.worldPosition, Blocks.DEAD_BUSH.getDefaultState()); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.END_FLOWER_DECAY, this.container.getAuraColor())); } } } else { - if (this.isDrainMode && this.world.getGameTime() % 5 == 0) + if (this.isDrainMode && this.level.getGameTime() % 5 == 0) NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.world.rand.nextGaussian() * 0.05F, - this.world.rand.nextFloat() * 0.1F, - this.world.rand.nextGaussian() * 0.05F, - this.container.getAuraColor(), this.world.rand.nextFloat() * 2F + 1F, 50, 0F, false, true); + this.worldPosition.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.worldPosition.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.worldPosition.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.level.rand.nextGaussian() * 0.05F, + this.level.rand.nextFloat() * 0.1F, + this.level.rand.nextGaussian() * 0.05F, + this.container.getAuraColor(), this.level.rand.nextFloat() * 2F + 1F, 50, 0F, false, true); } } @@ -105,7 +105,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { this.container.writeNBT(compound); @@ -114,7 +114,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.container.readNBT(compound); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java index 0cdc2f47..cade087f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java @@ -2,16 +2,16 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.BlockEnderCrate; import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; @@ -21,7 +21,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class TileEntityEnderCrate extends TileEntityImpl implements INamedContainerProvider { +public class BlockEntityEnderCrate extends BlockEntityImpl implements INamedContainerProvider { public String name; private final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() { @@ -46,7 +46,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { ItemStack remain = this.getStorage().insertItem(slot, stack, simulate); if (!simulate) - TileEntityEnderCrate.this.drainAura((stack.getCount() - remain.getCount()) * 20); + BlockEntityEnderCrate.this.drainAura((stack.getCount() - remain.getCount()) * 20); return remain; } @@ -55,7 +55,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai public ItemStack extractItem(int slot, int amount, boolean simulate) { ItemStack extracted = this.getStorage().extractItem(slot, amount, simulate); if (!simulate) - TileEntityEnderCrate.this.drainAura(extracted.getCount() * 20); + BlockEntityEnderCrate.this.drainAura(extracted.getCount() * 20); return extracted; } @@ -70,11 +70,11 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai } private IItemHandlerModifiable getStorage() { - return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name); + return ILevelData.getOverworldData(BlockEntityEnderCrate.this.level).getEnderStorage(BlockEntityEnderCrate.this.name); } }; - public TileEntityEnderCrate() { + public BlockEntityEnderCrate() { super(ModTileEntities.ENDER_CRATE); } @@ -97,7 +97,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai public void modifyDrop(ItemStack regularItem) { if (this.name != null) { if (!regularItem.hasTag()) - regularItem.setTag(new CompoundNBT()); + regularItem.setTag(new CompoundTag()); regularItem.getTag().putString(NaturesAura.MOD_ID + ":ender_name", this.name); } } @@ -105,7 +105,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai @Override public void loadDataOnPlace(ItemStack stack) { super.loadDataOnPlace(stack); - if (!this.world.isRemote) { + if (!this.level.isClientSide) { String name = BlockEnderCrate.getEnderName(stack); if (name != null && !name.isEmpty()) this.name = name; @@ -113,7 +113,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { if (this.name != null) @@ -122,7 +122,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { if (compound.contains("name")) @@ -132,8 +132,8 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai public void drainAura(int amount) { if (amount > 0) { - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, amount); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, amount); } } @@ -144,7 +144,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai @Nullable @Override - public Container createMenu(int window, PlayerInventory inv, PlayerEntity player) { + public Container createMenu(int window, PlayerInventory inv, Player player) { return new ContainerEnderCrate(ModContainers.ENDER_CRATE, window, player, this.getItemHandler()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java index a2c4a143..7fab156e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java @@ -13,44 +13,44 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.loot.LootContext; import net.minecraft.loot.LootParameters; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.event.level.BlockEvent; import java.util.List; -public class TileEntityFieldCreator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickableBlockEntity { public BlockPos connectionOffset; public boolean isMain; public boolean isCharged; private int chargeTimer; - public TileEntityFieldCreator() { + public BlockEntityFieldCreator() { super(ModTileEntities.FIELD_CREATOR); } @Override public void tick() { - if (this.world.isRemote || this.world.getGameTime() % 10 != 0) + if (this.level.isClientSide || this.level.getGameTime() % 10 != 0) return; BlockPos connectedPos = this.getConnectedPos(); - if (connectedPos == null || !this.world.isBlockLoaded(connectedPos)) + if (connectedPos == null || !this.level.isBlockLoaded(connectedPos)) return; - TileEntity other = this.world.getTileEntity(connectedPos); + BlockEntity other = this.level.getBlockEntity(connectedPos); if (!this.isCloseEnough(connectedPos) - || !(other instanceof TileEntityFieldCreator) - || !this.pos.equals(((TileEntityFieldCreator) other).getConnectedPos())) { + || !(other instanceof BlockEntityFieldCreator) + || !this.worldPosition.equals(((BlockEntityFieldCreator) other).getConnectedPos())) { this.connectionOffset = null; this.chargeTimer = 0; this.isCharged = false; @@ -62,7 +62,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT if (!this.isMain) return; - TileEntityFieldCreator creator = (TileEntityFieldCreator) other; + BlockEntityFieldCreator creator = (BlockEntityFieldCreator) other; if (this.redstonePower <= 0 && creator.redstonePower <= 0) { this.chargeTimer = 0; if (this.isCharged) { @@ -74,8 +74,8 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT return; } - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 32, this.pos); - IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 32, this.worldPosition); + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot); if (!this.isCharged) { this.chargeTimer += 10; @@ -91,14 +91,14 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT chunk.drainAura(spot, 300); this.sendParticles(); } else { - if (this.world.getGameTime() % 40 == 0) + if (this.level.getGameTime() % 40 == 0) chunk.drainAura(spot, 20); ItemStack tool = this.getToolUsed(creator); Vector3d dist = new Vector3d( - this.pos.getX() - connectedPos.getX(), - this.pos.getY() - connectedPos.getY(), - this.pos.getZ() - connectedPos.getZ() + this.worldPosition.getX() - connectedPos.getX(), + this.worldPosition.getY() - connectedPos.getY(), + this.worldPosition.getZ() - connectedPos.getZ() ); double length = dist.length(); Vector3d normal = new Vector3d(dist.x / length, dist.y / length, dist.z / length); @@ -109,23 +109,23 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT MathHelper.floor(scaled.y + 0.5F), MathHelper.floor(scaled.z + 0.5F)); - if (pos.equals(this.pos) || pos.equals(connectedPos)) + if (pos.equals(this.worldPosition) || pos.equals(connectedPos)) continue; - BlockState state = this.world.getBlockState(pos); + BlockState state = this.level.getBlockState(pos); Block block = state.getBlock(); - if (!block.isAir(state, this.world, pos) && state.getBlockHardness(this.world, pos) >= 0F) { - FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world); - if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.world, pos, state, fake))) { - List drops = state.getDrops(new LootContext.Builder((ServerWorld) this.world) + if (!block.isAir(state, this.level, pos) && state.getBlockHardness(this.level, pos) >= 0F) { + FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level); + if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake))) { + List drops = state.getDrops(new LootContext.Builder((ServerLevel) this.level) .withParameter(LootParameters.THIS_ENTITY, fake) .withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(pos)) .withParameter(LootParameters.BLOCK_STATE, state) .withParameter(LootParameters.TOOL, tool.isEmpty() ? new ItemStack(Items.DIAMOND_PICKAXE) : tool) - .withNullableParameter(LootParameters.BLOCK_ENTITY, this.world.getTileEntity(pos))); - this.world.destroyBlock(pos, false); + .withNullableParameter(LootParameters.BLOCK_ENTITY, this.level.getBlockEntity(pos))); + this.level.destroyBlock(pos, false); for (ItemStack stack : drops) - Block.spawnAsEntity(this.world, pos, stack); + Block.spawnAsEntity(this.level, pos, stack); chunk.drainAura(spot, !tool.isEmpty() ? 300 : 100); this.sendParticles(); } @@ -134,20 +134,20 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT } } - private ItemStack getToolUsed(TileEntityFieldCreator other) { + private ItemStack getToolUsed(BlockEntityFieldCreator other) { ItemStack myTool = this.getMyTool(); ItemStack otherTool = other.getMyTool(); if (!myTool.isEmpty()) { // if both have tools, choose randomly if (!otherTool.isEmpty()) - return this.world.rand.nextBoolean() ? myTool : otherTool; + return this.level.rand.nextBoolean() ? myTool : otherTool; return myTool; } return otherTool; } private ItemStack getMyTool() { - List frames = Helper.getAttachedItemFrames(this.world, this.pos); + List frames = Helper.getAttachedItemFrames(this.level, this.worldPosition); for (ItemFrameEntity frame : frames) { ItemStack stack = frame.getDisplayedItem(); if (!stack.isEmpty()) @@ -158,32 +158,32 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT private void sendParticles() { for (int j = 0; j < 2; j++) { - BlockPos p = j == 0 ? this.pos : this.getConnectedPos(); - PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream( - p.getX() + (float) this.world.rand.nextGaussian() * 3F, - p.getY() + 1 + this.world.rand.nextFloat() * 3F, - p.getZ() + (float) this.world.rand.nextGaussian() * 3F, + BlockPos p = j == 0 ? this.worldPosition : this.getConnectedPos(); + PacketHandler.sendToAllAround(this.level, p, 32, new PacketParticleStream( + p.getX() + (float) this.level.rand.nextGaussian() * 3F, + p.getY() + 1 + this.level.rand.nextFloat() * 3F, + p.getZ() + (float) this.level.rand.nextGaussian() * 3F, p.getX() + 0.5F, p.getY() + 0.5F, p.getZ() + 0.5F, - this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F + this.level.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.rand.nextFloat() + 0.5F )); } } public boolean isCloseEnough(BlockPos pos) { int range = ModConfig.instance.fieldCreatorRange.get() + 1; - return this.pos.distanceSq(pos) <= range * range; + return this.worldPosition.distanceSq(pos) <= range * range; } public BlockPos getConnectedPos() { if (this.connectionOffset == null) return null; - return this.pos.add(this.connectionOffset); + return this.worldPosition.add(this.connectionOffset); } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { if (this.connectionOffset != null) @@ -197,7 +197,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { if (compound.contains("connection")) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java index 54400291..5ec8238f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFireworkGenerator.java @@ -8,10 +8,10 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.projectile.FireworkRocketEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -22,23 +22,23 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITickableBlockEntity { private FireworkRocketEntity trackedEntity; private ItemStack trackedItem; private int toRelease; private int releaseTimer; - public TileEntityFireworkGenerator() { + public BlockEntityFireworkGenerator() { super(ModTileEntities.FIREWORK_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 10 == 0) { - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(this.pos).grow(4), EntityPredicates.IS_ALIVE); + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 10 == 0) { + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(this.worldPosition).grow(4), EntityPredicates.IS_ALIVE); for (ItemEntity item : items) { if (item.cannotPickup()) continue; @@ -46,10 +46,10 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick if (stack.isEmpty() || stack.getItem() != Items.FIREWORK_ROCKET) continue; if (this.trackedEntity == null && this.releaseTimer <= 0) { - FireworkRocketEntity entity = new FireworkRocketEntity(this.world, item.getPosX(), item.getPosY(), item.getPosZ(), stack); + FireworkRocketEntity entity = new FireworkRocketEntity(this.level, item.getPosX(), item.getPosY(), item.getPosZ(), stack); this.trackedEntity = entity; this.trackedItem = stack.copy(); - this.world.addEntity(entity); + this.level.addEntity(entity); } stack.shrink(1); if (stack.isEmpty()) @@ -64,8 +64,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick float generateFactor = 0; Set usedColors = new HashSet<>(); - CompoundNBT compound = this.trackedItem.getTag(); - CompoundNBT fireworks = compound.getCompound("Fireworks"); + CompoundTag compound = this.trackedItem.getTag(); + CompoundTag fireworks = compound.getCompound("Fireworks"); int flightTime = fireworks.getInt("Flight"); ListNBT explosions = fireworks.getList("Explosions", 10); @@ -73,7 +73,7 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick generateFactor += flightTime; for (INBT base : explosions) { - CompoundNBT explosion = (CompoundNBT) base; + CompoundTag explosion = (CompoundTag) base; generateFactor += 1.5F; boolean flicker = explosion.getBoolean("Flicker"); @@ -104,11 +104,11 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick } List data = new ArrayList<>(); - data.add(this.pos.getX()); - data.add(this.pos.getY()); - data.add(this.pos.getZ()); + data.add(this.worldPosition.getX()); + data.add(this.worldPosition.getY()); + data.add(this.worldPosition.getZ()); data.addAll(usedColors); - PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles( + PacketHandler.sendToAllLoaded(this.level, this.worldPosition, new PacketParticles( (float) this.trackedEntity.getPosX(), (float) this.trackedEntity.getPosY(), (float) this.trackedEntity.getPosZ(), PacketParticles.Type.FIREWORK_GEN, Ints.toArray(data))); } @@ -124,8 +124,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick this.generateAura(this.toRelease); this.toRelease = 0; - PacketHandler.sendToAllLoaded(this.world, this.pos, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION)); + PacketHandler.sendToAllLoaded(this.level, this.worldPosition, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION)); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java index 373a1a5f..5a6a434c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java @@ -9,11 +9,11 @@ import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ForgeRegistries; @@ -24,24 +24,24 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITickableBlockEntity { private final Map consumedRecently = new HashMap<>(); - public TileEntityFlowerGenerator() { + public BlockEntityFlowerGenerator() { super(ModTileEntities.FLOWER_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) { + if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) { List possible = new ArrayList<>(); int range = 3; for (int x = -range; x <= range; x++) { for (int y = -1; y <= 1; y++) { for (int z = -range; z <= range; z++) { - BlockPos offset = this.pos.add(x, y, z); - BlockState state = this.world.getBlockState(offset); + BlockPos offset = this.worldPosition.add(x, y, z); + BlockState state = this.level.getBlockState(offset); if (BlockTags.SMALL_FLOWERS.contains(state.getBlock())) possible.add(offset); } @@ -51,14 +51,14 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab if (possible.isEmpty()) return; - BlockPos pos = possible.get(this.world.rand.nextInt(possible.size())); - BlockState state = this.world.getBlockState(pos); + BlockPos pos = possible.get(this.level.rand.nextInt(possible.size())); + BlockState state = this.level.getBlockState(pos); MutableInt curr = this.consumedRecently.computeIfAbsent(state, s -> new MutableInt()); int addAmount = 25000; int toAdd = Math.max(0, addAmount - curr.getValue() * 100); if (toAdd > 0) { - if (IAuraType.forWorld(this.world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(toAdd)) { + if (IAuraType.forLevel(this.level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(toAdd)) { this.generateAura(toAdd); } else { toAdd = 0; @@ -74,23 +74,23 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab } curr.add(5); - this.world.removeBlock(pos, false); + this.level.removeBlock(pos, false); int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount); if (toAdd > 0) { - for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--) - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( - pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F, - pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F, - pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F, - this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F + for (int i = this.level.rand.nextInt(5) + 5; i >= 0; i--) + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( + pos.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F, + pos.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F, + pos.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.worldPosition.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.worldPosition.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.worldPosition.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F, + this.level.rand.nextFloat() * 0.02F + 0.1F, color, 1F )); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION)); } - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.FLOWER_GEN_CONSUME, color)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.FLOWER_GEN_CONSUME, color)); } } @@ -100,7 +100,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) { @@ -109,7 +109,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab BlockState state = entry.getKey(); Block block = state.getBlock(); - CompoundNBT tag = new CompoundNBT(); + CompoundTag tag = new CompoundTag(); tag.putString("block", block.getRegistryName().toString()); tag.putInt("amount", entry.getValue().intValue()); list.add(tag); @@ -119,13 +119,13 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.SYNC) { this.consumedRecently.clear(); ListNBT list = compound.getList("consumed_recently", 10); for (INBT base : list) { - CompoundNBT tag = (CompoundNBT) base; + CompoundTag tag = (CompoundTag) base; Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block"))); if (block != null) this.consumedRecently.put(block.getDefaultState(), new MutableInt(tag.getInt("amount"))); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java index 40c43af0..c1035c40 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java @@ -11,7 +11,7 @@ import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.tileentity.*; import net.minecraft.util.Direction; import net.minecraft.util.IIntArray; @@ -21,16 +21,16 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.lang.reflect.Field; -public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity { - private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceTileEntity.class, "field_214013_b"); + private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "field_214013_b"); public boolean isActive; - public TileEntityFurnaceHeater() { + public BlockEntityFurnaceHeater() { super(ModTileEntities.FURNACE_HEATER); } - public static IIntArray getFurnaceData(AbstractFurnaceTileEntity tile) { + public static IIntArray getFurnaceData(AbstractFurnaceBlockEntity tile) { try { return (IIntArray) FURNACE_DATA_FIELD.get(tile); } catch (IllegalAccessException e) { @@ -39,10 +39,10 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable } } - public static IRecipeType getRecipeType(AbstractFurnaceTileEntity furnace) { - if (furnace instanceof BlastFurnaceTileEntity) { + public static IRecipeType getRecipeType(AbstractFurnaceBlockEntity furnace) { + if (furnace instanceof BlastFurnaceBlockEntity) { return IRecipeType.BLASTING; - } else if (furnace instanceof SmokerTileEntity) { + } else if (furnace instanceof SmokerBlockEntity) { return IRecipeType.SMOKING; } else { return IRecipeType.SMELTING; @@ -51,38 +51,38 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 5 == 0) { + if (!this.level.isClientSide && this.level.getGameTime() % 5 == 0) { boolean did = false; - Direction facing = this.world.getBlockState(this.pos).get(BlockFurnaceHeater.FACING); - BlockPos tilePos = this.pos.offset(facing.getOpposite()); - TileEntity tile = this.world.getTileEntity(tilePos); - if (tile instanceof AbstractFurnaceTileEntity) { - AbstractFurnaceTileEntity furnace = (AbstractFurnaceTileEntity) tile; + Direction facing = this.level.getBlockState(this.worldPosition).get(BlockFurnaceHeater.FACING); + BlockPos tilePos = this.worldPosition.offset(facing.getOpposite()); + BlockEntity tile = this.level.getBlockEntity(tilePos); + if (tile instanceof AbstractFurnaceBlockEntity) { + AbstractFurnaceBlockEntity furnace = (AbstractFurnaceBlockEntity) tile; if (this.isReady(furnace)) { IIntArray data = getFurnaceData(furnace); int burnTime = data.get(0); if (burnTime <= 0) - this.world.setBlockState(tilePos, this.world.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true)); + this.level.setBlockState(tilePos, this.level.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true)); data.set(0, 200); //if set higher than 199, it'll never finish because the furnace does ++ and then == data.set(2, Math.min(data.get(3) - 1, data.get(2) + 5)); - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos); - IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition); + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot); chunk.drainAura(spot, MathHelper.ceil((200 - burnTime) * 16.6F)); did = true; - if (this.world.getGameTime() % 15 == 0) { - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( - this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F, - this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F, - this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F, - tilePos.getX() + this.world.rand.nextFloat(), - tilePos.getY() + this.world.rand.nextFloat(), - tilePos.getZ() + this.world.rand.nextFloat(), - this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F + if (this.level.getGameTime() % 15 == 0) { + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( + this.worldPosition.getX() + (float) this.level.rand.nextGaussian() * 5F, + this.worldPosition.getY() + 1 + this.level.rand.nextFloat() * 5F, + this.worldPosition.getZ() + (float) this.level.rand.nextGaussian() * 5F, + tilePos.getX() + this.level.rand.nextFloat(), + tilePos.getY() + this.level.rand.nextFloat(), + tilePos.getZ() + this.level.rand.nextFloat(), + this.level.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.rand.nextFloat() + 0.5F )); } } @@ -95,13 +95,13 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable } } - private boolean isReady(AbstractFurnaceTileEntity furnace) { + private boolean isReady(AbstractFurnaceBlockEntity furnace) { if (!furnace.getStackInSlot(1).isEmpty()) return false; ItemStack input = furnace.getStackInSlot(0); if (!input.isEmpty()) { - AbstractCookingRecipe recipe = this.world.getRecipeManager().getRecipe(getRecipeType(furnace), furnace, this.world).orElse(null); + AbstractCookingRecipe recipe = this.level.getRecipeManager().getRecipe(getRecipeType(furnace), furnace, this.level).orElse(null); if (recipe == null) return false; ItemStack output = recipe.getRecipeOutput(); @@ -112,7 +112,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.SYNC) @@ -120,7 +120,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.SYNC) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java index 6fe1c64f..efbfbcf3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java @@ -4,15 +4,15 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class TileEntityGeneratorLimitRemover extends TileEntityImpl { +public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl { - public TileEntityGeneratorLimitRemover() { + public BlockEntityGeneratorLimitRemover() { super(ModTileEntities.GENERATOR_LIMIT_REMOVER); } @Override @OnlyIn(Dist.CLIENT) public AxisAlignedBB getRenderBoundingBox() { - return new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)); + return new AxisAlignedBB(this.worldPosition, this.worldPosition.add(1, 2, 1)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java index a44f5bbd..71fd0140 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java @@ -6,9 +6,9 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.items.CapabilityItemHandler; @@ -17,29 +17,29 @@ import net.minecraftforge.items.IItemHandlerModifiable; import java.util.List; -public class TileEntityGratedChute extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity { public boolean isBlacklist; private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) { @Override protected boolean canExtract(ItemStack stack, int slot, int amount) { - return TileEntityGratedChute.this.redstonePower <= 0; + return BlockEntityGratedChute.this.redstonePower <= 0; } @Override protected boolean canInsert(ItemStack stack, int slot) { - return TileEntityGratedChute.this.isBlacklist != TileEntityGratedChute.this.isItemInFrame(stack); + return BlockEntityGratedChute.this.isBlacklist != BlockEntityGratedChute.this.isItemInFrame(stack); } }; private int cooldown; - public TileEntityGratedChute() { + public BlockEntityGratedChute() { super(ModTileEntities.GRATED_CHUTE); } @Override public void tick() { - if (!this.world.isRemote) { + if (!this.level.isClientSide) { if (this.cooldown <= 0) { this.cooldown = 6; if (this.redstonePower > 0) @@ -48,9 +48,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi ItemStack curr = this.items.getStackInSlot(0); push: if (!curr.isEmpty()) { - BlockState state = this.world.getBlockState(this.pos); + BlockState state = this.level.getBlockState(this.worldPosition); Direction facing = state.get(BlockGratedChute.FACING); - TileEntity tile = this.world.getTileEntity(this.pos.offset(facing)); + BlockEntity tile = this.level.getBlockEntity(this.worldPosition.offset(facing)); if (tile == null) break push; IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, @@ -70,9 +70,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi } pull: if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) { - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB( - this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(), - this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1)); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB( + this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(), + this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1)); for (ItemEntity item : items) { if (!item.isAlive()) continue; @@ -89,7 +89,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi } } - TileEntity tileUp = this.world.getTileEntity(this.pos.up()); + BlockEntity tileUp = this.level.getBlockEntity(this.worldPosition.up()); if (tileUp == null) break pull; IItemHandler handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null); @@ -112,7 +112,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi } private boolean isItemInFrame(ItemStack stack) { - List frames = Helper.getAttachedItemFrames(this.world, this.pos); + List frames = Helper.getAttachedItemFrames(this.level, this.worldPosition); if (frames.isEmpty()) return false; for (ItemFrameEntity frame : frames) { @@ -125,7 +125,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.putInt("cooldown", this.cooldown); @@ -135,7 +135,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.cooldown = compound.getInt("cooldown"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java index 9850834d..c87ab3a5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java @@ -6,9 +6,9 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.HopperBlock; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.HopperTileEntity; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.HopperBlockEntity; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -17,33 +17,33 @@ import net.minecraftforge.items.IItemHandler; import java.util.List; -public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickableTileEntity { - public TileEntityHopperUpgrade() { +public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickableBlockEntity { + public BlockEntityHopperUpgrade() { super(ModTileEntities.HOPPER_UPGRADE); } - private static boolean isValidHopper(TileEntity tile) { - if (tile instanceof HopperTileEntity) - return tile.getWorld().getBlockState(tile.getPos()).get(HopperBlock.ENABLED); - if (tile instanceof TileEntityGratedChute) - return ((TileEntityGratedChute) tile).redstonePower <= 0; + private static boolean isValidHopper(BlockEntity tile) { + if (tile instanceof HopperBlockEntity) + return tile.getLevel().getBlockState(tile.getPos()).get(HopperBlock.ENABLED); + if (tile instanceof BlockEntityGratedChute) + return ((BlockEntityGratedChute) tile).redstonePower <= 0; return false; } @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) { - if (IAuraChunk.getAuraInArea(this.world, this.pos, 25) < 100000) + if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) { + if (IAuraChunk.getAuraInArea(this.level, this.worldPosition, 25) < 100000) return; - TileEntity tile = this.world.getTileEntity(this.pos.down()); + BlockEntity tile = this.level.getBlockEntity(this.worldPosition.down()); if (!isValidHopper(tile)) return; IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null); if (handler == null) return; - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(this.pos).grow(7)); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(this.worldPosition).grow(7)); if (items.isEmpty()) return; @@ -67,10 +67,10 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable if (copy.isEmpty()) item.remove(); - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 25, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 500); - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.HOPPER_UPGRADE)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index 0542a354..006303cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -4,19 +4,18 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.blocks.ModBlocks; -import net.minecraft.block.BlockState; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SUpdateTileEntityPacket; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -24,40 +23,37 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nullable; -import java.util.stream.Stream; -public class TileEntityImpl extends TileEntity { +public class BlockEntityImpl extends BlockEntity { public int redstonePower; private LazyOptional itemHandler; private LazyOptional auraContainer; - public TileEntityImpl(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); + public BlockEntityImpl(BlockEntityType type, BlockPos pos, BlockState state) { + super(type, pos, state); } @Override - public CompoundNBT write(CompoundNBT compound) { + public void saveAdditional(CompoundTag compound) { this.writeNBT(compound, SaveType.TILE); - return compound; } @Override - public void read(BlockState state, CompoundNBT compound) { + public void load(CompoundTag compound) { this.readNBT(compound, SaveType.TILE); } - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { if (type != SaveType.BLOCK) { - super.write(compound); + super.saveAdditional(compound); compound.putInt("redstone", this.redstonePower); } } - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { if (type != SaveType.BLOCK) { - // looks like the block state isn't used in the super - super.read(null, compound); + super.load(compound); this.redstonePower = compound.getInt("redstone"); } } @@ -67,36 +63,38 @@ public class TileEntityImpl extends TileEntity { } @Override - public final SUpdateTileEntityPacket getUpdatePacket() { - CompoundNBT compound = new CompoundNBT(); - this.writeNBT(compound, SaveType.SYNC); - return new SUpdateTileEntityPacket(this.pos, 0, compound); + public final ClientboundBlockEntityDataPacket getUpdatePacket() { + return ClientboundBlockEntityDataPacket.create(this, e -> { + CompoundTag compound = new CompoundTag(); + this.writeNBT(compound, SaveType.SYNC); + return compound; + }); } @Override - public final CompoundNBT getUpdateTag() { - CompoundNBT compound = new CompoundNBT(); + public final CompoundTag getUpdateTag() { + CompoundTag compound = new CompoundTag(); this.writeNBT(compound, SaveType.SYNC); return compound; } @Override - public void handleUpdateTag(BlockState state, CompoundNBT tag) { + public void handleUpdateTag(CompoundTag tag) { this.readNBT(tag, SaveType.SYNC); - } @Override - public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) { - super.onDataPacket(net, packet); - this.readNBT(packet.getNbtCompound(), SaveType.SYNC); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + super.onDataPacket(net, pkt); + this.readNBT(pkt.getTag(), SaveType.SYNC); } public void sendToClients() { - ServerWorld world = (ServerWorld) this.getWorld(); - Stream entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos()), false); - SUpdateTileEntityPacket packet = this.getUpdatePacket(); - entities.forEach(e -> e.connection.sendPacket(packet)); + var world = (ServerLevel) this.getLevel(); + var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(this.getBlockPos()), false); + ClientboundBlockEntityDataPacket packet = this.getUpdatePacket(); + for (var e : entities) + e.connection.send(packet); } public IItemHandlerModifiable getItemHandler() { @@ -128,8 +126,8 @@ public class TileEntityImpl extends TileEntity { } @Override - public void remove() { - super.remove(); + public void setRemoved() { + super.setRemoved(); if (this.itemHandler != null) this.itemHandler.invalidate(); if (this.auraContainer != null) @@ -142,40 +140,36 @@ public class TileEntityImpl extends TileEntity { for (int i = 0; i < handler.getSlots(); i++) { ItemStack stack = handler.getStackInSlot(i); if (!stack.isEmpty()) { - ItemEntity item = new ItemEntity(this.world, - this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, - stack); - this.world.addEntity(item); + ItemEntity item = new ItemEntity(this.level, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, stack); + this.level.addFreshEntity(item); } } } } public void modifyDrop(ItemStack regularItem) { - CompoundNBT compound = new CompoundNBT(); + CompoundTag compound = new CompoundTag(); this.writeNBT(compound, SaveType.BLOCK); if (!compound.isEmpty()) { - if (!regularItem.hasTag()) - regularItem.setTag(new CompoundNBT()); + if (!regularItem.hasTag()) regularItem.setTag(new CompoundTag()); regularItem.getTag().put("data", compound); } } public void loadDataOnPlace(ItemStack stack) { if (stack.hasTag()) { - CompoundNBT compound = stack.getTag().getCompound("data"); - if (compound != null) - this.readNBT(compound, SaveType.BLOCK); + CompoundTag compound = stack.getTag().getCompound("data"); + if (compound != null) this.readNBT(compound, SaveType.BLOCK); } } public boolean canGenerateRightNow(int toAdd) { if (this.wantsLimitRemover()) { - BlockState below = this.world.getBlockState(this.pos.down()); + BlockState below = this.level.getBlockState(this.worldPosition.below()); if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER) return true; } - int aura = IAuraChunk.getAuraInArea(this.world, this.pos, 35); + int aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 35); return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2; } @@ -185,14 +179,12 @@ public class TileEntityImpl extends TileEntity { public void generateAura(int amount) { while (amount > 0) { - BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 35, this.pos); - amount -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, amount); + BlockPos spot = IAuraChunk.getLowestSpot(this.level, this.worldPosition, 35, this.worldPosition); + amount -= IAuraChunk.getAuraChunk(this.level, spot).storeAura(spot, amount); } } public enum SaveType { - TILE, - SYNC, - BLOCK + TILE, SYNC, BLOCK } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityItemDistributor.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityItemDistributor.java index 0a3284c0..a2bbecbe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityItemDistributor.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityItemDistributor.java @@ -1,9 +1,9 @@ package de.ellpeck.naturesaura.blocks.tiles; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.CapabilityItemHandler; @@ -12,19 +12,19 @@ import net.minecraftforge.items.IItemHandler; import java.util.ArrayList; import java.util.List; -public class TileEntityItemDistributor extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityItemDistributor extends BlockEntityImpl implements ITickableBlockEntity { private int cooldown; private Direction currentSide = Direction.NORTH; public boolean isRandomMode; - public TileEntityItemDistributor() { + public BlockEntityItemDistributor() { super(ModTileEntities.ITEM_DISTRIBUTOR); } @Override public void tick() { - if (this.world.isRemote) + if (this.level.isClientSide) return; if (this.cooldown > 0) { this.cooldown--; @@ -54,8 +54,8 @@ public class TileEntityItemDistributor extends TileEntityImpl implements ITickab } private IItemHandler getHandler(Direction direction) { - BlockPos offset = this.pos.offset(direction); - TileEntity tile = this.world.getTileEntity(offset); + BlockPos offset = this.worldPosition.offset(direction); + BlockEntity tile = this.level.getBlockEntity(offset); if (tile == null) return null; return tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).orElse(null); @@ -71,7 +71,7 @@ public class TileEntityItemDistributor extends TileEntityImpl implements ITickab } if (handlers.isEmpty()) return null; - return handlers.get(this.world.rand.nextInt(handlers.size())); + return handlers.get(this.level.rand.nextInt(handlers.size())); } else { for (int i = 0; i < 4; i++) { this.currentSide = this.currentSide.rotateY(); @@ -84,7 +84,7 @@ public class TileEntityItemDistributor extends TileEntityImpl implements ITickab } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) { compound.putInt("cooldown", this.cooldown); @@ -95,7 +95,7 @@ public class TileEntityItemDistributor extends TileEntityImpl implements ITickab } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) { this.cooldown = compound.getInt("cooldown"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java index 465381fa..7a74f38f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityMossGenerator.java @@ -2,39 +2,39 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import de.ellpeck.naturesaura.api.misc.IWorldData; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; +import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; import java.util.ArrayList; import java.util.List; -public class TileEntityMossGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityMossGenerator extends BlockEntityImpl implements ITickableBlockEntity { - public TileEntityMossGenerator() { + public BlockEntityMossGenerator() { super(ModTileEntities.MOSS_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 20 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 20 != 0) return; - WorldData data = (WorldData) IWorldData.getWorldData(this.world); + LevelData data = (LevelData) ILevelData.getLevelData(this.level); List possibleOffsets = new ArrayList<>(); int range = 2; for (int x = -range; x <= range; x++) for (int y = -range; y <= range; y++) for (int z = -range; z <= range; z++) { - BlockPos offset = this.pos.add(x, y, z); + BlockPos offset = this.worldPosition.add(x, y, z); boolean isRecent = data.recentlyConvertedMossStones.contains(offset); - BlockState state = this.world.getBlockState(offset); + BlockState state = this.level.getBlockState(offset); if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().containsKey(state)) { if (isRecent) continue; @@ -46,19 +46,19 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable if (possibleOffsets.isEmpty()) return; - BlockPos offset = possibleOffsets.get(this.world.rand.nextInt(possibleOffsets.size())); - BlockState state = this.world.getBlockState(offset); + BlockPos offset = possibleOffsets.get(this.level.rand.nextInt(possibleOffsets.size())); + BlockState state = this.level.getBlockState(offset); BlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.inverse().get(state); int toAdd = 7000; if (this.canGenerateRightNow(toAdd)) { this.generateAura(toAdd); - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.MOSS_GENERATOR)); } - this.world.playEvent(2001, offset, Block.getStateId(state)); - this.world.setBlockState(offset, result); + this.level.playEvent(2001, offset, Block.getStateId(state)); + this.level.setBlockState(offset, result); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index f70a96dc..8c64abbe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -14,8 +14,8 @@ import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -28,12 +28,12 @@ import net.minecraftforge.items.ItemStackHandler; import java.util.Random; -public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity { private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) { @Override public int getAuraColor() { - return IAuraType.forWorld(TileEntityNatureAltar.this.world).getColor(); + return IAuraType.forLevel(BlockEntityNatureAltar.this.level).getColor(); } }; private final ItemStack[] catalysts = new ItemStack[4]; @@ -45,7 +45,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi @Override protected boolean canInsert(ItemStack stack, int slot) { - return TileEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.getCapability(NaturesAuraAPI.capAuraContainer, null).isPresent(); + return BlockEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.getCapability(NaturesAuraAPI.capAuraContainer, null).isPresent(); } @Override @@ -54,7 +54,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi if (cap != null) return cap.storeAura(1, true) <= 0; else - return TileEntityNatureAltar.this.getRecipeForInput(stack) == null; + return BlockEntityNatureAltar.this.getRecipeForInput(stack) == null; } }; @OnlyIn(Dist.CLIENT) @@ -67,28 +67,28 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi private int lastAura; private boolean firstTick = true; - public TileEntityNatureAltar() { + public BlockEntityNatureAltar() { super(ModTileEntities.NATURE_ALTAR); } @Override public void tick() { - Random rand = this.world.rand; + Random rand = this.level.rand; - if (this.world.getGameTime() % 40 == 0) { + if (this.level.getGameTime() % 40 == 0) { int index = 0; for (int x = -2; x <= 2; x += 4) { for (int z = -2; z <= 2; z += 4) { - BlockPos offset = this.pos.add(x, 1, z); - BlockState state = this.world.getBlockState(offset); - this.catalysts[index] = state.getBlock().getItem(this.world, offset, state); + BlockPos offset = this.worldPosition.add(x, 1, z); + BlockState state = this.level.getBlockState(offset); + this.catalysts[index] = state.getBlock().getItem(this.level, offset, state); index++; } } } - if (!this.world.isRemote) { - if (this.world.getGameTime() % 40 == 0 || this.firstTick) { + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 40 == 0 || this.firstTick) { StructureState newState = this.getNewState(); if (newState != this.structureState) { this.structureState = newState; @@ -100,21 +100,21 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi if (this.structureState != StructureState.INVALID) { int space = this.container.storeAura(300, true); IAuraType expectedType = this.structureState == StructureState.NETHER ? NaturesAuraAPI.TYPE_NETHER : NaturesAuraAPI.TYPE_OVERWORLD; - if (space > 0 && IAuraType.forWorld(this.world).isSimilar(expectedType)) { - int toStore = Math.min(IAuraChunk.getAuraInArea(this.world, this.pos, 20), space); + if (space > 0 && IAuraType.forLevel(this.level).isSimilar(expectedType)) { + int toStore = Math.min(IAuraChunk.getAuraInArea(this.level, this.worldPosition, 20), space); if (toStore > 0) { - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos); - IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition); + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot); chunk.drainAura(spot, toStore); this.container.storeAura(toStore, false); - if (this.world.getGameTime() % 3 == 0) - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( - this.pos.getX() + (float) rand.nextGaussian() * 10F, - this.pos.getY() + rand.nextFloat() * 10F, - this.pos.getZ() + (float) rand.nextGaussian() * 10F, - this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F, + if (this.level.getGameTime() % 3 == 0) + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( + this.worldPosition.getX() + (float) rand.nextGaussian() * 10F, + this.worldPosition.getY() + rand.nextFloat() * 10F, + this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F, + this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F, rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() * 1F + 1F )); } @@ -129,8 +129,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi if (stored > 0) { this.container.drainAura(stored, false); - if (this.world.getGameTime() % 4 == 0) - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.ALTAR_CONVERSION, this.container.getAuraColor())); + if (this.level.getGameTime() % 4 == 0) + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.ALTAR_CONVERSION, this.container.getAuraColor())); } } } else { @@ -148,7 +148,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi this.container.drainAura(req, false); if (this.timer % 4 == 0) - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.ALTAR_CONVERSION, this.container.getAuraColor())); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.ALTAR_CONVERSION, this.container.getAuraColor())); this.timer++; if (this.timer >= this.currentRecipe.time) { @@ -156,7 +156,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi this.currentRecipe = null; this.timer = 0; - this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, + this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.BLOCKS, 0.65F, 1F); } } @@ -165,7 +165,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi } } - if (this.world.getGameTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) { + if (this.level.getGameTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) { this.lastAura = this.container.getStoredAura(); this.sendToClients(); } @@ -175,22 +175,22 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi int fourths = this.container.getMaxAura() / 4; if (this.container.getStoredAura() > 0) { NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() - 4F + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + rand.nextFloat(), + this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths) { NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + 4F + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + rand.nextFloat(), + this.worldPosition.getX() + 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 2) { NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() - 4F + rand.nextFloat(), + this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() - 4F + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 3) { NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + 4F + rand.nextFloat(), + this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + 4F + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } @@ -202,8 +202,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi } private AltarRecipe getRecipeForInput(ItemStack input) { - IAuraType type = IAuraType.forWorld(this.world); - for (AltarRecipe recipe : this.world.getRecipeManager().getRecipes(ModRecipes.ALTAR_TYPE, null, null)) { + IAuraType type = IAuraType.forLevel(this.level); + for (AltarRecipe recipe : this.level.getRecipeManager().getRecipes(ModRecipes.ALTAR_TYPE, null, null)) { if (recipe.input.test(input) && (recipe.requiredType == null || type.isSimilar(recipe.requiredType))) { if (recipe.catalyst == Ingredient.EMPTY) return recipe; @@ -216,15 +216,15 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi } private StructureState getNewState() { - if (Multiblocks.ALTAR.isComplete(this.world, this.pos)) + if (Multiblocks.ALTAR.isComplete(this.level, this.worldPosition)) return StructureState.OVERWORLD; - if (Multiblocks.NETHER_ALTAR.isComplete(this.world, this.pos)) + if (Multiblocks.NETHER_ALTAR.isComplete(this.level, this.worldPosition)) return StructureState.NETHER; return StructureState.INVALID; } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.put("items", this.items.serializeNBT()); @@ -240,7 +240,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.items.deserializeNBT(compound.getCompound("items")); @@ -250,8 +250,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi } if (type == SaveType.TILE) { if (compound.contains("recipe")) { - if (this.hasWorld()) - this.currentRecipe = (AltarRecipe) this.world.getRecipeManager().getRecipe(new ResourceLocation(compound.getString("recipe"))).orElse(null); + if (this.hasLevel()) + this.currentRecipe = (AltarRecipe) this.level.getRecipeManager().getRecipe(new ResourceLocation(compound.getString("recipe"))).orElse(null); this.timer = compound.getInt("timer"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java index 7d14e1a5..b6fa0236 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java @@ -4,33 +4,33 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; import java.util.ArrayDeque; import java.util.Queue; -public class TileEntityOakGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityOakGenerator extends BlockEntityImpl implements ITickableBlockEntity { public Queue scheduledBigTrees = new ArrayDeque<>(); - public TileEntityOakGenerator() { + public BlockEntityOakGenerator() { super(ModTileEntities.OAK_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote) + if (!this.level.isClientSide) while (!this.scheduledBigTrees.isEmpty()) { BlockPos pos = this.scheduledBigTrees.remove(); - if (this.world.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { + if (this.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { int toAdd = 100000; boolean canGen = this.canGenerateRightNow(toAdd); if (canGen) this.generateAura(toAdd); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles( - this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.OAK_GENERATOR, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles( + this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.OAK_GENERATOR, pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java index ea068c2f..b13bc36a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java @@ -12,10 +12,10 @@ import net.minecraft.entity.effect.LightningBoltEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.items.IItemHandlerModifiable; @@ -25,7 +25,7 @@ import java.util.ArrayDeque; import java.util.List; import java.util.Queue; -public class TileEntityOfferingTable extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickableBlockEntity { public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { @Override public int getSlotLimit(int slot) { @@ -34,12 +34,12 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable }; private final Queue itemsToSpawn = new ArrayDeque<>(); - public TileEntityOfferingTable() { + public BlockEntityOfferingTable() { super(ModTileEntities.OFFERING_TABLE); } private OfferingRecipe getRecipe(ItemStack input) { - for (OfferingRecipe recipe : this.world.getRecipeManager().getRecipes(ModRecipes.OFFERING_TYPE, null, null)) + for (OfferingRecipe recipe : this.level.getRecipeManager().getRecipes(ModRecipes.OFFERING_TYPE, null, null)) if (recipe.input.test(input)) return recipe; return null; @@ -47,16 +47,16 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable @Override public void tick() { - if (!this.world.isRemote) { - if (this.world.getGameTime() % 20 == 0) { - if (!Multiblocks.OFFERING_TABLE.isComplete(this.world, this.pos)) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 20 == 0) { + if (!Multiblocks.OFFERING_TABLE.isComplete(this.level, this.worldPosition)) return; ItemStack stack = this.items.getStackInSlot(0); if (stack.isEmpty()) return; - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(this.pos).grow(1)); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(this.worldPosition).grow(1)); if (items.isEmpty()) return; @@ -84,33 +84,33 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable for (int i = 0; i < recipeCount; i++) this.itemsToSpawn.add(recipe.output.copy()); - if (Multiblocks.OFFERING_TABLE.forEach(this.pos, 'R', (pos, m) -> this.world.getBlockState(pos).getBlock() == Blocks.WITHER_ROSE)) { - for (int i = this.world.rand.nextInt(5) + 3; i >= 0; i--) + if (Multiblocks.OFFERING_TABLE.forEach(this.worldPosition, 'R', (pos, m) -> this.level.getBlockState(pos).getBlock() == Blocks.WITHER_ROSE)) { + for (int i = this.level.rand.nextInt(5) + 3; i >= 0; i--) this.itemsToSpawn.add(new ItemStack(Items.BLACK_DYE)); } - LightningBoltEntity lightningboltentity = EntityType.LIGHTNING_BOLT.create(this.world); + LightningBoltEntity lightningboltentity = EntityType.LIGHTNING_BOLT.create(this.level); lightningboltentity.setEffectOnly(true); - lightningboltentity.moveForced(Vector3d.copyCenteredHorizontally(this.pos)); - this.world.addEntity(lightningboltentity); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles( + lightningboltentity.moveForced(Vector3d.copyCenteredHorizontally(this.worldPosition)); + this.level.addEntity(lightningboltentity); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles( (float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.OFFERING_TABLE, - this.pos.getX(), this.pos.getY(), this.pos.getZ())); + this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ())); break; } - } else if (this.world.getGameTime() % 3 == 0) { + } else if (this.level.getGameTime() % 3 == 0) { if (!this.itemsToSpawn.isEmpty()) - this.world.addEntity(new ItemEntity( - this.world, - this.pos.getX() + 0.5F, 256, this.pos.getZ() + 0.5F, + this.level.addEntity(new ItemEntity( + this.level, + this.worldPosition.getX() + 0.5F, 256, this.worldPosition.getZ() + 0.5F, this.itemsToSpawn.remove())); } } } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.put("items", this.items.serializeNBT()); @@ -126,7 +126,7 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.items.deserializeNBT(compound.getCompound("items")); @@ -135,7 +135,7 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable this.itemsToSpawn.clear(); ListNBT list = compound.getList("items_to_spawn", 10); for (INBT base : list) { - this.itemsToSpawn.add(ItemStack.read((CompoundNBT) base)); + this.itemsToSpawn.add(ItemStack.read((CompoundTag) base)); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java index 79ff4c16..5886af76 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.blocks.tiles; -public class TileEntityPickupStopper extends TileEntityImpl { +public class BlockEntityPickupStopper extends BlockEntityImpl { - public TileEntityPickupStopper() { + public BlockEntityPickupStopper() { super(ModTileEntities.PICKUP_STOPPER); } @@ -13,7 +13,7 @@ public class TileEntityPickupStopper extends TileEntityImpl { @Override public void onRedstonePowerChange(int newPower) { super.onRedstonePowerChange(newPower); - if (!this.world.isRemote) + if (!this.level.isClientSide) this.sendToClients(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java index 2d131bba..0be56e16 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java @@ -10,14 +10,14 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; @@ -27,24 +27,24 @@ import net.minecraftforge.items.IItemHandler; import java.util.ArrayList; import java.util.List; -public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlockEntity { - public TileEntityPlacer() { + public BlockEntityPlacer() { super(ModTileEntities.PLACER); } @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 15 == 0) { + if (!this.level.isClientSide && this.level.getGameTime() % 15 == 0) { if (this.redstonePower > 0) return; - TileEntity tileUp = this.world.getTileEntity(this.pos.up()); + BlockEntity tileUp = this.level.getBlockEntity(this.worldPosition.up()); if (tileUp == null) return; IItemHandler handler = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null); if (handler == null) return; - List frames = Helper.getAttachedItemFrames(this.world, this.pos); + List frames = Helper.getAttachedItemFrames(this.level, this.worldPosition); if (frames.isEmpty()) return; @@ -53,12 +53,12 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt for (int x = -range; x <= range; x++) for (int y = -range; y <= range; y++) for (int z = -range; z <= range; z++) { - BlockPos pos = this.pos.add(x, y, z); - if (!this.framesContain(frames, pos, this.world.getBlockState(pos))) + BlockPos pos = this.worldPosition.add(x, y, z); + if (!this.framesContain(frames, pos, this.level.getBlockState(pos))) continue; BlockPos up = pos.up(); - BlockState state = this.world.getBlockState(up); + BlockState state = this.level.getBlockState(up); if (state.getMaterial().isReplaceable()) validPositions.add(up); } @@ -70,16 +70,16 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt if (stack.isEmpty()) continue; - BlockPos pos = validPositions.get(this.world.rand.nextInt(validPositions.size())); + BlockPos pos = validPositions.get(this.level.rand.nextInt(validPositions.size())); ItemStack left = this.tryPlace(stack.copy(), pos); if (ItemStack.areItemStacksEqual(stack, left)) continue; handler.extractItem(i, 1, false); - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 1000); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 10, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 1000); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.PLACER_PLACING)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.PLACER_PLACING)); return; } @@ -87,7 +87,7 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt } private boolean framesContain(List frames, BlockPos pos, BlockState state) { - ItemStack stack = state.getBlock().getItem(this.world, pos, state); + ItemStack stack = state.getBlock().getItem(this.level, pos, state); if (stack.isEmpty()) return false; @@ -105,12 +105,12 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt } private ItemStack tryPlace(ItemStack stack, BlockPos pos) { - if (!(this.world instanceof ServerWorld)) + if (!(this.level instanceof ServerLevel)) return stack; - FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world); + FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level); fake.inventory.mainInventory.set(fake.inventory.currentItem, stack); BlockRayTraceResult ray = new BlockRayTraceResult(Vector3d.copyCentered(pos), Direction.UP, pos, false); - ForgeHooks.onPlaceItemIntoWorld(new ItemUseContext(fake, Hand.MAIN_HAND, ray)); + ForgeHooks.onPlaceItemIntoLevel(new ItemUseContext(fake, Hand.MAIN_HAND, ray)); return fake.getHeldItemMainhand().copy(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java index 8001b9a6..31bf2e8e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java @@ -9,26 +9,26 @@ import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionUtils; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.util.List; -public class TileEntityPotionGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityPotionGenerator extends BlockEntityImpl implements ITickableBlockEntity { - public TileEntityPotionGenerator() { + public BlockEntityPotionGenerator() { super(ModTileEntities.POTION_GENERATOR); } @Override public void tick() { - if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) { - if (Multiblocks.POTION_GENERATOR.isComplete(this.world, this.pos)) { + if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) { + if (Multiblocks.POTION_GENERATOR.isComplete(this.level, this.worldPosition)) { boolean addedOne = false; - List clouds = this.world.getEntitiesWithinAABB(AreaEffectCloudEntity.class, new AxisAlignedBB(this.pos).grow(2)); + List clouds = this.level.getEntitiesWithinAABB(AreaEffectCloudEntity.class, new AxisAlignedBB(this.worldPosition).grow(2)); for (AreaEffectCloudEntity cloud : clouds) { if (!cloud.isAlive()) continue; @@ -49,8 +49,8 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab if (canGen) this.generateAura(toAdd); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles( - this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.POTION_GEN, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles( + this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.POTION_GEN, PotionUtils.getPotionColor(type), canGen ? 1 : 0)); addedOne = true; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPowderPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPowderPlacer.java index 24b19877..dd916491 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPowderPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPowderPlacer.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; @@ -12,21 +12,21 @@ import net.minecraftforge.items.IItemHandler; import java.util.List; -public class TileEntityPowderPlacer extends TileEntityImpl { +public class BlockEntityPowderPlacer extends BlockEntityImpl { - public TileEntityPowderPlacer() { + public BlockEntityPowderPlacer() { super(ModTileEntities.POWDER_PLACER); } @Override public void onRedstonePowerChange(int newPower) { if (this.redstonePower <= 0 && newPower > 0) { - List powders = this.world.getEntitiesWithinAABB(EntityEffectInhibitor.class, - new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)), EntityPredicates.IS_ALIVE); + List powders = this.level.getEntitiesWithinAABB(EntityEffectInhibitor.class, + new AxisAlignedBB(this.worldPosition, this.worldPosition.add(1, 2, 1)), EntityPredicates.IS_ALIVE); for (Direction facing : Direction.values()) { if (!facing.getAxis().isHorizontal()) continue; - TileEntity tile = this.world.getTileEntity(this.pos.offset(facing)); + BlockEntity tile = this.level.getBlockEntity(this.worldPosition.offset(facing)); if (tile == null) continue; IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null); @@ -51,7 +51,7 @@ public class TileEntityPowderPlacer extends TileEntityImpl { ItemStack stack = handler.extractItem(i, Integer.MAX_VALUE, true); if (stack.isEmpty() || stack.getItem() != ModItems.EFFECT_POWDER) continue; - EntityEffectInhibitor.place(this.world, stack, this.pos.getX() + 0.5, this.pos.getY() + 1, this.pos.getZ() + 0.5); + EntityEffectInhibitor.place(this.level, stack, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 1, this.worldPosition.getZ() + 0.5); handler.extractItem(i, Integer.MAX_VALUE, false); break; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityProjectileGenerator.java index 12a5a71f..f78d4ff3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityProjectileGenerator.java @@ -1,18 +1,18 @@ package de.ellpeck.naturesaura.blocks.tiles; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Direction; -public class TileEntityProjectileGenerator extends TileEntityImpl { +public class BlockEntityProjectileGenerator extends BlockEntityImpl { public Direction nextSide = Direction.NORTH; - public TileEntityProjectileGenerator() { + public BlockEntityProjectileGenerator() { super(ModTileEntities.PROJECTILE_GENERATOR); } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.putInt("next_side", this.nextSide.getHorizontalIndex()); @@ -20,7 +20,7 @@ public class TileEntityProjectileGenerator extends TileEntityImpl { } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.nextSide = Direction.byHorizontalIndex(compound.getInt("next_side")); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java index a7b5c1d1..b698cb9d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java @@ -5,9 +5,9 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -19,38 +19,38 @@ import net.minecraftforge.energy.IEnergyStorage; import javax.annotation.Nullable; -public class TileEntityRFConverter extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityRFConverter extends BlockEntityImpl implements ITickableBlockEntity { public final RFStorage storage = new RFStorage(); private final LazyOptional storageOptional = LazyOptional.of(() -> this.storage); private int lastEnergy; - public TileEntityRFConverter() { + public BlockEntityRFConverter() { super(ModTileEntities.RF_CONVERTER); } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); compound.putInt("energy", this.storage.getEnergyStored()); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); this.storage.setEnergy(compound.getInt("energy")); } @Override public void tick() { - if (!this.world.isRemote && ModConfig.instance.rfConverter.get()) { - if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) { + if (!this.level.isClientSide && ModConfig.instance.rfConverter.get()) { + if (this.lastEnergy != this.storage.getEnergyStored() && this.level.getGameTime() % 10 == 0) { this.sendToClients(); this.lastEnergy = this.storage.getEnergyStored(); } for (Direction facing : Direction.values()) { - TileEntity tile = this.world.getTileEntity(this.pos.offset(facing)); + BlockEntity tile = this.level.getBlockEntity(this.worldPosition.offset(facing)); if (tile == null) continue; IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()).orElse(null); @@ -69,23 +69,23 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickableTi int emptyPart = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored(); if (emptyPart <= 0) return; - if (this.world.getGameTime() % 20 != 0) + if (this.level.getGameTime() % 20 != 0) return; - if (!Multiblocks.RF_CONVERTER.isComplete(this.world, this.pos)) + if (!Multiblocks.RF_CONVERTER.isComplete(this.level, this.worldPosition)) return; - int aura = IAuraChunk.getAuraInArea(this.world, this.pos, 45); + int aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 45); if (aura <= IAuraChunk.DEFAULT_AURA) return; int amountToGen = Math.min(Math.min(10000, aura / 1000), emptyPart); int amountToUse = MathHelper.ceil(amountToGen / ModConfig.instance.auraToRFRatio.get()); this.storage.setEnergy(this.storage.getEnergyStored() + amountToGen); - BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos); - IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse); + BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 45, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, amountToUse); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.RF_CONVERTER)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.RF_CONVERTER)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySlimeSplitGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySlimeSplitGenerator.java index 491aa93d..8d5615b4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySlimeSplitGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySlimeSplitGenerator.java @@ -5,29 +5,29 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.monster.MagmaCubeEntity; import net.minecraft.entity.monster.SlimeEntity; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; -public class TileEntitySlimeSplitGenerator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements ITickableBlockEntity { private int generationTimer; private int amountToRelease; private int color; - public TileEntitySlimeSplitGenerator() { + public BlockEntitySlimeSplitGenerator() { super(ModTileEntities.SLIME_SPLIT_GENERATOR); } @Override public void tick() { - if (this.world.isRemote || this.world.getGameTime() % 10 != 0) + if (this.level.isClientSide || this.level.getGameTime() % 10 != 0) return; if (this.generationTimer > 0) { int amount = this.amountToRelease * 10; if (this.canGenerateRightNow(amount)) { this.generateAura(amount); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_CREATE, this.color)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_CREATE, this.color)); } this.generationTimer -= 10; } @@ -48,12 +48,12 @@ public class TileEntitySlimeSplitGenerator extends TileEntityImpl implements ITi this.amountToRelease = (size * this.getGenerationAmount(slime)) / this.generationTimer; this.color = this.getSlimeColor(slime); - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) slime.getPosX(), (float) slime.getPosY(), (float) slime.getPosZ(), PacketParticles.Type.SLIME_SPLIT_GEN_START, - this.pos.getX(), this.pos.getY(), this.pos.getZ(), this.color)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) slime.getPosX(), (float) slime.getPosY(), (float) slime.getPosZ(), PacketParticles.Type.SLIME_SPLIT_GEN_START, + this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), this.color)); } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) { compound.putInt("timer", this.generationTimer); @@ -63,7 +63,7 @@ public class TileEntitySlimeSplitGenerator extends TileEntityImpl implements ITi } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) { this.generationTimer = compound.getInt("timer"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySnowCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySnowCreator.java index 9fe916c5..2056dc11 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySnowCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySnowCreator.java @@ -10,17 +10,17 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.SnowGolemEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.level.gen.Heightmap; -public class TileEntitySnowCreator extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickableBlockEntity { private int snowmanCount; - public TileEntitySnowCreator() { + public BlockEntitySnowCreator() { super(ModTileEntities.SNOW_CREATOR); } @@ -40,67 +40,67 @@ public class TileEntitySnowCreator extends TileEntityImpl implements ITickableTi if (range <= 0) return; - if (!this.world.isRemote) { - if (this.world.getGameTime() % 10 != 0) + if (!this.level.isClientSide) { + if (this.level.getGameTime() % 10 != 0) return; for (int i = 0; i < 10; i++) { - double angle = this.world.rand.nextFloat() * Math.PI * 2; - BlockPos pos = this.pos.add(Math.cos(angle) * range * this.world.rand.nextFloat(), 0, Math.sin(angle) * range * this.world.rand.nextFloat()); - pos = this.world.getHeight(Heightmap.Type.MOTION_BLOCKING, pos); + double angle = this.level.rand.nextFloat() * Math.PI * 2; + BlockPos pos = this.worldPosition.add(Math.cos(angle) * range * this.level.rand.nextFloat(), 0, Math.sin(angle) * range * this.level.rand.nextFloat()); + pos = this.level.getHeight(Heightmap.Type.MOTION_BLOCKING, pos); BlockPos down = pos.down(); - Fluid fluid = this.world.getFluidState(down).getFluid(); + Fluid fluid = this.level.getFluidState(down).getFluid(); if (fluid == Fluids.WATER) { - if (this.world.getBlockState(down).getMaterial().isReplaceable()) - this.world.setBlockState(down, Blocks.ICE.getDefaultState()); - } else if (Blocks.SNOW.getDefaultState().isValidPosition(this.world, pos) && this.world.getBlockState(pos).getBlock() != Blocks.SNOW && this.world.getBlockState(pos).getMaterial().isReplaceable()) { - this.world.setBlockState(pos, Blocks.SNOW.getDefaultState()); + if (this.level.getBlockState(down).getMaterial().isReplaceable()) + this.level.setBlockState(down, Blocks.ICE.getDefaultState()); + } else if (Blocks.SNOW.getDefaultState().isValidPosition(this.level, pos) && this.level.getBlockState(pos).getBlock() != Blocks.SNOW && this.level.getBlockState(pos).getMaterial().isReplaceable()) { + this.level.setBlockState(pos, Blocks.SNOW.getDefaultState()); - if (this.snowmanCount < range / 2 && this.world.rand.nextFloat() >= 0.995F) { + if (this.snowmanCount < range / 2 && this.level.rand.nextFloat() >= 0.995F) { this.snowmanCount++; - Entity golem = new SnowGolemEntity(EntityType.SNOW_GOLEM, this.world); + Entity golem = new SnowGolemEntity(EntityType.SNOW_GOLEM, this.level); golem.setPosition(pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F); - this.world.addEntity(golem); + this.level.addEntity(golem); } } else { continue; } - BlockPos auraPos = IAuraChunk.getHighestSpot(this.world, this.pos, 30, this.pos); - IAuraChunk.getAuraChunk(this.world, auraPos).drainAura(auraPos, 300); + BlockPos auraPos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, auraPos).drainAura(auraPos, 300); - PacketHandler.sendToAllAround(this.world, this.pos, 32, - new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.SNOW_CREATOR)); + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.SNOW_CREATOR)); break; } } else { - if (this.world.getGameTime() % 30 != 0) + if (this.level.getGameTime() % 30 != 0) return; for (int i = range * 4; i >= 0; i--) { - double angle = this.world.rand.nextFloat() * Math.PI * 2; - BlockPos pos = this.pos.add( - Math.cos(angle) * range * this.world.rand.nextFloat(), - MathHelper.nextInt(this.world.rand, range / 2, range), - Math.sin(angle) * range * this.world.rand.nextFloat()); + double angle = this.level.rand.nextFloat() * Math.PI * 2; + BlockPos pos = this.worldPosition.add( + Math.cos(angle) * range * this.level.rand.nextFloat(), + MathHelper.nextInt(this.level.rand, range / 2, range), + Math.sin(angle) * range * this.level.rand.nextFloat()); NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + this.world.rand.nextFloat(), pos.getY() + 1, pos.getZ() + this.world.rand.nextFloat(), - this.world.rand.nextGaussian() * 0.05, 0, this.world.rand.nextGaussian() * 0.05, - 0xdbe9ff, 1 + this.world.rand.nextFloat() * 1.5F, 10 * range, 0.05F + this.world.rand.nextFloat() * 0.05F, true, true + pos.getX() + this.level.rand.nextFloat(), pos.getY() + 1, pos.getZ() + this.level.rand.nextFloat(), + this.level.rand.nextGaussian() * 0.05, 0, this.level.rand.nextGaussian() * 0.05, + 0xdbe9ff, 1 + this.level.rand.nextFloat() * 1.5F, 10 * range, 0.05F + this.level.rand.nextFloat() * 0.05F, true, true ); } } } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type == SaveType.TILE) compound.putInt("snowman_count", this.snowmanCount); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type == SaveType.TILE) this.snowmanCount = compound.getInt("snowman_count"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java index b8d8b302..8b26e1b5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpawnLamp.java @@ -1,11 +1,11 @@ package de.ellpeck.naturesaura.blocks.tiles; -import de.ellpeck.naturesaura.api.misc.IWorldData; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; +import de.ellpeck.naturesaura.misc.LevelData; -public class TileEntitySpawnLamp extends TileEntityImpl { +public class BlockEntitySpawnLamp extends BlockEntityImpl { - public TileEntitySpawnLamp() { + public BlockEntitySpawnLamp() { super(ModTileEntities.SPAWN_LAMP); } @@ -16,8 +16,8 @@ public class TileEntitySpawnLamp extends TileEntityImpl { @Override public void validate() { super.validate(); - if (!this.world.isRemote) { - WorldData data = (WorldData) IWorldData.getWorldData(this.world); + if (!this.level.isClientSide) { + LevelData data = (LevelData) ILevelData.getLevelData(this.level); data.spawnLamps.add(this); } } @@ -25,8 +25,8 @@ public class TileEntitySpawnLamp extends TileEntityImpl { @Override public void remove() { super.remove(); - if (!this.world.isRemote) { - WorldData data = (WorldData) IWorldData.getWorldData(this.world); + if (!this.level.isClientSide) { + LevelData data = (LevelData) ILevelData.getLevelData(this.level); data.spawnLamps.remove(this); } } @@ -34,7 +34,7 @@ public class TileEntitySpawnLamp extends TileEntityImpl { @Override public void onRedstonePowerChange(int newPower) { super.onRedstonePowerChange(newPower); - if (!this.world.isRemote) + if (!this.level.isClientSide) this.sendToClients(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpring.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpring.java index f4d0b40a..b43db520 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpring.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntitySpring.java @@ -8,7 +8,7 @@ import net.minecraft.block.CauldronBlock; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; import net.minecraft.tags.FluidTags; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -25,29 +25,29 @@ import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -public class TileEntitySpring extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlockEntity { private final LazyOptional tank = LazyOptional.of(InfiniteTank::new); private AABBTicket waterTicket; - public TileEntitySpring() { + public BlockEntitySpring() { super(ModTileEntities.SPRING); } @Override public void validate() { super.validate(); - if (!this.world.isRemote) { + if (!this.level.isClientSide) { // add a ticket to water crops - AxisAlignedBB area = new AxisAlignedBB(this.pos).grow(5, 1, 5); - this.waterTicket = FarmlandWaterManager.addAABBTicket(this.world, area); + AxisAlignedBB area = new AxisAlignedBB(this.worldPosition).grow(5, 1, 5); + this.waterTicket = FarmlandWaterManager.addAABBTicket(this.level, area); } } @Override public void remove() { super.remove(); - if (!this.world.isRemote && this.waterTicket != null && this.waterTicket.isValid()) { + if (!this.level.isClientSide && this.waterTicket != null && this.waterTicket.isValid()) { this.waterTicket.invalidate(); this.waterTicket = null; } @@ -56,17 +56,17 @@ public class TileEntitySpring extends TileEntityImpl implements ITickableTileEnt @Override public void tick() { - if (this.world.isRemote || this.world.getGameTime() % 35 != 0) + if (this.level.isClientSide || this.level.getGameTime() % 35 != 0) return; // fill cauldrons - BlockPos up = this.pos.up(); - BlockState upState = this.world.getBlockState(up); + BlockPos up = this.worldPosition.up(); + BlockState upState = this.level.getBlockState(up); if (upState.hasProperty(CauldronBlock.LEVEL)) { int level = upState.get(CauldronBlock.LEVEL); if (level < 3) { - this.world.setBlockState(up, upState.with(CauldronBlock.LEVEL, level + 1)); - this.world.playSound(null, up, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1, 1); + this.level.setBlockState(up, upState.with(CauldronBlock.LEVEL, level + 1)); + this.level.playSound(null, up, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1, 1); this.consumeAura(2500); return; } @@ -77,11 +77,11 @@ public class TileEntitySpring extends TileEntityImpl implements ITickableTileEnt for (int x = -spongeRadius; x <= spongeRadius; x++) { for (int y = -spongeRadius; y <= spongeRadius; y++) { for (int z = -spongeRadius; z <= spongeRadius; z++) { - BlockPos pos = this.pos.add(x, y, z); - BlockState state = this.world.getBlockState(pos); + BlockPos pos = this.worldPosition.add(x, y, z); + BlockState state = this.level.getBlockState(pos); if (state.getBlock() == Blocks.SPONGE) { - this.world.setBlockState(pos, Blocks.WET_SPONGE.getDefaultState(), 2); - this.world.playEvent(2001, pos, Block.getStateId(Blocks.WATER.getDefaultState())); + this.level.setBlockState(pos, Blocks.WET_SPONGE.getDefaultState(), 2); + this.level.playEvent(2001, pos, Block.getStateId(Blocks.WATER.getDefaultState())); this.consumeAura(2500); return; } @@ -91,31 +91,31 @@ public class TileEntitySpring extends TileEntityImpl implements ITickableTileEnt // generate obsidian for (Direction dir : Direction.Plane.HORIZONTAL) { - BlockPos side = this.pos.offset(dir); + BlockPos side = this.worldPosition.offset(dir); if (this.isLava(side, true)) { - this.world.setBlockState(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.world, side, side, Blocks.OBSIDIAN.getDefaultState())); - this.world.playEvent(1501, side, 0); + this.level.setBlockState(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, side, side, Blocks.OBSIDIAN.getDefaultState())); + this.level.playEvent(1501, side, 0); this.consumeAura(1500); return; } } // generate stone - BlockPos twoUp = this.pos.up(2); - if (this.isLava(twoUp, false) && (this.world.getBlockState(up).isAir(this.world, up) || this.isLava(up, false))) { - this.world.setBlockState(up, ForgeEventFactory.fireFluidPlaceBlockEvent(this.world, up, twoUp, Blocks.STONE.getDefaultState())); - this.world.playEvent(1501, up, 0); + BlockPos twoUp = this.worldPosition.up(2); + if (this.isLava(twoUp, false) && (this.level.getBlockState(up).isAir(this.level, up) || this.isLava(up, false))) { + this.level.setBlockState(up, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, up, twoUp, Blocks.STONE.getDefaultState())); + this.level.playEvent(1501, up, 0); this.consumeAura(150); return; } // generate cobblestone for (Direction dir : Direction.Plane.HORIZONTAL) { - BlockPos twoSide = this.pos.offset(dir, 2); - BlockPos side = this.pos.offset(dir); - if (this.isLava(twoSide, false) && (this.world.getBlockState(side).isAir(this.world, side) || this.isLava(side, false))) { - this.world.setBlockState(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.world, side, twoSide, Blocks.COBBLESTONE.getDefaultState())); - this.world.playEvent(1501, side, 0); + BlockPos twoSide = this.worldPosition.offset(dir, 2); + BlockPos side = this.worldPosition.offset(dir); + if (this.isLava(twoSide, false) && (this.level.getBlockState(side).isAir(this.level, side) || this.isLava(side, false))) { + this.level.setBlockState(side, ForgeEventFactory.fireFluidPlaceBlockEvent(this.level, side, twoSide, Blocks.COBBLESTONE.getDefaultState())); + this.level.playEvent(1501, side, 0); this.consumeAura(100); return; } @@ -131,13 +131,13 @@ public class TileEntitySpring extends TileEntityImpl implements ITickableTileEnt public void consumeAura(int amount) { while (amount > 0) { - BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - amount -= IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amount); + BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + amount -= IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, amount); } } private boolean isLava(BlockPos offset, boolean source) { - FluidState state = this.world.getFluidState(offset); + FluidState state = this.level.getFluidState(offset); return (!source || state.isSource()) && state.getFluid().isIn(FluidTags.LAVA); } @@ -171,7 +171,7 @@ public class TileEntitySpring extends TileEntityImpl implements ITickableTileEnt public FluidStack drain(int maxDrain, IFluidHandler.FluidAction action) { int drain = Math.min(maxDrain, 1000); if (action.execute()) - TileEntitySpring.this.consumeAura(MathHelper.ceil(drain / 2F)); + BlockEntitySpring.this.consumeAura(MathHelper.ceil(drain / 2F)); return new FluidStack(Fluids.WATER, drain); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityTimeChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityTimeChanger.java index f93be670..cb21696c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityTimeChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityTimeChanger.java @@ -9,64 +9,64 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.play.server.SUpdateTimePacket; import net.minecraft.server.management.PlayerList; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.GameRules; -import net.minecraft.world.server.ServerWorld; -import net.minecraft.world.storage.IServerWorldInfo; +import net.minecraft.level.GameRules; +import net.minecraft.level.server.ServerLevel; +import net.minecraft.level.storage.IServerLevelInfo; import java.util.List; -public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickableBlockEntity { private long goalTime; - public TileEntityTimeChanger() { + public BlockEntityTimeChanger() { super(ModTileEntities.TIME_CHANGER); } @Override public void tick() { - if (!this.world.isRemote) { - List frames = Helper.getAttachedItemFrames(this.world, this.pos); + if (!this.level.isClientSide) { + List frames = Helper.getAttachedItemFrames(this.level, this.worldPosition); for (ItemFrameEntity frame : frames) { ItemStack frameStack = frame.getDisplayedItem(); if (frameStack.isEmpty() || frameStack.getItem() != ModItems.CLOCK_HAND) continue; if (this.goalTime > 0) { - long current = this.world.getDayTime(); + long current = this.level.getDayTime(); long toAdd = Math.min(75, this.goalTime - current); if (toAdd <= 0) { this.goalTime = 0; this.sendToClients(); return; } - ((IServerWorldInfo) this.world.getWorldInfo()).setDayTime(current + toAdd); + ((IServerLevelInfo) this.level.getLevelInfo()).setDayTime(current + toAdd); - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, (int) toAdd * 20); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, (int) toAdd * 20); - if (this.world instanceof ServerWorld) { - PlayerList list = this.world.getServer().getPlayerList(); + if (this.level instanceof ServerLevel) { + PlayerList list = this.level.getServer().getPlayerList(); list.sendPacketToAllPlayers(new SUpdateTimePacket( - this.world.getGameTime(), this.world.getDayTime(), - this.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); + this.level.getGameTime(), this.level.getDayTime(), + this.level.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); } return; } - if (this.world.getGameTime() % 20 != 0) + if (this.level.getGameTime() % 20 != 0) return; - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, - new AxisAlignedBB(this.pos).grow(1), EntityPredicates.IS_ALIVE); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, + new AxisAlignedBB(this.worldPosition).grow(1), EntityPredicates.IS_ALIVE); for (ItemEntity item : items) { if (item.cannotPickup()) continue; @@ -75,7 +75,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi continue; int dayGoal = MathHelper.floor((frame.getRotation() / 8F) * 24000F) + 18000; - long current = this.world.getDayTime(); + long current = this.level.getDayTime(); long toMove = (24000 - current % 24000 + dayGoal) % 24000; this.goalTime = current + toMove; this.sendToClients(); @@ -93,33 +93,33 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi this.goalTime = 0; this.sendToClients(); } - } else if (this.goalTime > 0 && this.world.rand.nextFloat() >= 0.25F) { - double angle = Math.toRadians(this.world.getDayTime() * 5F % 360); - double x = this.pos.getX() + 0.5 + Math.sin(angle) * 3F; - double z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F; + } else if (this.goalTime > 0 && this.level.rand.nextFloat() >= 0.25F) { + double angle = Math.toRadians(this.level.getDayTime() * 5F % 360); + double x = this.worldPosition.getX() + 0.5 + Math.sin(angle) * 3F; + double z = this.worldPosition.getZ() + 0.5 + Math.cos(angle) * 3F; int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926; NaturesAuraAPI.instance().spawnMagicParticle( - x, this.pos.getY() + 0.1F, z, + x, this.worldPosition.getY() + 0.1F, z, 0F, 0.12F, 0F, - color, 1F + this.world.rand.nextFloat() * 2F, - this.world.rand.nextInt(100) + 100, 0, false, true); + color, 1F + this.level.rand.nextFloat() * 2F, + this.level.rand.nextInt(100) + 100, 0, false, true); NaturesAuraAPI.instance().spawnMagicParticle( - x, this.pos.getY() + 0.1F, z, + x, this.worldPosition.getY() + 0.1F, z, 0F, 0F, 0F, - IAuraType.forWorld(this.world).getColor(), 1F + this.world.rand.nextFloat(), + IAuraType.forLevel(this.level).getColor(), 1F + this.level.rand.nextFloat(), 150, 0, false, true); } } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) compound.putLong("goal", this.goalTime); } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) this.goalTime = compound.getLong("goal"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWeatherChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWeatherChanger.java index 6d9c9798..646e34d8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWeatherChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWeatherChanger.java @@ -6,31 +6,31 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.misc.WeatherType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.ITickableBlockEntity; import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.server.ServerLevel; import org.apache.commons.lang3.tuple.Pair; import java.util.List; import java.util.Map; -public class TileEntityWeatherChanger extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITickableBlockEntity { private int processTime; private WeatherType type; private int itemAmount; - public TileEntityWeatherChanger() { + public BlockEntityWeatherChanger() { super(ModTileEntities.WEATHER_CHANGER); } @Override public void tick() { - if (this.world.isRemote) { - if (this.world.getGameTime() % 10 != 0) + if (this.level.isClientSide) { + if (this.level.getGameTime() % 10 != 0) return; if (this.processTime <= 0) return; @@ -38,15 +38,15 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl for (int r = 0; r < 360; r += 20) { double xOff = Math.cos(Math.toRadians(r)) * 3F; double zOff = Math.sin(Math.toRadians(r)) * 3F; - for (int i = this.world.rand.nextInt(3); i > 0; i--) { + for (int i = this.level.rand.nextInt(3); i > 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( - this.pos.getX() + 0.5F + xOff, - this.pos.getY(), - this.pos.getZ() + 0.5F + zOff, - this.world.rand.nextGaussian() * 0.02F, - this.world.rand.nextFloat() * 0.1F + 0.1F, - this.world.rand.nextGaussian() * 0.02F, - color, this.world.rand.nextFloat() * 2 + 1, this.world.rand.nextInt(80) + 80, 0, false, true); + this.worldPosition.getX() + 0.5F + xOff, + this.worldPosition.getY(), + this.worldPosition.getZ() + 0.5F + zOff, + this.level.rand.nextGaussian() * 0.02F, + this.level.rand.nextFloat() * 0.1F + 0.1F, + this.level.rand.nextGaussian() * 0.02F, + color, this.level.rand.nextFloat() * 2 + 1, this.level.rand.nextInt(80) + 80, 0, false, true); } } return; @@ -54,15 +54,15 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl if (this.processTime > 0) { if (this.processTime % 20 == 0) { - BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos); - IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 30000 * this.itemAmount); + BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition); + IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, 30000 * this.itemAmount); } this.processTime--; if (this.processTime <= 0) { this.sendToClients(); int time = 6000 * this.itemAmount; - ServerWorld server = (ServerWorld) this.world; + ServerLevel server = (ServerLevel) this.level; switch (this.type) { case SUN: server.func_241113_a_(time, 0, false, false); @@ -76,7 +76,7 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl } } } else { - if (this.world.getGameTime() % 20 != 0) + if (this.level.getGameTime() % 20 != 0) return; Pair type = this.getNextWeatherType(); if (type == null) @@ -89,7 +89,7 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { compound.putInt("time", this.processTime); @@ -100,7 +100,7 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { this.processTime = compound.getInt("time"); @@ -110,8 +110,8 @@ public class TileEntityWeatherChanger extends TileEntityImpl implements ITickabl } private Pair getNextWeatherType() { - AxisAlignedBB area = new AxisAlignedBB(this.pos).grow(2); - List items = this.world.getEntitiesWithinAABB(ItemEntity.class, area, EntityPredicates.IS_ALIVE); + AxisAlignedBB area = new AxisAlignedBB(this.worldPosition).grow(2); + List items = this.level.getEntitiesWithinAABB(ItemEntity.class, area, EntityPredicates.IS_ALIVE); for (ItemEntity entity : items) { if (entity.cannotPickup()) continue; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index 4c94e5b4..d52262d2 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -11,15 +11,15 @@ import net.minecraft.block.LeavesBlock; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.ITickableBlockEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class TileEntityWoodStand extends TileEntityImpl implements ITickableTileEntity { +public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBlockEntity { public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { @Override @@ -40,7 +40,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile private BlockPos ritualPos; private int timer; - public TileEntityWoodStand() { + public BlockEntityWoodStand() { super(ModTileEntities.WOOD_STAND); } @@ -51,9 +51,9 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile @Override public void tick() { - if (!this.world.isRemote) { + if (!this.level.isClientSide) { if (this.ritualPos != null && this.recipe != null) { - if (this.world.getGameTime() % 5 == 0) { + if (this.level.getGameTime() % 5 == 0) { if (this.isRitualOkay()) { boolean wasOverHalf = this.timer >= this.recipe.time / 2; this.timer += 5; @@ -61,37 +61,37 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile if (!isOverHalf) Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> { - TileEntity tile = this.world.getTileEntity(pos); - if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) { - PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( - (float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F, + BlockEntity tile = this.level.getBlockEntity(pos); + if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) { + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( + (float) pos.getX() + 0.2F + this.level.rand.nextFloat() * 0.6F, (float) pos.getY() + 0.85F, - (float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F, - this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F, - this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F + (float) pos.getZ() + 0.2F + this.level.rand.nextFloat() * 0.6F, + this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F, + this.level.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.rand.nextFloat() * 1F + 1F )); } return true; }); - PacketHandler.sendToAllAround(this.world, this.ritualPos, 32, + PacketHandler.sendToAllAround(this.level, this.ritualPos, 32, new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER)); if (this.timer >= this.recipe.time) { Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> { - this.world.setBlockState(pos, Blocks.AIR.getDefaultState()); + this.level.setBlockState(pos, Blocks.AIR.getDefaultState()); return true; }); - recurseTreeDestruction(this.world, this.ritualPos, this.ritualPos, true, false); + recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false); - ItemEntity item = new ItemEntity(this.world, + ItemEntity item = new ItemEntity(this.level, this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5, this.recipe.result.copy()); - this.world.addEntity(item); + this.level.addEntity(item); - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.TR_SPAWN_RESULT)); - this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, + this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F); this.ritualPos = null; @@ -99,13 +99,13 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile this.timer = 0; } else if (isOverHalf && !wasOverHalf) { Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> { - TileEntity tile = this.world.getTileEntity(pos); - if (tile instanceof TileEntityWoodStand) { - TileEntityWoodStand stand = (TileEntityWoodStand) tile; + BlockEntity tile = this.level.getBlockEntity(pos); + if (tile instanceof BlockEntityWoodStand) { + BlockEntityWoodStand stand = (BlockEntityWoodStand) tile; if (!stand.items.getStackInSlot(0).isEmpty()) { - PacketHandler.sendToAllAround(this.world, this.pos, 32, + PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), PacketParticles.Type.TR_CONSUME_ITEM)); - this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5, + this.level.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5, SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F); stand.items.setStackInSlot(0, ItemStack.EMPTY); @@ -126,7 +126,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile } - public static void recurseTreeDestruction(World world, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) { + public static void recurseTreeDestruction(Level level, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) { if (Math.abs(pos.getX() - start.getX()) >= 6 || Math.abs(pos.getZ() - start.getZ()) >= 6 || Math.abs(pos.getY() - start.getY()) >= 32) { @@ -137,16 +137,16 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile for (int y = -1; y <= 1; y++) { for (int z = -1; z <= 1; z++) { BlockPos offset = pos.add(x, y, z); - BlockState state = world.getBlockState(offset); + BlockState state = level.getBlockState(offset); if (state.getBlock().getTags().contains(BlockTags.LOGS.getName()) || includeLeaves && state.getBlock() instanceof LeavesBlock) { if (drop) { - world.destroyBlock(offset, true); + level.destroyBlock(offset, true); } else { // in this case we don't want the particles, so we can't use destroyBlock - world.setBlockState(offset, Blocks.AIR.getDefaultState()); - PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR)); + level.setBlockState(offset, Blocks.AIR.getDefaultState()); + PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR)); } - recurseTreeDestruction(world, offset, start, includeLeaves, drop); + recurseTreeDestruction(level, offset, start, includeLeaves, drop); } } } @@ -154,20 +154,20 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile } private boolean isRitualOkay() { - if (!Multiblocks.TREE_RITUAL.isComplete(this.world, this.ritualPos)) { + if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) { return false; } for (int i = 0; i < 2; i++) { - BlockState state = this.world.getBlockState(this.ritualPos.up(i)); + BlockState state = this.level.getBlockState(this.ritualPos.up(i)); if (!(state.getBlock().getTags().contains(BlockTags.LOGS.getName()))) return false; } if (this.timer < this.recipe.time / 2) { List required = new ArrayList<>(Arrays.asList(this.recipe.ingredients)); boolean fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> { - TileEntity tile = this.world.getTileEntity(pos); - if (tile instanceof TileEntityWoodStand) { - ItemStack stack = ((TileEntityWoodStand) tile).items.getStackInSlot(0); + BlockEntity tile = this.level.getBlockEntity(pos); + if (tile instanceof BlockEntityWoodStand) { + ItemStack stack = ((BlockEntityWoodStand) tile).items.getStackInSlot(0); if (!stack.isEmpty()) { for (int i = required.size() - 1; i >= 0; i--) { Ingredient req = required.get(i); @@ -187,7 +187,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile } @Override - public void writeNBT(CompoundNBT compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) compound.put("items", this.items.serializeNBT()); @@ -202,7 +202,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile } @Override - public void readNBT(CompoundNBT compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) this.items.deserializeNBT(compound.getCompound("items")); @@ -211,8 +211,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile if (compound.contains("recipe")) { this.ritualPos = BlockPos.fromLong(compound.getLong("ritual_pos")); this.timer = compound.getInt("timer"); - if (this.hasWorld()) - this.recipe = (TreeRitualRecipe) this.world.getRecipeManager().getRecipe(new ResourceLocation(compound.getString("recipe"))).orElse(null); + if (this.hasLevel()) + this.recipe = (TreeRitualRecipe) this.level.getRecipeManager().getRecipe(new ResourceLocation(compound.getString("recipe"))).orElse(null); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java index 2c814fcb..741d891a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java @@ -4,27 +4,27 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraTimer; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer; import de.ellpeck.naturesaura.items.ItemAuraBottle; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public class RenderAuraTimer extends TileEntityRenderer { +public class RenderAuraTimer extends BlockEntityRenderer { private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png"); private final AuraModel model = new AuraModel(); - public RenderAuraTimer(TileEntityRendererDispatcher disp) { + public RenderAuraTimer(BlockEntityRendererDispatcher disp) { super(disp); } @Override - public void render(TileEntityAuraTimer tile, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { + public void render(BlockEntityAuraTimer tile, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { ItemStack bottle = tile.getItemHandler().getStackInSlot(0); if (bottle.isEmpty()) return; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java index 4fc625da..ce25408c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java @@ -3,11 +3,11 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.util.math.vector.Matrix4f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -17,16 +17,16 @@ import java.util.Random; import java.util.stream.IntStream; @OnlyIn(Dist.CLIENT) -public class RenderEnderCrate extends TileEntityRenderer { +public class RenderEnderCrate extends BlockEntityRenderer { private static final Random RANDOM = new Random(31100L); private static final List RENDER_TYPES = IntStream.range(0, 16).mapToObj(i -> RenderType.getEndPortal(i + 1)).collect(ImmutableList.toImmutableList()); - public RenderEnderCrate(TileEntityRendererDispatcher rendererDispatcherIn) { + public RenderEnderCrate(BlockEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } @Override - public void render(TileEntityEnderCrate tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { + public void render(BlockEntityEnderCrate tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { RANDOM.setSeed(31100L); double d0 = tileEntityIn.getPos().distanceSq(this.renderDispatcher.renderInfo.getProjectedView(), true); int i = this.getPasses(d0); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java index 70d55702..00c158a1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java @@ -3,33 +3,33 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class RenderGeneratorLimitRemover extends TileEntityRenderer { +public class RenderGeneratorLimitRemover extends BlockEntityRenderer { private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png"); private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint(); - public RenderGeneratorLimitRemover(TileEntityRendererDispatcher disp) { + public RenderGeneratorLimitRemover(BlockEntityRendererDispatcher disp) { super(disp); } @Override - public void render(TileEntityGeneratorLimitRemover te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { - TileEntity above = te.getWorld().getTileEntity(te.getPos().up()); - if (above instanceof TileEntityImpl && ((TileEntityImpl) above).wantsLimitRemover()) { + public void render(BlockEntityGeneratorLimitRemover te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { + BlockEntity above = te.getLevel().getBlockEntity(te.getPos().up()); + if (above instanceof BlockEntityImpl && ((BlockEntityImpl) above).wantsLimitRemover()) { this.renderGlint(matrixStack, iRenderTypeBuffer, 1, combinedOverlayIn); this.renderGlint(matrixStack, iRenderTypeBuffer, 0, combinedOverlayIn); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java index 948a7039..c66f1cfd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java @@ -1,22 +1,22 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.matrix.MatrixStack; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3f; -public class RenderNatureAltar extends TileEntityRenderer { - public RenderNatureAltar(TileEntityRendererDispatcher rendererDispatcherIn) { +public class RenderNatureAltar extends BlockEntityRenderer { + public RenderNatureAltar(BlockEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } @Override - public void render(TileEntityNatureAltar tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { + public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { ItemStack stack = tileEntityIn.items.getStackInSlot(0); if (!stack.isEmpty()) { matrixStackIn.push(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java index 04298523..c21a3f29 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderOfferingTable.java @@ -1,12 +1,12 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.matrix.MatrixStack; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -15,16 +15,16 @@ import net.minecraft.util.math.vector.Vector3f; import java.util.Random; -public class RenderOfferingTable extends TileEntityRenderer { +public class RenderOfferingTable extends BlockEntityRenderer { private final Random rand = new Random(); - public RenderOfferingTable(TileEntityRendererDispatcher disp) { + public RenderOfferingTable(BlockEntityRendererDispatcher disp) { super(disp); } @Override - public void render(TileEntityOfferingTable tileEntityOfferingTable, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { + public void render(BlockEntityOfferingTable tileEntityOfferingTable, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int combinedLightIn, int combinedOverlayIn) { ItemStack stack = tileEntityOfferingTable.items.getStackInSlot(0); if (!stack.isEmpty()) { this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getDamage()); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java index cee8168d..6d6b8d80 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java @@ -3,13 +3,13 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Vector3f; @@ -17,16 +17,16 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class RenderProjectileGenerator extends TileEntityRenderer { +public class RenderProjectileGenerator extends BlockEntityRenderer { private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png"); private final ModelOverlay model = new ModelOverlay(); - public RenderProjectileGenerator(TileEntityRendererDispatcher rendererDispatcherIn) { + public RenderProjectileGenerator(BlockEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } @Override - public void render(TileEntityProjectileGenerator te, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { + public void render(BlockEntityProjectileGenerator te, float partialTicks, MatrixStack stack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { stack.push(); if (te.nextSide == Direction.NORTH) { stack.rotate(Vector3f.YP.rotationDegrees(270)); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java index c25ae5fb..adb736c5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderWoodStand.java @@ -1,25 +1,25 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.matrix.MatrixStack; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3f; -public class RenderWoodStand extends TileEntityRenderer { +public class RenderWoodStand extends BlockEntityRenderer { - public RenderWoodStand(TileEntityRendererDispatcher disp) { + public RenderWoodStand(BlockEntityRendererDispatcher disp) { super(disp); } @Override - public void render(TileEntityWoodStand tileEntityWoodStand, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int i, int i1) { + public void render(BlockEntityWoodStand tileEntityWoodStand, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int i, int i1) { ItemStack stack = tileEntityWoodStand.items.getStackInSlot(0); if (!stack.isEmpty()) { matrixStack.push(); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunk.java b/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunk.java index 426cd7f4..ad6b6395 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunk.java @@ -5,21 +5,21 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect.ActiveType; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import de.ellpeck.naturesaura.api.misc.IWorldData; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; +import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.nbt.INBT; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.ResourceLocation; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; import org.apache.commons.lang3.mutable.MutableInt; import java.util.ArrayList; @@ -31,13 +31,13 @@ import java.util.function.Supplier; public class AuraChunk implements IAuraChunk { - private final Chunk chunk; + private final LevelChunk chunk; private final IAuraType type; private final Map drainSpots = new ConcurrentHashMap<>(); private final List effects = new ArrayList<>(); private boolean needsSync; - public AuraChunk(Chunk chunk, IAuraType type) { + public AuraChunk(LevelChunk chunk, IAuraType type) { this.chunk = chunk; this.type = type; @@ -55,7 +55,7 @@ public class AuraChunk implements IAuraChunk { MutableInt spot = this.getActualDrainSpot(pos, !simulate); int curr = spot != null ? spot.intValue() : 0; if (curr < 0 && curr - amount > 0) // Underflow protection - return this.drainAura(pos.up(), amount, aimForZero, simulate); + return this.drainAura(pos.above(), amount, aimForZero, simulate); if (aimForZero) { if (curr > 0 && curr - amount < 0) amount = curr; @@ -81,7 +81,7 @@ public class AuraChunk implements IAuraChunk { MutableInt spot = this.getActualDrainSpot(pos, !simulate); int curr = spot != null ? spot.intValue() : 0; if (curr > 0 && curr + amount < 0) // Overflow protection - return this.storeAura(pos.up(), amount, aimForZero, simulate); + return this.storeAura(pos.above(), amount, aimForZero, simulate); if (aimForZero) { if (curr < 0 && curr + amount > 0) { amount = -curr; @@ -146,18 +146,18 @@ public class AuraChunk implements IAuraChunk { } public void update() { - World world = this.chunk.getWorld(); + Level level = this.chunk.getLevel(); for (Map.Entry entry : this.drainSpots.entrySet()) { BlockPos pos = entry.getKey(); MutableInt amount = entry.getValue(); for (IDrainSpotEffect effect : this.effects) - effect.update(world, this.chunk, this, pos, amount.intValue()); + effect.update(level, this.chunk, this, pos, amount.intValue()); } if (this.needsSync) { ChunkPos pos = this.chunk.getPos(); - PacketHandler.sendToAllLoaded(world, + PacketHandler.sendToAllLoaded(level, new BlockPos(pos.x * 16, 0, pos.z * 16), this.makePacket()); this.needsSync = false; @@ -172,13 +172,13 @@ public class AuraChunk implements IAuraChunk { public void getSpotsInArea(BlockPos pos, int radius, BiConsumer consumer) { for (Map.Entry entry : this.drainSpots.entrySet()) { BlockPos drainPos = entry.getKey(); - if (drainPos.distanceSq(pos) <= radius * radius) { + if (drainPos.distSqr(pos) <= radius * radius) { consumer.accept(drainPos, entry.getValue().intValue()); } } } - public void getActiveEffectIcons(PlayerEntity player, Map> icons) { + public void getActiveEffectIcons(Player player, Map> icons) { for (IDrainSpotEffect effect : this.effects) { Tuple alreadyThere = icons.get(effect.getName()); if (alreadyThere != null && alreadyThere.getB()) @@ -198,28 +198,28 @@ public class AuraChunk implements IAuraChunk { } @Override - public CompoundNBT serializeNBT() { - ListNBT list = new ListNBT(); + public CompoundTag serializeNBT() { + ListTag list = new ListTag(); for (Map.Entry entry : this.drainSpots.entrySet()) { - CompoundNBT tag = new CompoundNBT(); - tag.putLong("pos", entry.getKey().toLong()); + CompoundTag tag = new CompoundTag(); + tag.putLong("pos", entry.getKey().asLong()); tag.putInt("amount", entry.getValue().intValue()); list.add(tag); } - CompoundNBT compound = new CompoundNBT(); + CompoundTag compound = new CompoundTag(); compound.put("drain_spots", list); return compound; } @Override - public void deserializeNBT(CompoundNBT compound) { + public void deserializeNBT(CompoundTag compound) { this.drainSpots.clear(); - ListNBT list = compound.getList("drain_spots", 10); - for (INBT base : list) { - CompoundNBT tag = (CompoundNBT) base; + ListTag list = compound.getList("drain_spots", 10); + for (Tag base : list) { + CompoundTag tag = (CompoundTag) base; this.addDrainSpot( - BlockPos.fromLong(tag.getLong("pos")), + BlockPos.of(tag.getLong("pos")), new MutableInt(tag.getInt("amount"))); } this.addOrRemoveAsActive(); @@ -227,7 +227,7 @@ public class AuraChunk implements IAuraChunk { private void addOrRemoveAsActive() { long chunkPos = this.chunk.getPos().asLong(); - WorldData data = (WorldData) IWorldData.getWorldData(this.chunk.getWorld()); + LevelData data = (LevelData) ILevelData.getLevelData(this.chunk.getLevel()); if (this.drainSpots.size() > 0) { data.auraChunksWithSpots.put(chunkPos, this); } else { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunkProvider.java b/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunkProvider.java index 079f399b..378f3545 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunkProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/AuraChunkProvider.java @@ -3,9 +3,9 @@ package de.ellpeck.naturesaura.chunk; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Direction; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.chunk.Chunk; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.INBTSerializable; @@ -14,7 +14,7 @@ import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable { +public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable { private final Chunk chunk; private final LazyOptional lazyChunk = LazyOptional.of(this::getAuraChunk); @@ -26,7 +26,7 @@ public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable< private IAuraChunk getAuraChunk() { if (this.auraChunk == null) - this.auraChunk = new AuraChunk(this.chunk, IAuraType.forWorld(this.chunk.getWorld())); + this.auraChunk = new AuraChunk(this.chunk, IAuraType.forLevel(this.chunk.getLevel())); return this.auraChunk; } @@ -37,12 +37,12 @@ public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable< } @Override - public CompoundNBT serializeNBT() { + public CompoundTag serializeNBT() { return this.getAuraChunk().serializeNBT(); } @Override - public void deserializeNBT(CompoundNBT nbt) { + public void deserializeNBT(CompoundTag nbt) { this.getAuraChunk().deserializeNBT(nbt); } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/AngerEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/AngerEffect.java index 2b0b071c..bc6d736f 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/AngerEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/AngerEffect.java @@ -7,14 +7,14 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.entity.IAngerable; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import java.util.List; @@ -24,10 +24,10 @@ public class AngerEffect implements IDrainSpotEffect { private AxisAlignedBB bb; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot >= 0) return false; - int aura = IAuraChunk.getAuraInArea(world, pos, 50); + int aura = IAuraChunk.getAuraInArea(level, pos, 50); if (aura > 0) return false; int dist = Math.min(Math.abs(aura) / 50000, 75); @@ -38,8 +38,8 @@ public class AngerEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (!this.bb.contains(player.getPositionVec())) return ActiveType.INACTIVE; @@ -52,16 +52,16 @@ public class AngerEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 100 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 100 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; - List entities = world.getEntitiesWithinAABB(LivingEntity.class, this.bb); + List entities = level.getEntitiesWithinAABB(LivingEntity.class, this.bb); for (LivingEntity entity : entities) { if (!(entity instanceof IAngerable)) continue; - PlayerEntity player = world.getClosestPlayer(entity, 25); + Player player = level.getClosestPlayer(entity, 25); if (player == null) continue; ((IAngerable) entity).setAttackTarget(player); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/AnimalEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/AnimalEffect.java index 4eb91222..3682908e 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/AnimalEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/AnimalEffect.java @@ -10,7 +10,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.ChickenEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.EggItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -19,8 +19,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import org.apache.commons.lang3.tuple.Pair; @@ -35,10 +35,10 @@ public class AnimalEffect implements IDrainSpotEffect { private int chance; private AxisAlignedBB bb; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot <= 0) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 30); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30); int aura = auraAndSpots.getLeft(); if (aura < 1500000) return false; @@ -51,12 +51,12 @@ public class AnimalEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (!this.bb.contains(player.getPositionVec())) return ActiveType.INACTIVE; - if (!NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -67,21 +67,21 @@ public class AnimalEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 200 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 200 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; - List animals = world.getEntitiesWithinAABB(AnimalEntity.class, this.bb); + List animals = level.getEntitiesWithinAABB(AnimalEntity.class, this.bb); if (animals.size() >= ModConfig.instance.maxAnimalsAroundPowder.get()) return; - List items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb); + List items = level.getEntitiesWithinAABB(ItemEntity.class, this.bb); for (ItemEntity item : items) { if (!item.isAlive()) continue; - if (!NaturesAuraAPI.instance().isEffectPowderActive(world, item.getPosition(), NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(level, item.getPosition(), NAME)) continue; ItemStack stack = item.getItem(); @@ -99,22 +99,22 @@ public class AnimalEffect implements IDrainSpotEffect { item.setItem(stack); } - ChickenEntity chicken = new ChickenEntity(EntityType.CHICKEN, world); + ChickenEntity chicken = new ChickenEntity(EntityType.CHICKEN, level); chicken.setGrowingAge(-24000); chicken.setPosition(item.getPosX(), item.getPosY(), item.getPosZ()); - world.addEntity(chicken); + level.addEntity(chicken); - BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos); - IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000); + BlockPos closestSpot = IAuraChunk.getHighestSpot(level, item.getPosition(), 35, pos); + IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 2000); } - if (world.rand.nextInt(20) <= this.chance) { + if (level.rand.nextInt(20) <= this.chance) { if (animals.size() < 2) return; - AnimalEntity first = animals.get(world.rand.nextInt(animals.size())); + AnimalEntity first = animals.get(level.rand.nextInt(animals.size())); if (first.isChild() || first.isInLove()) return; - if (!NaturesAuraAPI.instance().isEffectPowderActive(world, first.getPosition(), NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(level, first.getPosition(), NAME)) return; Optional secondOptional = animals.stream() @@ -129,21 +129,21 @@ public class AnimalEffect implements IDrainSpotEffect { this.setInLove(first); this.setInLove(second); - BlockPos closestSpot = IAuraChunk.getHighestSpot(world, first.getPosition(), 35, pos); - IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500); + BlockPos closestSpot = IAuraChunk.getHighestSpot(level, first.getPosition(), 35, pos); + IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500); } } private void setInLove(AnimalEntity animal) { animal.setInLove(null); for (int j = 0; j < 7; j++) - animal.world.addParticle(ParticleTypes.HEART, - animal.getPosX() + (double) (animal.world.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), - animal.getPosY() + 0.5D + (double) (animal.world.rand.nextFloat() * animal.getHeight()), - animal.getPosZ() + (double) (animal.world.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), - animal.world.rand.nextGaussian() * 0.02D, - animal.world.rand.nextGaussian() * 0.02D, - animal.world.rand.nextGaussian() * 0.02D); + animal.level.addParticle(ParticleTypes.HEART, + animal.getPosX() + (double) (animal.level.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), + animal.getPosY() + 0.5D + (double) (animal.level.rand.nextFloat() * animal.getHeight()), + animal.getPosZ() + (double) (animal.level.rand.nextFloat() * animal.getWidth() * 2.0F) - animal.getWidth(), + animal.level.rand.nextGaussian() * 0.02D, + animal.level.rand.nextGaussian() * 0.02D, + animal.level.rand.nextGaussian() * 0.02D); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java index f9f23255..0ea68bd5 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java @@ -6,8 +6,8 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import org.apache.commons.lang3.mutable.MutableInt; public class BalanceEffect implements IDrainSpotEffect { @@ -15,22 +15,22 @@ public class BalanceEffect implements IDrainSpotEffect { public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "balance"); @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { if (spot < 100000) return; - if (world.getGameTime() % 200 != 0) + if (level.getGameTime() % 200 != 0) return; int searchRadius = Math.min(45, spot / 10000); MutableInt positiveAura = new MutableInt(); - IAuraChunk.getSpotsInArea(world, pos, searchRadius, (otherPos, otherSpot) -> { + IAuraChunk.getSpotsInArea(level, pos, searchRadius, (otherPos, otherSpot) -> { if (otherSpot > 0) positiveAura.add(otherSpot); }); int radius = Math.min(80, positiveAura.intValue() / 5000); - BlockPos lowestPos = IAuraChunk.getLowestSpot(world, pos, radius, null); + BlockPos lowestPos = IAuraChunk.getLowestSpot(level, pos, radius, null); if (lowestPos == null) return; - int stored = IAuraChunk.getAuraChunk(world, lowestPos).storeAura(lowestPos, spot / 50); + int stored = IAuraChunk.getAuraChunk(level, lowestPos).storeAura(lowestPos, spot / 50); auraChunk.drainAura(pos, stored); } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java index 8ecdfef2..1f5b351a 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java @@ -8,15 +8,15 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.potion.ModPotions; import net.minecraft.block.Blocks; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import java.util.List; @@ -27,10 +27,10 @@ public class BreathlessEffect implements IDrainSpotEffect { private int amp; private AxisAlignedBB bb; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot >= 0) return false; - int aura = IAuraChunk.getAuraInArea(world, pos, 50); + int aura = IAuraChunk.getAuraInArea(level, pos, 50); if (aura > 0) return false; int dist = Math.min(Math.abs(aura) / 50000, 75); @@ -42,8 +42,8 @@ public class BreathlessEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (!this.bb.contains(player.getPositionVec())) return ActiveType.INACTIVE; @@ -56,12 +56,12 @@ public class BreathlessEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 100 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 100 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; - List entities = world.getEntitiesWithinAABB(LivingEntity.class, this.bb); + List entities = level.getEntitiesWithinAABB(LivingEntity.class, this.bb); for (LivingEntity entity : entities) entity.addPotionEffect(new EffectInstance(ModPotions.BREATHLESS, 300, this.amp)); } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java index 1a26f6af..5de12804 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java @@ -7,14 +7,14 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.items.ModItems; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import org.apache.commons.lang3.tuple.Pair; import java.util.List; @@ -26,10 +26,10 @@ public class CacheRechargeEffect implements IDrainSpotEffect { private int amount; private AxisAlignedBB bb; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot < 100000) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 20); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 20); int aura = auraAndSpots.getLeft(); if (aura < 1500000) return false; @@ -40,12 +40,12 @@ public class CacheRechargeEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (!this.bb.contains(player.getPositionVec())) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -56,12 +56,12 @@ public class CacheRechargeEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(world, pos, spot)) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(level, pos, spot)) return; - List players = world.getEntitiesWithinAABB(PlayerEntity.class, this.bb); - for (PlayerEntity player : players) { - if (NaturesAuraAPI.instance().isEffectPowderActive(world, player.getPosition(), NAME)) + List players = level.getEntitiesWithinAABB(Player.class, this.bb); + for (Player player : players) { + if (NaturesAuraAPI.instance().isEffectPowderActive(level, player.getPosition(), NAME)) continue; if (NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, true)) { NaturesAuraAPI.instance().insertAuraIntoPlayer(player, this.amount, false); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java index b6a2e68d..20452716 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java @@ -6,15 +6,15 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.level.Explosion; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; +import net.minecraft.level.gen.Heightmap; public class ExplosionEffect implements IDrainSpotEffect { @@ -23,14 +23,14 @@ public class ExplosionEffect implements IDrainSpotEffect { private float strength; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot >= 0) return false; - int aura = IAuraChunk.getAuraInArea(world, pos, 85); + int aura = IAuraChunk.getAuraInArea(level, pos, 85); if (aura > -5000000) return false; int chance = 140 - Math.abs(aura) / 200000; - if (chance > 1 && world.rand.nextInt(chance) != 0) + if (chance > 1 && level.rand.nextInt(chance) != 0) return false; this.strength = Math.min(Math.abs(aura) / 5000000F, 5F); if (this.strength <= 0) @@ -40,8 +40,8 @@ public class ExplosionEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; @@ -54,17 +54,17 @@ public class ExplosionEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 40 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 40 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; - int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist); - int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist); - BlockPos chosenPos = new BlockPos(x, world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z); - if (chosenPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(chosenPos)) { - world.createExplosion(null, + int x = MathHelper.floor(pos.getX() + level.rand.nextGaussian() * this.dist); + int z = MathHelper.floor(pos.getZ() + level.rand.nextGaussian() * this.dist); + BlockPos chosenPos = new BlockPos(x, level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z); + if (chosenPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(chosenPos)) { + level.createExplosion(null, chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5, this.strength, false, Explosion.Mode.DESTROY); } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java index 6cec3701..653cac5f 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java @@ -8,13 +8,13 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.block.*; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import org.apache.commons.lang3.tuple.Pair; public class GrassDieEffect implements IDrainSpotEffect { @@ -24,9 +24,9 @@ public class GrassDieEffect implements IDrainSpotEffect { private int amount; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot < 0) { - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 50); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50); int aura = auraAndSpots.getLeft(); if (aura < 0) { this.amount = Math.min(300, MathHelper.ceil(Math.abs(aura) / 100000F / auraAndSpots.getRight())); @@ -40,8 +40,8 @@ public class GrassDieEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; @@ -54,17 +54,17 @@ public class GrassDieEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(world, pos, spot)) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(level, pos, spot)) return; - for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) { + for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { BlockPos grassPos = new BlockPos( - pos.getX() + world.rand.nextGaussian() * this.dist, - pos.getY() + world.rand.nextGaussian() * this.dist, - pos.getZ() + world.rand.nextGaussian() * this.dist + pos.getX() + level.rand.nextGaussian() * this.dist, + pos.getY() + level.rand.nextGaussian() * this.dist, + pos.getZ() + level.rand.nextGaussian() * this.dist ); - if (grassPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(grassPos)) { - BlockState state = world.getBlockState(grassPos); + if (grassPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(grassPos)) { + BlockState state = level.getBlockState(grassPos); Block block = state.getBlock(); BlockState newState = null; @@ -78,7 +78,7 @@ public class GrassDieEffect implements IDrainSpotEffect { newState = Blocks.NETHERRACK.getDefaultState(); } if (newState != null) - world.setBlockState(grassPos, newState); + level.setBlockState(grassPos, newState); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java index f509941a..0f083289 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java @@ -10,7 +10,7 @@ import net.minecraft.block.AbstractFireBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.tags.BlockTags; @@ -18,8 +18,8 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import org.apache.commons.lang3.tuple.Pair; public class NetherDecayEffect implements IDrainSpotEffect { @@ -29,10 +29,10 @@ public class NetherDecayEffect implements IDrainSpotEffect { private int amount; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot >= 0) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 50); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 50); int aura = auraAndSpots.getLeft(); if (aura >= 0) return false; @@ -44,8 +44,8 @@ public class NetherDecayEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; @@ -58,20 +58,20 @@ public class NetherDecayEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(world, pos, spot)) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(level, pos, spot)) return; - for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) { + for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { BlockPos offset = new BlockPos( - pos.getX() + world.rand.nextGaussian() * this.dist, - pos.getY() + world.rand.nextGaussian() * this.dist, - pos.getZ() + world.rand.nextGaussian() * this.dist); - if (offset.distanceSq(pos) > this.dist * this.dist || !world.isBlockLoaded(offset)) + pos.getX() + level.rand.nextGaussian() * this.dist, + pos.getY() + level.rand.nextGaussian() * this.dist, + pos.getZ() + level.rand.nextGaussian() * this.dist); + if (offset.distanceSq(pos) > this.dist * this.dist || !level.isBlockLoaded(offset)) continue; // degrade blocks Block degraded = null; - BlockState state = world.getBlockState(offset); + BlockState state = level.getBlockState(offset); if (state.getBlock() == Blocks.GLOWSTONE) { degraded = Blocks.NETHERRACK; } else if (state.getBlock().isIn(BlockTags.NYLIUM) || state.getBlock() == Blocks.NETHERRACK) { @@ -80,15 +80,15 @@ public class NetherDecayEffect implements IDrainSpotEffect { degraded = Blocks.SOUL_SAND; } if (degraded != null) { - world.playEvent(2001, offset, Block.getStateId(state)); - world.setBlockState(offset, degraded.getDefaultState()); + level.playEvent(2001, offset, Block.getStateId(state)); + level.setBlockState(offset, degraded.getDefaultState()); } // ignite blocks - if (AbstractFireBlock.canLightBlock(world, offset, Direction.NORTH)) { - BlockState fire = AbstractFireBlock.getFireForPlacement(world, offset); - world.setBlockState(offset, fire); - world.playEvent(1009, offset, 0); + if (AbstractFireBlock.canLightBlock(level, offset, Direction.NORTH)) { + BlockState fire = AbstractFireBlock.getFireForPlacement(level, offset); + level.setBlockState(offset, fire); + level.playEvent(1009, offset, 0); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java index 813d8e53..8ddb3302 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java @@ -11,14 +11,14 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import net.minecraftforge.common.Tags; import org.apache.commons.lang3.tuple.Pair; @@ -29,10 +29,10 @@ public class NetherGrassEffect implements IDrainSpotEffect { private int amount; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot <= 0) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 30); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30); int aura = auraAndSpots.getLeft(); if (aura < 1500000) return false; @@ -44,12 +44,12 @@ public class NetherGrassEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -60,34 +60,34 @@ public class NetherGrassEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 40 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 40 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; - for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) { - int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist); - int y = MathHelper.floor(pos.getY() + world.rand.nextGaussian() * this.dist); - int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist); + for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { + int x = MathHelper.floor(pos.getX() + level.rand.nextGaussian() * this.dist); + int y = MathHelper.floor(pos.getY() + level.rand.nextGaussian() * this.dist); + int z = MathHelper.floor(pos.getZ() + level.rand.nextGaussian() * this.dist); for (int yOff = -5; yOff <= 5; yOff++) { BlockPos goalPos = new BlockPos(x, y + yOff, z); - if (goalPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(goalPos)) { - if (NaturesAuraAPI.instance().isEffectPowderActive(world, goalPos, NAME)) + if (goalPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(goalPos)) { + if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NAME)) continue; BlockPos up = goalPos.up(); - if (world.getBlockState(up).isSolidSide(world, up, Direction.DOWN)) + if (level.getBlockState(up).isSolidSide(level, up, Direction.DOWN)) continue; - BlockState state = world.getBlockState(goalPos); + BlockState state = level.getBlockState(goalPos); Block block = state.getBlock(); if (Tags.Blocks.NETHERRACK.contains(block)) { - world.setBlockState(goalPos, ModBlocks.NETHER_GRASS.getDefaultState()); + level.setBlockState(goalPos, ModBlocks.NETHER_GRASS.getDefaultState()); - BlockPos closestSpot = IAuraChunk.getHighestSpot(world, goalPos, 25, pos); - IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 500); + BlockPos closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos); + IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500); - PacketHandler.sendToAllAround(world, goalPos, 32, + PacketHandler.sendToAllAround(level, goalPos, 32, new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST)); break; } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index f7d5a4a8..576b5117 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -10,7 +10,7 @@ import de.ellpeck.naturesaura.api.misc.WeightedOre; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; @@ -21,9 +21,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; import org.apache.commons.lang3.tuple.Pair; @@ -40,10 +40,10 @@ public class OreSpawnEffect implements IDrainSpotEffect { private int amount; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot <= 0) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 30); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30); int aura = auraAndSpots.getLeft(); if (aura <= 2000000) return false; @@ -55,12 +55,12 @@ public class OreSpawnEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (!NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -71,10 +71,10 @@ public class OreSpawnEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (world.getGameTime() % 40 != 0) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (level.getGameTime() % 40 != 0) return; - if (!this.calcValues(world, pos, spot)) + if (!this.calcValues(level, pos, spot)) return; IAuraType type = auraChunk.getType(); Block requiredBlock; @@ -88,7 +88,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { } int totalWeight = WeightedRandom.getTotalWeight(ores); - List> powders = NaturesAuraAPI.instance().getActiveEffectPowders(world, + List> powders = NaturesAuraAPI.instance().getActiveEffectPowders(level, new AxisAlignedBB(pos).grow(this.dist), NAME); if (powders.isEmpty()) return; @@ -96,27 +96,27 @@ public class OreSpawnEffect implements IDrainSpotEffect { Tuple powder = powders.get(i % powders.size()); Vector3d powderPos = powder.getA(); int range = powder.getB(); - int x = MathHelper.floor(powderPos.x + world.rand.nextGaussian() * range); - int y = MathHelper.floor(powderPos.y + world.rand.nextGaussian() * range); - int z = MathHelper.floor(powderPos.z + world.rand.nextGaussian() * range); + int x = MathHelper.floor(powderPos.x + level.rand.nextGaussian() * range); + int y = MathHelper.floor(powderPos.y + level.rand.nextGaussian() * range); + int z = MathHelper.floor(powderPos.z + level.rand.nextGaussian() * range); BlockPos orePos = new BlockPos(x, y, z); if (orePos.distanceSq(powderPos.x, powderPos.y, powderPos.z, true) <= range * range - && orePos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(orePos)) { - BlockState state = world.getBlockState(orePos); + && orePos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(orePos)) { + BlockState state = level.getBlockState(orePos); if (state.getBlock() != requiredBlock) continue; outer: while (true) { - WeightedOre ore = WeightedRandom.getRandomItem(world.rand, ores, totalWeight); - ITag tag = world.getTags().func_241835_a().get(ore.tag); + WeightedOre ore = WeightedRandom.getRandomItem(level.rand, ores, totalWeight); + ITag tag = level.getTags().func_241835_a().get(ore.tag); if (tag == null) continue; for (Block toPlace : tag.getAllElements()) { if (toPlace == null || toPlace == Blocks.AIR) continue; - FakePlayer player = FakePlayerFactory.getMinecraft((ServerWorld) world); + FakePlayer player = FakePlayerFactory.getMinecraft((ServerLevel) level); player.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY); BlockRayTraceResult ray = new BlockRayTraceResult(Vector3d.copyCentered(pos), Direction.UP, pos, false); BlockItemUseContext context = new BlockItemUseContext(new ItemUseContext(player, Hand.MAIN_HAND, ray)); @@ -124,12 +124,12 @@ public class OreSpawnEffect implements IDrainSpotEffect { if (SPAWN_EXCEPTIONS.contains(stateToPlace)) continue; - world.setBlockState(orePos, stateToPlace); - world.playEvent(2001, orePos, Block.getStateId(stateToPlace)); + level.setBlockState(orePos, stateToPlace); + level.playEvent(2001, orePos, Block.getStateId(stateToPlace)); int toDrain = (20000 - ore.itemWeight * 2) * 2; - BlockPos highestSpot = IAuraChunk.getHighestSpot(world, orePos, 30, pos); - IAuraChunk.getAuraChunk(world, highestSpot).drainAura(highestSpot, toDrain); + BlockPos highestSpot = IAuraChunk.getHighestSpot(level, orePos, 30, pos); + IAuraChunk.getAuraChunk(level, highestSpot).drainAura(highestSpot, toDrain); break outer; } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java index 43d24725..1f68e314 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java @@ -9,16 +9,16 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.*; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; +import net.minecraft.level.gen.Heightmap; +import net.minecraft.level.server.ServerLevel; import org.apache.commons.lang3.tuple.Pair; public class PlantBoostEffect implements IDrainSpotEffect { @@ -28,10 +28,10 @@ public class PlantBoostEffect implements IDrainSpotEffect { private int amount; private int dist; - private boolean calcValues(World world, BlockPos pos, Integer spot) { + private boolean calcValues(Level level, BlockPos pos, Integer spot) { if (spot <= 0) return false; - Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(world, pos, 30); + Pair auraAndSpots = IAuraChunk.getAuraAndSpotAmountInArea(level, pos, 30); int aura = auraAndSpots.getLeft(); if (aura < 1500000) return false; @@ -43,12 +43,12 @@ public class PlantBoostEffect implements IDrainSpotEffect { } @Override - public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.world, pos, spot)) + public ActiveType isActiveHere(Player player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(player.level, pos, spot)) return ActiveType.INACTIVE; if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.getPosition(), NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -59,32 +59,32 @@ public class PlantBoostEffect implements IDrainSpotEffect { } @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(world, pos, spot)) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (!this.calcValues(level, pos, spot)) return; - for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) { - int x = MathHelper.floor(pos.getX() + (2 * world.rand.nextFloat() - 1) * this.dist); - int z = MathHelper.floor(pos.getZ() + (2 * world.rand.nextFloat() - 1) * this.dist); - BlockPos plantPos = new BlockPos(x, world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z).down(); - if (plantPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(plantPos)) { - if (NaturesAuraAPI.instance().isEffectPowderActive(world, plantPos, NAME)) + for (int i = this.amount / 2 + level.rand.nextInt(this.amount / 2); i >= 0; i--) { + int x = MathHelper.floor(pos.getX() + (2 * level.rand.nextFloat() - 1) * this.dist); + int z = MathHelper.floor(pos.getZ() + (2 * level.rand.nextFloat() - 1) * this.dist); + BlockPos plantPos = new BlockPos(x, level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z).down(); + if (plantPos.distanceSq(pos) <= this.dist * this.dist && level.isBlockLoaded(plantPos)) { + if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, NAME)) continue; - BlockState state = world.getBlockState(plantPos); + BlockState state = level.getBlockState(plantPos); Block block = state.getBlock(); if (block instanceof IGrowable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS_BLOCK) { IGrowable growable = (IGrowable) block; - if (growable.canGrow(world, plantPos, state, false)) { + if (growable.canGrow(level, plantPos, state, false)) { try { - growable.grow((ServerWorld) world, world.rand, plantPos, state); + growable.grow((ServerLevel) level, level.rand, plantPos, state); } catch (Exception e) { - // a lot of stuff throws here (double plants where generation only caused half of it to exist, bamboo at world height...) + // a lot of stuff throws here (double plants where generation only caused half of it to exist, bamboo at level height...) // so just catch all, bleh } - BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos); - IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500); + BlockPos closestSpot = IAuraChunk.getHighestSpot(level, plantPos, 25, pos); + IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500); - PacketHandler.sendToAllAround(world, plantPos, 32, + PacketHandler.sendToAllAround(level, plantPos, 32, new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), PacketParticles.Type.PLANT_BOOST)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java index 20e33c97..e47cebe9 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java @@ -10,8 +10,8 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; import java.util.ArrayList; import java.util.List; @@ -21,19 +21,19 @@ public class ReplenishingEffect implements IDrainSpotEffect { public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "replenishing"); @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { if (spot < 0) { List tiles = new ArrayList<>(); - Helper.getTileEntitiesInArea(world, pos, 25, tile -> { + Helper.getTileEntitiesInArea(level, pos, 25, tile -> { IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); if (container instanceof ISpotDrainable) tiles.add((ISpotDrainable) container); return false; }); if (!tiles.isEmpty()) { - IAuraType type = IAuraType.forWorld(world); - for (int i = world.rand.nextInt(6); i >= 0; i--) { - ISpotDrainable tile = tiles.get(world.rand.nextInt(tiles.size())); + IAuraType type = IAuraType.forLevel(level); + for (int i = level.rand.nextInt(6); i >= 0; i--) { + ISpotDrainable tile = tiles.get(level.rand.nextInt(tiles.size())); if (!tile.isAcceptableType(type)) continue; int drained = tile.drainAuraPassively(-spot, false); diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java index 726f155f..62e50e02 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java @@ -8,16 +8,16 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; public class SpreadEffect implements IDrainSpotEffect { public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread"); @Override - public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(world, pos, 25)) < 2000000) + public void update(Level level, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { + if (Math.abs(spot) < 500000 || Math.abs(IAuraChunk.getAuraInArea(level, pos, 25)) < 2000000) return; boolean drain = spot > 0; int toMove = MathHelper.ceil(Math.abs(spot) * 0.72F); @@ -27,8 +27,8 @@ public class SpreadEffect implements IDrainSpotEffect { int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE; for (Direction facing : Direction.values()) { BlockPos offset = pos.offset(facing, 15); - if (world.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= world.getHeight()) { - int amount = IAuraChunk.getAuraInArea(world, offset, 14); + if (level.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= level.getHeight()) { + int amount = IAuraChunk.getAuraInArea(level, offset, 14); if (drain ? amount < bestAmount : amount > bestAmount) { bestAmount = amount; bestOffset = offset; @@ -38,9 +38,9 @@ public class SpreadEffect implements IDrainSpotEffect { if (bestOffset == null) break; - BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(world, bestOffset, 14, bestOffset) - : IAuraChunk.getHighestSpot(world, bestOffset, 14, bestOffset); - IAuraChunk bestChunk = IAuraChunk.getAuraChunk(world, bestPos); + BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(level, bestOffset, 14, bestOffset) + : IAuraChunk.getHighestSpot(level, bestOffset, 14, bestOffset); + IAuraChunk bestChunk = IAuraChunk.getAuraChunk(level, bestPos); int moved; if (drain) { diff --git a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java index 9e797840..e0bda956 100644 --- a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java +++ b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java @@ -17,8 +17,8 @@ public final class CommandAura { CommandSource source = context.getSource(); BlockPos pos = new BlockPos(source.getPos()); while (amount > 0) { - BlockPos spot = IAuraChunk.getLowestSpot(source.getWorld(), pos, 35, pos); - amount -= IAuraChunk.getAuraChunk(source.getWorld(), spot).storeAura(spot, amount); + BlockPos spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos); + amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount); } source.sendFeedback(new StringTextComponent("Added aura to area"), true); return 0; @@ -28,8 +28,8 @@ public final class CommandAura { CommandSource source = context.getSource(); BlockPos pos = new BlockPos(source.getPos()); while (amount > 0) { - BlockPos spot = IAuraChunk.getHighestSpot(source.getWorld(), pos, 35, pos); - amount -= IAuraChunk.getAuraChunk(source.getWorld(), spot).drainAura(spot, amount); + BlockPos spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos); + amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount); } source.sendFeedback(new StringTextComponent("Removed aura from area"), true); return 0; @@ -37,8 +37,8 @@ public final class CommandAura { .then(Commands.literal("reset").executes(context -> { CommandSource source = context.getSource(); BlockPos pos = new BlockPos(source.getPos()); - IAuraChunk.getSpotsInArea(source.getWorld(), pos, 35, (spot, amount) -> { - IAuraChunk chunk = IAuraChunk.getAuraChunk(source.getWorld(), spot); + IAuraChunk.getSpotsInArea(source.getLevel(), pos, 35, (spot, amount) -> { + IAuraChunk chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot); if (amount > 0) chunk.drainAura(spot, amount); else diff --git a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java index ac2df16d..7c082d94 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java @@ -62,7 +62,7 @@ public class CuriosCompat implements ICompat { private final LazyOptional curio = LazyOptional.of(() -> new ICurio() { @Override public void curioTick(String identifier, int index, LivingEntity livingEntity) { - stack.getItem().inventoryTick(stack, livingEntity.world, livingEntity, -1, false); + stack.getItem().inventoryTick(stack, livingEntity.level, livingEntity, -1, false); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java index eb2c0e74..fc3b8d9c 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.compat.enchantibility; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.PlayerTickEvent; @@ -13,14 +13,14 @@ public class EnchantibilityAuraMending extends AbstractEnchantEffect { public static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "aura_mending"); - public EnchantibilityAuraMending(PlayerEntity player, Enchantment enchantment, int level) { + public EnchantibilityAuraMending(Player player, Enchantment enchantment, int level) { super(player, enchantment, level); } public static void onPlayerTick(EnchantibilityAuraMending enchant, PlayerTickEvent event) { if (event.phase != TickEvent.Phase.END) return; - if (event.player.world.isRemote || event.player.world.getGameTime() % 10 != 0) + if (event.player.level.isClientSide || event.player.level.getGameTime() % 10 != 0) return; if (!event.player.isSneaking() || event.player.getHealth() >= event.player.getMaxHealth()) return; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java index 26262fcd..7f6e92ca 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java @@ -126,7 +126,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory> T getRecipe(String type, String name) { - RecipeManager manager = Minecraft.getInstance().world.getRecipeManager(); + RecipeManager manager = Minecraft.getInstance().level.getRecipeManager(); ResourceLocation res = new ResourceLocation(name); ResourceLocation pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath()); return (T) manager.getRecipe(pre).orElse(null); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java index 15df749a..74d1743f 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java @@ -3,15 +3,15 @@ package de.ellpeck.naturesaura.entities; import com.google.common.collect.ListMultimap; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.items.ItemEffectPowder; import de.ellpeck.naturesaura.items.ModItems; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.misc.LevelData; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.IPacket; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; @@ -23,7 +23,7 @@ import net.minecraft.util.Tuple; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; @@ -41,29 +41,29 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { @OnlyIn(Dist.CLIENT) public int renderTicks; - public EntityEffectInhibitor(EntityType entityTypeIn, World worldIn) { - super(entityTypeIn, worldIn); + public EntityEffectInhibitor(EntityType entityTypeIn, Level levelIn) { + super(entityTypeIn, levelIn); } - public static void place(World world, ItemStack stack, double posX, double posY, double posZ) { + public static void place(Level level, ItemStack stack, double posX, double posY, double posZ) { ResourceLocation effect = ItemEffectPowder.getEffect(stack); - EntityEffectInhibitor entity = new EntityEffectInhibitor(ModEntities.EFFECT_INHIBITOR, world); + EntityEffectInhibitor entity = new EntityEffectInhibitor(ModEntities.EFFECT_INHIBITOR, level); entity.setInhibitedEffect(effect); entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect)); entity.setAmount(stack.getCount()); entity.setPosition(posX, posY, posZ); - world.addEntity(entity); + level.addEntity(entity); } @Override - public void onAddedToWorld() { - super.onAddedToWorld(); + public void onAddedToLevel() { + super.onAddedToLevel(); this.powderListDirty = true; } @Override - public void onRemovedFromWorld() { - super.onRemovedFromWorld(); + public void onRemovedFromLevel() { + super.onRemovedFromLevel(); this.setInhibitedEffect(null); this.updatePowderListStatus(); } @@ -96,16 +96,16 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { if (this.powderListDirty) this.updatePowderListStatus(); - if (this.world.isRemote) { - if (this.world.getGameTime() % 5 == 0) { + if (this.level.isClientSide) { + if (this.level.getGameTime() % 5 == 0) { NaturesAuraAPI.instance().spawnMagicParticle( - this.getPosX() + this.world.rand.nextGaussian() * 0.1F, + this.getPosX() + this.level.rand.nextGaussian() * 0.1F, this.getPosY(), - this.getPosZ() + this.world.rand.nextGaussian() * 0.1F, - this.world.rand.nextGaussian() * 0.005F, - this.world.rand.nextFloat() * 0.03F, - this.world.rand.nextGaussian() * 0.005F, - this.getColor(), this.world.rand.nextFloat() * 3F + 1F, 120, 0F, true, true); + this.getPosZ() + this.level.rand.nextGaussian() * 0.1F, + this.level.rand.nextGaussian() * 0.005F, + this.level.rand.nextFloat() * 0.03F, + this.level.rand.nextGaussian() * 0.005F, + this.getColor(), this.level.rand.nextFloat() * 3F + 1F, 120, 0F, true, true); } this.renderTicks++; } @@ -117,14 +117,14 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { } @Override - protected void readAdditional(CompoundNBT compound) { + protected void readAdditional(CompoundTag compound) { this.setInhibitedEffect(new ResourceLocation(compound.getString("effect"))); this.setColor(compound.getInt("color")); this.setAmount(compound.contains("amount") ? compound.getInt("amount") : 24); } @Override - protected void writeAdditional(CompoundNBT compound) { + protected void writeAdditional(CompoundTag compound) { compound.putString("effect", this.getInhibitedEffect().toString()); compound.putInt("color", this.getColor()); compound.putInt("amount", this.getAmount()); @@ -137,7 +137,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { @Override public boolean attackEntityFrom(DamageSource source, float amount) { - if (source instanceof EntityDamageSource && !this.world.isRemote) { + if (source instanceof EntityDamageSource && !this.level.isClientSide) { this.remove(); this.entityDropItem(this.getDrop(), 0F); return true; @@ -178,18 +178,18 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { @Override @OnlyIn(Dist.CLIENT) - public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { + public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { return Helper.aabb(this.getPositionVec()).grow(this.getAmount()); } @Override @OnlyIn(Dist.CLIENT) - public int getVisualizationColor(World world, BlockPos pos) { + public int getVisualizationColor(Level level, BlockPos pos) { return this.getColor(); } private void updatePowderListStatus() { - ListMultimap> powders = ((WorldData) IWorldData.getWorldData(this.world)).effectPowders; + ListMultimap> powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders; if (this.lastEffect != null) { List> oldList = powders.get(this.lastEffect); oldList.removeIf(t -> this.getPositionVec().equals(t.getA())); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java index 533b12ab..ef6dbe1e 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java @@ -9,22 +9,22 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.network.IPacket; import net.minecraft.util.math.*; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.fml.network.NetworkHooks; public class EntityLightProjectile extends ThrowableEntity { - public EntityLightProjectile(EntityType type, World worldIn) { - super(type, worldIn); + public EntityLightProjectile(EntityType type, Level levelIn) { + super(type, levelIn); } - public EntityLightProjectile(EntityType type, LivingEntity livingEntityIn, World worldIn) { - super(type, livingEntityIn, worldIn); + public EntityLightProjectile(EntityType type, LivingEntity livingEntityIn, Level levelIn) { + super(type, livingEntityIn, levelIn); } @Override public void tick() { super.tick(); - if (this.world.isRemote && this.ticksExisted > 1) { + if (this.level.isClientSide && this.ticksExisted > 1) { for (float i = 0; i <= 1; i += 0.2F) { NaturesAuraAPI.instance().spawnMagicParticle( MathHelper.lerp(i, this.prevPosX, this.getPosX()), @@ -38,13 +38,13 @@ public class EntityLightProjectile extends ThrowableEntity { @Override protected void onImpact(RayTraceResult result) { - if (!this.world.isRemote) { + if (!this.level.isClientSide) { if (result instanceof BlockRayTraceResult) { BlockRayTraceResult res = (BlockRayTraceResult) result; BlockPos pos = res.getPos().offset(res.getFace()); - BlockState state = this.world.getBlockState(pos); + BlockState state = this.level.getBlockState(pos); if (state.getMaterial().isReplaceable()) - this.world.setBlockState(pos, ModBlocks.LIGHT.getDefaultState()); + this.level.setBlockState(pos, ModBlocks.LIGHT.getDefaultState()); } else if (result instanceof EntityRayTraceResult) { Entity entity = ((EntityRayTraceResult) result).getEntity(); entity.setFire(5); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index 67d645a2..8d093396 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -10,7 +10,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.LongNBT; @@ -20,9 +20,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.GameRules; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.GameRules; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ITeleporter; import net.minecraftforge.fml.network.NetworkHooks; @@ -37,12 +37,12 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { public boolean isActive; private BlockPos lastPosition = BlockPos.ZERO; - public EntityMoverMinecart(EntityType type, World world) { - super(type, world); + public EntityMoverMinecart(EntityType type, Level level) { + super(type, level); } - public EntityMoverMinecart(EntityType type, World world, double x, double y, double z) { - super(type, world, x, y, z); + public EntityMoverMinecart(EntityType type, Level level, double x, double y, double z) { + super(type, level, x, y, z); } @Override @@ -52,22 +52,22 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { return; BlockPos pos = this.getPosition(); - if (!this.spotOffsets.isEmpty() && this.world.getGameTime() % 10 == 0) - PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles( + if (!this.spotOffsets.isEmpty() && this.level.getGameTime() % 10 == 0) + PacketHandler.sendToAllAround(this.level, pos, 32, new PacketParticles( (float) this.getPosX(), (float) this.getPosY(), (float) this.getPosZ(), PacketParticles.Type.MOVER_CART, MathHelper.floor(this.getMotion().getX() * 100F), MathHelper.floor(this.getMotion().getY() * 100F), MathHelper.floor(this.getMotion().getZ() * 100F))); if (pos.distanceSq(this.lastPosition) < 8 * 8) return; - this.moveAura(this.world, this.lastPosition, this.world, pos); + this.moveAura(this.level, this.lastPosition, this.level, pos); this.lastPosition = pos; } - private void moveAura(World oldWorld, BlockPos oldPos, World newWorld, BlockPos newPos) { + private void moveAura(Level oldLevel, BlockPos oldPos, Level newLevel, BlockPos newPos) { for (BlockPos offset : this.spotOffsets) { BlockPos spot = oldPos.add(offset); - IAuraChunk chunk = IAuraChunk.getAuraChunk(oldWorld, spot); + IAuraChunk chunk = IAuraChunk.getAuraChunk(oldLevel, spot); int amount = chunk.getDrainSpot(spot); if (amount <= 0) continue; @@ -77,7 +77,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { continue; int toLose = MathHelper.ceil(drained / 250F); BlockPos newSpot = newPos.add(offset); - IAuraChunk.getAuraChunk(newWorld, newSpot).storeAura(newSpot, drained - toLose, false, false); + IAuraChunk.getAuraChunk(newLevel, newSpot).storeAura(newSpot, drained - toLose, false, false); } } @@ -88,13 +88,13 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { BlockPos pos = this.getPosition(); if (!this.isActive) { - this.moveAura(this.world, this.lastPosition, this.world, pos); + this.moveAura(this.level, this.lastPosition, this.level, pos); this.spotOffsets.clear(); this.lastPosition = BlockPos.ZERO; return; } - IAuraChunk.getSpotsInArea(this.world, pos, 25, (spot, amount) -> { + IAuraChunk.getSpotsInArea(this.level, pos, 25, (spot, amount) -> { if (amount > 0) this.spotOffsets.add(spot.subtract(pos)); }); @@ -105,13 +105,13 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { @Override public void killMinecart(DamageSource source) { this.remove(); - if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) + if (this.level.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) this.entityDropItem(new ItemStack(ModItems.MOVER_CART), 0); } @Override - public CompoundNBT serializeNBT() { - CompoundNBT compound = super.serializeNBT(); + public CompoundTag serializeNBT() { + CompoundTag compound = super.serializeNBT(); compound.putBoolean("active", this.isActive); compound.putLong("last_pos", this.lastPosition.toLong()); @@ -123,7 +123,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { } @Override - public void deserializeNBT(CompoundNBT compound) { + public void deserializeNBT(CompoundTag compound) { super.deserializeNBT(compound); this.isActive = compound.getBoolean("active"); this.lastPosition = BlockPos.fromLong(compound.getLong("last_pos")); @@ -136,11 +136,11 @@ public class EntityMoverMinecart extends AbstractMinecartEntity { @Nullable @Override - public Entity changeDimension(ServerWorld destination, ITeleporter teleporter) { + public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) { Entity entity = super.changeDimension(destination, teleporter); if (entity instanceof EntityMoverMinecart) { BlockPos pos = entity.getPosition(); - this.moveAura(this.world, this.lastPosition, entity.world, pos); + this.moveAura(this.level, this.lastPosition, entity.level, pos); ((EntityMoverMinecart) entity).lastPosition = pos; } return entity; diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java index 90b60c50..aa5d12b2 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java @@ -6,7 +6,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.projectile.EyeOfEnderEntity; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.IPacket; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; @@ -16,7 +16,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.fml.network.NetworkHooks; public class EntityStructureFinder extends EyeOfEnderEntity { @@ -29,8 +29,8 @@ public class EntityStructureFinder extends EyeOfEnderEntity { private int despawnTimer; private boolean shatterOrDrop; - public EntityStructureFinder(EntityType type, World world) { - super(type, world); + public EntityStructureFinder(EntityType type, Level level) { + super(type, level); } @Override @@ -40,13 +40,13 @@ public class EntityStructureFinder extends EyeOfEnderEntity { } @Override - public void writeAdditional(CompoundNBT compound) { + public void writeAdditional(CompoundTag compound) { super.writeAdditional(compound); compound.putInt("color", this.dataManager.get(COLOR)); } @Override - public void readAdditional(CompoundNBT compound) { + public void readAdditional(CompoundTag compound) { super.readAdditional(compound); this.dataManager.set(COLOR, compound.getInt("color")); } @@ -94,7 +94,7 @@ public class EntityStructureFinder extends EyeOfEnderEntity { this.prevRotationYaw += 360.0F; this.rotationPitch = MathHelper.lerp(0.2F, this.prevRotationPitch, this.rotationPitch); this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw); - if (!this.world.isRemote) { + if (!this.level.isClientSide) { double d3 = this.targetX - d0; double d4 = this.targetZ - d2; float f1 = (float) Math.sqrt(d3 * d3 + d4 * d4); @@ -113,21 +113,21 @@ public class EntityStructureFinder extends EyeOfEnderEntity { if (this.isInWater()) { for (int i = 0; i < 4; ++i) - this.world.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); - } else if (this.world.isRemote) { + this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); + } else if (this.level.isClientSide) { NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.dataManager.get(COLOR), 1, 50, 0, false, true); } - if (!this.world.isRemote) { + if (!this.level.isClientSide) { this.setPosition(d0, d1, d2); ++this.despawnTimer; - if (this.despawnTimer > 80 && !this.world.isRemote) { + if (this.despawnTimer > 80 && !this.level.isClientSide) { this.playSound(SoundEvents.ENTITY_ENDER_EYE_DEATH, 1.0F, 1.0F); this.remove(); if (this.shatterOrDrop) { - this.world.addEntity(new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), this.getItem())); + this.level.addEntity(new ItemEntity(this.level, this.getPosX(), this.getPosY(), this.getPosZ(), this.getItem())); } else { - PacketHandler.sendToAllAround(this.world, this.getPosition(), 32, new PacketParticles((float) this.getPosX(), (float) this.getPosY(), (float) this.getPosZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getEntityId())); + PacketHandler.sendToAllAround(this.level, this.getPosition(), 32, new PacketParticles((float) this.getPosX(), (float) this.getPosY(), (float) this.getPosZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getEntityId())); } } } else { diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index ea09b6fd..ee7ebaf1 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -26,7 +26,7 @@ import net.minecraft.client.resources.I18n; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.RegistryKey; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; @@ -36,14 +36,14 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeColors; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.level.Level; +import net.minecraft.level.biome.BiomeColors; +import net.minecraft.level.gen.Heightmap; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.RenderLevelLastEvent; import net.minecraftforge.common.IPlantable; import net.minecraftforge.energy.EnergyStorage; import net.minecraftforge.event.TickEvent; @@ -81,14 +81,14 @@ public class ClientEvents { MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA); MutableInt spots = new MutableInt(); MutableInt chunks = new MutableInt(); - IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (blockPos, drainSpot) -> { + IAuraChunk.getSpotsInArea(mc.level, mc.player.getPosition(), 35, (blockPos, drainSpot) -> { spots.increment(); amount.add(drainSpot); }); - Helper.getAuraChunksWithSpotsInArea(mc.world, mc.player.getPosition(), 35, c -> chunks.increment()); + Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.getPosition(), 35, c -> chunks.increment()); NumberFormat format = NumberFormat.getInstance(); left.add(prefix + "A: " + format.format(amount.intValue()) + " (S: " + spots.intValue() + ", C: " + chunks.intValue() + ")"); - left.add(prefix + "AT: " + IAuraType.forWorld(mc.world).getName()); + left.add(prefix + "AT: " + IAuraType.forLevel(mc.level).getName()); } } } @@ -101,52 +101,52 @@ public class ClientEvents { heldOcular = ItemStack.EMPTY; Minecraft mc = Minecraft.getInstance(); - if (mc.world == null) { + if (mc.level == null) { ItemRangeVisualizer.clear(); PENDING_AURA_CHUNKS.clear(); } else { - PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.world)); + PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); if (!mc.isGamePaused()) { - if (mc.world.getGameTime() % 20 == 0) { + if (mc.level.getGameTime() % 20 == 0) { int amount = MathHelper.floor(190 * ModConfig.instance.excessParticleAmount.get()); for (int i = 0; i < amount; i++) { - int x = MathHelper.floor(mc.player.getPosX()) + mc.world.rand.nextInt(64) - 32; - int z = MathHelper.floor(mc.player.getPosZ()) + mc.world.rand.nextInt(64) - 32; - BlockPos pos = new BlockPos(x, mc.world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z) - 1, z); - BlockState state = mc.world.getBlockState(pos); + int x = MathHelper.floor(mc.player.getPosX()) + mc.level.rand.nextInt(64) - 32; + int z = MathHelper.floor(mc.player.getPosZ()) + mc.level.rand.nextInt(64) - 32; + BlockPos pos = new BlockPos(x, mc.level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z) - 1, z); + BlockState state = mc.level.getBlockState(pos); Block block = state.getBlock(); if (block instanceof IGrowable || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) { - int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA; + int excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA; if (excess > 0) { int chance = Math.max(10, 50 - excess / 25000); - if (mc.world.rand.nextInt(chance) <= 0) + if (mc.level.rand.nextInt(chance) <= 0) NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + mc.world.rand.nextFloat(), + pos.getX() + mc.level.rand.nextFloat(), pos.getY() + 0.5F, - pos.getZ() + mc.world.rand.nextFloat(), - mc.world.rand.nextGaussian() * 0.01F, - mc.world.rand.nextFloat() * 0.025F, - mc.world.rand.nextGaussian() * 0.01F, - block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getGrassColor(mc.world, pos), - Math.min(2F, 1F + mc.world.rand.nextFloat() * (excess / 30000F)), - Math.min(300, 100 + mc.world.rand.nextInt(excess / 3000 + 1)), + pos.getZ() + mc.level.rand.nextFloat(), + mc.level.rand.nextGaussian() * 0.01F, + mc.level.rand.nextFloat() * 0.025F, + mc.level.rand.nextGaussian() * 0.01F, + block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getGrassColor(mc.level, pos), + Math.min(2F, 1F + mc.level.rand.nextFloat() * (excess / 30000F)), + Math.min(300, 100 + mc.level.rand.nextInt(excess / 3000 + 1)), 0F, false, true); } } } } - if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.world.getGameTime() % 5 == 0) { + if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.level.getGameTime() % 5 == 0) { NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); inst.setParticleSpawnRange(512); inst.setParticleDepth(false); - for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.world.func_234923_W_().func_240901_a_())) { + for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.func_234923_W_().func_240901_a_())) { NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + mc.world.rand.nextFloat(), - pos.getY() + mc.world.rand.nextFloat(), - pos.getZ() + mc.world.rand.nextFloat(), - 0F, 0F, 0F, 0xe0faff, mc.world.rand.nextFloat() * 5 + 1, 100, 0F, false, true); + pos.getX() + mc.level.rand.nextFloat(), + pos.getY() + mc.level.rand.nextFloat(), + pos.getZ() + mc.level.rand.nextFloat(), + 0F, 0F, 0F, 0xe0faff, mc.level.rand.nextFloat() * 5 + 1, 100, 0F, false, true); } inst.setParticleDepth(true); inst.setParticleSpawnRange(32); @@ -156,9 +156,9 @@ public class ClientEvents { heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player); heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player); - if (!heldOcular.isEmpty() && mc.world.getGameTime() % 20 == 0) { + if (!heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { SHOWING_EFFECTS.clear(); - Helper.getAuraChunksWithSpotsInArea(mc.world, mc.player.getPosition(), 100, + Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.getPosition(), 100, chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS)); } } @@ -167,7 +167,7 @@ public class ClientEvents { } @SubscribeEvent - public void onWorldRender(RenderWorldLastEvent event) { + public void onLevelRender(RenderLevelLastEvent event) { Minecraft mc = Minecraft.getInstance(); RenderSystem.pushMatrix(); @@ -177,7 +177,7 @@ public class ClientEvents { Vector3d view = info.getProjectedView(); GL11.glTranslated(-view.getX(), -view.getY(), -view.getZ()); - if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.instance.debugWorld.get()) { + if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.instance.debugLevel.get()) { Map spots = new HashMap<>(); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_DEPTH_TEST); @@ -185,7 +185,7 @@ public class ClientEvents { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); - IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (pos, spot) -> { + IAuraChunk.getSpotsInArea(mc.level, mc.player.getPosition(), 64, (pos, spot) -> { spots.put(pos, spot); RenderSystem.color4f(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F); @@ -212,7 +212,7 @@ public class ClientEvents { } if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) { - RegistryKey dim = mc.world.func_234923_W_(); + RegistryKey dim = mc.level.func_234923_W_(); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); @@ -220,18 +220,18 @@ public class ClientEvents { GL11.glEnable(GL11.GL_BLEND); GL11.glBegin(GL11.GL_QUADS); for (BlockPos pos : ItemRangeVisualizer.VISUALIZED_BLOCKS.get(dim.func_240901_a_())) { - if (!mc.world.isBlockLoaded(pos)) + if (!mc.level.isBlockLoaded(pos)) continue; - BlockState state = mc.world.getBlockState(pos); + BlockState state = mc.level.getBlockState(pos); Block block = state.getBlock(); if (!(block instanceof IVisualizable)) continue; - this.renderVisualize((IVisualizable) block, mc.world, pos); + this.renderVisualize((IVisualizable) block, mc.level, pos); } for (Entity entity : ItemRangeVisualizer.VISUALIZED_ENTITIES.get(dim.func_240901_a_())) { if (!entity.isAlive() || !(entity instanceof IVisualizable)) continue; - this.renderVisualize((IVisualizable) entity, mc.world, entity.getPosition()); + this.renderVisualize((IVisualizable) entity, mc.level, entity.getPosition()); } GL11.glEnd(); GL11.glPopAttrib(); @@ -242,13 +242,13 @@ public class ClientEvents { GL11.glPopMatrix(); } - private void renderVisualize(IVisualizable visualize, World - world, BlockPos pos) { - AxisAlignedBB box = visualize.getVisualizationBounds(world, pos); + private void renderVisualize(IVisualizable visualize, Level + level, BlockPos pos) { + AxisAlignedBB box = visualize.getVisualizationBounds(level, pos); if (box == null) return; box = box.grow(0.05F); - int color = visualize.getVisualizationColor(world, pos); + int color = visualize.getVisualizationColor(level, pos); RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F); Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ); } @@ -293,10 +293,10 @@ public class ClientEvents { int conf = ModConfig.instance.auraBarLocation.get(); if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) { - int color = IAuraType.forWorld(mc.world).getColor(); + int color = IAuraType.forLevel(mc.level).getColor(); RenderSystem.color4f((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1); - int totalAmount = IAuraChunk.triangulateAuraInArea(mc.world, mc.player.getPosition(), 35); + int totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.getPosition(), 35); float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F); String text = I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"); float textScale = 0.75F; @@ -365,18 +365,18 @@ public class ClientEvents { if (mc.objectMouseOver instanceof BlockRayTraceResult) { BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos(); if (pos != null) { - TileEntity tile = mc.world.getTileEntity(pos); + BlockEntity tile = mc.level.getBlockEntity(pos); IAuraContainer container; int x = res.getScaledWidth() / 2; int y = res.getScaledHeight() / 2; if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) { - BlockState state = mc.world.getBlockState(pos); - ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player); + BlockState state = mc.level.getBlockState(pos); + ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.level, pos, mc.player); this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), mc, res, 35, blockStack.getDisplayName().getString(), null); - if (tile instanceof TileEntityNatureAltar) { - ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler().getStackInSlot(0); + if (tile instanceof BlockEntityNatureAltar) { + ItemStack tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0); if (!tileStack.isEmpty()) { IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); if (stackCont != null) { @@ -385,13 +385,13 @@ public class ClientEvents { } } } - } else if (tile instanceof TileEntityRFConverter) { - EnergyStorage storage = ((TileEntityRFConverter) tile).storage; + } else if (tile instanceof BlockEntityRFConverter) { + EnergyStorage storage = ((BlockEntityRFConverter) tile).storage; this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, mc, res, 35, I18n.format("block.naturesaura.rf_converter"), storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); - } else if (tile instanceof TileEntityGratedChute) { - TileEntityGratedChute chute = (TileEntityGratedChute) tile; + } else if (tile instanceof BlockEntityGratedChute) { + BlockEntityGratedChute chute = (BlockEntityGratedChute) tile; ItemStack itemStack = chute.getItemHandler().getStackInSlot(0); if (itemStack.isEmpty()) @@ -407,16 +407,16 @@ public class ClientEvents { GlStateManager.disableDepthTest(); AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); GlStateManager.enableDepthTest(); - } else if (tile instanceof TileEntityItemDistributor) { - TileEntityItemDistributor distributor = (TileEntityItemDistributor) tile; + } else if (tile instanceof BlockEntityItemDistributor) { + BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile; Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F); mc.getTextureManager().bindTexture(OVERLAYS); int u = !distributor.isRandomMode ? 240 : 224; GlStateManager.disableDepthTest(); AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); GlStateManager.enableDepthTest(); - } else if (tile instanceof TileEntityAuraTimer) { - TileEntityAuraTimer timer = (TileEntityAuraTimer) tile; + } else if (tile instanceof BlockEntityAuraTimer) { + BlockEntityAuraTimer timer = (BlockEntityAuraTimer) tile; ItemStack itemStack = timer.getItemHandler().getStackInSlot(0); if (!itemStack.isEmpty()) { Helper.renderItemInGui(itemStack, x - 20, y - 20, 1); diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 2c31542b..e7bff95e 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -7,31 +7,31 @@ import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunkProvider; import de.ellpeck.naturesaura.commands.CommandAura; import de.ellpeck.naturesaura.gen.ModFeatures; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.GenerationStage.Decoration; -import net.minecraft.world.server.ChunkHolder; -import net.minecraft.world.server.ChunkManager; -import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.level.Level; +import net.minecraft.level.chunk.Chunk; +import net.minecraft.level.chunk.IChunk; +import net.minecraft.level.gen.GenerationStage.Decoration; +import net.minecraft.level.server.ChunkHolder; +import net.minecraft.level.server.ChunkManager; +import net.minecraft.level.server.ServerChunkProvider; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.world.BiomeLoadingEvent; -import net.minecraftforge.event.world.ChunkEvent; -import net.minecraftforge.event.world.ChunkWatchEvent; +import net.minecraftforge.event.level.BiomeLoadingEvent; +import net.minecraftforge.event.level.ChunkEvent; +import net.minecraftforge.event.level.ChunkWatchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; @@ -72,8 +72,8 @@ public class CommonEvents { } @SubscribeEvent - public void onWorldCapsAttach(AttachCapabilitiesEvent event) { - event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "data"), new WorldData()); + public void onLevelCapsAttach(AttachCapabilitiesEvent event) { + event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "data"), new LevelData()); } @SubscribeEvent @@ -83,7 +83,7 @@ public class CommonEvents { Chunk chunk = (Chunk) iChunk; IAuraChunk auraChunk = chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null); if (auraChunk instanceof AuraChunk) { - WorldData data = (WorldData) IWorldData.getWorldData(chunk.getWorld()); + LevelData data = (LevelData) ILevelData.getLevelData(chunk.getLevel()); data.auraChunksWithSpots.remove(chunk.getPos().asLong()); } } @@ -91,26 +91,26 @@ public class CommonEvents { @SubscribeEvent public void onItemUse(PlayerInteractEvent.RightClickBlock event) { - PlayerEntity player = event.getPlayer(); - if (player.world.isRemote) + Player player = event.getPlayer(); + if (player.level.isClientSide) return; ItemStack held = event.getItemStack(); if (!held.isEmpty() && held.getItem().getRegistryName().getPath().contains("chisel")) { - BlockState state = player.world.getBlockState(event.getPos()); + BlockState state = player.level.getBlockState(event.getPos()); if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) { - WorldData data = (WorldData) IWorldData.getWorldData(player.world); + LevelData data = (LevelData) ILevelData.getLevelData(player.level); data.addMossStone(event.getPos()); } } } @SubscribeEvent - public void onWorldTick(TickEvent.WorldTickEvent event) { - if (!event.world.isRemote && event.phase == TickEvent.Phase.END) { - if (event.world.getGameTime() % 20 == 0) { - event.world.getProfiler().startSection(NaturesAura.MOD_ID + ":onWorldTick"); + public void onLevelTick(TickEvent.LevelTickEvent event) { + if (!event.level.isClientSide && event.phase == TickEvent.Phase.END) { + if (event.level.getGameTime() % 20 == 0) { + event.level.getProfiler().startSection(NaturesAura.MOD_ID + ":onLevelTick"); try { - ChunkManager manager = ((ServerChunkProvider) event.world.getChunkProvider()).chunkManager; + ChunkManager manager = ((ServerChunkProvider) event.level.getChunkProvider()).chunkManager; Iterable chunks = (Iterable) GET_LOADED_CHUNKS_METHOD.invoke(manager); for (ChunkHolder holder : chunks) { Chunk chunk = holder.getChunkIfComplete(); @@ -123,23 +123,23 @@ public class CommonEvents { } catch (IllegalAccessException | InvocationTargetException e) { NaturesAura.LOGGER.fatal(e); } - event.world.getProfiler().endSection(); + event.level.getProfiler().endSection(); } } } @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (!event.player.world.isRemote && event.phase == TickEvent.Phase.END) { - if (event.player.world.getGameTime() % 10 == 0) { + if (!event.player.level.isClientSide && event.phase == TickEvent.Phase.END) { + if (event.player.level.getGameTime() % 10 == 0) { List pending = PENDING_AURA_CHUNKS.get(event.player.getUniqueID()); pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p)); } - if (event.player.world.getGameTime() % 200 != 0) + if (event.player.level.getGameTime() % 200 != 0) return; - int aura = IAuraChunk.triangulateAuraInArea(event.player.world, event.player.getPosition(), 25); + int aura = IAuraChunk.triangulateAuraInArea(event.player.level, event.player.getPosition(), 25); if (aura <= 0) Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); else if (aura >= 1500000) @@ -152,8 +152,8 @@ public class CommonEvents { PENDING_AURA_CHUNKS.put(event.getPlayer().getUniqueID(), event.getPos()); } - private boolean handleChunkWatchDeferred(PlayerEntity player, ChunkPos pos) { - Chunk chunk = Helper.getLoadedChunk(player.world, pos.x, pos.z); + private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) { + Chunk chunk = Helper.getLoadedChunk(player.level, pos.x, pos.z); if (chunk == null) return false; AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 43a2cedb..12089d3b 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.gen; -import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.placement.IPlacementConfig; -import net.minecraft.world.gen.placement.Placement; +import net.minecraft.level.gen.feature.*; +import net.minecraft.level.gen.placement.IPlacementConfig; +import net.minecraft.level.gen.placement.Placement; @SuppressWarnings("FieldNamingConvention") public final class ModFeatures { diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAncientTree.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAncientTree.java index 14d92d7e..8fb97bf6 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAncientTree.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAncientTree.java @@ -10,29 +10,29 @@ import net.minecraft.block.material.Material; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.IWorldGenerationReader; -import net.minecraft.world.gen.feature.BaseTreeFeatureConfig; -import net.minecraft.world.gen.feature.Feature; +import net.minecraft.level.ISeedReader; +import net.minecraft.level.gen.ChunkGenerator; +import net.minecraft.level.gen.ILevelGenerationReader; +import net.minecraft.level.gen.feature.BaseTreeFeatureConfig; +import net.minecraft.level.gen.feature.Feature; import java.util.Random; -public class WorldGenAncientTree extends Feature { +public class LevelGenAncientTree extends Feature { // what the heck even is this public static final BaseTreeFeatureConfig CONFIG = new BaseTreeFeatureConfig.Builder(null, null, null, null, null).build(); - public WorldGenAncientTree() { + public LevelGenAncientTree() { super(Codec.unit(CONFIG)); } @Override - public boolean func_241855_a(ISeedReader world, ChunkGenerator generator, Random rand, BlockPos pos, BaseTreeFeatureConfig p_241855_5_) { + public boolean func_241855_a(ISeedReader level, ChunkGenerator generator, Random rand, BlockPos pos, BaseTreeFeatureConfig p_241855_5_) { int height = rand.nextInt(3) + 5; BlockPos trunkTop = pos.up(height); - this.func_230367_a_(world, pos, Blocks.AIR.getDefaultState()); + this.func_230367_a_(level, pos, Blocks.AIR.getDefaultState()); //Roots int rootsAmount = rand.nextInt(4) + 5; for (int i = 0; i < rootsAmount; i++) { @@ -42,12 +42,12 @@ public class WorldGenAncientTree extends Feature { float z = (float) Math.cos(angle) * length; BlockPos goal = pos.add(x, 0, z); - while (world.hasBlockState(goal, state -> state.getMaterial().isReplaceable())) { + while (level.hasBlockState(goal, state -> state.getMaterial().isReplaceable())) { goal = goal.down(); if (goal.distanceSq(pos) >= 10 * 10) break; } - this.makeBranch(world, pos.up(rand.nextInt(1)), goal, ModBlocks.ANCIENT_BARK.getDefaultState(), false); + this.makeBranch(level, pos.up(rand.nextInt(1)), goal, ModBlocks.ANCIENT_BARK.getDefaultState(), false); } //Trunk @@ -55,13 +55,13 @@ public class WorldGenAncientTree extends Feature { for (int z = 0; z <= 1; z++) { for (int i = height - (x + z) * (rand.nextInt(2) + 2); i >= 0; i--) { BlockPos goal = pos.add(x, i, z); - if (!world.hasBlockState(goal, s -> !s.canBeReplacedByLogs(world, goal))) { - this.func_230367_a_(world, goal, ModBlocks.ANCIENT_LOG.getDefaultState().with(RotatedPillarBlock.AXIS, Axis.Y)); + if (!level.hasBlockState(goal, s -> !s.canBeReplacedByLogs(level, goal))) { + this.func_230367_a_(level, goal, ModBlocks.ANCIENT_LOG.getDefaultState().with(RotatedPillarBlock.AXIS, Axis.Y)); } } } } - this.makeLeaves(world, trunkTop.up(rand.nextInt(2) - 1), ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 3, rand); + this.makeLeaves(level, trunkTop.up(rand.nextInt(2) - 1), ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 3, rand); //Branches int branchAmount = rand.nextInt(3) + 4; @@ -72,14 +72,14 @@ public class WorldGenAncientTree extends Feature { float z = (float) Math.cos(angle) * length; BlockPos goal = trunkTop.add(x, rand.nextInt(3) + 1, z); - this.makeBranch(world, trunkTop, goal, ModBlocks.ANCIENT_LOG.getDefaultState(), true); - this.makeLeaves(world, goal, ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 2, rand); + this.makeBranch(level, trunkTop, goal, ModBlocks.ANCIENT_LOG.getDefaultState(), true); + this.makeLeaves(level, goal, ModBlocks.ANCIENT_LEAVES.getDefaultState(), rand.nextInt(2) + 2, rand); } return true; } - private void makeBranch(ISeedReader world, BlockPos first, BlockPos second, BlockState state, boolean hasAxis) { + private void makeBranch(ISeedReader level, BlockPos first, BlockPos second, BlockState state, boolean hasAxis) { BlockPos pos = second.add(-first.getX(), -first.getY(), -first.getZ()); int length = this.getHighestCoord(pos); float stepX = (float) pos.getX() / (float) length; @@ -88,29 +88,29 @@ public class WorldGenAncientTree extends Feature { for (int i = 0; i <= length; i++) { BlockPos goal = first.add(0.5F + i * stepX, 0.5F + i * stepY, 0.5F + i * stepZ); - if (!world.hasBlockState(goal, s -> !s.canBeReplacedByLogs(world, goal))) { + if (!level.hasBlockState(goal, s -> !s.canBeReplacedByLogs(level, goal))) { if (hasAxis) { Axis axis = this.getLogAxis(first, goal); - this.func_230367_a_(world, goal, state.with(RotatedPillarBlock.AXIS, axis)); + this.func_230367_a_(level, goal, state.with(RotatedPillarBlock.AXIS, axis)); } else { - this.func_230367_a_(world, goal, state); + this.func_230367_a_(level, goal, state); } } } } - private void makeLeaves(IWorldGenerationReader world, BlockPos pos, BlockState state, int radius, Random rand) { + private void makeLeaves(ILevelGenerationReader level, BlockPos pos, BlockState state, int radius, Random rand) { for (int x = -radius; x <= radius; x++) { for (int y = -radius; y <= radius; y++) { for (int z = -radius; z <= radius; z++) { BlockPos goal = pos.add(x, y, z); if (pos.distanceSq(goal) <= radius * radius + rand.nextInt(3) - 1) { - if (!world.hasBlockState(goal, s -> s.getMaterial() == Material.LEAVES)) { - if (world.hasBlockState(goal, st -> { + if (!level.hasBlockState(goal, s -> s.getMaterial() == Material.LEAVES)) { + if (level.hasBlockState(goal, st -> { Block block = st.getBlock(); return st.getMaterial() != Material.WOOD && block != Blocks.DIRT && block != Blocks.GRASS; })) { - this.func_230367_a_(world, goal, state); + this.func_230367_a_(level, goal, state); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java index 442a2e1e..11bc51e7 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenAuraBloom.java @@ -1,28 +1,28 @@ package de.ellpeck.naturesaura.gen; import com.mojang.serialization.Codec; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.Heightmap; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.level.ISeedReader; +import net.minecraft.level.gen.ChunkGenerator; +import net.minecraft.level.gen.Heightmap; +import net.minecraft.level.gen.feature.Feature; +import net.minecraft.level.gen.feature.IFeatureConfig; +import net.minecraft.level.gen.feature.NoFeatureConfig; import java.util.Random; -public class WorldGenAuraBloom extends Feature { +public class LevelGenAuraBloom extends Feature { private final Block block; private final int chance; private final boolean nether; - public WorldGenAuraBloom(Block block, int chance, boolean nether) { + public LevelGenAuraBloom(Block block, int chance, boolean nether) { super(Codec.unit(IFeatureConfig.NO_FEATURE_CONFIG)); this.block = block; this.chance = chance; @@ -30,7 +30,7 @@ public class WorldGenAuraBloom extends Feature { } @Override - public boolean func_241855_a(ISeedReader worldIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig config) { + public boolean func_241855_a(ISeedReader levelIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig config) { if (rand.nextInt(this.chance) != 0) return false; int startX = pos.getX() + rand.nextInt(16); @@ -43,27 +43,27 @@ public class WorldGenAuraBloom extends Feature { int y = MathHelper.nextInt(rand, 0, 128); for (int off = 0; off < 64; off++) { // try to find a good location in both directions of the random pos - if (this.tryPlace(worldIn, new BlockPos(offX, y - off, offZ)) || this.tryPlace(worldIn, new BlockPos(offX, y + off, offZ))) { + if (this.tryPlace(levelIn, new BlockPos(offX, y - off, offZ)) || this.tryPlace(levelIn, new BlockPos(offX, y + off, offZ))) { any = true; break; } } } else { - BlockPos placePos = new BlockPos(offX, worldIn.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, offX, offZ), offZ); - if (this.tryPlace(worldIn, placePos)) + BlockPos placePos = new BlockPos(offX, levelIn.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, offX, offZ), offZ); + if (this.tryPlace(levelIn, placePos)) any = true; } } return any; } - private boolean tryPlace(ISeedReader world, BlockPos pos) { + private boolean tryPlace(ISeedReader level, BlockPos pos) { BlockState state = this.block.getDefaultState(); - if (this.block.isValidPosition(state, world, pos)) { - world.setBlockState(pos, state, 3); - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityAuraBloom) - ((TileEntityAuraBloom) tile).justGenerated = true; + if (this.block.isValidPosition(state, level, pos)) { + level.setBlockState(pos, state, 3); + BlockEntity tile = level.getBlockEntity(pos); + if (tile instanceof BlockEntityAuraBloom) + ((BlockEntityAuraBloom) tile).justGenerated = true; return true; } return false; diff --git a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java index 0a40de61..f8bf0113 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/WorldGenNetherWartMushroom.java @@ -5,23 +5,23 @@ import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.IWorld; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.level.ISeedReader; +import net.minecraft.level.ILevel; +import net.minecraft.level.gen.ChunkGenerator; +import net.minecraft.level.gen.feature.Feature; +import net.minecraft.level.gen.feature.IFeatureConfig; +import net.minecraft.level.gen.feature.NoFeatureConfig; import java.util.Random; -public class WorldGenNetherWartMushroom extends Feature { +public class LevelGenNetherWartMushroom extends Feature { - public WorldGenNetherWartMushroom() { + public LevelGenNetherWartMushroom() { super(Codec.unit(IFeatureConfig.NO_FEATURE_CONFIG)); } @Override - public boolean func_241855_a(ISeedReader worldIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig p_241855_5_) { + public boolean func_241855_a(ISeedReader levelIn, ChunkGenerator gen, Random rand, BlockPos pos, NoFeatureConfig p_241855_5_) { int height = rand.nextInt(5) + 4; if (rand.nextInt(10) == 0) height += 5; @@ -29,14 +29,14 @@ public class WorldGenNetherWartMushroom extends Feature { // Check if the stem has space for (int i = 1; i < height; i++) { BlockPos offset = pos.up(i); - if (worldIn.hasBlockState(offset, s -> !s.canBeReplacedByLogs(worldIn, offset))) + if (levelIn.hasBlockState(offset, s -> !s.canBeReplacedByLogs(levelIn, offset))) return false; } // Place stem - this.func_230367_a_(worldIn, pos, Blocks.AIR.getDefaultState()); + this.func_230367_a_(levelIn, pos, Blocks.AIR.getDefaultState()); for (int i = 0; i < height; i++) - this.placeIfPossible(worldIn, pos.up(i), Blocks.NETHER_WART_BLOCK); + this.placeIfPossible(levelIn, pos.up(i), Blocks.NETHER_WART_BLOCK); // Place hat int rad = 3; @@ -45,19 +45,19 @@ public class WorldGenNetherWartMushroom extends Feature { int absX = Math.abs(x); int absZ = Math.abs(z); if (absX <= 1 && absZ <= 1) { - this.placeIfPossible(worldIn, pos.add(x, height, z), ModBlocks.NETHER_WART_MUSHROOM); + this.placeIfPossible(levelIn, pos.add(x, height, z), ModBlocks.NETHER_WART_MUSHROOM); } else if (absX <= 2 && absZ <= 2 && absX != absZ) { - this.placeIfPossible(worldIn, pos.add(x, height - 1, z), ModBlocks.NETHER_WART_MUSHROOM); + this.placeIfPossible(levelIn, pos.add(x, height - 1, z), ModBlocks.NETHER_WART_MUSHROOM); } else if (absX < rad - 1 || absZ < rad - 1 || absX == rad - 1 && absZ == rad - 1) { - this.placeIfPossible(worldIn, pos.add(x, height - 2, z), ModBlocks.NETHER_WART_MUSHROOM); + this.placeIfPossible(levelIn, pos.add(x, height - 2, z), ModBlocks.NETHER_WART_MUSHROOM); } } } return true; } - private void placeIfPossible(IWorld world, BlockPos pos, Block block) { - if (world.hasBlockState(pos, s -> s.canBeReplacedByLogs(world, pos))) - world.setBlockState(pos, block.getDefaultState(), 19); + private void placeIfPossible(ILevel level, BlockPos pos, Block block) { + if (level.hasBlockState(pos, s -> s.canBeReplacedByLogs(level, pos))) + level.setBlockState(pos, block.getDefaultState(), 19); } } diff --git a/src/main/java/de/ellpeck/naturesaura/gui/ContainerEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/gui/ContainerEnderCrate.java index e29a75c8..75a49361 100644 --- a/src/main/java/de/ellpeck/naturesaura/gui/ContainerEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/gui/ContainerEnderCrate.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.gui; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; @@ -10,7 +10,7 @@ import net.minecraftforge.items.SlotItemHandler; public class ContainerEnderCrate extends Container { - public ContainerEnderCrate(ContainerType type, int id, PlayerEntity player, IItemHandler handler) { + public ContainerEnderCrate(ContainerType type, int id, Player player, IItemHandler handler) { super(type, id); int i = (3 - 4) * 18; for (int j = 0; j < 3; ++j) @@ -24,12 +24,12 @@ public class ContainerEnderCrate extends Container { } @Override - public boolean canInteractWith(PlayerEntity playerIn) { + public boolean canInteractWith(Player playerIn) { return true; } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack transferStackInSlot(Player playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); diff --git a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java index c90edd5c..8cdc55cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.gui; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; @@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class GuiEnderCrate extends ContainerScreen { private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png"); - private final PlayerEntity player; + private final Player player; public GuiEnderCrate(ContainerEnderCrate container, PlayerInventory inv, ITextComponent title) { super(container, inv, title); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index acc89235..520c77a3 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -9,7 +9,7 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel; import net.minecraft.block.BlockState; import net.minecraft.block.DispenserBlock; import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -19,7 +19,7 @@ import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -35,23 +35,23 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu MinecraftForge.EVENT_BUS.register(new EventHandler()); DispenserBlock.registerDispenseBehavior(emptyBottle, (source, stack) -> { - World world = source.getWorld(); + Level level = source.getLevel(); BlockState state = source.getBlockState(); Direction facing = state.get(DispenserBlock.FACING); BlockPos offset = source.getBlockPos().offset(facing); - BlockState offsetState = world.getBlockState(offset); + BlockState offsetState = level.getBlockState(offset); ItemStack dispense = stack.split(1); - if (offsetState.getBlock().isAir(offsetState, world, offset)) { - if (IAuraChunk.getAuraInArea(world, offset, 30) >= 100000) { - dispense = setType(new ItemStack(ItemAuraBottle.this), IAuraType.forWorld(world)); + if (offsetState.getBlock().isAir(offsetState, level, offset)) { + if (IAuraChunk.getAuraInArea(level, offset, 30) >= 100000) { + dispense = setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level)); - BlockPos spot = IAuraChunk.getHighestSpot(world, offset, 30, offset); - IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 20000); + BlockPos spot = IAuraChunk.getHighestSpot(level, offset, 30, offset); + IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000); } } - doDispense(world, dispense, 6, facing, DispenserBlock.getDispensePosition(source)); + doDispense(level, dispense, 6, facing, DispenserBlock.getDispensePosition(source)); return stack; }); } @@ -106,24 +106,24 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu ItemStack held = event.getItemStack(); if (held.isEmpty() || held.getItem() != ModItems.BOTTLE_TWO_THE_REBOTTLING) return; - PlayerEntity player = event.getPlayer(); - RayTraceResult ray = rayTrace(player.world, player, RayTraceContext.FluidMode.NONE); + Player player = event.getPlayer(); + RayTraceResult ray = rayTrace(player.level, player, RayTraceContext.FluidMode.NONE); if (ray.getType() == RayTraceResult.Type.BLOCK) return; BlockPos pos = player.getPosition(); - if (IAuraChunk.getAuraInArea(player.world, pos, 30) < 100000) + if (IAuraChunk.getAuraInArea(player.level, pos, 30) < 100000) return; - if (!player.world.isRemote) { + if (!player.level.isClientSide) { held.shrink(1); player.inventory.addItemStackToInventory( - setType(new ItemStack(ItemAuraBottle.this), IAuraType.forWorld(player.world))); + setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level))); - BlockPos spot = IAuraChunk.getHighestSpot(player.world, pos, 30, pos); - IAuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 20000); + BlockPos spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos); + IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000); - player.world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), + player.level.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1F, 1F); } player.swingArm(event.getHand()); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index fb85efc6..e0ad81ba 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -14,15 +14,15 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Direction; import net.minecraft.util.NonNullList; import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; @@ -42,9 +42,9 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { } @Override - public void inventoryTick(ItemStack stackIn, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (!worldIn.isRemote && entityIn instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entityIn; + public void inventoryTick(ItemStack stackIn, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (!levelIn.isClientSide && entityIn instanceof Player) { + Player player = (Player) entityIn; if (player.isSneaking() && stackIn.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) { IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); if (container.getStoredAura() <= 0) { @@ -96,7 +96,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return new ICapabilityProvider() { private final LazyOptional container = LazyOptional.of(() -> new ItemAuraContainer(stack, null, ItemAuraCache.this.capacity)); @@ -114,7 +114,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Override @OnlyIn(Dist.CLIENT) - public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { + public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { if (type == RenderType.BODY && !isHolding) { boolean chest = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); boolean legs = !player.inventory.armorInventory.get(EquipmentSlotType.LEGS.getIndex()).isEmpty(); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java b/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java index 3c535f1e..2fc678ac 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java @@ -19,19 +19,19 @@ public class ItemBirthSpirit extends ItemGlowing { @SubscribeEvent public void onBabyBorn(BabyEntitySpawnEvent event) { LivingEntity parent = event.getParentA(); - if (!parent.world.isRemote && event.getCausedByPlayer() != null) { + if (!parent.level.isClientSide && event.getCausedByPlayer() != null) { BlockPos pos = parent.getPosition(); - int aura = IAuraChunk.getAuraInArea(parent.world, pos, 30); + int aura = IAuraChunk.getAuraInArea(parent.level, pos, 30); if (aura < 1200000) return; - int amount = parent.world.rand.nextInt(3) + 1; - ItemEntity item = new ItemEntity(parent.world, parent.getPosX(), parent.getPosY(), parent.getPosZ(), + int amount = parent.level.rand.nextInt(3) + 1; + ItemEntity item = new ItemEntity(parent.level, parent.getPosX(), parent.getPosY(), parent.getPosZ(), new ItemStack(ModItems.BIRTH_SPIRIT, amount)); - parent.world.addEntity(item); + parent.level.addEntity(item); - BlockPos spot = IAuraChunk.getHighestSpot(parent.world, pos, 30, pos); - IAuraChunk.getAuraChunk(parent.world, spot).drainAura(spot, 800 * amount); + BlockPos spot = IAuraChunk.getHighestSpot(parent.level, pos, 30, pos); + IAuraChunk.getAuraChunk(parent.level, spot).drainAura(spot, 800 * amount); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java b/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java index e6e88822..5b3aadee 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.NaturesAura; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ElytraItem; import net.minecraft.item.ItemStack; import net.minecraft.util.text.*; @@ -39,7 +39,7 @@ public class ItemBreakPrevention extends ItemImpl { @SubscribeEvent public void onBreakSpeed(PlayerEvent.BreakSpeed event) { - PlayerEntity player = event.getPlayer(); + Player player = event.getPlayer(); if (player == null) return; ItemStack stack = player.getHeldItemMainhand(); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java index d088f37f..7b2bace7 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java @@ -3,14 +3,14 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.block.BlockState; import net.minecraft.entity.EntitySpawnPlacementRegistry; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; -import net.minecraft.world.World; +import net.minecraft.level.LightType; +import net.minecraft.level.Level; public class ItemCaveFinder extends ItemImpl { public ItemCaveFinder() { @@ -18,12 +18,12 @@ public class ItemCaveFinder extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); - if (!inst.extractAuraFromPlayer(playerIn, 20000, worldIn.isRemote)) - return new ActionResult<>(ActionResultType.FAIL, stack); - if (worldIn.isRemote) { + if (!inst.extractAuraFromPlayer(playerIn, 20000, levelIn.isClientSide)) + return new ActionResult<>(InteractionResult.FAIL, stack); + if (levelIn.isClientSide) { inst.setParticleDepth(false); inst.setParticleSpawnRange(64); inst.setParticleCulling(false); @@ -33,21 +33,21 @@ public class ItemCaveFinder extends ItemImpl { for (int y = -range; y <= range; y++) for (int z = -range; z <= range; z++) { BlockPos offset = pos.add(x, y, z); - BlockState state = worldIn.getBlockState(offset); + BlockState state = levelIn.getBlockState(offset); try { - if (!state.getBlock().canCreatureSpawn(state, worldIn, offset, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, null)) + if (!state.getBlock().canCreatureSpawn(state, levelIn, offset, EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, null)) continue; } catch (Exception e) { continue; } BlockPos offUp = offset.up(); - BlockState stateUp = worldIn.getBlockState(offUp); - if (stateUp.isNormalCube(worldIn, offUp) || stateUp.getMaterial().isLiquid()) + BlockState stateUp = levelIn.getBlockState(offUp); + if (stateUp.isNormalCube(levelIn, offUp) || stateUp.getMaterial().isLiquid()) continue; - int sky = worldIn.getLightFor(LightType.SKY, offUp); - int block = worldIn.getLightFor(LightType.BLOCK, offUp); + int sky = levelIn.getLightFor(LightType.SKY, offUp); + int block = levelIn.getLightFor(LightType.BLOCK, offUp); if (sky > 7 || block > 7) continue; @@ -62,6 +62,6 @@ public class ItemCaveFinder extends ItemImpl { playerIn.swingArm(handIn); } playerIn.getCooldownTracker().setCooldown(this, 20 * 30); - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java index f916fdea..adce45b7 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java @@ -7,13 +7,13 @@ import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.ICustomItemModel; import net.minecraft.block.Block; import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -25,8 +25,8 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I super("color_changer", new Properties().maxStackSize(1)); } - private static boolean changeOrCopyColor(PlayerEntity player, ItemStack stack, World world, BlockPos pos, DyeColor firstColor) { - Block block = world.getBlockState(pos).getBlock(); + private static boolean changeOrCopyColor(Player player, ItemStack stack, Level level, BlockPos pos, DyeColor firstColor) { + Block block = level.getBlockState(pos).getBlock(); List blocks = ColoredBlockHelper.getBlocksContaining(block); if (blocks == null) return false; @@ -35,25 +35,25 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I DyeColor stored = getStoredColor(stack); if (player.isSneaking()) { if (stored != color) { - world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.PLAYERS, 0.65F, 1F); - if (!world.isRemote) + if (!level.isClientSide) storeColor(stack, color); return true; } } else { if (stored != null && stored != color) { - if (NaturesAuraAPI.instance().extractAuraFromPlayer(player, 1000, world.isRemote)) { + if (NaturesAuraAPI.instance().extractAuraFromPlayer(player, 1000, level.isClientSide)) { if (firstColor == null) { - world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.PLAYERS, 0.65F, 1F); } - if (!world.isRemote) { - world.setBlockState(pos, blocks.get(stored.getId()).getDefaultState()); + if (!level.isClientSide) { + level.setBlockState(pos, blocks.get(stored.getId()).getDefaultState()); if (isFillMode(stack)) { for (Direction off : Direction.values()) { - changeOrCopyColor(player, stack, world, pos.offset(off), color); + changeOrCopyColor(player, stack, level, pos.offset(off), color); } } } @@ -91,26 +91,26 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public InteractionResult onItemUse(ItemUseContext context) { ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); - if (changeOrCopyColor(context.getPlayer(), stack, context.getWorld(), context.getPos(), null)) { - return ActionResultType.SUCCESS; + if (changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getPos(), null)) { + return InteractionResult.SUCCESS; } else { - return ActionResultType.PASS; + return InteractionResult.PASS; } } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); if (playerIn.isSneaking() && getStoredColor(stack) != null) { - worldIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.PLAYERS, 0.65F, 1F); - if (!worldIn.isRemote) { + levelIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.PLAYERS, 0.65F, 1F); + if (!levelIn.isClientSide) { setFillMode(stack, !isFillMode(stack)); } - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } else { - return new ActionResult<>(ActionResultType.PASS, stack); + return new ActionResult<>(InteractionResult.PASS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java index 5fc195db..ce27177d 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCrimsonMeal.java @@ -5,12 +5,12 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.NetherWartBlock; import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.gen.feature.IFeatureConfig; +import net.minecraft.level.server.ServerLevel; public class ItemCrimsonMeal extends ItemImpl { public ItemCrimsonMeal() { @@ -18,37 +18,37 @@ public class ItemCrimsonMeal extends ItemImpl { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); + public InteractionResult onItemUse(ItemUseContext context) { + Level level = context.getLevel(); BlockPos pos = context.getPos(); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); if (state.getBlock() == Blocks.NETHER_WART) { - if (!world.isRemote) { - if (world.rand.nextInt(5) == 0) { + if (!level.isClientSide) { + if (level.rand.nextInt(5) == 0) { int age = state.get(NetherWartBlock.AGE); if (age >= 3) { - ModFeatures.NETHER_WART_MUSHROOM.func_241855_a((ServerWorld) world, ((ServerWorld) world).getChunkProvider().getChunkGenerator(), world.rand, pos, IFeatureConfig.NO_FEATURE_CONFIG); + ModFeatures.NETHER_WART_MUSHROOM.func_241855_a((ServerLevel) level, ((ServerLevel) level).getChunkProvider().getChunkGenerator(), level.rand, pos, IFeatureConfig.NO_FEATURE_CONFIG); } else { - world.setBlockState(pos, state.with(NetherWartBlock.AGE, age + 1)); + level.setBlockState(pos, state.with(NetherWartBlock.AGE, age + 1)); } } - world.playEvent(2005, pos, 0); + level.playEvent(2005, pos, 0); context.getItem().shrink(1); } - return ActionResultType.SUCCESS; - } else if (world.getBlockState(pos.up()).isAir(world, pos.up()) && world.getBlockState(pos).getBlock() == Blocks.SOUL_SAND) { - if (!world.isRemote) { - for (int i = world.rand.nextInt(5); i >= 0; i--) { - BlockPos offset = pos.add(MathHelper.nextInt(world.rand, -3, 3), 1, MathHelper.nextInt(world.rand, -3, 3)); - if (world.getBlockState(offset.down()).getBlock() == Blocks.SOUL_SAND && world.getBlockState(offset).isAir(world, offset)) { - world.setBlockState(offset, Blocks.NETHER_WART.getDefaultState()); + return InteractionResult.SUCCESS; + } else if (level.getBlockState(pos.up()).isAir(level, pos.up()) && level.getBlockState(pos).getBlock() == Blocks.SOUL_SAND) { + if (!level.isClientSide) { + for (int i = level.rand.nextInt(5); i >= 0; i--) { + BlockPos offset = pos.add(MathHelper.nextInt(level.rand, -3, 3), 1, MathHelper.nextInt(level.rand, -3, 3)); + if (level.getBlockState(offset.down()).getBlock() == Blocks.SOUL_SAND && level.getBlockState(offset).isAir(level, offset)) { + level.setBlockState(offset, Blocks.NETHER_WART.getDefaultState()); } } - world.playEvent(2005, pos, 0); + level.playEvent(2005, pos, 0); context.getItem().shrink(1); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.FAIL; + return InteractionResult.FAIL; } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java b/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java index 64ec3152..975de1fe 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java @@ -4,9 +4,9 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.packet.PacketClient; import de.ellpeck.naturesaura.packet.PacketHandler; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraftforge.common.MinecraftForge; @@ -24,16 +24,16 @@ public class ItemDeathRing extends ItemImpl { @SubscribeEvent public void onDeath(LivingDeathEvent event) { LivingEntity entity = event.getEntityLiving(); - if (!entity.world.isRemote && entity instanceof PlayerEntity) { - ItemStack equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (PlayerEntity) entity); + if (!entity.level.isClientSide && entity instanceof Player) { + ItemStack equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity); if (!equipped.isEmpty()) { entity.setHealth(entity.getMaxHealth() / 2); entity.clearActivePotions(); entity.addPotionEffect(new EffectInstance(Effects.REGENERATION, 500, 1)); - CompoundNBT data = new CompoundNBT(); + CompoundTag data = new CompoundTag(); data.putInt("id", entity.getEntityId()); - PacketHandler.sendToAllAround(entity.world, entity.getPosition(), 32, new PacketClient(1, data)); + PacketHandler.sendToAllAround(entity.level, entity.getPosition(), 32, new PacketClient(1, data)); equipped.shrink(1); event.setCanceled(true); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java index 30c9e4cc..0f9f8f77 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java @@ -7,13 +7,13 @@ import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -38,15 +38,15 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - if (!world.isRemote) { + public InteractionResult onItemUse(ItemUseContext context) { + Level level = context.getLevel(); + if (!level.isClientSide) { Vector3d hit = context.getHitVec(); ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); - EntityEffectInhibitor.place(world, stack, hit.x, hit.y + 1, hit.z); + EntityEffectInhibitor.place(level, stack, hit.x, hit.y + 1, hit.z); stack.setCount(0); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java index 66186181..2af598d6 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java @@ -3,24 +3,24 @@ package de.ellpeck.naturesaura.items; import com.google.common.base.Strings; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.BlockEnderCrate; import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.ServerPlayer; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; @@ -35,14 +35,14 @@ public class ItemEnderAccess extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { if (handIn != Hand.MAIN_HAND) - return new ActionResult<>(ActionResultType.PASS, playerIn.getHeldItem(handIn)); + return new ActionResult<>(InteractionResult.PASS, playerIn.getHeldItem(handIn)); ItemStack stack = playerIn.getHeldItemMainhand(); String name = BlockEnderCrate.getEnderName(stack); if (!Strings.isNullOrEmpty(name)) { - if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) { - NetworkHooks.openGui((ServerPlayerEntity) playerIn, new INamedContainerProvider() { + if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) { + NetworkHooks.openGui((ServerPlayer) playerIn, new INamedContainerProvider() { @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".ender_access", TextFormatting.ITALIC + name + TextFormatting.RESET); @@ -50,20 +50,20 @@ public class ItemEnderAccess extends ItemImpl { @Nullable @Override - public Container createMenu(int windowId, PlayerInventory inv, PlayerEntity player) { - IItemHandler handler = IWorldData.getOverworldData(inv.player.world).getEnderStorage(name); + public Container createMenu(int windowId, PlayerInventory inv, Player player) { + IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(name); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, player, handler); } }, buffer -> buffer.writeString(name)); } - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } - return new ActionResult<>(ActionResultType.FAIL, stack); + return new ActionResult<>(InteractionResult.FAIL, stack); } @Override @OnlyIn(Dist.CLIENT) - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + public void addInformation(ItemStack stack, @Nullable Level levelIn, List tooltip, ITooltipFlag flagIn) { BlockEnderCrate.addEnderNameInfo(stack, tooltip); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java index d49dede1..570dafa2 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java @@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.util.math.vector.Vector3f; @@ -21,7 +21,7 @@ public class ItemEye extends ItemImpl implements ITrinketItem { @Override @OnlyIn(Dist.CLIENT) - public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { + public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { if (type == RenderType.BODY && !isHolding) { boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); matrices.translate(0.1F, 0.225F, armor ? -0.195F : -0.1475F); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java b/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java index 89f40ef1..24ef162b 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java @@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.reg.IColorProvidingItem; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem { @@ -19,14 +19,14 @@ public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem { } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public InteractionResult onItemUse(ItemUseContext context) { ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); - if (BlockGoldenLeaves.convert(context.getWorld(), context.getPos())) { - if (!context.getWorld().isRemote) { + if (BlockGoldenLeaves.convert(context.getLevel(), context.getPos())) { + if (!context.getLevel().isClientSide) { stack.shrink(1); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java b/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java index 714778e2..ddb733ba 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java @@ -3,12 +3,12 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.entities.EntityLightProjectile; import de.ellpeck.naturesaura.entities.ModEntities; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; -import net.minecraft.world.World; +import net.minecraft.level.Level; public class ItemLightStaff extends ItemImpl { public ItemLightStaff() { @@ -16,13 +16,13 @@ public class ItemLightStaff extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); - if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) { - EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, worldIn); + if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) { + EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, levelIn); projectile.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 1.5F, 0); - worldIn.addEntity(projectile); + levelIn.addEntity(projectile); } - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemLootFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemLootFinder.java index 90e44d4d..58030cc2 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemLootFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemLootFinder.java @@ -4,15 +4,15 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.MobSpawnerTileEntity; +import net.minecraft.tileentity.MobSpawnerBlockEntity; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.items.CapabilityItemHandler; public class ItemLootFinder extends ItemImpl { @@ -21,26 +21,26 @@ public class ItemLootFinder extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); if (!inst.extractAuraFromPlayer(playerIn, 100000, false)) - return new ActionResult<>(ActionResultType.FAIL, stack); - if (worldIn.isRemote) { + return new ActionResult<>(InteractionResult.FAIL, stack); + if (levelIn.isClientSide) { inst.setParticleDepth(false); inst.setParticleSpawnRange(64); inst.setParticleCulling(false); BlockPos pos = playerIn.getPosition(); - Helper.getTileEntitiesInArea(worldIn, pos, 64, tile -> { - if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() || tile instanceof MobSpawnerTileEntity) { + Helper.getTileEntitiesInArea(levelIn, pos, 64, tile -> { + if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() || tile instanceof MobSpawnerBlockEntity) { inst.spawnMagicParticle( tile.getPos().getX() + 0.5F, tile.getPos().getY() + 0.5F, tile.getPos().getZ() + 0.5F, 0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true); } return false; }); - for (Entity entity : worldIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos).grow(64))) { + for (Entity entity : levelIn.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos).grow(64))) { if (!(entity instanceof LivingEntity) && entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent()) { inst.spawnMagicParticle( entity.getPosX(), entity.getPosYEye(), entity.getPosZ(), @@ -55,6 +55,6 @@ public class ItemLootFinder extends ItemImpl { playerIn.swingArm(handIn); } playerIn.getCooldownTracker().setCooldown(this, 20 * 60); - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/items/ItemMoverMinecart.java index 0c42d702..39f7db2e 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemMoverMinecart.java @@ -5,9 +5,9 @@ import de.ellpeck.naturesaura.entities.ModEntities; import net.minecraft.block.AbstractRailBlock; import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import javax.annotation.Nonnull; @@ -19,17 +19,17 @@ public class ItemMoverMinecart extends ItemImpl { @Nonnull @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); + public InteractionResult onItemUse(ItemUseContext context) { + Level level = context.getLevel(); BlockPos pos = context.getPos(); - if (AbstractRailBlock.isRail(world.getBlockState(pos))) { - if (!world.isRemote) { - AbstractMinecartEntity cart = new EntityMoverMinecart(ModEntities.MOVER_CART, world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - world.addEntity(cart); + if (AbstractRailBlock.isRail(level.getBlockState(pos))) { + if (!level.isClientSide) { + AbstractMinecartEntity cart = new EntityMoverMinecart(ModEntities.MOVER_CART, level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + level.addEntity(cart); } context.getPlayer().getHeldItem(context.getHand()).shrink(1); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java index 6a3573f3..1f7e8c67 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java @@ -2,15 +2,15 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.multiblock.IMultiblock; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import java.util.ArrayList; import java.util.List; @@ -38,36 +38,36 @@ public class ItemMultiblockMaker extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); - if (!worldIn.isRemote && playerIn.isCreative()) { + if (!levelIn.isClientSide && playerIn.isCreative()) { int curr = getMultiblock(stack); int next = (curr + 1) % multiblocks().size(); stack.getOrCreateTag().putInt("multiblock", next); } - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } @Override - public ActionResultType onItemUse(ItemUseContext context) { - PlayerEntity player = context.getPlayer(); + public InteractionResult onItemUse(ItemUseContext context) { + Player player = context.getPlayer(); if (player.isCreative()) { int id = getMultiblock(player.getHeldItem(context.getHand())); if (id < 0) - return ActionResultType.PASS; + return InteractionResult.PASS; IMultiblock multi = multiblocks().get(id); if (multi == null) - return ActionResultType.PASS; + return InteractionResult.PASS; - if (!context.getWorld().isRemote) + if (!context.getLevel().isClientSide) multi.forEach(context.getPos().up(), (char) 0, (blockPos, matcher) -> { - context.getWorld().setBlockState(blockPos, matcher.getDefaultState()); + context.getLevel().setBlockState(blockPos, matcher.getDefaultState()); return true; }); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java index 5e672ef0..669243cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java @@ -3,13 +3,13 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; public class ItemNetheriteFinder extends ItemImpl { public ItemNetheriteFinder() { @@ -17,12 +17,12 @@ public class ItemNetheriteFinder extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance(); if (!inst.extractAuraFromPlayer(playerIn, 200000, false)) - return new ActionResult<>(ActionResultType.FAIL, stack); - if (worldIn.isRemote) { + return new ActionResult<>(InteractionResult.FAIL, stack); + if (levelIn.isClientSide) { inst.setParticleDepth(false); inst.setParticleSpawnRange(64); inst.setParticleCulling(false); @@ -33,7 +33,7 @@ public class ItemNetheriteFinder extends ItemImpl { for (int y = 0; y <= 128; y++) { for (int z = -range; z <= range; z++) { BlockPos offset = new BlockPos(pos.getX() + x, y, pos.getZ() + z); - BlockState state = worldIn.getBlockState(offset); + BlockState state = levelIn.getBlockState(offset); if (state.getBlock() == Blocks.ANCIENT_DEBRIS || state.getBlock().getRegistryName().toString().contains("netherite")) { inst.spawnMagicParticle( offset.getX() + 0.5F, offset.getY() + 0.5F, offset.getZ() + 0.5F, @@ -49,6 +49,6 @@ public class ItemNetheriteFinder extends ItemImpl { playerIn.swingArm(handIn); } playerIn.getCooldownTracker().setCooldown(this, 20 * 60); - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java index 9fbac27e..66e8f3c4 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java @@ -7,16 +7,16 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.TameableEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.Player; +import net.minecraft.entity.player.ServerPlayer; import net.minecraft.item.ItemStack; import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -38,7 +38,7 @@ public class ItemPetReviver extends ItemImpl { @SubscribeEvent public void onEntityTick(LivingEvent.LivingUpdateEvent event) { LivingEntity entity = event.getEntityLiving(); - if (entity.world.isRemote || entity.world.getGameTime() % 20 != 0 || !(entity instanceof TameableEntity)) + if (entity.level.isClientSide || entity.level.getGameTime() % 20 != 0 || !(entity instanceof TameableEntity)) return; TameableEntity tameable = (TameableEntity) entity; if (!tameable.isTamed() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver")) @@ -46,12 +46,12 @@ public class ItemPetReviver extends ItemImpl { LivingEntity owner = tameable.getOwner(); if (owner == null || owner.getDistanceSq(tameable) > 5 * 5) return; - if (entity.world.rand.nextFloat() >= 0.65F) { - ((ServerWorld) entity.world).spawnParticle(ParticleTypes.HEART, - entity.getPosX() + entity.world.rand.nextGaussian() * 0.25F, - entity.getPosYEye() + entity.world.rand.nextGaussian() * 0.25F, - entity.getPosZ() + entity.world.rand.nextGaussian() * 0.25F, - entity.world.rand.nextInt(2) + 1, 0, 0, 0, 0); + if (entity.level.rand.nextFloat() >= 0.65F) { + ((ServerLevel) entity.level).spawnParticle(ParticleTypes.HEART, + entity.getPosX() + entity.level.rand.nextGaussian() * 0.25F, + entity.getPosYEye() + entity.level.rand.nextGaussian() * 0.25F, + entity.getPosZ() + entity.level.rand.nextGaussian() * 0.25F, + entity.level.rand.nextInt(2) + 1, 0, 0, 0, 0); } } @@ -67,9 +67,9 @@ public class ItemPetReviver extends ItemImpl { if (stack.getItem() != ModItems.PET_REVIVER) return; target.getPersistentData().putBoolean(NaturesAura.MOD_ID + ":pet_reviver", true); - if (!target.world.isRemote) + if (!target.level.isClientSide) stack.shrink(1); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); } @@ -77,45 +77,45 @@ public class ItemPetReviver extends ItemImpl { @SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingDeath(LivingDeathEvent event) { LivingEntity entity = event.getEntityLiving(); - if (entity.world.isRemote || !(entity instanceof TameableEntity)) + if (entity.level.isClientSide || !(entity instanceof TameableEntity)) return; TameableEntity tameable = (TameableEntity) entity; if (!tameable.isTamed() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver")) return; // get the overworld, and the overworld's spawn point, by default - ServerWorld spawnWorld = tameable.world.getServer().func_241755_D_(); - Vector3d spawn = Vector3d.copyCenteredHorizontally(spawnWorld.func_241135_u_()); + ServerLevel spawnLevel = tameable.level.getServer().func_241755_D_(); + Vector3d spawn = Vector3d.copyCenteredHorizontally(spawnLevel.func_241135_u_()); // check if the owner is online, and respawn at the bed if they are LivingEntity owner = tameable.getOwner(); - if (owner instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) owner; + if (owner instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) owner; // I'm not really sure what this means, but I got it from PlayerList.func_232644_a_ haha BlockPos pos = player.func_241140_K_(); if (pos != null) { float f = player.func_242109_L(); boolean b = player.func_241142_M_(); - Optional bed = PlayerEntity.func_242374_a((ServerWorld) player.world, pos, f, b, false); + Optional bed = Player.func_242374_a((ServerLevel) player.level, pos, f, b, false); if (bed.isPresent()) { - spawnWorld = (ServerWorld) player.world; + spawnLevel = (ServerLevel) player.level; spawn = bed.get(); } } } - PacketHandler.sendToAllAround(tameable.world, tameable.getPosition(), 32, new PacketParticles((float) tameable.getPosX(), (float) tameable.getPosYEye(), (float) tameable.getPosZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d)); + PacketHandler.sendToAllAround(tameable.level, tameable.getPosition(), 32, new PacketParticles((float) tameable.getPosX(), (float) tameable.getPosYEye(), (float) tameable.getPosZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d)); TameableEntity spawnedPet = tameable; - if (tameable.world != spawnWorld) { - ((ServerWorld) tameable.world).removeEntity(tameable, true); - spawnedPet = (TameableEntity) tameable.getType().create(spawnWorld); + if (tameable.level != spawnLevel) { + ((ServerLevel) tameable.level).removeEntity(tameable, true); + spawnedPet = (TameableEntity) tameable.getType().create(spawnLevel); } // respawn (a copy of) the pet spawnedPet.copyDataFromOld(tameable); spawnedPet.setMotion(0, 0, 0); spawnedPet.setLocationAndAngles(spawn.x, spawn.y, spawn.z, tameable.rotationYaw, tameable.rotationPitch); - while (!spawnWorld.hasNoCollisions(spawnedPet)) + while (!spawnLevel.hasNoCollisions(spawnedPet)) spawnedPet.setPosition(spawnedPet.getPosX(), spawnedPet.getPosY() + 1, spawnedPet.getPosZ()); spawnedPet.setHealth(spawnedPet.getMaxHealth()); spawnedPet.getNavigator().clearPath(); @@ -123,18 +123,18 @@ public class ItemPetReviver extends ItemImpl { spawnedPet.func_233687_w_(true); spawnedPet.setJumping(false); spawnedPet.setAttackTarget(null); - if (tameable.world != spawnWorld) { - spawnWorld.addEntity(spawnedPet); + if (tameable.level != spawnLevel) { + spawnLevel.addEntity(spawnedPet); tameable.remove(false); } // drain aura - BlockPos auraPos = IAuraChunk.getHighestSpot(spawnWorld, spawnedPet.getPosition(), 35, spawnedPet.getPosition()); - IAuraChunk.getAuraChunk(spawnWorld, auraPos).drainAura(auraPos, 200000); + BlockPos auraPos = IAuraChunk.getHighestSpot(spawnLevel, spawnedPet.getPosition(), 35, spawnedPet.getPosition()); + IAuraChunk.getAuraChunk(spawnLevel, auraPos).drainAura(auraPos, 200000); - PacketHandler.sendToAllAround(spawnedPet.world, spawnedPet.getPosition(), 32, new PacketParticles((float) spawnedPet.getPosX(), (float) spawnedPet.getPosYEye(), (float) spawnedPet.getPosZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); + PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.getPosition(), 32, new PacketParticles((float) spawnedPet.getPosX(), (float) spawnedPet.getPosYEye(), (float) spawnedPet.getPosZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); - if (owner instanceof PlayerEntity) + if (owner instanceof Player) owner.sendMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).mergeStyle(TextFormatting.ITALIC, TextFormatting.GRAY), UUID.randomUUID()); event.setCanceled(true); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java index fd7f3e34..c69f4ca1 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java @@ -7,16 +7,16 @@ import de.ellpeck.naturesaura.api.render.IVisualizable; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -41,7 +41,7 @@ public class ItemRangeVisualizer extends ItemImpl { VISUALIZED_RAILS.clear(); } - public static void visualize(PlayerEntity player, ListMultimap map, ResourceLocation dim, T value) { + public static void visualize(Player player, ListMultimap map, ResourceLocation dim, T value) { if (map.containsEntry(dim, value)) { map.remove(dim, value); player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); @@ -52,28 +52,28 @@ public class ItemRangeVisualizer extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); if (playerIn.isSneaking()) { clear(); playerIn.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true); - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } - return new ActionResult<>(ActionResultType.PASS, stack); + return new ActionResult<>(InteractionResult.PASS, stack); } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); + public InteractionResult onItemUse(ItemUseContext context) { + Level level = context.getLevel(); BlockPos pos = context.getPos(); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); Block block = state.getBlock(); if (block instanceof IVisualizable) { - if (world.isRemote) - visualize(context.getPlayer(), VISUALIZED_BLOCKS, world.func_234923_W_().func_240901_a_(), pos); - return ActionResultType.SUCCESS; + if (level.isClientSide) + visualize(context.getPlayer(), VISUALIZED_BLOCKS, level.func_234923_W_().func_240901_a_(), pos); + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } public class EventHandler { @@ -85,12 +85,12 @@ public class ItemRangeVisualizer extends ItemImpl { return; Entity entity = event.getTarget(); if (entity instanceof IVisualizable) { - if (entity.world.isRemote) { - ResourceLocation dim = entity.world.func_234923_W_().func_240901_a_(); + if (entity.level.isClientSide) { + ResourceLocation dim = entity.level.func_234923_W_().func_240901_a_(); visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity); } event.getPlayer().swingArm(event.getHand()); - event.setCancellationResult(ActionResultType.SUCCESS); + event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java index 56140e6a..fbea2d95 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java @@ -16,10 +16,10 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.DamageSource; @@ -27,7 +27,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -40,12 +40,12 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (worldIn.isRemote || !(entityIn instanceof LivingEntity)) + public void inventoryTick(ItemStack stack, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { + if (levelIn.isClientSide || !(entityIn instanceof LivingEntity)) return; LivingEntity living = (LivingEntity) entityIn; if (!living.isOnGround()) { - CompoundNBT compound = stack.getOrCreateTag(); + CompoundTag compound = stack.getOrCreateTag(); if (compound.getBoolean("air")) return; @@ -56,7 +56,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { } else { if (!stack.hasTag()) return; - CompoundNBT compound = stack.getTag(); + CompoundTag compound = stack.getTag(); if (!compound.getBoolean("air")) return; @@ -66,18 +66,18 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { return; if (living.getDistanceSq(compound.getDouble("x"), compound.getDouble("y"), compound.getDouble("z")) > 0.75F) return; - if (living instanceof PlayerEntity && !NaturesAuraAPI.instance().extractAuraFromPlayer((PlayerEntity) living, 1000, false)) + if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 1000, false)) return; DamageSource source; - if (living instanceof PlayerEntity) - source = DamageSource.causePlayerDamage((PlayerEntity) living); + if (living instanceof Player) + source = DamageSource.causePlayerDamage((Player) living); else source = DamageSource.MAGIC; boolean infusedSet = ItemArmor.isFullSetEquipped(living, ModArmorMaterial.INFUSED); int range = 5; - List mobs = worldIn.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB( + List mobs = levelIn.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB( living.getPosX() - range, living.getPosY() - 0.5, living.getPosZ() - range, living.getPosX() + range, living.getPosY() + 0.5, living.getPosZ() + range)); for (LivingEntity mob : mobs) { @@ -85,7 +85,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { continue; if (living.getDistanceSq(mob) > range * range) continue; - if (living instanceof PlayerEntity && !NaturesAuraAPI.instance().extractAuraFromPlayer((PlayerEntity) living, 500, false)) + if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 500, false)) break; mob.attackEntityFrom(source, 4F); @@ -95,20 +95,20 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { BlockPos pos = living.getPosition(); BlockPos down = pos.down(); - BlockState downState = worldIn.getBlockState(down); + BlockState downState = levelIn.getBlockState(down); if (downState.getMaterial() != Material.AIR) { - SoundType type = downState.getBlock().getSoundType(downState, worldIn, down, null); - worldIn.playSound(null, pos, type.getBreakSound(), SoundCategory.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F); + SoundType type = downState.getBlock().getSoundType(downState, levelIn, down, null); + levelIn.playSound(null, pos, type.getBreakSound(), SoundCategory.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F); } - PacketHandler.sendToAllAround(worldIn, pos, 32, new PacketParticles((float) living.getPosX(), (float) living.getPosY(), (float) living.getPosZ(), PacketParticles.Type.SHOCKWAVE_CREATOR)); + PacketHandler.sendToAllAround(levelIn, pos, 32, new PacketParticles((float) living.getPosX(), (float) living.getPosY(), (float) living.getPosZ(), PacketParticles.Type.SHOCKWAVE_CREATOR)); } } @Override @OnlyIn(Dist.CLIENT) - public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { + public void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) { if (type == RenderType.BODY && !isHolding) { boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty(); matrices.translate(0, 0.125F, armor ? -0.195F : -0.1475F); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java index d84b9c41..3751d9be 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java @@ -2,15 +2,15 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.entities.EntityStructureFinder; import de.ellpeck.naturesaura.entities.ModEntities; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; +import net.minecraft.util.InteractionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.structure.Structure; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.gen.feature.structure.Structure; +import net.minecraft.level.server.ServerLevel; public class ItemStructureFinder extends ItemImpl { private final Structure structureName; @@ -25,22 +25,22 @@ public class ItemStructureFinder extends ItemImpl { } @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + public ActionResult onItemRightClick(Level levelIn, Player playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); - // ServerWorld.getStructureManager().doesGenerateFeatures() - if (!worldIn.isRemote && ((ServerWorld) worldIn).func_241112_a_().func_235005_a_()) { - BlockPos pos = ((ServerWorld) worldIn).getChunkProvider().getChunkGenerator().func_235956_a_((ServerWorld) worldIn, this.structureName, playerIn.getPosition(), this.radius, false); + // ServerLevel.getStructureManager().doesGenerateFeatures() + if (!levelIn.isClientSide && ((ServerLevel) levelIn).func_241112_a_().func_235005_a_()) { + BlockPos pos = ((ServerLevel) levelIn).getChunkProvider().getChunkGenerator().func_235956_a_((ServerLevel) levelIn, this.structureName, playerIn.getPosition(), this.radius, false); if (pos != null) { - EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, worldIn); + EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn); entity.setPosition(playerIn.getPosX(), playerIn.getPosYHeight(0.5D), playerIn.getPosZ()); entity.func_213863_b(stack); entity.getDataManager().set(EntityStructureFinder.COLOR, this.color); entity.moveTowards(pos.up(64)); - worldIn.addEntity(entity); + levelIn.addEntity(entity); stack.shrink(1); } } - return new ActionResult<>(ActionResultType.SUCCESS, stack); + return new ActionResult<>(InteractionResult.SUCCESS, stack); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java index 52f0052c..2d801bf9 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java @@ -10,10 +10,10 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.*; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -62,7 +62,7 @@ public class ItemArmor extends ArmorItem implements IModItem { @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, false); } @@ -72,7 +72,7 @@ public class ItemArmor extends ArmorItem implements IModItem { @SubscribeEvent public static void onAttack(LivingAttackEvent event) { LivingEntity entity = event.getEntityLiving(); - if (!entity.world.isRemote) { + if (!entity.level.isClientSide) { if (!isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) return; Entity source = event.getSource().getTrueSource(); @@ -83,10 +83,10 @@ public class ItemArmor extends ArmorItem implements IModItem { @SubscribeEvent public static void update(TickEvent.PlayerTickEvent event) { - PlayerEntity player = event.player; + Player player = event.player; ModifiableAttributeInstance speed = player.getAttribute(Attributes.MOVEMENT_SPEED); String key = NaturesAura.MOD_ID + ":sky_equipped"; - CompoundNBT nbt = player.getPersistentData(); + CompoundTag nbt = player.getPersistentData(); boolean equipped = isFullSetEquipped(player, ModArmorMaterial.SKY); if (equipped && !nbt.getBoolean(key)) { // we just equipped it diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java index 4bb5a021..17529268 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; @@ -10,11 +10,11 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.AxeItem; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -45,10 +45,10 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { } @Override - public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player) { + public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, Player player) { if (itemstack.getItem() == ModItems.SKY_AXE) { - if (player.world.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { - TileEntityWoodStand.recurseTreeDestruction(player.world, pos, pos, false, true); + if (player.level.getBlockState(pos).getBlock().getTags().contains(BlockTags.LOGS.getName())) { + BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true); return true; } } @@ -57,7 +57,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java index 8004eac7..a12a1d5f 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java @@ -10,13 +10,13 @@ import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockState; import net.minecraft.block.BushBlock; import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.*; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResultType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.InteractionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; @@ -33,13 +33,13 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public InteractionResult onItemUse(ItemUseContext context) { if (this == ModItems.INFUSED_IRON_HOE) { - World world = context.getWorld(); - ActionResultType result = super.onItemUse(context); - if (!world.isRemote && result.isSuccessOrConsume()) { + Level level = context.getLevel(); + InteractionResult result = super.onItemUse(context); + if (!level.isClientSide && result.isSuccessOrConsume()) { ItemStack seed = ItemStack.EMPTY; - Random random = world.getRandom(); + Random random = level.getRandom(); BlockPos pos = context.getPos(); if (random.nextInt(5) == 0) { seed = new ItemStack(Items.WHEAT_SEEDS); @@ -55,8 +55,8 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { } if (!seed.isEmpty()) { - ItemEntity item = new ItemEntity(world, pos.getX() + random.nextFloat(), pos.getY() + 1F, pos.getZ() + random.nextFloat(), seed); - world.addEntity(item); + ItemEntity item = new ItemEntity(level, pos.getX() + random.nextFloat(), pos.getY() + 1F, pos.getZ() + random.nextFloat(), seed); + level.addEntity(item); } } return result; @@ -67,20 +67,20 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { BlockPos offset = context.getPos().add(x, 0, z); BlockRayTraceResult newResult = new BlockRayTraceResult(context.getHitVec(), context.getFace(), offset, context.isInside()); ItemUseContext newContext = new ItemUseContext(context.getPlayer(), context.getHand(), newResult); - success |= super.onItemUse(newContext) == ActionResultType.SUCCESS; + success |= super.onItemUse(newContext) == InteractionResult.SUCCESS; } } - return success ? ActionResultType.SUCCESS : ActionResultType.PASS; + return success ? InteractionResult.SUCCESS : InteractionResult.PASS; } return super.onItemUse(context); } @Override - public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) { + public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) { if (stack.getItem() == ModItems.SKY_HOE) { - if (!(player.world.getBlockState(pos).getBlock() instanceof BushBlock)) + if (!(player.level.getBlockState(pos).getBlock() instanceof BushBlock)) return false; - if (!player.world.isRemote) { + if (!player.level.isClientSide) { int range = 3; for (int x = -range; x <= range; x++) { for (int y = -range; y <= range; y++) { @@ -88,9 +88,9 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { if (x == 0 && y == 0 && z == 0) continue; BlockPos offset = pos.add(x, y, z); - BlockState otherState = player.world.getBlockState(offset); + BlockState otherState = player.level.getBlockState(offset); if (otherState.getBlock() instanceof BushBlock) - player.world.destroyBlock(offset, true); + player.level.destroyBlock(offset, true); } } } @@ -106,7 +106,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java index 1fb8f702..0af4d75a 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java @@ -3,28 +3,28 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; -import de.ellpeck.naturesaura.misc.WorldData; +import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.item.PickaxeItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResultType; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.InteractionResult; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; @@ -45,50 +45,50 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public InteractionResult onItemUse(ItemUseContext context) { if (this == ModItems.INFUSED_IRON_PICKAXE) { - PlayerEntity player = context.getPlayer(); - World world = context.getWorld(); + Player player = context.getPlayer(); + Level level = context.getLevel(); BlockPos pos = context.getPos(); ItemStack stack = player.getHeldItem(context.getHand()); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); BlockState result = NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.get(state); if (result != null) { - if (!world.isRemote) { - world.setBlockState(pos, result); + if (!level.isClientSide) { + level.setBlockState(pos, result); - WorldData data = (WorldData) IWorldData.getWorldData(world); + LevelData data = (LevelData) ILevelData.getLevelData(level); data.addMossStone(pos); } - world.playSound(player, pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(15, player, playerEntity -> playerEntity.sendBreakAnimation(context.getHand())); - return ActionResultType.SUCCESS; + level.playSound(player, pos, SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F); + stack.damageItem(15, player, Player -> Player.sendBreakAnimation(context.getHand())); + return InteractionResult.SUCCESS; } } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override - public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { + public void inventoryTick(ItemStack stack, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { if (this == ModItems.SKY_PICKAXE) { - if (!(entityIn instanceof PlayerEntity)) + if (!(entityIn instanceof Player)) return; - if (!isSelected || worldIn.isRemote) + if (!isSelected || levelIn.isClientSide) return; AxisAlignedBB bounds = new AxisAlignedBB(entityIn.getPosition()).grow(3.5F); - for (ItemEntity item : worldIn.getEntitiesWithinAABB(ItemEntity.class, bounds)) { + for (ItemEntity item : levelIn.getEntitiesWithinAABB(ItemEntity.class, bounds)) { // only pick up freshly dropped items if (item.ticksExisted >= 5 || !item.isAlive()) continue; item.setPickupDelay(0); - item.onCollideWithPlayer((PlayerEntity) entityIn); + item.onCollideWithPlayer((Player) entityIn); } } } @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java index c1ab8a0f..0b500e91 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java @@ -11,14 +11,14 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.*; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; @@ -33,17 +33,17 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - PlayerEntity player = context.getPlayer(); + public InteractionResult onItemUse(ItemUseContext context) { + Level level = context.getLevel(); + Player player = context.getPlayer(); ItemStack stack = player.getHeldItem(context.getHand()); BlockPos pos = context.getPos(); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); if (this == ModItems.INFUSED_IRON_SHOVEL) { int damage = 0; if (state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.MYCELIUM) { - if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) { - world.setBlockState(pos, Blocks.GRASS_BLOCK.getDefaultState()); + if (level.getBlockState(pos.up()).getMaterial() == Material.AIR) { + level.setBlockState(pos, Blocks.GRASS_BLOCK.getDefaultState()); damage = 5; } } else { @@ -54,10 +54,10 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel Direction facing = context.getFace(); if (player.canPlayerEdit(actualPos.offset(facing), facing, stack)) { if (facing != Direction.DOWN - && world.getBlockState(actualPos.up()).getMaterial() == Material.AIR - && world.getBlockState(actualPos).getBlock() == Blocks.GRASS_BLOCK) { - if (!world.isRemote) { - world.setBlockState(actualPos, Blocks.GRASS_PATH.getDefaultState(), 11); + && level.getBlockState(actualPos.up()).getMaterial() == Material.AIR + && level.getBlockState(actualPos).getBlock() == Blocks.GRASS_BLOCK) { + if (!level.isClientSide) { + level.setBlockState(actualPos, Blocks.GRASS_PATH.getDefaultState(), 11); } damage = 1; } @@ -67,9 +67,9 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel } if (damage > 0) { - world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(damage, player, playerEntity -> playerEntity.sendBreakAnimation(context.getHand())); - return ActionResultType.SUCCESS; + level.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); + stack.damageItem(damage, player, Player -> Player.sendBreakAnimation(context.getHand())); + return InteractionResult.SUCCESS; } } else if (this == ModItems.SKY_SHOVEL) { if (this.getDestroySpeed(stack, state) <= 1) @@ -78,15 +78,15 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel ItemStack other = player.getHeldItem(otherHand); if (other.isEmpty() || !(other.getItem() instanceof BlockItem)) return super.onItemUse(context); - world.removeBlock(pos, false); - TileEntity tile = state.hasTileEntity() ? world.getTileEntity(pos) : null; - Block.spawnDrops(state, world, pos, tile, null, ItemStack.EMPTY); + level.removeBlock(pos, false); + BlockEntity tile = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; + Block.spawnDrops(state, level, pos, tile, null, ItemStack.EMPTY); ItemUseContext newContext = new ItemUseContext(player, otherHand, new BlockRayTraceResult(context.getHitVec(), context.getFace(), context.getPos(), context.isInside())); other.onItemUse(newContext); stack.damageItem(1, player, p -> p.sendBreakAnimation(context.getHand())); - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } @Override @@ -96,7 +96,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java index 14c1000c..9f8fec98 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -11,7 +11,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -44,7 +44,7 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { @Nullable @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { return Helper.makeRechargeProvider(stack, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java b/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java index 3589afa7..c7d77602 100644 --- a/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java +++ b/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java @@ -4,14 +4,14 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA; -import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpawnLamp; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.items.ModItems; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.LongNBT; @@ -28,30 +28,31 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; -public class WorldData implements IWorldData { +public class LevelData implements ILevelData { + public final ListMultimap> effectPowders = ArrayListMultimap.create(); public final Long2ObjectOpenHashMap auraChunksWithSpots = new Long2ObjectOpenHashMap<>(); public final List recentlyConvertedMossStones = new ArrayList<>(); - public final Set spawnLamps = new HashSet<>(); + public final Set spawnLamps = new HashSet<>(); private final Map enderStorages = new HashMap<>(); - private final LazyOptional lazyThis = LazyOptional.of(() -> this); + private final LazyOptional lazyThis = LazyOptional.of(() -> this); @Nullable @Override public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction facing) { - return capability == NaturesAuraAPI.capWorldData ? this.lazyThis.cast() : LazyOptional.empty(); + return capability == NaturesAuraAPI.capLevelData ? this.lazyThis.cast() : LazyOptional.empty(); } @Override - public CompoundNBT serializeNBT() { - CompoundNBT compound = new CompoundNBT(); + public CompoundTag serializeNBT() { + CompoundTag compound = new CompoundTag(); ListNBT storages = new ListNBT(); for (Map.Entry entry : this.enderStorages.entrySet()) { ItemStackHandlerNA handler = entry.getValue(); if (Helper.isEmpty(handler)) continue; - CompoundNBT storageComp = handler.serializeNBT(); + CompoundTag storageComp = handler.serializeNBT(); storageComp.putString("name", entry.getKey()); storages.add(storageComp); } @@ -66,10 +67,10 @@ public class WorldData implements IWorldData { } @Override - public void deserializeNBT(CompoundNBT compound) { + public void deserializeNBT(CompoundTag compound) { this.enderStorages.clear(); for (INBT base : compound.getList("storages", 10)) { - CompoundNBT storageComp = (CompoundNBT) base; + CompoundTag storageComp = (CompoundTag) base; ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name")); storage.deserializeNBT(storageComp); } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java index a189fc9c..d21cad12 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java @@ -4,11 +4,12 @@ import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.events.ClientEvents; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.level.chunk.Chunk; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraftforge.network.NetworkEvent; import org.apache.commons.lang3.mutable.MutableInt; import java.util.HashMap; @@ -30,7 +31,7 @@ public class PacketAuraChunk { private PacketAuraChunk() { } - public static PacketAuraChunk fromBytes(PacketBuffer buf) { + public static PacketAuraChunk fromBytes(FriendlyByteBuf buf) { PacketAuraChunk packet = new PacketAuraChunk(); packet.chunkX = buf.readInt(); packet.chunkZ = buf.readInt(); @@ -47,7 +48,7 @@ public class PacketAuraChunk { return packet; } - public static void toBytes(PacketAuraChunk packet, PacketBuffer buf) { + public static void toBytes(PacketAuraChunk packet, FriendlyByteBuf buf) { buf.writeInt(packet.chunkX); buf.writeInt(packet.chunkZ); @@ -63,9 +64,9 @@ public class PacketAuraChunk { ctx.get().setPacketHandled(true); } - public boolean tryHandle(World world) { + public boolean tryHandle(Level level) { try { - Chunk chunk = world.getChunk(this.chunkX, this.chunkZ); + LevelChunk chunk = level.getChunk(this.chunkX, this.chunkZ); if (chunk.isEmpty()) return false; AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null); diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketClient.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketClient.java index 0b17ee07..8caf5551 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketClient.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketClient.java @@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.PacketBuffer; import net.minecraft.particles.ParticleTypes; import net.minecraft.util.ResourceLocation; @@ -17,9 +17,9 @@ import java.util.function.Supplier; public class PacketClient { private int type; - private CompoundNBT data; + private CompoundTag data; - public PacketClient(int type, CompoundNBT data) { + public PacketClient(int type, CompoundTag data) { this.type = type; this.data = data; } @@ -47,16 +47,16 @@ public class PacketClient { @Override public void run() { Minecraft mc = Minecraft.getInstance(); - if (mc.world != null) { + if (mc.level != null) { switch (message.type) { case 0: // dimension rail visualization ResourceLocation goalDim = new ResourceLocation(message.data.getString("dim")); BlockPos goalPos = BlockPos.fromLong(message.data.getLong("pos")); ItemRangeVisualizer.visualize(mc.player, ItemRangeVisualizer.VISUALIZED_RAILS, goalDim, goalPos); case 1: - Entity entity = mc.world.getEntityByID(message.data.getInt("id")); + Entity entity = mc.level.getEntityByID(message.data.getInt("id")); mc.particles.emitParticleAtEntity(entity, ParticleTypes.TOTEM_OF_UNDYING, 30); - mc.world.playSound(entity.getPosX(), entity.getPosY(), entity.getPosZ(), SoundEvents.ITEM_TOTEM_USE, entity.getSoundCategory(), 1.0F, 1.0F, false); + mc.level.playSound(entity.getPosX(), entity.getPosY(), entity.getPosZ(), SoundEvents.ITEM_TOTEM_USE, entity.getSoundCategory(), 1.0F, 1.0F, false); if (entity == mc.player) { mc.gameRenderer.displayItemActivation(new ItemStack(ModItems.DEATH_RING)); } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java index a920e021..9811cd70 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java @@ -1,14 +1,15 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.NaturesAura; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.network.NetworkRegistry; -import net.minecraftforge.fml.network.PacketDistributor; -import net.minecraftforge.fml.network.simple.SimpleChannel; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraftforge.network.NetworkRegistry; +import net.minecraftforge.network.PacketDistributor; +import net.minecraftforge.network.simple.SimpleChannel; public final class PacketHandler { @@ -23,15 +24,15 @@ public final class PacketHandler { network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient::onMessage); } - public static void sendToAllLoaded(World world, BlockPos pos, Object message) { - network.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), message); + public static void sendToAllLoaded(Level level, BlockPos pos, Object message) { + network.send(PacketDistributor.TRACKING_CHUNK.with(() -> level.getChunkAt(pos)), message); } - public static void sendToAllAround(World world, BlockPos pos, int range, Object message) { - network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, world.func_234923_W_())), message); + public static void sendToAllAround(Level level, BlockPos pos, int range, Object message) { + network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.func_234923_W_())), message); } - public static void sendTo(PlayerEntity player, Object message) { - network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), message); + public static void sendTo(Player player, Object message) { + network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message); } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java index bf4c1727..03f0b504 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; @@ -35,7 +35,7 @@ public class PacketParticleStream { private PacketParticleStream() { } - public static PacketParticleStream fromBytes(PacketBuffer buf) { + public static PacketParticleStream fromBytes(FriendlyByteBuf buf) { PacketParticleStream packet = new PacketParticleStream(); packet.startX = buf.readFloat(); @@ -51,7 +51,7 @@ public class PacketParticleStream { return packet; } - public static void toBytes(PacketParticleStream packet, PacketBuffer buf) { + public static void toBytes(PacketParticleStream packet, FriendlyByteBuf buf) { buf.writeFloat(packet.startX); buf.writeFloat(packet.startY); buf.writeFloat(packet.startZ); diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 32448ed9..f2fd45ce 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -5,17 +5,17 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.entities.EntityStructureFinder; -import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.network.PacketBuffer; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.level.biome.BiomeColors; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeColors; -import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraftforge.network.NetworkEvent; import java.util.function.BiConsumer; import java.util.function.Supplier; @@ -39,7 +39,7 @@ public class PacketParticles { private PacketParticles() { } - public static PacketParticles fromBytes(PacketBuffer buf) { + public static PacketParticles fromBytes(FriendlyByteBuf buf) { PacketParticles packet = new PacketParticles(); packet.posX = buf.readFloat(); @@ -55,7 +55,7 @@ public class PacketParticles { return packet; } - public static void toBytes(PacketParticles packet, PacketBuffer buf) { + public static void toBytes(PacketParticles packet, FriendlyByteBuf buf) { buf.writeFloat(packet.posX); buf.writeFloat(packet.posY); buf.writeFloat(packet.posZ); @@ -73,76 +73,76 @@ public class PacketParticles { ctx.get().enqueueWork(new Runnable() { @Override public void run() { - World world = Minecraft.getInstance().world; - if (world != null) - message.type.action.accept(message, world); + Level level = Minecraft.getInstance().level; + if (level != null) + message.type.action.accept(message, level); } }); ctx.get().setPacketHandled(true); } public enum Type { - TR_GOLD_POWDER((message, world) -> { + TR_GOLD_POWDER((message, level) -> { BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> { - BlockState state = world.getBlockState(dustPos); - AxisAlignedBB box = state.getShape(world, dustPos).getBoundingBox(); + BlockState state = level.getBlockState(dustPos); + AABB box = state.getShape(level, dustPos).getBoundingBox(); NaturesAuraAPI.instance().spawnMagicParticle( - dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(), + dustPos.getX() + box.minX + (box.maxX - box.minX) * level.rand.nextFloat(), dustPos.getY() + 0.1F, - dustPos.getZ() + box.minZ + (box.maxZ - box.minZ) * world.rand.nextFloat(), - (float) world.rand.nextGaussian() * 0.02F, - world.rand.nextFloat() * 0.01F + 0.02F, - (float) world.rand.nextGaussian() * 0.02F, + dustPos.getZ() + box.minZ + (box.maxZ - box.minZ) * level.rand.nextFloat(), + (float) level.rand.nextGaussian() * 0.02F, + level.rand.nextFloat() * 0.01F + 0.02F, + (float) level.rand.nextGaussian() * 0.02F, 0xf4cb42, 2F, 50, 0F, false, true); return true; }); }), - TR_CONSUME_ITEM((message, world) -> { - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) { + TR_CONSUME_ITEM((message, level) -> { + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( message.posX + 0.5F, message.posY + 0.9F, message.posZ + 0.5F, - (float) world.rand.nextGaussian() * 0.04F, world.rand.nextFloat() * 0.04F, (float) world.rand.nextGaussian() * 0.04F, + (float) level.rand.nextGaussian() * 0.04F, level.rand.nextFloat() * 0.04F, (float) level.rand.nextGaussian() * 0.04F, 0x89cc37, 1.5F, 25, 0F, false, true); } }), - TR_DISAPPEAR((message, world) -> { - for (int i = world.rand.nextInt(5) + 3; i >= 0; i--) { + TR_DISAPPEAR((message, level) -> { + for (int i = level.rand.nextInt(5) + 3; i >= 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat(), message.posY + world.rand.nextFloat(), message.posZ + world.rand.nextFloat(), + message.posX + level.rand.nextFloat(), message.posY + level.rand.nextFloat(), message.posZ + level.rand.nextFloat(), 0F, 0F, 0F, 0x33FF33, 1F, 50, 0F, false, true); } }), - TR_SPAWN_RESULT((message, world) -> { - for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) { + TR_SPAWN_RESULT((message, level) -> { + for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY, message.posZ, - world.rand.nextGaussian() * 0.1F, world.rand.nextGaussian() * 0.1F, world.rand.nextGaussian() * 0.1F, + level.rand.nextGaussian() * 0.1F, level.rand.nextGaussian() * 0.1F, level.rand.nextGaussian() * 0.1F, 0x89cc37, 2F, 100, 0F, true, true); } }), - ALTAR_CONVERSION((message, world) -> { + ALTAR_CONVERSION((message, level) -> { int color = message.data[0]; - for (int i = world.rand.nextInt(5) + 2; i >= 0; i--) { + for (int i = level.rand.nextInt(5) + 2; i >= 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, - message.posY + 0.9F + 0.25F * world.rand.nextFloat(), - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.02F, world.rand.nextFloat() * 0.02F, world.rand.nextGaussian() * 0.02F, - color, world.rand.nextFloat() * 1.5F + 0.75F, 20, 0F, false, true); + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, + message.posY + 0.9F + 0.25F * level.rand.nextFloat(), + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.02F, level.rand.nextFloat() * 0.02F, level.rand.nextGaussian() * 0.02F, + color, level.rand.nextFloat() * 1.5F + 0.75F, 20, 0F, false, true); } }), - POTION_GEN((message, world) -> { + POTION_GEN((message, level) -> { int color = message.data[0]; boolean releaseAura = message.data[1] > 0; - for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) { + for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) { NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat(), + message.posX + level.rand.nextFloat(), message.posY + 1.1F, - message.posZ + world.rand.nextFloat(), - world.rand.nextGaussian() * 0.01F, world.rand.nextFloat() * 0.1F, world.rand.nextGaussian() * 0.01F, - color, 2F + world.rand.nextFloat(), 40, 0F, true, true); + message.posZ + level.rand.nextFloat(), + level.rand.nextGaussian() * 0.01F, level.rand.nextFloat() * 0.1F, level.rand.nextGaussian() * 0.01F, + color, 2F + level.rand.nextFloat(), 40, 0F, true, true); if (releaseAura) for (int x = -1; x <= 1; x += 2) @@ -151,66 +151,66 @@ public class PacketParticles { message.posX + x * 3 + 0.5F, message.posY + 2.5, message.posZ + z * 3 + 0.5F, - world.rand.nextGaussian() * 0.02F, - world.rand.nextFloat() * 0.04F, - world.rand.nextGaussian() * 0.02F, - 0xd6340c, 1F + world.rand.nextFloat() * 2F, 75, 0F, true, true); + level.rand.nextGaussian() * 0.02F, + level.rand.nextFloat() * 0.04F, + level.rand.nextGaussian() * 0.02F, + 0xd6340c, 1F + level.rand.nextFloat() * 2F, 75, 0F, true, true); } } }), - PLANT_BOOST((message, world) -> { - for (int i = world.rand.nextInt(20) + 15; i >= 0; i--) + PLANT_BOOST((message, level) -> { + for (int i = level.rand.nextInt(20) + 15; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat(), - message.posY + 0.25F + world.rand.nextFloat() * 0.5F, - message.posZ + world.rand.nextFloat(), - 0F, world.rand.nextFloat() * 0.02F, 0F, - 0x5ccc30, 1F + world.rand.nextFloat() * 2F, 50, 0F, false, true); + message.posX + level.rand.nextFloat(), + message.posY + 0.25F + level.rand.nextFloat() * 0.5F, + message.posZ + level.rand.nextFloat(), + 0F, level.rand.nextFloat() * 0.02F, 0F, + 0x5ccc30, 1F + level.rand.nextFloat() * 2F, 50, 0F, false, true); }), - FLOWER_GEN_CONSUME((message, world) -> { + FLOWER_GEN_CONSUME((message, level) -> { int color = message.data[0]; - for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, - message.posY + 0.25F + world.rand.nextFloat() * 0.5F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.02F, - world.rand.nextGaussian() * 0.02F, - world.rand.nextGaussian() * 0.02F, - color, world.rand.nextFloat() * 2F + 1F, 25, 0F, false, true); + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, + message.posY + 0.25F + level.rand.nextFloat() * 0.5F, + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.02F, + level.rand.nextGaussian() * 0.02F, + level.rand.nextGaussian() * 0.02F, + color, level.rand.nextFloat() * 2F + 1F, 25, 0F, false, true); }), - FLOWER_GEN_AURA_CREATION((message, world) -> { - for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) + FLOWER_GEN_AURA_CREATION((message, level) -> { + for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 1.01F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true); + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + 0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); }), - PLACER_PLACING((message, world) -> { - for (int i = world.rand.nextInt(20) + 20; i >= 0; i--) { - boolean side = world.rand.nextBoolean(); - float x = side ? world.rand.nextFloat() : world.rand.nextBoolean() ? 1.1F : -0.1F; - float z = !side ? world.rand.nextFloat() : world.rand.nextBoolean() ? 1.1F : -0.1F; + PLACER_PLACING((message, level) -> { + for (int i = level.rand.nextInt(20) + 20; i >= 0; i--) { + boolean side = level.rand.nextBoolean(); + float x = side ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; + float z = !side ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + x, message.posY + 0.1F + world.rand.nextFloat() * 0.98F, message.posZ + z, + message.posX + x, message.posY + 0.1F + level.rand.nextFloat() * 0.98F, message.posZ + z, 0F, 0F, 0F, - 0xad7a37, world.rand.nextFloat() + 1F, 50, 0F, true, true); + 0xad7a37, level.rand.nextFloat() + 1F, 50, 0F, true, true); } }), - HOPPER_UPGRADE((message, world) -> { - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + HOPPER_UPGRADE((message, level) -> { + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY + 0.45F, message.posZ, - world.rand.nextGaussian() * 0.015F, - world.rand.nextGaussian() * 0.015F, - world.rand.nextGaussian() * 0.015F, - 0xdde7ff, world.rand.nextFloat() + 1F, 30, -0.06F, true, true); + level.rand.nextGaussian() * 0.015F, + level.rand.nextGaussian() * 0.015F, + level.rand.nextGaussian() * 0.015F, + 0xdde7ff, level.rand.nextFloat() + 1F, 30, -0.06F, true, true); }), - SHOCKWAVE_CREATOR((message, world) -> { + SHOCKWAVE_CREATOR((message, level) -> { for (int i = 0; i < 360; i += 2) { double rad = Math.toRadians(i); NaturesAuraAPI.instance().spawnMagicParticle( @@ -221,311 +221,311 @@ public class PacketParticles { 0x911b07, 3F, 10, 0F, false, true); } }), - OAK_GENERATOR((message, world) -> { + OAK_GENERATOR((message, level) -> { int sapX = message.data[0]; int sapY = message.data[1]; int sapZ = message.data[2]; boolean releaseAura = message.data[3] > 0; - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnParticleStream( - sapX + 0.5F + (float) world.rand.nextGaussian() * 3F, - sapY + 0.5F + world.rand.nextFloat() * 4F, - sapZ + 0.5F + (float) world.rand.nextGaussian() * 3F, + sapX + 0.5F + (float) level.rand.nextGaussian() * 3F, + sapY + 0.5F + level.rand.nextFloat() * 4F, + sapZ + 0.5F + (float) level.rand.nextGaussian() * 3F, message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, - 0.6F, BiomeColors.getGrassColor(world, new BlockPos(sapX, sapY, sapZ)), 1.5F); + 0.6F, BiomeColors.getGrassColor(level, new BlockPos(sapX, sapY, sapZ)), 1.5F); if (releaseAura) - for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 1.01F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.03F, - world.rand.nextFloat() * 0.04F + 0.04F, - world.rand.nextGaussian() * 0.03F, - 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 60, 0F, false, true); + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.03F, + level.rand.nextFloat() * 0.04F + 0.04F, + level.rand.nextGaussian() * 0.03F, + 0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 60, 0F, false, true); }), - OFFERING_TABLE((message, world) -> { + OFFERING_TABLE((message, level) -> { int genX = message.data[0]; int genY = message.data[1]; int genZ = message.data[2]; - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY + 0.5F, message.posZ, - world.rand.nextGaussian() * 0.02F, - world.rand.nextFloat() * 0.25F, - world.rand.nextGaussian() * 0.02F, + level.rand.nextGaussian() * 0.02F, + level.rand.nextFloat() * 0.25F, + level.rand.nextGaussian() * 0.02F, 0xffadfd, 1.5F, 40, 0F, false, true); - for (int i = world.rand.nextInt(50) + 30; i >= 0; i--) + for (int i = level.rand.nextInt(50) + 30; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - genX + 0.5F + world.rand.nextGaussian() * 2.5F, + genX + 0.5F + level.rand.nextGaussian() * 2.5F, genY + 0.1F, - genZ + 0.5F + world.rand.nextGaussian() * 2.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.01F, - world.rand.nextGaussian() * 0.01F, + genZ + 0.5F + level.rand.nextGaussian() * 2.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.01F, + level.rand.nextGaussian() * 0.01F, 0xd3e4ff, 1.5F, 150, 0F, false, true); }), - PICKUP_STOPPER((message, world) -> { + PICKUP_STOPPER((message, level) -> { NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY + 0.4F, message.posZ, - world.rand.nextGaussian() * 0.005F, - world.rand.nextFloat() * 0.005F, - world.rand.nextGaussian() * 0.005F, + level.rand.nextGaussian() * 0.005F, + level.rand.nextFloat() * 0.005F, + level.rand.nextGaussian() * 0.005F, 0xcc3116, 1.5F, 40, 0F, false, true); }), - SPAWN_LAMP((message, world) -> { - for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) + SPAWN_LAMP((message, level) -> { + for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.3F + world.rand.nextFloat() * 0.4F, - message.posY + 0.15F + world.rand.nextFloat() * 0.5F, - message.posZ + 0.3F + world.rand.nextFloat() * 0.4F, + message.posX + 0.3F + level.rand.nextFloat() * 0.4F, + message.posY + 0.15F + level.rand.nextFloat() * 0.5F, + message.posZ + 0.3F + level.rand.nextFloat() * 0.4F, 0F, 0F, 0F, 0xf4a142, 1F, 30, 0F, false, true); }), - ANIMAL_GEN_CREATE((message, world) -> { - for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) + ANIMAL_GEN_CREATE((message, level) -> { + for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 1.01F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - 0xd13308, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true); + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + 0xd13308, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); }), - ANIMAL_GEN_CONSUME((message, world) -> { + ANIMAL_GEN_CONSUME((message, level) -> { boolean child = message.data[0] > 0; float height = message.data[1] / 10F; int genX = message.data[2]; int genY = message.data[3]; int genZ = message.data[4]; - for (int i = child ? world.rand.nextInt(10) + 10 : world.rand.nextInt(20) + 20; i >= 0; i--) + for (int i = child ? level.rand.nextInt(10) + 10 : level.rand.nextInt(20) + 20; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextGaussian() * 0.25F, - message.posY + height * 0.75F + world.rand.nextGaussian() * 0.25F, - message.posZ + world.rand.nextGaussian() * 0.25F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.01F, - world.rand.nextGaussian() * 0.01F, - 0x42f4c8, world.rand.nextFloat() * (child ? 0.5F : 2F) + 1F, world.rand.nextInt(30) + 40, 0F, true, true); + message.posX + level.rand.nextGaussian() * 0.25F, + message.posY + height * 0.75F + level.rand.nextGaussian() * 0.25F, + message.posZ + level.rand.nextGaussian() * 0.25F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.01F, + level.rand.nextGaussian() * 0.01F, + 0x42f4c8, level.rand.nextFloat() * (child ? 0.5F : 2F) + 1F, level.rand.nextInt(30) + 40, 0F, true, true); NaturesAuraAPI.instance().spawnParticleStream( message.posX, message.posY + height * 0.75F, message.posZ, genX + 0.5F, genY + 0.5F, genZ + 0.5F, 0.15F, 0x41c4f4, child ? 1.5F : 3F); }), - END_FLOWER_DECAY((message, world) -> { + END_FLOWER_DECAY((message, level) -> { int color = message.data[0]; - for (int i = world.rand.nextInt(10) + 20; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 20; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat(), - message.posY + world.rand.nextFloat(), - message.posZ + world.rand.nextFloat(), - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.01F, - world.rand.nextGaussian() * 0.01F, + message.posX + level.rand.nextFloat(), + message.posY + level.rand.nextFloat(), + message.posZ + level.rand.nextFloat(), + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.01F, + level.rand.nextGaussian() * 0.01F, color, 1.5F, 80, 0F, true, true); }), - ANIMAL_SPAWNER((message, world) -> { - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + ANIMAL_SPAWNER((message, level) -> { + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY + 0.5F, message.posZ, - world.rand.nextGaussian() * 0.02F, - world.rand.nextFloat() * 0.02F, - world.rand.nextGaussian() * 0.02F, + level.rand.nextGaussian() * 0.02F, + level.rand.nextFloat() * 0.02F, + level.rand.nextGaussian() * 0.02F, 0x16b7b2, 1.5F, 40, 0F, false, true); }), - RF_CONVERTER((message, world) -> { - for (int i = world.rand.nextInt(5) + 2; i >= 0; i--) + RF_CONVERTER((message, level) -> { + for (int i = level.rand.nextInt(5) + 2; i >= 0; i--) Multiblocks.RF_CONVERTER.forEach(new BlockPos(message.posX, message.posY, message.posZ), 'R', (blockPos, matcher) -> { - if (world.rand.nextFloat() < 0.35F) { + if (level.rand.nextFloat() < 0.35F) { NaturesAuraAPI.instance().spawnParticleStream( - blockPos.getX() + world.rand.nextFloat(), - blockPos.getY() + world.rand.nextFloat(), - blockPos.getZ() + world.rand.nextFloat(), - message.posX + world.rand.nextFloat(), - message.posY + world.rand.nextFloat(), - message.posZ + world.rand.nextFloat(), + blockPos.getX() + level.rand.nextFloat(), + blockPos.getY() + level.rand.nextFloat(), + blockPos.getZ() + level.rand.nextFloat(), + message.posX + level.rand.nextFloat(), + message.posY + level.rand.nextFloat(), + message.posZ + level.rand.nextFloat(), 0.05F, 0xff1a05, 1.5F); } return true; }); }), - END_FLOWER_CONSUME((message, world) -> { + END_FLOWER_CONSUME((message, level) -> { int color = message.data[0]; - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( message.posX, message.posY + 0.5F, message.posZ, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.01F, - world.rand.nextGaussian() * 0.01F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.01F, + level.rand.nextGaussian() * 0.01F, color, 1.5F, 40, 0F, false, true); }), - MOVER_CART((message, world) -> { + MOVER_CART((message, level) -> { float motionX = message.data[0] / 100F; float motionY = message.data[1] / 100F; float motionZ = message.data[2] / 100F; - for (int i = world.rand.nextInt(60) + 30; i >= 0; i--) + for (int i = level.rand.nextInt(60) + 30; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextGaussian() * 10F, - message.posY + world.rand.nextGaussian() * 10F, - message.posZ + world.rand.nextGaussian() * 10F, + message.posX + level.rand.nextGaussian() * 10F, + message.posY + level.rand.nextGaussian() * 10F, + message.posZ + level.rand.nextGaussian() * 10F, motionX * 0.2F, motionY * 0.2F, motionZ * 0.2F, - IAuraType.forWorld(world).getColor(), 2F, 30, 0F, false, true); + IAuraType.forLevel(level).getColor(), 2F, 30, 0F, false, true); }), - MOSS_GENERATOR((message, world) -> { - for (int i = world.rand.nextInt(30) + 30; i >= 0; i--) { - int side = world.rand.nextInt(3); - float x = side != 0 ? world.rand.nextFloat() : world.rand.nextBoolean() ? 1.1F : -0.1F; - float y = side != 1 ? world.rand.nextFloat() : world.rand.nextBoolean() ? 1.1F : -0.1F; - float z = side != 2 ? world.rand.nextFloat() : world.rand.nextBoolean() ? 1.1F : -0.1F; + MOSS_GENERATOR((message, level) -> { + for (int i = level.rand.nextInt(30) + 30; i >= 0; i--) { + int side = level.rand.nextInt(3); + float x = side != 0 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; + float y = side != 1 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; + float z = side != 2 ? level.rand.nextFloat() : level.rand.nextBoolean() ? 1.1F : -0.1F; NaturesAuraAPI.instance().spawnMagicParticle( message.posX + x, message.posY + y, message.posZ + z, 0F, 0F, 0F, - 0x184c0d, world.rand.nextFloat() + 1F, 30, 0F, true, true); + 0x184c0d, level.rand.nextFloat() + 1F, 30, 0F, true, true); } - for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + for (int i = level.rand.nextInt(20) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat(), + message.posX + level.rand.nextFloat(), message.posY + 1F, - message.posZ + world.rand.nextFloat(), - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, true, true); + message.posZ + level.rand.nextFloat(), + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + 0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, true, true); }), - FIREWORK_GEN((message, world) -> { + FIREWORK_GEN((message, level) -> { int goalX = message.data[0]; int goalY = message.data[1]; int goalZ = message.data[2]; NaturesAuraAPI.instance().setParticleSpawnRange(64); - for (int i = world.rand.nextInt(30) + 30; i >= 0; i--) + for (int i = level.rand.nextInt(30) + 30; i >= 0; i--) NaturesAuraAPI.instance().spawnParticleStream( - message.posX + (float) world.rand.nextGaussian(), - message.posY + (float) world.rand.nextGaussian(), - message.posZ + (float) world.rand.nextGaussian(), - goalX + 0.25F + world.rand.nextFloat() * 0.5F, - goalY + 0.25F + world.rand.nextFloat() * 0.5F, - goalZ + 0.25F + world.rand.nextFloat() * 0.5F, - 0.65F, message.data[3 + world.rand.nextInt(message.data.length - 3)], 1F); + message.posX + (float) level.rand.nextGaussian(), + message.posY + (float) level.rand.nextGaussian(), + message.posZ + (float) level.rand.nextGaussian(), + goalX + 0.25F + level.rand.nextFloat() * 0.5F, + goalY + 0.25F + level.rand.nextFloat() * 0.5F, + goalZ + 0.25F + level.rand.nextFloat() * 0.5F, + 0.65F, message.data[3 + level.rand.nextInt(message.data.length - 3)], 1F); NaturesAuraAPI.instance().setParticleSpawnRange(32); }), - DIMENSION_RAIL((message, world) -> { + DIMENSION_RAIL((message, level) -> { float width = message.data[0] / 100F; float height = message.data[1] / 100F; float depth = message.data[2] / 100F; - for (int i = world.rand.nextInt(100) + 50; i >= 0; i--) + for (int i = level.rand.nextInt(100) + 50; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextFloat() * width, - message.posY + world.rand.nextFloat() * height, - message.posZ + world.rand.nextFloat() * depth, - 0F, 0F, 0F, 0xd60cff, 1F + world.rand.nextFloat(), 60, 0F, false, true); + message.posX + level.rand.nextFloat() * width, + message.posY + level.rand.nextFloat() * height, + message.posZ + level.rand.nextFloat() * depth, + 0F, 0F, 0F, 0xd60cff, 1F + level.rand.nextFloat(), 60, 0F, false, true); }), - PROJECTILE_GEN((message, world) -> { + PROJECTILE_GEN((message, level) -> { int x = message.data[0]; int y = message.data[1]; int z = message.data[2]; - for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - x + 0.25F + world.rand.nextFloat() * 0.5F, + x + 0.25F + level.rand.nextFloat() * 0.5F, y + 1.01F, - z + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - 0x5ccc30, 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true); - for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) - world.addParticle(ParticleTypes.FIREWORK, + z + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + 0x5ccc30, 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); + for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) + level.addParticle(ParticleTypes.FIREWORK, message.posX, message.posY, message.posZ, - world.rand.nextGaussian() * 0.03F, - world.rand.nextGaussian() * 0.03F, - world.rand.nextGaussian() * 0.03F); + level.rand.nextGaussian() * 0.03F, + level.rand.nextGaussian() * 0.03F, + level.rand.nextGaussian() * 0.03F); }), - BLAST_FURNACE_BOOSTER((message, world) -> { + BLAST_FURNACE_BOOSTER((message, level) -> { boolean worked = message.data[0] > 0; - for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) - world.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, - message.posX + 5 / 16F + world.rand.nextInt(6) / 16F, + for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) + level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, + message.posX + 5 / 16F + level.rand.nextInt(6) / 16F, message.posY + 0.6F, - message.posZ + 5 / 16F + world.rand.nextInt(6) / 16F, - world.rand.nextGaussian() * 0.005F, - world.rand.nextFloat() * 0.02F + 0.01F, - world.rand.nextGaussian() * 0.005F); + message.posZ + 5 / 16F + level.rand.nextInt(6) / 16F, + level.rand.nextGaussian() * 0.005F, + level.rand.nextFloat() * 0.02F + 0.01F, + level.rand.nextGaussian() * 0.005F); if (worked) { BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); - int color = IAuraChunk.getAuraChunk(world, pos).getType().getColor(); - for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) + int color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); + for (int i = level.rand.nextInt(10) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnParticleStream( - message.posX + (float) world.rand.nextGaussian() * 5, - message.posY + world.rand.nextFloat() * 5, - message.posZ + (float) world.rand.nextGaussian() * 5, + message.posX + (float) level.rand.nextGaussian() * 5, + message.posY + level.rand.nextFloat() * 5, + message.posZ + (float) level.rand.nextGaussian() * 5, message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, - 0.25F, color, 0.5F + world.rand.nextFloat() + 0.25F, color, 0.5F + level.rand.nextFloat() ); } }), - ANIMAL_CONTAINER((message, world) -> { - for (int i = world.rand.nextInt(2) + 1; i > 0; i--) + ANIMAL_CONTAINER((message, level) -> { + for (int i = level.rand.nextInt(2) + 1; i > 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + world.rand.nextGaussian() * 0.15F, - message.posY - world.rand.nextFloat() * 0.5F, - message.posZ + world.rand.nextGaussian() * 0.15F, - 0, 0, 0, 0x42e9f5, 1 + world.rand.nextFloat() * 2, 40, 0, false, true + message.posX + level.rand.nextGaussian() * 0.15F, + message.posY - level.rand.nextFloat() * 0.5F, + message.posZ + level.rand.nextGaussian() * 0.15F, + 0, 0, 0, 0x42e9f5, 1 + level.rand.nextFloat() * 2, 40, 0, false, true ); }), - SNOW_CREATOR((message, world) -> { + SNOW_CREATOR((message, level) -> { BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); - int color = IAuraChunk.getAuraChunk(world, pos).getType().getColor(); - for (int i = world.rand.nextInt(3) + 1; i > 0; i--) + int color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); + for (int i = level.rand.nextInt(3) + 1; i > 0; i--) NaturesAuraAPI.instance().spawnParticleStream( - message.posX + (float) world.rand.nextGaussian() * 5, - message.posY + world.rand.nextFloat() * 5, - message.posZ + (float) world.rand.nextGaussian() * 5, + message.posX + (float) level.rand.nextGaussian() * 5, + message.posY + level.rand.nextFloat() * 5, + message.posZ + (float) level.rand.nextGaussian() * 5, message.posX + 0.5F, message.posY + 0.5F, message.posZ + 0.5F, - 0.25F, color, 0.5F + world.rand.nextFloat() + 0.25F, color, 0.5F + level.rand.nextFloat() ); }), - CHORUS_GENERATOR((message, world) -> { + CHORUS_GENERATOR((message, level) -> { int chorusX = message.data[0]; int chorusY = message.data[1]; int chorusZ = message.data[2]; - for (int i = world.rand.nextInt(5) + 3; i >= 0; i--) + for (int i = level.rand.nextInt(5) + 3; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - chorusX + world.rand.nextFloat(), chorusY + world.rand.nextFloat(), chorusZ + world.rand.nextFloat(), + chorusX + level.rand.nextFloat(), chorusY + level.rand.nextFloat(), chorusZ + level.rand.nextFloat(), 0F, 0F, 0F, - 0xbb0be3, 1F + world.rand.nextFloat(), 50, 0F, false, true); - for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) + 0xbb0be3, 1F + level.rand.nextFloat(), 50, 0F, false, true); + for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 1.01F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - IAuraType.forWorld(world).getColor(), 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true); + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + IAuraType.forLevel(level).getColor(), 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); }), - TIMER_RESET((message, world) -> { + TIMER_RESET((message, level) -> { int color = message.data[0]; - for (int i = world.rand.nextInt(10) + 15; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 15; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 5 / 16F + world.rand.nextFloat() * 6 / 16F, - message.posY + 2 / 16F + world.rand.nextFloat() * 8 / 16F, - message.posZ + 5 / 16F + world.rand.nextFloat() * 6 / 16F, - 0, 0, 0, color, 2, 40 + world.rand.nextInt(20), 0, false, true); + message.posX + 5 / 16F + level.rand.nextFloat() * 6 / 16F, + message.posY + 2 / 16F + level.rand.nextFloat() * 8 / 16F, + message.posZ + 5 / 16F + level.rand.nextFloat() * 6 / 16F, + 0, 0, 0, color, 2, 40 + level.rand.nextInt(20), 0, false, true); }), - STRUCTURE_FINDER((message, world) -> { - EntityStructureFinder entity = (EntityStructureFinder) world.getEntityByID(message.data[0]); - WorldRenderer renderer = Minecraft.getInstance().worldRenderer; + STRUCTURE_FINDER((message, level) -> { + EntityStructureFinder entity = (EntityStructureFinder) level.getEntityByID(message.data[0]); + LevelRenderer renderer = Minecraft.getInstance().levelRenderer; double d0 = message.posX + 0.5D; double d13 = message.posY; double d18 = message.posZ + 0.5D; for (int j2 = 0; j2 < 8; ++j2) - renderer.addParticle(new ItemParticleData(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, world.rand.nextGaussian() * 0.15D, world.rand.nextDouble() * 0.2D, world.rand.nextGaussian() * 0.15D); + renderer.addParticle(new ItemParticleData(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, level.rand.nextGaussian() * 0.15D, level.rand.nextDouble() * 0.2D, level.rand.nextGaussian() * 0.15D); int color = entity.getDataManager().get(EntityStructureFinder.COLOR); for (double d24 = 0.0D; d24 < (Math.PI * 2D); d24 += 0.15707963267948966D) { @@ -533,53 +533,53 @@ public class PacketParticles { NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2.5, 0.0D, Math.sin(d24) * -2.5, color, 2, 60, 0, false, true); } }), - SLIME_SPLIT_GEN_CREATE((message, world) -> { - for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) + SLIME_SPLIT_GEN_CREATE((message, level) -> { + for (int i = level.rand.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + 0.25F + world.rand.nextFloat() * 0.5F, + message.posX + 0.25F + level.rand.nextFloat() * 0.5F, message.posY + 1.01F, - message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, - world.rand.nextGaussian() * 0.01F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.01F, - message.data[0], 1F + world.rand.nextFloat() * 1.5F, 40, 0F, false, true); + message.posZ + 0.25F + level.rand.nextFloat() * 0.5F, + level.rand.nextGaussian() * 0.01F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.01F, + message.data[0], 1F + level.rand.nextFloat() * 1.5F, 40, 0F, false, true); }), - SLIME_SPLIT_GEN_START((message, world) -> { + SLIME_SPLIT_GEN_START((message, level) -> { int x = message.data[0]; int y = message.data[1]; int z = message.data[2]; int color = message.data[3]; - for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) + for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + (float) world.rand.nextGaussian() * 0.5F, - message.posY + (float) world.rand.nextGaussian() * 0.5F, - message.posZ + (float) world.rand.nextGaussian() * 0.5F, - world.rand.nextGaussian() * 0.02F, - world.rand.nextFloat() * 0.04F + 0.02F, - world.rand.nextGaussian() * 0.02F, - color, world.rand.nextFloat() + 1, world.rand.nextInt(20) + 20, 0, false, true); - for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) + message.posX + (float) level.rand.nextGaussian() * 0.5F, + message.posY + (float) level.rand.nextGaussian() * 0.5F, + message.posZ + (float) level.rand.nextGaussian() * 0.5F, + level.rand.nextGaussian() * 0.02F, + level.rand.nextFloat() * 0.04F + 0.02F, + level.rand.nextGaussian() * 0.02F, + color, level.rand.nextFloat() + 1, level.rand.nextInt(20) + 20, 0, false, true); + for (int i = level.rand.nextInt(10) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnParticleStream( - message.posX + (float) world.rand.nextGaussian() * 0.5F, - message.posY + (float) world.rand.nextGaussian() * 0.5F, - message.posZ + (float) world.rand.nextGaussian() * 0.5F, - x + 0.5F, y + 0.5F, z + 0.5F, 0.2F, color, world.rand.nextFloat() + 1); + message.posX + (float) level.rand.nextGaussian() * 0.5F, + message.posY + (float) level.rand.nextGaussian() * 0.5F, + message.posZ + (float) level.rand.nextGaussian() * 0.5F, + x + 0.5F, y + 0.5F, z + 0.5F, 0.2F, color, level.rand.nextFloat() + 1); }), - PET_REVIVER((message, world) -> { - for (int i = world.rand.nextInt(50) + 150; i >= 0; i--) + PET_REVIVER((message, level) -> { + for (int i = level.rand.nextInt(50) + 150; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - message.posX + (float) world.rand.nextGaussian() * 0.4F, - message.posY + (float) world.rand.nextGaussian() * 0.4F, - message.posZ + (float) world.rand.nextGaussian() * 0.4F, - world.rand.nextGaussian() * 0.002F, - world.rand.nextFloat() * 0.001F + 0.002F, - world.rand.nextGaussian() * 0.002F, - message.data[0], world.rand.nextFloat() * 2 + 1, world.rand.nextInt(50) + 50, 0, false, true); + message.posX + (float) level.rand.nextGaussian() * 0.4F, + message.posY + (float) level.rand.nextGaussian() * 0.4F, + message.posZ + (float) level.rand.nextGaussian() * 0.4F, + level.rand.nextGaussian() * 0.002F, + level.rand.nextFloat() * 0.001F + 0.002F, + level.rand.nextGaussian() * 0.002F, + message.data[0], level.rand.nextFloat() * 2 + 1, level.rand.nextInt(50) + 50, 0, false, true); }); - public final BiConsumer action; + public final BiConsumer action; - Type(BiConsumer action) { + Type(BiConsumer action) { this.action = action; } } diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index 2b0ff32a..5419dede 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -71,12 +71,12 @@ public final class ParticleHandler { if (ModConfig.instance.respectVanillaParticleSettings.get()) { ParticleStatus setting = mc.gameSettings.particles; if (setting != ParticleStatus.ALL && - (setting != ParticleStatus.DECREASED || mc.world.rand.nextInt(3) != 0) && - (setting != ParticleStatus.MINIMAL || mc.world.rand.nextInt(10) != 0)) + (setting != ParticleStatus.DECREASED || mc.level.rand.nextInt(3) != 0) && + (setting != ParticleStatus.MINIMAL || mc.level.rand.nextInt(10) != 0)) return; } double setting = ModConfig.instance.particleAmount.get(); - if (setting < 1 && mc.world.rand.nextDouble() > setting) + if (setting < 1 && mc.level.rand.nextDouble() > setting) return; } mc.particles.addEffect(particle.get()); diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java index f419bfd3..642dfe2a 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java @@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.NaturesAura; import net.minecraft.client.particle.IParticleRenderType; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.world.ClientWorld; +import net.minecraft.client.level.ClientLevel; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.ReuseableStream; @@ -29,8 +29,8 @@ public class ParticleMagic extends Particle { private final boolean depth; private float particleScale; - public ParticleMagic(ClientWorld world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade, boolean depth) { - super(world, posX, posY, posZ); + public ParticleMagic(ClientLevel level, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade, boolean depth) { + super(level, posX, posY, posZ); this.desiredScale = scale; this.maxAge = maxAge; this.canCollide = collision; @@ -78,7 +78,7 @@ public class ParticleMagic extends Particle { public void move(double x, double y, double z) { double lastY = y; if (this.canCollide && (x != 0 || y != 0 || z != 0)) { - Vector3d motion = Entity.collideBoundingBoxHeuristically(null, new Vector3d(x, y, z), this.getBoundingBox(), this.world, ISelectionContext.dummy(), new ReuseableStream<>(Stream.empty())); + Vector3d motion = Entity.collideBoundingBoxHeuristically(null, new Vector3d(x, y, z), this.getBoundingBox(), this.level, ISelectionContext.dummy(), new ReuseableStream<>(Stream.empty())); x = motion.x; y = motion.y; z = motion.z; diff --git a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java index 79080919..80744678 100644 --- a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java @@ -19,14 +19,14 @@ import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.entity.PlayerRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.BlockEntityRenderer; +import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.item.Item; import net.minecraft.item.ItemModelsProperties; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.tileentity.BlockEntityType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraftforge.common.MinecraftForge; @@ -49,9 +49,9 @@ public class ClientProxy implements IProxy { ScreenManager.registerFactory(ModContainers.ENDER_ACCESS, GuiEnderCrate::new); ItemModelsProperties.func_239418_a_(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "fill_mode"), - (stack, worldIn, entityIn) -> ItemColorChanger.isFillMode(stack) ? 1F : 0F); + (stack, levelIn, entityIn) -> ItemColorChanger.isFillMode(stack) ? 1F : 0F); ItemModelsProperties.func_239418_a_(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "has_color"), - (stack, worldIn, entityIn) -> ItemColorChanger.getStoredColor(stack) != null ? 1F : 0F); + (stack, levelIn, entityIn) -> ItemColorChanger.getStoredColor(stack) != null ? 1F : 0F); } @Override @@ -91,13 +91,13 @@ public class ClientProxy implements IProxy { @Override public void registerTESR(ITESRProvider provider) { - Tuple, Supplier>>> tesr = provider.getTESR(); - ClientRegistry.bindTileEntityRenderer(tesr.getA(), tesr.getB().get()); + Tuple, Supplier>>> tesr = provider.getTESR(); + ClientRegistry.bindBlockEntityRenderer(tesr.getA(), tesr.getB().get()); } @Override public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { - ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().world, + ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision, fade, ParticleHandler.depthEnabled), posX, posY, posZ); diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java index 8a448d62..a75b1e4c 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java @@ -12,8 +12,8 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.level.Level; +import net.minecraft.level.server.ServerLevel; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistryEntry; @@ -36,11 +36,11 @@ public class AnimalSpawnerRecipe extends ModRecipe { this.time = time; } - public Entity makeEntity(World world, BlockPos pos) { + public Entity makeEntity(Level level, BlockPos pos) { // passed position is zero on the client, so we don't want to do initialization stuff for the entity if (pos == BlockPos.ZERO) - return this.entity.create(world); - return this.entity.create((ServerWorld) world, null, null, null, pos, SpawnReason.SPAWNER, false, false); + return this.entity.create(level); + return this.entity.create((ServerLevel) level, null, null, null, pos, SpawnReason.SPAWNER, false, false); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java index 9c2daff0..cfa7f6b3 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.recipes; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; +import net.minecraft.level.Level; import net.minecraftforge.items.wrapper.RecipeWrapper; public abstract class ModRecipe implements IRecipe { @@ -15,7 +15,7 @@ public abstract class ModRecipe implements IRecipe { } @Override - public boolean matches(RecipeWrapper inv, World worldIn) { + public boolean matches(RecipeWrapper inv, Level levelIn) { // return true here so that we can easily get all recipes of a type from the recipe manager return true; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 95a6c53a..93ddd2b5 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -14,7 +14,7 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; -import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.INBT; import net.minecraft.nbt.NBTDynamicOps; import net.minecraft.util.ResourceLocation; @@ -138,7 +138,7 @@ public final class ModRecipes { } public static JsonObject serializeStack(ItemStack stack) { - CompoundNBT nbt = stack.write(new CompoundNBT()); + CompoundTag nbt = stack.write(new CompoundTag()); byte c = nbt.getByte("Count"); if (c != 1) { nbt.putByte("count", c); @@ -150,7 +150,7 @@ public final class ModRecipes { return dyn.convert(JsonOps.INSTANCE).getValue().getAsJsonObject(); } - private static void renameTag(CompoundNBT nbt, String oldName, String newName) { + private static void renameTag(CompoundTag nbt, String oldName, String newName) { INBT tag = nbt.get(oldName); if (tag != null) { nbt.remove(oldName); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java index dc430843..1702918c 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java @@ -6,7 +6,7 @@ public interface IModItem { String getBaseName(); - default ForgeRegistryEntry getRegistryEntry() { - return (ForgeRegistryEntry) this; + default ForgeRegistryEntry getRegistryEntry() { + return (ForgeRegistryEntry) this; } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ITESRProvider.java b/src/main/java/de/ellpeck/naturesaura/reg/ITESRProvider.java index 602fe4c7..40500949 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ITESRProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ITESRProvider.java @@ -1,19 +1,19 @@ package de.ellpeck.naturesaura.reg; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.util.Tuple; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.function.Function; import java.util.function.Supplier; -public interface ITESRProvider { +public interface ITESRProvider { @OnlyIn(Dist.CLIENT) - Tuple, Supplier>>> getTESR(); + Tuple, Supplier>>> getTESR(); } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 9ecffd90..b4aa2351 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -2,11 +2,11 @@ package de.ellpeck.naturesaura.reg; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.api.misc.IWorldData; +import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.*; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom; -import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom; +import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment; import de.ellpeck.naturesaura.enchant.ModEnchantments; import de.ellpeck.naturesaura.entities.*; @@ -14,9 +14,9 @@ import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor; import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart; import de.ellpeck.naturesaura.entities.render.RenderStub; import de.ellpeck.naturesaura.gen.ModFeatures; -import de.ellpeck.naturesaura.gen.WorldGenAncientTree; -import de.ellpeck.naturesaura.gen.WorldGenAuraBloom; -import de.ellpeck.naturesaura.gen.WorldGenNetherWartMushroom; +import de.ellpeck.naturesaura.gen.LevelGenAncientTree; +import de.ellpeck.naturesaura.gen.LevelGenAuraBloom; +import de.ellpeck.naturesaura.gen.LevelGenNetherWartMushroom; import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; import de.ellpeck.naturesaura.items.*; @@ -43,14 +43,14 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.potion.Effect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.tileentity.BlockEntity; +import net.minecraft.tileentity.BlockEntityType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.WorldGenRegistries; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.structure.Structure; +import net.minecraft.util.registry.LevelGenRegistries; +import net.minecraft.level.Level; +import net.minecraft.level.gen.feature.Feature; +import net.minecraft.level.gen.feature.structure.Structure; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; @@ -122,9 +122,9 @@ public final class ModRegistry { new BlockPowderPlacer(), new BlockFireworkGenerator(), new BlockProjectileGenerator(), - new BlockDimensionRail("overworld", World.field_234918_g_, World.field_234919_h_, World.field_234920_i_), - new BlockDimensionRail("nether", World.field_234919_h_, World.field_234918_g_), - new BlockDimensionRail("end", World.field_234920_i_, World.field_234918_g_), + new BlockDimensionRail("overworld", Level.field_234918_g_, Level.field_234919_h_, Level.field_234920_i_), + new BlockDimensionRail("nether", Level.field_234919_h_, Level.field_234918_g_), + new BlockDimensionRail("end", Level.field_234920_i_, Level.field_234918_g_), new BlockBlastFurnaceBooster(), new BlockImpl("nether_wart_mushroom", Block.Properties.from(Blocks.RED_MUSHROOM_BLOCK)), new BlockAnimalContainer(), @@ -231,9 +231,9 @@ public final class ModRegistry { } @SubscribeEvent - public static void registerTiles(RegistryEvent.Register> event) { + public static void registerTiles(RegistryEvent.Register> event) { // add tile entities that support multiple blocks - add(new ModTileType<>(TileEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new))); + add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new))); for (IModItem item : ALL_ITEMS) { if (item instanceof ModTileType) @@ -254,13 +254,13 @@ public final class ModRegistry { public static void registerContainers(RegistryEvent.Register> event) { event.getRegistry().registerAll( IForgeContainerType.create((windowId, inv, data) -> { - TileEntity tile = inv.player.world.getTileEntity(data.readBlockPos()); - if (tile instanceof TileEntityEnderCrate) - return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, ((TileEntityEnderCrate) tile).getItemHandler()); + BlockEntity tile = inv.player.level.getBlockEntity(data.readBlockPos()); + if (tile instanceof BlockEntityEnderCrate) + return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, ((BlockEntityEnderCrate) tile).getItemHandler()); return null; }).setRegistryName("ender_crate"), IForgeContainerType.create((windowId, inv, data) -> { - IItemHandler handler = IWorldData.getOverworldData(inv.player.world).getEnderStorage(data.readString()); + IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(data.readString()); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler); }).setRegistryName("ender_access") ); @@ -313,13 +313,13 @@ public final class ModRegistry { @SubscribeEvent public static void registerFeatures(RegistryEvent.Register> event) { event.getRegistry().registerAll( - new WorldGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false).setRegistryName("aura_bloom"), - new WorldGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false).setRegistryName("aura_cactus"), - new WorldGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true).setRegistryName("warped_aura_mushroom"), - new WorldGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true).setRegistryName("crimson_aura_mushroom"), - new WorldGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false).setRegistryName("aura_mushroom"), - new WorldGenAncientTree().setRegistryName("ancient_tree"), - new WorldGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") + new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false).setRegistryName("aura_bloom"), + new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false).setRegistryName("aura_cactus"), + new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true).setRegistryName("warped_aura_mushroom"), + new LevelGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true).setRegistryName("crimson_aura_mushroom"), + new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false).setRegistryName("aura_mushroom"), + new LevelGenAncientTree().setRegistryName("ancient_tree"), + new LevelGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") ); Helper.populateObjectHolders(ModFeatures.class, event.getRegistry()); } @@ -341,11 +341,11 @@ public final class ModRegistry { } // register features again for some reason - Registry.register(WorldGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), ModFeatures.Configured.AURA_BLOOM); - Registry.register(WorldGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), ModFeatures.Configured.AURA_CACTUS); - Registry.register(WorldGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "crimson_aura_mushroom"), ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); - Registry.register(WorldGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), ModFeatures.Configured.WARPED_AURA_MUSHROOM); - Registry.register(WorldGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), ModFeatures.Configured.AURA_MUSHROOM); + Registry.register(LevelGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), ModFeatures.Configured.AURA_BLOOM); + Registry.register(LevelGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), ModFeatures.Configured.AURA_CACTUS); + Registry.register(LevelGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "crimson_aura_mushroom"), ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); + Registry.register(LevelGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), ModFeatures.Configured.WARPED_AURA_MUSHROOM); + Registry.register(LevelGenRegistries.field_243653_e, new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), ModFeatures.Configured.AURA_MUSHROOM); } public static Block createFlowerPot(Block block) { diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java index 15f4a474..c873922a 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java @@ -1,26 +1,25 @@ package de.ellpeck.naturesaura.reg; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.registries.ForgeRegistryEntry; import java.util.Arrays; -import java.util.function.Supplier; -public class ModTileType implements IModItem { +public class ModTileType implements IModItem { - public final TileEntityType type; + public final BlockEntityType type; public final String name; - public ModTileType(Supplier supplier, IModItem item) { + public ModTileType(BlockEntityType.BlockEntitySupplier supplier, IModItem item) { this(supplier, item.getBaseName(), item); } - public ModTileType(Supplier supplier, String name, IModItem... items) { + public ModTileType(BlockEntityType.BlockEntitySupplier supplier, String name, IModItem... items) { this.name = name; Block[] blocks = Arrays.stream(items).map(i -> (Block) i).toArray(Block[]::new); - this.type = TileEntityType.Builder.create(supplier, blocks).build(null); + this.type = BlockEntityType.Builder.of(supplier, blocks).build(null); } @Override @@ -29,7 +28,7 @@ public class ModTileType implements IModItem { } @Override - public ForgeRegistryEntry getRegistryEntry() { + public ForgeRegistryEntry getRegistryEntry() { return this.type; } } diff --git a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java index 34032b62..e3f0f2a1 100644 --- a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java +++ b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java @@ -5,13 +5,13 @@ import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType; import de.ellpeck.naturesaura.compat.Compat; -import net.minecraft.client.entity.player.AbstractClientPlayerEntity; +import net.minecraft.client.entity.player.AbstractClientPlayer; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.entity.Pose; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.Player; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Effects; @@ -25,16 +25,16 @@ import java.util.HashSet; import java.util.Set; @OnlyIn(Dist.CLIENT) -public class PlayerLayerTrinkets extends LayerRenderer> { +public class PlayerLayerTrinkets extends LayerRenderer> { private final Set alreadyRendered = new HashSet<>(); - public PlayerLayerTrinkets(IEntityRenderer> entityRendererIn) { + public PlayerLayerTrinkets(IEntityRenderer> entityRendererIn) { super(entityRendererIn); } @Override - public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { + public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (!ModConfig.instance.renderItemsOnPlayer.get()) return; if (player.getActivePotionEffect(Effects.INVISIBILITY) != null) @@ -55,7 +55,7 @@ public class PlayerLayerTrinkets extends LayerRenderer= 0.75F) { int color; if (info.tier == 1) { BlockPos pos = player.getPosition(); - color = BiomeColors.getGrassColor(player.world, pos); + color = BiomeColors.getGrassColor(player.level, pos); } else { color = info.color; }