From 9b93760445ef726ffb8f69f9a09dd3ab9b80002c Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 13 Nov 2021 11:02:42 -0600 Subject: [PATCH] More cleanup... --- .../data/BlockRecipeGenerator.java | 4 +-- .../mod/blocks/ActuallyBlocks.java | 5 ++- .../mod/blocks/BlockVerticalDigger.java | 12 +++---- .../blocks/base/FullyDirectionalBlock.java | 4 +-- .../chapter/BookletChapterCrusher.java | 16 ++++----- .../mod/crafting/TargetNBTIngredient.java | 10 ++++-- .../mod/entity/InitEntities.java | 9 +++-- .../mod/entity/RenderWorm.java | 6 ++-- .../mod/tile/TileEntityFarmer.java | 5 ++- .../mod/tile/TileEntityFluidCollector.java | 6 ++-- .../mod/tile/TileEntityFluidPlacer.java | 4 ++- .../mod/tile/TileEntityItemInterface.java | 33 ++++++++++--------- .../tile/TileEntityItemInterfaceHopping.java | 25 ++++++++------ .../mod/tile/TileEntityOilGenerator.java | 9 ++--- .../mod/tile/TileEntityPoweredFurnace.java | 24 +++++++------- .../mod/tile/TileEntityRangedCollector.java | 5 ++- 16 files changed, 90 insertions(+), 87 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java index 34d63d80d..db9191fff 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java @@ -168,7 +168,7 @@ public class BlockRecipeGenerator extends RecipeProvider { .save(consumer); // Item Interface - Recipe.shaped(ActuallyBlocks.ITEM_VIEWER.getItem()) + Recipe.shaped(ActuallyBlocks.ITEM_INTERFACE.getItem()) .pattern("OBO", "RCR", "OBO") .define('B', Tags.Items.DUSTS_REDSTONE) .define('O', ActuallyItems.COIL.get()) @@ -177,7 +177,7 @@ public class BlockRecipeGenerator extends RecipeProvider { .save(consumer); // Hopping Item Interface - Recipe.shapeless(ActuallyBlocks.ITEM_VIEWER_HOPPING.get()).ingredients(ActuallyBlocks.ITEM_VIEWER.get()).save(consumer); + Recipe.shapeless(ActuallyBlocks.ITEM_INTERFACE_HOPPING.get()).ingredients(ActuallyBlocks.ITEM_INTERFACE.get()).save(consumer); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java index b831f89de..c82ceb03f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java @@ -21,7 +21,6 @@ import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.common.ToolType; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -156,9 +155,9 @@ public final class ActuallyBlocks { // Interface Blocks public static final AABlockReg PLAYER_INTERFACE = new AABlockReg<>("player_interface", BlockPlayerInterface::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityPlayerInterface::new); - public static final AABlockReg ITEM_VIEWER = new AABlockReg<>("item_viewer", BlockItemInterface::new, + public static final AABlockReg ITEM_INTERFACE = new AABlockReg<>("item_viewer", BlockItemInterface::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityItemInterface::new); - public static final AABlockReg ITEM_VIEWER_HOPPING = new AABlockReg<>("item_viewer_hopping", BlockItemInterfaceHopping::new, + public static final AABlockReg ITEM_INTERFACE_HOPPING = new AABlockReg<>("item_viewer_hopping", BlockItemInterfaceHopping::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityItemInterfaceHopping::new); // Phantom stuff diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java index 44e28bacd..c35934fde 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java @@ -41,12 +41,12 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I @Override public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - return this.openGui(worldIn, player, pos, TileEntityMiner.class); + return this.openGui(worldIn, player, pos, TileEntityVerticalDigger.class); } @Override public TileEntity newBlockEntity(IBlockReader world) { - return new TileEntityMiner(); + return new TileEntityVerticalDigger(); } @Override @@ -56,13 +56,13 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I return; } TileEntity tile = minecraft.level.getBlockEntity(((BlockRayTraceResult) rayCast).getBlockPos()); - if (tile instanceof TileEntityMiner) { - TileEntityMiner miner = (TileEntityMiner) tile; + if (tile instanceof TileEntityVerticalDigger) { + TileEntityVerticalDigger miner = (TileEntityVerticalDigger) tile; String info = miner.checkY == 0 ? "Done Mining!" : miner.checkY == -1 - ? "Calculating positions..." - : "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + "."; + ? "Calculating positions..." + : "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + "."; minecraft.font.drawShadow(matrices, info, resolution.getGuiScaledWidth() / 2f + 5, resolution.getGuiScaledHeight() / 2f - 20, StringUtil.DECIMAL_COLOR_WHITE); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/FullyDirectionalBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/FullyDirectionalBlock.java index 4c642378e..fee383377 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/FullyDirectionalBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/FullyDirectionalBlock.java @@ -8,8 +8,6 @@ import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; -import net.minecraft.block.AbstractBlock.Properties; - /** * Wrapper for Fully Direction block states extending from our base blocks. It's not super nice but it'll do. */ @@ -28,7 +26,7 @@ public abstract class FullyDirectionalBlock extends BlockBase { } public BlockState getBaseConstructorState() { - return this.stateContainer.getBaseState().with(FACING, Direction.NORTH); + return this.stateDefinition.getOwner().defaultBlockState().setValue(FACING, Direction.NORTH); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java index 8096cfac7..3769aaceb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java @@ -10,17 +10,17 @@ package de.ellpeck.actuallyadditions.mod.booklet.chapter; +import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; +import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; +import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; +import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; +import net.minecraft.item.ItemStack; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; -import net.minecraft.item.ItemStack; - public class BookletChapterCrusher extends BookletChapter { public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { @@ -31,7 +31,7 @@ public class BookletChapterCrusher extends BookletChapter { List allPages = new ArrayList<>(); allPages.addAll(Arrays.asList(pages)); - for (CrusherRecipe recipe : CrusherCrafting.MISC_RECIPES) { + for (CrushingRecipe recipe : CrusherCrafting.MISC_RECIPES) { allPages.add(new PageCrusherRecipe(allPages.size() + 1, recipe).setNoText()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java index 4d6164818..ff1965418 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/TargetNBTIngredient.java @@ -11,6 +11,7 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.IIngredientSerializer; +import javax.annotation.Nonnull; import java.util.stream.Stream; public class TargetNBTIngredient extends Ingredient { @@ -19,6 +20,7 @@ public class TargetNBTIngredient extends Ingredient { } @Override + @Nonnull public IIngredientSerializer getSerializer() { return SERIALIZER; } @@ -29,13 +31,15 @@ public class TargetNBTIngredient extends Ingredient { public static TargetNBTIngredient of(ItemStack itemStack) { return new TargetNBTIngredient(Stream.of(new SingleItemList(itemStack))); } - public static TargetNBTIngredient of(ITag tag) { + @Nonnull + public static TargetNBTIngredient of(@Nonnull ITag tag) { return new TargetNBTIngredient(Stream.of(new TagList(tag))); } @Override + @Nonnull public JsonElement toJson() { JsonObject tmp = super.toJson().getAsJsonObject(); tmp.addProperty("type", Serializer.NAME.toString()); @@ -48,12 +52,14 @@ public class TargetNBTIngredient extends Ingredient { public static ResourceLocation NAME = new ResourceLocation(ActuallyAdditions.MODID, "nbt_target"); @Override + @Nonnull public TargetNBTIngredient parse(PacketBuffer buffer) { return new TargetNBTIngredient(Stream.generate(() -> new SingleItemList(buffer.readItem())).limit(buffer.readVarInt())); } @Override - public TargetNBTIngredient parse(JsonObject json) { + @Nonnull + public TargetNBTIngredient parse(@Nonnull JsonObject json) { return new TargetNBTIngredient(Stream.of(Ingredient.valueFromJson(json))); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java index 946e72c85..882aedac6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java @@ -11,9 +11,8 @@ package de.ellpeck.actuallyadditions.mod.entity; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.common.registry.EntityRegistry; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public final class InitEntities { @@ -21,12 +20,12 @@ public final class InitEntities { public static void init() { ActuallyAdditions.LOGGER.info("Initializing Entities..."); - EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); + //EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); } @OnlyIn(Dist.CLIENT) public static void initClient() { - RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new); + //RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java index 2427f886d..4b71135dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java @@ -10,15 +10,15 @@ package de.ellpeck.actuallyadditions.mod.entity; +import com.mojang.blaze3d.platform.GlStateManager; +import com.sun.prism.TextureMap; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java index 1293d3444..b1f016954 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFarmer; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -41,8 +42,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType; - public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer, INamedContainerProvider { private static final List SORTED_FARMER_BEHAVIORS = new ArrayList<>(); @@ -55,7 +54,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer private int lastEnergy; public TileEntityFarmer() { - super(ActuallyTiles.FARMER_TILE.get(), 12); + super(ActuallyBlocks.FARMER.getTileEntityType(), 12); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 4e406d397..3e02d749c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFluidCollector; import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; @@ -41,9 +42,6 @@ import net.minecraftforge.fluids.capability.templates.FluidTank; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; - public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler, INamedContainerProvider { public boolean isPlacer; @@ -84,7 +82,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing } public TileEntityFluidCollector() { - this(ActuallyTiles.FLUIDCOLLECTOR_TILE.get()); + this(ActuallyBlocks.FLUID_COLLECTOR.getTileEntityType()); this.isPlacer = false; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java index c241c9019..e07a091fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java @@ -10,10 +10,12 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; + public class TileEntityFluidPlacer extends TileEntityFluidCollector { public TileEntityFluidPlacer() { - super(ActuallyTiles.FLUIDPLACER_TILE.get()); + super(ActuallyBlocks.FLUID_PLACER.getTileEntityType()); this.isPlacer = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java index df99f735b..a1a138083 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterface.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.Network; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.util.StackUtil; @@ -66,9 +67,9 @@ public class TileEntityItemInterface extends TileEntityBase { IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot); if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stack, false)) { ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate); - if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { - TileEntityItemInterface.this.markDirty(); - TileEntityItemInterface.this.doItemParticle(stack, info.relayInQuestion.getPos(), TileEntityItemInterface.this.connectedRelay.getPos()); + if (!ItemStack.isSame(remain, stack) && !simulate) { + TileEntityItemInterface.this.setChanged(); + TileEntityItemInterface.this.doItemParticle(stack, info.relayInQuestion.getBlockPos(), TileEntityItemInterface.this.connectedRelay.getBlockPos()); } return remain; } @@ -83,8 +84,8 @@ public class TileEntityItemInterface extends TileEntityBase { if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stackIn, true)) { ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate); if (StackUtil.isValid(extracted) && !simulate) { - TileEntityItemInterface.this.markDirty(); - TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getPos(), info.relayInQuestion.getPos()); + TileEntityItemInterface.this.setChanged(); + TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getBlockPos(), info.relayInQuestion.getBlockPos()); } return extracted; } @@ -118,7 +119,7 @@ public class TileEntityItemInterface extends TileEntityBase { } public TileEntityItemInterface() { - this(ActuallyTiles.ITEMVIEWER_TILE.get()); + this(ActuallyBlocks.ITEM_INTERFACE.getTileEntityType()); } @Override @@ -153,9 +154,9 @@ public class TileEntityItemInterface extends TileEntityBase { } public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) { - if (!this.world.isRemote) { + if (!this.level.isClientSide) { CompoundNBT compound = new CompoundNBT(); - stack.write(compound); + stack.save(compound); compound.putDouble("InX", input.getX()); compound.putDouble("InY", input.getY()); @@ -166,9 +167,9 @@ public class TileEntityItemInterface extends TileEntityBase { compound.putDouble("OutZ", output.getZ()); int rangeSq = 16 * 16; - for (PlayerEntity player : this.world.getPlayers()) { + for (PlayerEntity player : this.level.players()) { if (player instanceof ServerPlayerEntity) { - if (player.getDistanceSq(input.getX(), input.getY(), input.getZ()) <= rangeSq || player.getDistanceSq(output.getX(), output.getY(), output.getZ()) <= rangeSq) { + if (player.distanceToSqr(input.getX(), input.getY(), input.getZ()) <= rangeSq || player.distanceToSqr(output.getX(), output.getY(), output.getZ()) <= rangeSq) { PacketHandler.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (ServerPlayerEntity) player); } } @@ -249,13 +250,13 @@ public class TileEntityItemInterface extends TileEntityBase { @Override public void saveDataOnChangeOrWorldStart() { TileEntityLaserRelayItem tileFound = null; - if (this.world != null) { //Why is that even possible..? + if (this.level != null) { //Why is that even possible..? for (int i = 0; i <= 5; i++) { Direction side = WorldUtil.getDirectionBySidesInOrder(i); - BlockPos pos = this.getPos().offset(side); + BlockPos pos = this.getBlockPos().relative(side); - if (this.world.isBlockLoaded(pos)) { - TileEntity tile = this.world.getTileEntity(pos); + if (this.level.isLoaded(pos)) { + TileEntity tile = this.level.getBlockEntity(pos); if (tile instanceof TileEntityLaserRelayItem) { if (tileFound != null) { @@ -312,7 +313,7 @@ public class TileEntityItemInterface extends TileEntityBase { } public boolean isLoaded() { - return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); + return this.relayInQuestion.hasLevel() && this.relayInQuestion.getLevel().isLoaded(this.relayInQuestion.getBlockPos()); } } @@ -326,7 +327,7 @@ public class TileEntityItemInterface extends TileEntityBase { } public boolean isLoaded() { - return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); + return this.relayInQuestion.hasLevel() && this.relayInQuestion.getLevel().isLoaded(this.relayInQuestion.getBlockPos()); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java index bb0278660..1bdbbf337 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemInterfaceHopping.java @@ -11,15 +11,18 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.block.BlockState; +import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.EntityPredicates; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.util.LazyOptional; @@ -34,7 +37,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface { private SlotlessableItemHandlerWrapper handlerToPushTo; public TileEntityItemInterfaceHopping() { - super(ActuallyTiles.ITEMVIEWERHOPPING_TILE.get()); + super(ActuallyBlocks.ITEM_INTERFACE_HOPPING.getTileEntityType()); } @Override @@ -42,12 +45,14 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface { super.updateEntity(); // TODO: [port] validate this is the correct way to get total game time getGameTime - if (!this.world.isRemote && this.world.getWorldInfo().getGameTime() % 10 == 0) { + if (!this.level.isClientSide && this.level.getLevelData().getGameTime() % 10 == 0) { if (this.handlerToPullFrom != null) { WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4); } else { - if (this.world.getWorldInfo().getGameTime() % 20 == 0) { - 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)); + if (this.level.getLevelData().getGameTime() % 20 == 0) { + //TODO hmm? + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(this.getBlockPos().getX(), this.getBlockPos().getY() + 0.5, this.getBlockPos().getZ(), this.getBlockPos().getX() + 1, this.getBlockPos().getY() + 2, this.getBlockPos().getZ() + 1); + List items = this.level.getEntities(EntityType.ITEM, axisAlignedBB, EntityPredicates.ENTITY_STILL_ALIVE); if (items != null && !items.isEmpty()) { for (ItemEntity item : items) { if (item != null && item.isAlive()) { @@ -96,7 +101,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface { this.handlerToPullFrom = null; this.handlerToPushTo = null; - TileEntity from = this.world.getTileEntity(this.pos.offset(Direction.UP)); + TileEntity from = this.level.getBlockEntity(this.getBlockPos().relative(Direction.UP)); if (from != null && !(from instanceof TileEntityItemInterface)) { LazyOptional normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN); @@ -112,12 +117,12 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface { this.handlerToPullFrom = new SlotlessableItemHandlerWrapper(normal, slotless); } - BlockState state = this.world.getBlockState(this.pos); - Direction facing = state.get(BlockStateProperties.FACING); + BlockState state = this.level.getBlockState(this.getBlockPos()); + Direction facing = state.getValue(BlockStateProperties.FACING); - BlockPos toPos = this.pos.offset(facing); - if (this.world.isBlockLoaded(toPos)) { - TileEntity to = this.world.getTileEntity(toPos); + BlockPos toPos = this.getBlockPos().relative(facing); + if (this.level.isLoaded(toPos)) { + TileEntity to = this.level.getBlockEntity(toPos); if (to != null && !(to instanceof TileEntityItemInterface)) { LazyOptional normal = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index 17ef1fc3d..965679998 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -37,9 +37,6 @@ import net.minecraftforge.fluids.capability.templates.FluidTank; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType; -import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction; - public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler, INamedContainerProvider { int[] i = ConfigIntListValues.OIL_POWER.getValue(); @@ -59,12 +56,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn return FluidStack.EMPTY; } - @Override + //@Override public boolean canFillFluidType(FluidStack stack) { Fluid fluid = stack == null ? null : stack.getFluid(); - return fluid != null && getRecipeForFluid(fluid.getName()) != null; + return fluid != null && getRecipeForFluid(fluid.getRegistryName().toString()) != null; } }; public final LazyOptional lazyTank = LazyOptional.of(() -> this.tank); @@ -103,7 +100,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn if (stack != null) { Fluid fluid = stack.getFluid(); if (fluid != null) { - return getRecipeForFluid(fluid.getName()); + return getRecipeForFluid(fluid.getRegistryName().toString()); } } return null; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java index 154603b0d..11a62108e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPoweredFurnace.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; @@ -23,13 +24,12 @@ 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.item.crafting.FurnaceRecipe; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; -import net.minecraft.util.datafix.fixes.FurnaceRecipes; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; +import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; @@ -55,7 +55,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements private boolean lastSmelted; public TileEntityPoweredFurnace() { - super(ActuallyTiles.FURNACE_DOUBLE_TILE.get(), 4); + super(ActuallyBlocks.POWERED_FURNACE.getTileEntityType(), 4); } public static void autoSplit(ItemStackHandlerAA inv, int slot1, int slot2) { @@ -111,7 +111,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements @Override public void updateEntity() { super.updateEntity(); - if (!this.world.isRemote) { + if (!this.level.isClientSide) { if (this.isAutoSplit) { autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2); } @@ -149,8 +149,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements this.secondSmeltTime = 0; } - BlockState currState = this.world.getBlockState(this.pos); - boolean current = currState.get(BlockStateProperties.LIT); + BlockState currState = this.level.getBlockState(this.getBlockPos()); + boolean current = currState.getValue(BlockStateProperties.LIT); boolean changeTo = current; if (this.lastSmelted != smelted) { changeTo = smelted; @@ -163,7 +163,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements } if (changeTo != current) { - this.world.setBlockState(this.pos, currState.with(BlockStateProperties.LIT, changeTo)); + this.level.setBlock(this.worldPosition, currState.setValue(BlockStateProperties.LIT, changeTo), Constants.BlockFlags.DEFAULT); } this.lastSmelted = smelted; @@ -179,7 +179,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)); + return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2); //&& StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)); //TODO } @Override @@ -189,9 +189,9 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements public boolean canSmeltOn(int theInput, int theOutput) { if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) { - ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); + ItemStack output = ItemStack.EMPTY; //FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); //TODO if (StackUtil.isValid(output)) { - if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).isItemEqual(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) { + if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).sameItem(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) { return true; } } @@ -201,7 +201,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements } public void finishBurning(int theInput, int theOutput) { - ItemStack output = FurnaceRecipe.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); + ItemStack output = ItemStack.EMPTY; //FurnaceRecipe.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); //TODO if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) { this.inv.setStackInSlot(theOutput, output.copy()); } else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) { @@ -223,7 +223,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements public void onButtonPressed(int buttonID, PlayerEntity player) { if (buttonID == 0) { this.isAutoSplit = !this.isAutoSplit; - this.markDirty(); + this.setChanged(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index 27be8e5ed..a4768c2d6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -31,15 +32,13 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType; - public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { public static final int RANGE = 6; public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000); public TileEntityRangedCollector() { - super(ActuallyTiles.RANGEDCOLLECTOR_TILE.get(), 6); + super(ActuallyBlocks.RANGED_COLLECTOR.getTileEntityType(), 6); } @Override