From d18d1b820e584d154e38a6078a81a1e611e110fe Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 4 Jun 2019 12:05:18 +0100 Subject: [PATCH] 397 --- src/main/java/techreborn/TechReborn.java | 70 ++------ .../FluidReplicatorRecipe.java | 3 +- .../FluidReplicatorRecipeList.java | 2 + .../api/generator/FluidGeneratorRecipe.java | 2 +- .../generator/FluidGeneratorRecipeList.java | 1 - .../recipe/recipes/BlastFurnaceRecipe.java | 6 +- .../recipes/IndustrialGrinderRecipe.java | 6 +- .../recipes/IndustrialSawmillRecipe.java | 6 +- .../java/techreborn/blocks/BlockAlarm.java | 7 +- .../techreborn/blocks/BlockComputerCube.java | 7 +- .../blocks/BlockReinforcedGlass.java | 7 +- .../techreborn/blocks/BlockRubberLeaves.java | 3 +- .../techreborn/blocks/BlockRubberLog.java | 13 +- .../techreborn/blocks/cable/BlockCable.java | 7 +- .../blocks/generator/BlockFusionCoil.java | 5 +- .../generator/BlockFusionControlComputer.java | 7 +- .../techreborn/blocks/lighting/BlockLamp.java | 26 +-- .../blocks/storage/BlockEnergyStorage.java | 7 +- .../blocks/storage/BlockLSUStorage.java | 7 +- .../blocks/tier1/BlockPlayerDetector.java | 7 +- .../blocks/tier2/BlockDistillationTower.java | 4 +- .../blocks/transformers/BlockTransformer.java | 7 +- .../client/gui/GuiAlloyFurnace.java | 2 +- .../java/techreborn/client/gui/GuiBatbox.java | 1 + .../techreborn/client/gui/GuiChunkLoader.java | 6 +- .../client/gui/GuiDistillationTower.java | 1 + .../client/gui/GuiFluidReplicator.java | 4 +- .../client/gui/GuiFusionReactor.java | 4 +- .../java/techreborn/client/gui/GuiIDSU.java | 2 +- .../client/gui/GuiImplosionCompressor.java | 4 +- .../client/gui/GuiIndustrialGrinder.java | 4 +- .../techreborn/client/gui/GuiIronFurnace.java | 3 +- .../java/techreborn/client/gui/GuiMFE.java | 1 - .../java/techreborn/client/gui/GuiMFSU.java | 1 - .../java/techreborn/client/gui/GuiManual.java | 25 ++- .../client/gui/GuiVacuumFreezer.java | 4 +- .../techreborn/entities/EntityNukePrimed.java | 24 ++- .../events/ModelRegistryEventHandler.java | 6 +- src/main/java/techreborn/init/ModRecipes.java | 35 ++-- src/main/java/techreborn/init/TRContent.java | 2 +- .../init/recipes/FluidGeneratorRecipes.java | 1 + .../java/techreborn/items/DynamicCell.java | 163 ++---------------- .../items/armor/ItemCloakingDevice.java | 5 - .../items/armor/ItemLapotronicOrbpack.java | 10 +- .../items/armor/ItemLithiumIonBatpack.java | 10 +- .../techreborn/items/armor/ItemTRArmour.java | 3 +- .../techreborn/items/battery/ItemBattery.java | 8 - .../techreborn/items/tool/ItemChainsaw.java | 11 +- .../java/techreborn/items/tool/ItemDrill.java | 11 +- .../techreborn/items/tool/ItemJackhammer.java | 11 +- .../techreborn/items/tool/ItemWrench.java | 3 +- .../items/tool/advanced/ItemRockCutter.java | 9 +- .../items/tool/basic/ItemElectricTreetap.java | 9 +- .../items/tool/industrial/ItemNanosaber.java | 11 +- .../items/tool/industrial/ItemOmniTool.java | 9 +- .../packets/ServerboundPackets.java | 62 ++++--- .../techreborn/tiles/TileTechStorageBase.java | 16 -- .../techreborn/tiles/cable/TileCable.java | 74 ++++---- .../generator/TileBaseFluidGenerator.java | 3 +- .../machine/iron/TileIronAlloyFurnace.java | 12 +- .../multiblock/TileFluidReplicator.java | 1 + .../multiblock/TileIndustrialGrinder.java | 2 +- .../machine/tier1/TileAutoCraftingTable.java | 2 +- .../machine/tier1/TilePlayerDectector.java | 3 +- .../java/techreborn/utils/FluidUtils.java | 19 ++ 65 files changed, 287 insertions(+), 520 deletions(-) diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index 7b8eddfec..773daea8c 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -24,18 +24,12 @@ package techreborn; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.api.ModInitializer; import net.minecraft.block.DispenserBlock; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - - - - - - - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import reborncore.common.multiblock.MultiblockEventHandler; @@ -55,10 +49,8 @@ import techreborn.tiles.fusionReactor.TileFusionControlComputer; import techreborn.utils.BehaviorDispenseScrapbox; import techreborn.utils.StackWIPHandler; import techreborn.world.village.ModLootTables; -import techreborn.world.village.VillagePlantaionHandler; -@Mod("techreborn") -public class TechReborn { +public class TechReborn implements ModInitializer { public static final String MOD_ID = "techreborn"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); @@ -72,14 +64,8 @@ public class TechReborn { } }; - - public TechReborn() { - IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); - eventBus.addListener(this::setup); - eventBus.addListener(this::loadComplete); - } - - private void setup(FMLCommonSetupEvent event) { + @Override + public void onInitialize() { MinecraftForge.EVENT_BUS.register(this); INSTANCE = this; @@ -131,47 +117,13 @@ public class TechReborn { } Torus.genSizeMap(TileFusionControlComputer.maxCoilSize); - LOGGER.info("TechReborn setup done!"); - } - - private void loadComplete(FMLLoadCompleteEvent event) { - + proxy.postInit(); ModRecipes.postInit(); - - //todo: remove, gens localization -// for (Item item : ForgeRegistries.ITEMS.getValues()) { -// if (item.getRegistryName().getNamespace().equals("techreborn")) { -// StringBuilder localName = new StringBuilder(); -// String[] words = item.getRegistryName().getPath().split("_|\\."); -// for (String word : words) { -// if (!word.contains("techreborn")) { -// if (localName.length() > 0) { -// localName.append(" "); -// } -// localName.append(word); -// } -// } -// System.out.println(item.getRegistryName().getPath()); -// } -// } - -// for (Block item : ForgeRegistries.BLOCKS.getValues()) { -// if (item.getRegistryName().getNamespace().equals("techreborn")) { -// StringBuilder localName = new StringBuilder(); -// String[] words = item.getRegistryName().getPath().split("_|\\."); -// for (String word : words) { -// if (!word.contains("techreborn")) { -// if (localName.length() > 0) { -// localName.append(" "); -// } -// localName.append(word); -// } -// } -// System.out.println(item.getRegistryName().getPath()); -// } -// } - + + + LOGGER.info("TechReborn setup done!"); } + } diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java index b788abbfa..2b8aa55e8 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipe.java @@ -26,9 +26,10 @@ package techreborn.api.fluidreplicator; import net.minecraft.util.math.BlockPos; -import reborncore.common.util.FluidUtils; +import reborncore.fluid.Fluid; import techreborn.init.TRContent; import techreborn.tiles.machine.multiblock.TileFluidReplicator; +import techreborn.utils.FluidUtils; import javax.annotation.Nonnull; import java.util.ArrayList; diff --git a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java index 29dde6277..8b0d5e2c1 100644 --- a/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java +++ b/src/main/java/techreborn/api/fluidreplicator/FluidReplicatorRecipeList.java @@ -27,6 +27,8 @@ package techreborn.api.fluidreplicator; import org.apache.commons.lang3.Validate; import reborncore.common.util.FluidUtils; +import reborncore.fluid.Fluid; +import techreborn.utils.FluidUtils; import java.util.ArrayList; import java.util.Optional; diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java index e69aa9a17..3c380c41b 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipe.java @@ -25,8 +25,8 @@ package techreborn.api.generator; -import reborncore.common.util.FluidUtils; import reborncore.fluid.Fluid; +import techreborn.utils.FluidUtils; public class FluidGeneratorRecipe { private final EFluidGenerator generatorType; diff --git a/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java b/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java index f7ec250cd..38443fc76 100644 --- a/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java +++ b/src/main/java/techreborn/api/generator/FluidGeneratorRecipeList.java @@ -26,7 +26,6 @@ package techreborn.api.generator; import com.google.common.collect.Sets; -import reborncore.common.util.FluidUtils; import reborncore.fluid.Fluid; import java.util.HashSet; diff --git a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java index 0cd397b23..cd2fb5d8e 100644 --- a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java @@ -28,15 +28,17 @@ import com.google.gson.JsonObject; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; +import reborncore.common.crafting.RebornRecipe; +import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RecipeType; import techreborn.tiles.machine.multiblock.TileIndustrialBlastFurnace; -public class BlastFurnaceRecipe extends Recipe { +public class BlastFurnaceRecipe extends RebornRecipe { int heat; - public BlastFurnaceRecipe(RecipeType type, Identifier name) { + public BlastFurnaceRecipe(RebornRecipeType type, Identifier name) { super(type, name); } diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java index cd0fa79a8..14d78011b 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java @@ -27,15 +27,17 @@ package techreborn.api.recipe.recipes; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; +import reborncore.common.crafting.RebornRecipe; +import reborncore.common.crafting.RebornRecipeType; import reborncore.fluid.FluidStack; import techreborn.tiles.machine.multiblock.TileIndustrialGrinder; -public class IndustrialGrinderRecipe extends Recipe { +public class IndustrialGrinderRecipe extends RebornRecipe { //TODO 1.14 fluids FluidStack fluidStack = null; - public IndustrialGrinderRecipe(RecipeType type, Identifier name) { + public IndustrialGrinderRecipe(RebornRecipeType type, Identifier name) { super(type, name); } diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java index 7ab8494a9..fe1a69c44 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java @@ -27,15 +27,17 @@ package techreborn.api.recipe.recipes; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; +import reborncore.common.crafting.RebornRecipe; +import reborncore.common.crafting.RebornRecipeType; import reborncore.fluid.FluidStack; import techreborn.tiles.machine.multiblock.TileIndustrialSawmill; -public class IndustrialSawmillRecipe extends Recipe { +public class IndustrialSawmillRecipe extends RebornRecipe { //TODO 1.14 fluids FluidStack fluidStack = null; - public IndustrialSawmillRecipe(RecipeType type, Identifier name) { + public IndustrialSawmillRecipe(RebornRecipeType type, Identifier name) { super(type, name); } diff --git a/src/main/java/techreborn/blocks/BlockAlarm.java b/src/main/java/techreborn/blocks/BlockAlarm.java index 5afc4c904..390f9a75c 100644 --- a/src/main/java/techreborn/blocks/BlockAlarm.java +++ b/src/main/java/techreborn/blocks/BlockAlarm.java @@ -41,6 +41,7 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -130,7 +131,7 @@ public class BlockAlarm extends BaseTileBlock { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -140,7 +141,7 @@ public class BlockAlarm extends BaseTileBlock { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } @@ -151,7 +152,7 @@ public class BlockAlarm extends BaseTileBlock { } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } @Override diff --git a/src/main/java/techreborn/blocks/BlockComputerCube.java b/src/main/java/techreborn/blocks/BlockComputerCube.java index d84cf8b65..902f7a495 100644 --- a/src/main/java/techreborn/blocks/BlockComputerCube.java +++ b/src/main/java/techreborn/blocks/BlockComputerCube.java @@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundCategory; import net.minecraft.util.BlockRotation; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -56,11 +57,11 @@ public class BlockComputerCube extends BlockMachineBase { } @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND); if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { - if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, side, false)) { + if (ToolManager.INSTANCE.handleTool(tool, pos, worldIn, playerIn, hitResult.getSide(), false)) { if (playerIn.isSneaking()) { ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1); dropStack(worldIn, pos, drop); @@ -72,7 +73,7 @@ public class BlockComputerCube extends BlockMachineBase { return true; } else { - rotate(worldIn.getBlockState(pos), worldIn, pos, BlockRotation.CLOCKWISE_90); + rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90); return true; } } diff --git a/src/main/java/techreborn/blocks/BlockReinforcedGlass.java b/src/main/java/techreborn/blocks/BlockReinforcedGlass.java index 415ffb87e..475cb9eb5 100644 --- a/src/main/java/techreborn/blocks/BlockReinforcedGlass.java +++ b/src/main/java/techreborn/blocks/BlockReinforcedGlass.java @@ -24,6 +24,7 @@ package techreborn.blocks; +import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.GlassBlock; @@ -38,12 +39,8 @@ import java.util.Random; public class BlockReinforcedGlass extends GlassBlock { public BlockReinforcedGlass() { - super(Block.Settings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE)); + super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).build()); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this)); } - @Override - public int quantityDropped(BlockState state, Random random) { - return 1; - } } diff --git a/src/main/java/techreborn/blocks/BlockRubberLeaves.java b/src/main/java/techreborn/blocks/BlockRubberLeaves.java index 39fc3ef63..1a09993ea 100644 --- a/src/main/java/techreborn/blocks/BlockRubberLeaves.java +++ b/src/main/java/techreborn/blocks/BlockRubberLeaves.java @@ -24,6 +24,7 @@ package techreborn.blocks; +import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -42,7 +43,7 @@ import techreborn.init.TRContent; public class BlockRubberLeaves extends LeavesBlock { public BlockRubberLeaves() { - super(Block.Settings.of(Material.LEAVES).strength(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS)); + super(FabricBlockSettings.of(Material.LEAVES).hardness(0.2F).ticksRandomly().sounds(BlockSoundGroup.GRASS).build()); ((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 30, 60); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, EnvTypeANCE, PERSISTENT)); } diff --git a/src/main/java/techreborn/blocks/BlockRubberLog.java b/src/main/java/techreborn/blocks/BlockRubberLog.java index a57d40eae..1189bae83 100644 --- a/src/main/java/techreborn/blocks/BlockRubberLog.java +++ b/src/main/java/techreborn/blocks/BlockRubberLog.java @@ -44,6 +44,7 @@ import net.minecraft.tag.BlockTags; import net.minecraft.tag.Tag; import net.minecraft.util.DefaultedList; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -92,7 +93,7 @@ public class BlockRubberLog extends LogBlock { int i = 4; int j = i + 1; if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) { - for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) { + for (BlockPos blockpos : BlockPos.iterate(pos.add(-i, -i, -i), pos.add(i, i, i))) { BlockState state1 = worldIn.getBlockState(blockpos); if (state1.matches(BlockTags.LEAVES)) { state1.scheduledTick(worldIn, blockpos, worldIn.getRandom()); @@ -123,9 +124,9 @@ public class BlockRubberLog extends LogBlock { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, - Hand hand, Direction side, float hitX, float hitY, float hitZ) { - super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, BlockHitResult hitResult) { + super.activate(state, worldIn, pos, playerIn, hand, hitResult); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); if (stack.isEmpty()) { return false; @@ -135,7 +136,7 @@ public class BlockRubberLog extends LogBlock { capEnergy = new ItemPowerManager(stack); } if ((capEnergy != null && capEnergy.getEnergyStored() > 20) || stack.getItem() instanceof ItemTreeTap) { - if (state.get(HAS_SAP) && state.get(SAP_SIDE) == side) { + if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) { worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0))); worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F); @@ -148,7 +149,7 @@ public class BlockRubberLog extends LogBlock { playerIn.getStackInHand(Hand.MAIN_HAND).damageItem(1, playerIn); } if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) { - WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(side)); + WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide())); } if (playerIn instanceof ServerPlayerEntity) { TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn); diff --git a/src/main/java/techreborn/blocks/cable/BlockCable.java b/src/main/java/techreborn/blocks/cable/BlockCable.java index 09060b981..63d382a9d 100644 --- a/src/main/java/techreborn/blocks/cable/BlockCable.java +++ b/src/main/java/techreborn/blocks/cable/BlockCable.java @@ -36,6 +36,7 @@ import net.minecraft.state.StateFactory; import net.minecraft.state.property.AbstractProperty; import net.minecraft.state.property.BooleanProperty; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -126,7 +127,7 @@ public class BlockCable extends BlockWithEntity { // Block @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -136,11 +137,11 @@ public class BlockCable extends BlockWithEntity { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } @Override diff --git a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java index f530e2c94..9e8a83f43 100644 --- a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java +++ b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java @@ -36,6 +36,7 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -59,8 +60,8 @@ public class BlockFusionCoil extends Block { } @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, - Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, BlockHitResult hitResult) { ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND); if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { diff --git a/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java b/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java index a5cc40770..44e8d7487 100644 --- a/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java +++ b/src/main/java/techreborn/blocks/generator/BlockFusionControlComputer.java @@ -29,6 +29,7 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -54,8 +55,8 @@ public class BlockFusionControlComputer extends BlockMachineBase { } @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, - Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, + Hand hand, BlockHitResult hitResult) { final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getBlockEntity(pos); if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){ List coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size); @@ -78,7 +79,7 @@ public class BlockFusionControlComputer extends BlockMachineBase { } tileFusionControlComputer.checkCoils(); - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } @Override diff --git a/src/main/java/techreborn/blocks/lighting/BlockLamp.java b/src/main/java/techreborn/blocks/lighting/BlockLamp.java index 52655d514..17cda8a7e 100644 --- a/src/main/java/techreborn/blocks/lighting/BlockLamp.java +++ b/src/main/java/techreborn/blocks/lighting/BlockLamp.java @@ -40,6 +40,7 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; @@ -142,29 +143,10 @@ public class BlockLamp extends BaseTileBlock { public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } - - @Override - public boolean isFullCube(BlockState state) { - return false; - } - - @Override - public BlockFaceShape getBlockFaceShape(BlockView worldIn, BlockState state, BlockPos pos, Direction facing) { - // This makes only the back face of lamps connect to fences. - if (getFacing(state).getOpposite() == facing) - return BlockFaceShape.SOLID; - else - return BlockFaceShape.UNDEFINED; - } - - @Override - public VoxelShape getShape(BlockState state, BlockView worldIn, BlockPos pos) { - return shape[getFacing(state).getId()]; - } @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -174,11 +156,11 @@ public class BlockLamp extends BaseTileBlock { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } } diff --git a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java index c15e81be2..10156c02b 100644 --- a/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockEnergyStorage.java @@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -102,7 +103,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -112,7 +113,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } @@ -122,7 +123,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock { return true; } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } @Override diff --git a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java index 99209c27f..f94e9e50d 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java @@ -33,6 +33,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.DefaultedList; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -93,7 +94,7 @@ public class BlockLSUStorage extends BaseTileBlock { // Block @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -103,12 +104,12 @@ public class BlockLSUStorage extends BaseTileBlock { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } @Override diff --git a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java index 852a4396c..b37904c11 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java +++ b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java @@ -38,6 +38,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.chat.TextComponent; import net.minecraft.state.StateFactory; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.BlockView; @@ -90,12 +91,12 @@ public class BlockPlayerDetector extends BlockMachineBase { } @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); if (tileEntity == null) { - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } String type = state.get(TYPE); @@ -103,7 +104,7 @@ public class BlockPlayerDetector extends BlockMachineBase { ChatFormat color = ChatFormat.GREEN; if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, side, false)) { + if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, hitResult.getSide(), false)) { if (playerIn.isSneaking()) { if (tileEntity instanceof IToolDrop) { ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(playerIn); diff --git a/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java b/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java index 77e95cb03..cbf6bb2f7 100644 --- a/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java +++ b/src/main/java/techreborn/blocks/tier2/BlockDistillationTower.java @@ -34,9 +34,9 @@ import techreborn.TechReborn; import techreborn.client.EGui; import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower; -public class BlockEnvTypeillationTower extends BlockMachineBase { +public class BlockDistillationTower extends BlockMachineBase { - public BlockEnvTypeillationTower() { + public BlockDistillationTower() { super(); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier2_machines")); } diff --git a/src/main/java/techreborn/blocks/transformers/BlockTransformer.java b/src/main/java/techreborn/blocks/transformers/BlockTransformer.java index 03ece7b7c..1ac8ce5db 100644 --- a/src/main/java/techreborn/blocks/transformers/BlockTransformer.java +++ b/src/main/java/techreborn/blocks/transformers/BlockTransformer.java @@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -92,7 +93,7 @@ public abstract class BlockTransformer extends BaseTileBlock { @SuppressWarnings("deprecation") @Override - public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Direction side, float hitX, float hitY, float hitZ) { + public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); BlockEntity tileEntity = worldIn.getBlockEntity(pos); @@ -102,11 +103,11 @@ public abstract class BlockTransformer extends BaseTileBlock { } if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { - if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, side)) { + if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) { return true; } } - return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); + return super.activate(state, worldIn, pos, playerIn, hand, hitResult); } } diff --git a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java index b32e5f995..2a2da5757 100644 --- a/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiAlloyFurnace.java @@ -49,7 +49,7 @@ public class GuiAlloyFurnace extends AbstractContainerScreen { protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { this.drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(GuiAlloyFurnace.texture); + this.minecraft.getTextureManager().bindTexture(GuiAlloyFurnace.texture); final int k = (this.width - this.containerWidth) / 2; final int l = (this.height - this.containerHeight) / 2; this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); diff --git a/src/main/java/techreborn/client/gui/GuiBatbox.java b/src/main/java/techreborn/client/gui/GuiBatbox.java index 9317a1d04..3b2ba84b1 100644 --- a/src/main/java/techreborn/client/gui/GuiBatbox.java +++ b/src/main/java/techreborn/client/gui/GuiBatbox.java @@ -24,6 +24,7 @@ package techreborn.client.gui; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; diff --git a/src/main/java/techreborn/client/gui/GuiChunkLoader.java b/src/main/java/techreborn/client/gui/GuiChunkLoader.java index deed5d1dd..336115913 100644 --- a/src/main/java/techreborn/client/gui/GuiChunkLoader.java +++ b/src/main/java/techreborn/client/gui/GuiChunkLoader.java @@ -53,8 +53,8 @@ public class GuiChunkLoader extends AbstractContainerScreen { } @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); this.left = this.width / 2 - this.containerWidth / 2; this.top = this.height / 2 - this.containerHeight / 2; this.plusOneButton = new GuiButtonSimple(0, this.left + 5, this.top + 37, 40, 20, "+1"); @@ -73,7 +73,7 @@ public class GuiChunkLoader extends AbstractContainerScreen { protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { this.drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(GuiChunkLoader.texture); + minecraft.getTextureManager().bindTexture(GuiChunkLoader.texture); final int k = (this.width - this.containerWidth) / 2; final int l = (this.height - this.containerHeight) / 2; this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); diff --git a/src/main/java/techreborn/client/gui/GuiDistillationTower.java b/src/main/java/techreborn/client/gui/GuiDistillationTower.java index 2adc2eb07..08275d1b1 100644 --- a/src/main/java/techreborn/client/gui/GuiDistillationTower.java +++ b/src/main/java/techreborn/client/gui/GuiDistillationTower.java @@ -24,6 +24,7 @@ package techreborn.client.gui; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/techreborn/client/gui/GuiFluidReplicator.java b/src/main/java/techreborn/client/gui/GuiFluidReplicator.java index 0b94b09c8..6e5e0524d 100644 --- a/src/main/java/techreborn/client/gui/GuiFluidReplicator.java +++ b/src/main/java/techreborn/client/gui/GuiFluidReplicator.java @@ -57,8 +57,8 @@ public class GuiFluidReplicator extends GuiBase { // GuiBase @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); ClientProxy.multiblockRenderEvent.setMultiblock(null); } diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index 3ecbaddec..8dcae76de 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -100,8 +100,8 @@ public class GuiFusionReactor extends GuiBase { } } builder.drawUpDownButtons(this, 121, 79, layer); - draw("Size: " + tile.size, 83, 81, 0xFFFFFF, layer); - draw("" + tile.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer); + drawString("Size: " + tile.size, 83, 81, 0xFFFFFF, layer); + drawString("" + tile.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer); buttons.add(new GuiButtonUpDown(300, 121, 79, this, GuiBase.Layer.FOREGROUND)); buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, GuiBase.Layer.FOREGROUND)); diff --git a/src/main/java/techreborn/client/gui/GuiIDSU.java b/src/main/java/techreborn/client/gui/GuiIDSU.java index 08545444a..2b4d82734 100644 --- a/src/main/java/techreborn/client/gui/GuiIDSU.java +++ b/src/main/java/techreborn/client/gui/GuiIDSU.java @@ -24,7 +24,7 @@ package techreborn.client.gui; -import net.minecraft.client.renderer.GlStateManager; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; diff --git a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java index b87be54b4..c73a4e7ba 100644 --- a/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java +++ b/src/main/java/techreborn/client/gui/GuiImplosionCompressor.java @@ -49,8 +49,8 @@ public class GuiImplosionCompressor extends GuiBase { } @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); ClientProxy.multiblockRenderEvent.setMultiblock(null); } diff --git a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java index c59eb4b44..161e05aa1 100644 --- a/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java +++ b/src/main/java/techreborn/client/gui/GuiIndustrialGrinder.java @@ -49,8 +49,8 @@ public class GuiIndustrialGrinder extends GuiBase { } @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); ClientProxy.multiblockRenderEvent.setMultiblock(null); } diff --git a/src/main/java/techreborn/client/gui/GuiIronFurnace.java b/src/main/java/techreborn/client/gui/GuiIronFurnace.java index 210f93615..3bbdd117a 100644 --- a/src/main/java/techreborn/client/gui/GuiIronFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiIronFurnace.java @@ -24,6 +24,7 @@ package techreborn.client.gui; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.player.PlayerEntity; @@ -52,7 +53,7 @@ public class GuiIronFurnace extends GuiBase { drawDefaultBackground(); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); builder.drawSlotTab(this, left - 24, top + 6, new ItemStack(TRContent.WRENCH)); - mc.getTextureManager().bindTexture(GuiIronFurnace.texture); + minecraft.getTextureManager().bindTexture(GuiIronFurnace.texture); final int k = (this.width - containerWidth) / 2; final int l = (this.height - containerHeight) / 2; blit(k, l, 0, 0, containerWidth, containerHeight); diff --git a/src/main/java/techreborn/client/gui/GuiMFE.java b/src/main/java/techreborn/client/gui/GuiMFE.java index 637c554f6..3b3c82cb6 100644 --- a/src/main/java/techreborn/client/gui/GuiMFE.java +++ b/src/main/java/techreborn/client/gui/GuiMFE.java @@ -25,7 +25,6 @@ package techreborn.client.gui; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; diff --git a/src/main/java/techreborn/client/gui/GuiMFSU.java b/src/main/java/techreborn/client/gui/GuiMFSU.java index a75983e61..4d645126e 100644 --- a/src/main/java/techreborn/client/gui/GuiMFSU.java +++ b/src/main/java/techreborn/client/gui/GuiMFSU.java @@ -25,7 +25,6 @@ package techreborn.client.gui; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.PlayerEntity; import reborncore.client.gui.builder.GuiBase; import reborncore.common.powerSystem.PowerSystem; diff --git a/src/main/java/techreborn/client/gui/GuiManual.java b/src/main/java/techreborn/client/gui/GuiManual.java index 253252eb5..024ced308 100644 --- a/src/main/java/techreborn/client/gui/GuiManual.java +++ b/src/main/java/techreborn/client/gui/GuiManual.java @@ -24,19 +24,18 @@ package techreborn.client.gui; +import net.minecraft.client.gui.ingame.ConfirmChatLinkScreen; +import net.minecraft.client.gui.screen.ConfirmChatLinkScreen; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; import reborncore.client.gui.builder.widget.GuiButtonExtended; import reborncore.common.network.NetworkManager; - import techreborn.items.ItemManual; import techreborn.packets.ServerboundPackets; import java.awt.*; -import net.minecraft.client.gui.Screen; -import net.minecraft.client.gui.ingame.ConfirmChatLinkScreen; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.Identifier; public class GuiManual extends Screen { @@ -61,7 +60,7 @@ public class GuiManual extends Screen { } @Override - public void initGui() { + public void init() { int y = height / 4; buttons.add(new GuiButtonExtended(1, (width / 2 - 30), y + 10, 60, 20, I18n.translate("techreborn.manual.wikibtn"))); buttons.add(new GuiButtonExtended(2, (width / 2 - 30), y + 60, 60, 20, I18n.translate("techreborn.manual.discordbtn"))); @@ -73,7 +72,7 @@ public class GuiManual extends Screen { @Override public void render(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); - mc.getTextureManager().bindTexture(GuiManual.texture); + minecraft.getTextureManager().bindTexture(GuiManual.texture); int centerX = (width / 2) - guiWidth / 2; int centerY = (height / 2) - guiHeight / 2; blit(centerX, centerY, 0, 0, guiWidth, guiHeight); @@ -89,13 +88,13 @@ public class GuiManual extends Screen { public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){ switch (button.id) { case 1: - mc.displayGuiScreen(new ConfirmChatLinkScreen(this, "http://wiki.techreborn.ovh", 1, false)); + minecraft.openScreen(new ConfirmChatLinkScreen(this, "http://wiki.techreborn.ovh", 1, false)); break; case 2: - this.mc.displayGuiScreen(new ConfirmChatLinkScreen(this, "https://discord.gg/teamreborn", 2, false)); + this.minecraft.openScreen(new ConfirmChatLinkScreen(this, "https://discord.gg/teamreborn", 2, false)); break; case 3: - mc.displayGuiScreen(null); + minecraft.openScreen(null); NetworkManager.sendToServer(ServerboundPackets.createRefundPacket()); break; } @@ -112,7 +111,7 @@ public class GuiManual extends Screen { System.err.print(e); } }else { - mc.displayGuiScreen(this); + minecraft.openScreen(this); } break; case 2: @@ -123,7 +122,7 @@ public class GuiManual extends Screen { System.err.print(e); } }else { - mc.displayGuiScreen(this); + minecraft.openScreen(this); } break; } diff --git a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java index e9abfe586..5a1ea4eba 100644 --- a/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java +++ b/src/main/java/techreborn/client/gui/GuiVacuumFreezer.java @@ -47,8 +47,8 @@ public class GuiVacuumFreezer extends GuiBase { } @Override - public void initGui() { - super.initGui(); + public void init() { + super.init(); ClientProxy.multiblockRenderEvent.setMultiblock(null); } diff --git a/src/main/java/techreborn/entities/EntityNukePrimed.java b/src/main/java/techreborn/entities/EntityNukePrimed.java index b7497790b..fc9641522 100644 --- a/src/main/java/techreborn/entities/EntityNukePrimed.java +++ b/src/main/java/techreborn/entities/EntityNukePrimed.java @@ -29,6 +29,7 @@ import net.minecraft.entity.MovementType; import net.minecraft.entity.PrimedTntEntity; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import reborncore.common.explosion.RebornExplosion; import reborncore.common.registration.RebornRegister; @@ -66,21 +67,28 @@ public class EntityNukePrimed extends PrimedTntEntity { this.prevY = this.y; this.prevZ = this.z; + Vec3d velocity = getVelocity(); + double motionX = velocity.x; + double motionY = velocity.y; + double motionZ = velocity.z; + if (!this.hasNoGravity()) { - this.motionY -= 0.03999999910593033D; + motionY -= 0.03999999910593033D; } - this.move(MovementType.SELF, this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; + this.move(MovementType.SELF, new Vec3d(motionX, motionZ, motionY)); + motionX *= 0.9800000190734863D; + motionY *= 0.9800000190734863D; + motionZ *= 0.9800000190734863D; if (this.onGround) { - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - this.motionY *= -0.5D; + motionX *= 0.699999988079071D; + motionZ *= 0.699999988079071D; + motionY *= -0.5D; } + setVelocity(new Vec3d(motionX, motionZ, motionY)); + setFuse(getFuseTimer() - 1); if (getFuseTimer() <= 0) { diff --git a/src/main/java/techreborn/events/ModelRegistryEventHandler.java b/src/main/java/techreborn/events/ModelRegistryEventHandler.java index dcf8a677d..27897d1cd 100644 --- a/src/main/java/techreborn/events/ModelRegistryEventHandler.java +++ b/src/main/java/techreborn/events/ModelRegistryEventHandler.java @@ -34,7 +34,6 @@ import net.fabricmc.api.Environment; import reborncore.client.models.ModelCompound; import reborncore.client.models.RebornModelRegistry; import techreborn.TechReborn; -import techreborn.client.render.ModelDynamicCell; import techreborn.config.ConfigTechReborn; import techreborn.init.TRContent; import techreborn.init.TRContent.*; @@ -46,15 +45,12 @@ import java.util.Arrays; * */ @Environment(EnvType.CLIENT) -@Mod.EventBusSubscriber(modid = TechReborn.MOD_ID) public class ModelRegistryEventHandler { - @SubscribeEvent - public static void registerModels(ModelRegistryEvent event) { + public static void registerModels() { registerBlocks(); registerFluidBlocks(); registerItems(); - ModelDynamicCell.init(); //RebornModelRegistry.registerModels(TechReborn.MOD_ID); } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 9c6d8fb51..429eb1670 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -28,6 +28,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import reborncore.common.crafting.RebornRecipe; +import reborncore.common.crafting.RebornRecipeType; import reborncore.common.crafting.RecipeManager; import reborncore.common.registration.RebornRegister; import techreborn.TechReborn; @@ -39,23 +40,23 @@ import techreborn.api.recipe.recipes.IndustrialSawmillRecipe; public class ModRecipes { - public static final RecipeType ALLOY_SMELTER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:alloy_smelter")); - public static final RecipeType ASSEMBLING_MACHINE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:assembling_machine")); - public static final RecipeType BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new Identifier("techreborn:blast_furnace")); - public static final RecipeType CENTRIFUGE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:centrifuge")); - public static final RecipeType CHEMICAL_REACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:chemical_reactor")); - public static final RecipeType COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:compressor")); - public static final RecipeType EnvTypeILLATION_TOWER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:EnvTypeillation_tower")); - public static final RecipeType EXTRACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:extractor")); - public static final RecipeType GRINDER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:grinder")); - public static final RecipeType IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:implosion_compressor")); - public static final RecipeType INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:industrial_electrolyzer")); - public static final RecipeType INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new Identifier("techreborn:industrial_grinder")); - public static final RecipeType INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new Identifier("techreborn:industrial_sawmill")); - public static final RecipeType RECYCLER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:recycler")); - public static final RecipeType SCRAPBOX = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:scrapbox")); - public static final RecipeType VACUUM_FREEZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:vacuum_freezer")); - public static final RecipeType FLUID_REPLICATOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:fluid_replicator")); + public static final RebornRecipeType ALLOY_SMELTER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:alloy_smelter")); + public static final RebornRecipeType ASSEMBLING_MACHINE = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:assembling_machine")); + public static final RebornRecipeType BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new Identifier("techreborn:blast_furnace")); + public static final RebornRecipeType CENTRIFUGE = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:centrifuge")); + public static final RebornRecipeType CHEMICAL_REACTOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:chemical_reactor")); + public static final RebornRecipeType COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:compressor")); + public static final RebornRecipeType EnvTypeILLATION_TOWER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:EnvTypeillation_tower")); + public static final RebornRecipeType EXTRACTOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:extractor")); + public static final RebornRecipeType GRINDER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:grinder")); + public static final RebornRecipeType IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:implosion_compressor")); + public static final RebornRecipeType INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:industrial_electrolyzer")); + public static final RebornRecipeType INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new Identifier("techreborn:industrial_grinder")); + public static final RebornRecipeType INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new Identifier("techreborn:industrial_sawmill")); + public static final RebornRecipeType RECYCLER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:recycler")); + public static final RebornRecipeType SCRAPBOX = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:scrapbox")); + public static final RebornRecipeType VACUUM_FREEZER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:vacuum_freezer")); + public static final RebornRecipeType FLUID_REPLICATOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:fluid_replicator")); diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 922defa18..a37f11968 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -334,7 +334,7 @@ public class TRContent { AUTO_CRAFTING_TABLE(new BlockAutoCraftingTable()), CHEMICAL_REACTOR(new BlockChemicalReactor()), COMPRESSOR(new BlockCompressor()), - EnvTypeILLATION_TOWER(new BlockEnvTypeillationTower()), + EnvTypeILLATION_TOWER(new BlockDistillationTower()), EXTRACTOR(new BlockExtractor()), FLUID_REPLICATOR(new BlockFluidReplicator()), GRINDER(new BlockGrinder()), diff --git a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java index 0e1fa3e48..7c91a353e 100644 --- a/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java +++ b/src/main/java/techreborn/init/recipes/FluidGeneratorRecipes.java @@ -25,6 +25,7 @@ package techreborn.init.recipes; +import reborncore.fluid.Fluid; import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.init.ModFluids; diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java index c7ff24287..4e38dc9e4 100644 --- a/src/main/java/techreborn/items/DynamicCell.java +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -24,31 +24,17 @@ package techreborn.items; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.FluidBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.ActionResult; import net.minecraft.util.DefaultedList; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - - - - - - - import org.apache.commons.lang3.Validate; -import reborncore.common.util.StringUtils; +import reborncore.fluid.Fluid; +import reborncore.fluid.FluidStack; import techreborn.TechReborn; import techreborn.events.TRRecipeHandler; import techreborn.init.TRContent; @@ -59,7 +45,7 @@ import techreborn.utils.FluidUtils; */ public class DynamicCell extends Item { - public static final int CAPACITY = Fluid.BUCKET_VOLUME; + public static final int CAPACITY = 1000; public DynamicCell() { super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); @@ -81,64 +67,6 @@ public class DynamicCell extends Item { } } - @Override - public TypedActionResult use(World worldIn, PlayerEntity playerIn, Hand hand) { - ItemStack stack = playerIn.getStackInHand(hand); - if (!worldIn.isClient) { - HitResult result = rayTrace(worldIn, playerIn, true); - - if (result != null && result.type == HitResult.Type.BLOCK) { - BlockPos pos = result.getBlockPos(); - BlockState state = worldIn.getBlockState(pos); - Block block = state.getBlock(); - - if (block instanceof IFluidBlock) { - IFluidBlock fluidBlock = (IFluidBlock) block; - - if (fluidBlock.canDrain(worldIn, pos)) { - FluidStack fluid = fluidBlock.drain(worldIn, pos, false); - - if (fluid != null && fluid.amount == DynamicCell.CAPACITY) { - if (tryAddCellToInventory(playerIn, stack, fluid.getFluid())) { - fluidBlock.drain(worldIn, pos, true); - return TypedActionResult.newResult(ActionResult.SUCCESS, stack); - } - } - - } - - } else if (block instanceof FluidBlock) { - //TODO 1.13 fix me -// Fluid fluid = state.getMaterial() == Material.LAVA ? Fluids.LAVA : Fluids.WATER; -// -// if (tryAddCellToInventory(playerIn, stack, fluid)) { -// if (fluid != Fluids.WATER) -// worldIn.setBlockToAir(pos); -// return ActionResult.newResult(EnumActionResult.SUCCESS, stack); -// } - - } else { - ItemStack usedCell = stack.copy(); - usedCell.setAmount(1); - IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(usedCell).orElseGet(null); - if (fluidHandler != null) { - FluidStack fluid = fluidHandler.drain(DynamicCell.CAPACITY, false); - if (fluid != null){ - if(FluidUtil.tryPlaceFluid(playerIn, worldIn, pos.offset(result.sideHit), fluidHandler, fluid)){ - stack.subtractAmount(1); - playerIn.inventory.insertStack(getEmptyCell(1)); - return TypedActionResult.newResult(ActionResult.SUCCESS, stack); - } - return TypedActionResult.newResult(ActionResult.FAIL, stack); - } - return TypedActionResult.newResult(ActionResult.FAIL, stack); - } - return TypedActionResult.newResult(ActionResult.FAIL, stack); - } - } - } - return TypedActionResult.newResult(ActionResult.FAIL, stack); - } public boolean tryAddCellToInventory(PlayerEntity player, ItemStack stack, Fluid fluid) { if (player.inventory.insertStack(DynamicCell.getCellWithFluid(fluid))) { @@ -159,22 +87,19 @@ public class DynamicCell extends Item { } } - @Override - public String getTranslationKey(ItemStack stack) { - FluidStack fluidStack = getFluidHandler(stack).getFluid(); - if (fluidStack == null) - return super.getTranslationKey(stack); - return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName()); - } - - @Override - public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) { - return getFluidHandler(stack); - } - - public static FluidHandler getFluidHandler(ItemStack stack) { - return new FluidHandler(stack, CAPACITY); - } +// @Override +// public String getTranslationKey(ItemStack stack) { +// FluidStack fluidStack = getFluidHandler(stack).getFluid(); +// if (fluidStack == null) +// return super.getTranslationKey(stack); +// return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName()); +// } +// +// @Override +// public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) { +// return getFluidHandler(stack); +// } +// public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) { Validate.notNull(fluid); @@ -192,61 +117,5 @@ public class DynamicCell extends Item { return getCellWithFluid(fluid, 1); } - public static class FluidHandler extends FluidHandlerItemStack { - public FluidHandler(ItemStack container, int capacity) { - super(container, capacity); - - //backwards compatibility - if (container.hasTag() && container.getTag().containsKey("FluidName")) { - FluidStack stack = FluidStack.loadFluidStackFromNBT(container.getTag()); - if (stack != null) { - container.setTag(new CompoundTag()); - fill(stack, true); - } - } - - } - - @Override - public int fill(FluidStack resource, boolean doFill) { - if(resource == null) - return 0; - //Done to allow mods that try to move max int of fluid, allows the cells to work with thermal tanks. - if(resource.amount > capacity){ - resource.amount = capacity; - } - if (resource.amount != capacity) - return 0; - return super.fill(resource, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - //Done to allow mods that try to move max int of fluid, allows the cells to work with thermal tanks. - if(maxDrain > capacity){ - maxDrain = capacity; - } - if (maxDrain != capacity) - return null; - return super.drain(maxDrain, doDrain); - } - - @Override - public ItemStack getContainer() { - ItemStack cell; - if (container.hasTag() && container.getTag().contains(FLUID_NBT_KEY)) { - cell = super.getContainer(); - } - else { - cell = new ItemStack(TRContent.CELL, 1); - } - return cell; - } - - @Override - protected void setContainerToEmpty() { - container = new ItemStack(TRContent.CELL, 1); - } - } } diff --git a/src/main/java/techreborn/items/armor/ItemCloakingDevice.java b/src/main/java/techreborn/items/armor/ItemCloakingDevice.java index 4a75693ff..fc63d6bb1 100644 --- a/src/main/java/techreborn/items/armor/ItemCloakingDevice.java +++ b/src/main/java/techreborn/items/armor/ItemCloakingDevice.java @@ -119,11 +119,6 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } // IEnergyItemInfo @Override diff --git a/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java b/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java index ebe9f955d..2c60b7ac5 100644 --- a/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java +++ b/src/main/java/techreborn/items/armor/ItemLapotronicOrbpack.java @@ -38,6 +38,7 @@ import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.config.ConfigTechReborn; @@ -45,7 +46,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; -public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo { +public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo, ItemDurabilityExtensions { // 400M FE maxCharge and 100k FE\t charge rate. Fully charged in 3 mins. public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; @@ -92,13 +93,6 @@ public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } @Override @Environment(EnvType.CLIENT) diff --git a/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java b/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java index 7c5287a42..bd9f2aad2 100644 --- a/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java +++ b/src/main/java/techreborn/items/armor/ItemLithiumIonBatpack.java @@ -37,8 +37,8 @@ import net.fabricmc.api.Environment; import reborncore.api.power.IEnergyItemInfo; import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; -import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.config.ConfigTechReborn; @@ -46,7 +46,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; -public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo { +public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo, ItemDurabilityExtensions { // 8M FE maxCharge and 2k FE\t charge rate. Fully charged in 3 mins. public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; @@ -93,12 +93,6 @@ public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Override @Environment(EnvType.CLIENT) public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { diff --git a/src/main/java/techreborn/items/armor/ItemTRArmour.java b/src/main/java/techreborn/items/armor/ItemTRArmour.java index f393e4819..5137ef92c 100644 --- a/src/main/java/techreborn/items/armor/ItemTRArmour.java +++ b/src/main/java/techreborn/items/armor/ItemTRArmour.java @@ -29,6 +29,7 @@ import net.minecraft.item.ArmorItem; import net.minecraft.item.ArmorMaterial; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.events.TRRecipeHandler; @@ -36,7 +37,7 @@ import techreborn.events.TRRecipeHandler; /** * Created by modmuss50 on 26/02/2016. */ -public class ItemTRArmour extends ArmorItem { +public class ItemTRArmour extends ArmorItem implements ItemDurabilityExtensions { String repairOreDict = ""; diff --git a/src/main/java/techreborn/items/battery/ItemBattery.java b/src/main/java/techreborn/items/battery/ItemBattery.java index 2fd88edfd..012158545 100644 --- a/src/main/java/techreborn/items/battery/ItemBattery.java +++ b/src/main/java/techreborn/items/battery/ItemBattery.java @@ -80,14 +80,6 @@ public class ItemBattery extends Item implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - // IEnergyItemInfo @Override public int getCapacity() { diff --git a/src/main/java/techreborn/items/tool/ItemChainsaw.java b/src/main/java/techreborn/items/tool/ItemChainsaw.java index 9095464fb..a17441520 100644 --- a/src/main/java/techreborn/items/tool/ItemChainsaw.java +++ b/src/main/java/techreborn/items/tool/ItemChainsaw.java @@ -43,13 +43,14 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import javax.annotation.Nullable; import java.util.Random; -public class ItemChainsaw extends AxeItem implements IEnergyItemInfo { +public class ItemChainsaw extends AxeItem implements IEnergyItemInfo, ItemDurabilityExtensions { public int maxCharge = 1; public int cost = 250; @@ -120,14 +121,6 @@ public class ItemChainsaw extends AxeItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { return !(newStack.isEqualIgnoreTags(oldStack)); diff --git a/src/main/java/techreborn/items/tool/ItemDrill.java b/src/main/java/techreborn/items/tool/ItemDrill.java index d36cfd593..323b35a20 100644 --- a/src/main/java/techreborn/items/tool/ItemDrill.java +++ b/src/main/java/techreborn/items/tool/ItemDrill.java @@ -42,13 +42,14 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import javax.annotation.Nullable; import java.util.Random; -public class ItemDrill extends PickaxeItem implements IEnergyItemInfo { +public class ItemDrill extends PickaxeItem implements IEnergyItemInfo, ItemDurabilityExtensions { public int maxCharge = 1; public int cost = 250; @@ -115,14 +116,6 @@ public class ItemDrill extends PickaxeItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { return !(newStack.isEqualIgnoreTags(oldStack)); diff --git a/src/main/java/techreborn/items/tool/ItemJackhammer.java b/src/main/java/techreborn/items/tool/ItemJackhammer.java index af0ed3863..611feba93 100644 --- a/src/main/java/techreborn/items/tool/ItemJackhammer.java +++ b/src/main/java/techreborn/items/tool/ItemJackhammer.java @@ -43,6 +43,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.utils.TagUtils; @@ -50,7 +51,7 @@ import techreborn.utils.TagUtils; import javax.annotation.Nullable; import java.util.Random; -public class ItemJackhammer extends PickaxeItem implements IEnergyItemInfo { +public class ItemJackhammer extends PickaxeItem implements IEnergyItemInfo, ItemDurabilityExtensions { public int maxCharge = 1; public int cost = 250; @@ -118,14 +119,6 @@ public class ItemJackhammer extends PickaxeItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { return !(newStack.isEqualIgnoreTags(oldStack)); diff --git a/src/main/java/techreborn/items/tool/ItemWrench.java b/src/main/java/techreborn/items/tool/ItemWrench.java index 617ed62b1..0caa9d83d 100644 --- a/src/main/java/techreborn/items/tool/ItemWrench.java +++ b/src/main/java/techreborn/items/tool/ItemWrench.java @@ -27,6 +27,7 @@ package techreborn.items.tool; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -45,7 +46,7 @@ public class ItemWrench extends Item implements IToolHandler { @Override public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) { if (damage) { - stack.damageItem(1, player); + stack.applyDamage(1, player.world.random, (ServerPlayerEntity) player); } return true; } diff --git a/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java b/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java index b61b6783f..7232bb158 100644 --- a/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java +++ b/src/main/java/techreborn/items/tool/advanced/ItemRockCutter.java @@ -43,6 +43,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.config.ConfigTechReborn; @@ -51,7 +52,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; import java.util.Random; -public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo { +public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo, ItemDurabilityExtensions { public static final int maxCharge = ConfigTechReborn.RockCutterCharge; public int transferLimit = 1_000; @@ -130,12 +131,6 @@ public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Override public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { return !(newStack.isEqualIgnoreTags(oldStack)); diff --git a/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java b/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java index 3001c0f7c..11c66fba0 100644 --- a/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java +++ b/src/main/java/techreborn/items/tool/basic/ItemElectricTreetap.java @@ -39,6 +39,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.api.TechRebornAPI; @@ -49,7 +50,7 @@ import javax.annotation.Nullable; /** * Created by modmuss50 on 05/11/2016. */ -public class ItemElectricTreetap extends Item implements IEnergyItemInfo { +public class ItemElectricTreetap extends Item implements IEnergyItemInfo, ItemDurabilityExtensions { public static final int maxCharge = 10_000; public int cost = 20; @@ -88,12 +89,6 @@ public class ItemElectricTreetap extends Item implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Environment(EnvType.CLIENT) @Override public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList itemList) { diff --git a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java index 963353a67..18fc6300f 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java @@ -51,6 +51,7 @@ import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.util.ChatUtils; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import techreborn.TechReborn; import techreborn.config.ConfigTechReborn; @@ -60,7 +61,7 @@ import techreborn.utils.MessageIDs; import javax.annotation.Nullable; import java.util.List; -public class ItemNanosaber extends SwordItem implements IEnergyItemInfo { +public class ItemNanosaber extends SwordItem implements IEnergyItemInfo, ItemDurabilityExtensions { public static final int maxCharge = ConfigTechReborn.nanoSaberCharge; public int transferLimit = 1_000; public int cost = 250; @@ -188,14 +189,6 @@ public class ItemNanosaber extends SwordItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Environment(EnvType.CLIENT) @Override public void appendItemsForGroup( diff --git a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java index 04e3dd47d..2852fa46b 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java @@ -46,6 +46,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.ItemPowerManager; +import reborncore.common.util.ItemDurabilityExtensions; import reborncore.common.util.ItemUtils; import reborncore.common.util.TorchHelper; import techreborn.TechReborn; @@ -55,7 +56,7 @@ import techreborn.init.TRContent; import javax.annotation.Nullable; import java.util.List; -public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo { +public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo, ItemDurabilityExtensions { public static final int maxCharge = ConfigTechReborn.OmniToolCharge; public int transferLimit = 1_000; @@ -153,12 +154,6 @@ public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo { return PowerSystem.getDisplayPower().colour; } - @Override - @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { - return new PoweredItemContainerProvider(stack); - } - @Environment(EnvType.CLIENT) @Override public void appendItemsForGroup( diff --git a/src/main/java/techreborn/packets/ServerboundPackets.java b/src/main/java/techreborn/packets/ServerboundPackets.java index 07c218bb3..74bce4fb6 100644 --- a/src/main/java/techreborn/packets/ServerboundPackets.java +++ b/src/main/java/techreborn/packets/ServerboundPackets.java @@ -24,10 +24,15 @@ package techreborn.packets; +import net.fabricmc.fabric.api.network.PacketContext; +import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; - import reborncore.common.network.ExtendedPacketBuffer; import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkPacket; @@ -40,7 +45,6 @@ import techreborn.tiles.storage.TileAdjustableSU; import techreborn.tiles.storage.idsu.TileInterdimensionalSU; import java.util.function.BiConsumer; -import java.util.function.Consumer; public class ServerboundPackets { @@ -50,45 +54,45 @@ public class ServerboundPackets { public static final Identifier FUSION_CONTROL_SIZE = new Identifier("techreborn", "fusion_control_size"); public static final Identifier IDSU = new Identifier("techreborn", "idsu"); public static final Identifier REFUND = new Identifier("techreborn", "refund"); - + public static void init() { - NetworkManager.registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { + registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { BlockPos pos = extendedPacketBuffer.readBlockPos(); int buttonID = extendedPacketBuffer.readInt(); - context.enqueueWork(() -> { - TileEntity tile = context.getSender().world.getTileEntity(pos); + context.getTaskQueue().execute(() -> { + BlockEntity tile = context.getPlayer().world.getBlockEntity(pos); if (tile instanceof TileAdjustableSU) { ((TileAdjustableSU) tile).handleGuiInputFromClient(buttonID, false, false); } }); }); - NetworkManager.registerPacketHandler(AUTO_CRAFTING_LOCK, (extendedPacketBuffer, context) -> { + registerPacketHandler(AUTO_CRAFTING_LOCK, (extendedPacketBuffer, context) -> { BlockPos machinePos = extendedPacketBuffer.readBlockPos(); boolean locked = extendedPacketBuffer.readBoolean(); - context.enqueueWork(() -> { - TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos); - if (tileEntity instanceof TileAutoCraftingTable) { - ((TileAutoCraftingTable) tileEntity).locked = locked; + context.getTaskQueue().execute(() -> { + BlockEntity BlockEntity = context.getPlayer().world.getBlockEntity(machinePos); + if (BlockEntity instanceof TileAutoCraftingTable) { + ((TileAutoCraftingTable) BlockEntity).locked = locked; } }); }); - NetworkManager.registerPacketHandler(FUSION_CONTROL_SIZE, (extendedPacketBuffer, context) -> { + registerPacketHandler(FUSION_CONTROL_SIZE, (extendedPacketBuffer, context) -> { int sizeDelta = extendedPacketBuffer.readInt(); BlockPos pos = extendedPacketBuffer.readBlockPos(); - context.enqueueWork(() -> { - TileEntity tile = context.getSender().world.getTileEntity(pos); + context.getTaskQueue().execute(() -> { + BlockEntity tile = context.getPlayer().world.getBlockEntity(pos); if (tile instanceof TileFusionControlComputer) { ((TileFusionControlComputer) tile).changeSize(sizeDelta); } }); }); - NetworkManager.registerPacketHandler(IDSU, (extendedPacketBuffer, context) -> { + registerPacketHandler(IDSU, (extendedPacketBuffer, context) -> { BlockPos pos = extendedPacketBuffer.readBlockPos(); int buttonID = extendedPacketBuffer.readInt(); - context.enqueueWork(() -> { + context.getTaskQueue().execute(() -> { //TODO was commented out when I ported it, so ill leave it here, needs looking into tho // if (!pos.getWorld().isRemote) { // pos.handleGuiInputFromClient(buttonID); @@ -96,27 +100,27 @@ public class ServerboundPackets { }); }); - NetworkManager.registerPacketHandler(ROLLING_MACHINE_LOCK, (extendedPacketBuffer, context) -> { + registerPacketHandler(ROLLING_MACHINE_LOCK, (extendedPacketBuffer, context) -> { BlockPos machinePos = extendedPacketBuffer.readBlockPos(); boolean locked = extendedPacketBuffer.readBoolean(); - context.enqueueWork(() -> { - TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos); - if (tileEntity instanceof TileRollingMachine) { - ((TileRollingMachine) tileEntity).locked = locked; + context.getTaskQueue().execute(() -> { + BlockEntity BlockEntity = context.getPlayer().world.getBlockEntity(machinePos); + if (BlockEntity instanceof TileRollingMachine) { + ((TileRollingMachine) BlockEntity).locked = locked; } }); }); - NetworkManager.registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> { + registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> { if(!ItemManual.allowRefund){ return; } - context.enqueueWork(() -> { - EntityPlayerMP playerMP = context.getSender(); - for (int i = 0; i < playerMP.inventory.getSizeInventory(); i++) { - ItemStack stack = playerMP.inventory.getStackInSlot(i); + context.getTaskQueue().execute(() -> { + PlayerEntity playerMP = context.getPlayer(); + for (int i = 0; i < playerMP.inventory.getInvSize(); i++) { + ItemStack stack = playerMP.inventory.getInvStack(i); if (stack.getItem() == TRContent.MANUAL) { - playerMP.inventory.removeStackFromSlot(i); + playerMP.inventory.removeInvStack(i); playerMP.inventory.addItemStackToInventory(new ItemStack(Items.BOOK)); //TODO 1.13 //playerMP.inventory.addItemStackToInventory(OreUtil.getStackFromName("ingotRefinedIron")); @@ -128,6 +132,10 @@ public class ServerboundPackets { }); } + private static void registerPacketHandler(Identifier identifier, BiConsumer consumer){ + ServerSidePacketRegistry.INSTANCE.register(identifier, (packetContext, packetByteBuf) -> consumer.accept(new ExtendedPacketBuffer(packetByteBuf), packetContext)); + } + public static NetworkPacket createPacketAesu(int buttonID, TileAdjustableSU tile) { return NetworkManager.createPacket(AESU, extendedPacketBuffer -> { extendedPacketBuffer.writeBlockPos(tile.getPos()); diff --git a/src/main/java/techreborn/tiles/TileTechStorageBase.java b/src/main/java/techreborn/tiles/TileTechStorageBase.java index 25a8cb91b..8a2eed761 100644 --- a/src/main/java/techreborn/tiles/TileTechStorageBase.java +++ b/src/main/java/techreborn/tiles/TileTechStorageBase.java @@ -218,22 +218,6 @@ public class TileTechStorageBase extends TileMachineBase return tagCompound; } - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability cap) { - if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - - return LazyOptional.of(new NonNullSupplier() { - @Nonnull - @Override - public T get() { - return (T) inventory; - } - }); - } - return super.getCapability(cap); - } - // ItemHandlerProvider @Override public Inventory getInventory() { diff --git a/src/main/java/techreborn/tiles/cable/TileCable.java b/src/main/java/techreborn/tiles/cable/TileCable.java index 72cb67916..235c13f8c 100644 --- a/src/main/java/techreborn/tiles/cable/TileCable.java +++ b/src/main/java/techreborn/tiles/cable/TileCable.java @@ -34,7 +34,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.ClientConnection; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; -import net.minecraft.util.ITickable; +import net.minecraft.util.Tickable; import net.minecraft.util.math.Direction; @@ -57,7 +57,7 @@ import java.util.List; */ public class TileCable extends BlockEntity - implements ITickable, IEnergyStorage, IListInfoProvider, IToolDrop { + implements Tickable, IEnergyStorage, IListInfoProvider, IToolDrop { public int power = 0; private int transferRate = 0; @@ -84,14 +84,6 @@ public class TileCable extends BlockEntity } return canReceive(); } - - @Override - public LazyOptional getCapability(Capability capability) { - if (capability == CapabilityEnergy.ENERGY) { - return LazyOptional.of(() -> (T)this); - } - return super.getCapability(capability); - } @Override public CompoundTag toInitialChunkDataTag() { @@ -151,37 +143,39 @@ public class TileCable extends BlockEntity return; } - ArrayList acceptors = new ArrayList(); - for (Direction face : Direction.values()) { - BlockEntity tile = world.getBlockEntity(pos.offset(face)); + //TODO needs a full recode to not use a specific power net - if (tile == null) { - continue; - } else if (tile instanceof TileCable) { - TileCable cable = (TileCable) tile; - if (power > cable.power && cable.canReceiveFromFace(face.getOpposite())) { - acceptors.add((IEnergyStorage) tile); - if (!sendingFace.contains(face)) { - sendingFace.add(face); - } - } - } else if (tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).isPresent()) { - IEnergyStorage energyTile = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).orElse(null); - if (energyTile != null && energyTile.canReceive()) { - acceptors.add(energyTile); - } - } - } - - if (acceptors.size() > 0 ) { - for (IEnergyStorage tile : acceptors) { - int drain = Math.min(power, transferRate); - if (drain > 0 && tile.receiveEnergy(drain, true) > 0) { - int move = tile.receiveEnergy(drain, false); - extractEnergy(move, false); - } - } - } +// ArrayList acceptors = new ArrayList(); +// for (Direction face : Direction.values()) { +// BlockEntity tile = world.getBlockEntity(pos.offset(face)); +// +// if (tile == null) { +// continue; +// } else if (tile instanceof TileCable) { +// TileCable cable = (TileCable) tile; +// if (power > cable.power && cable.canReceiveFromFace(face.getOpposite())) { +// acceptors.add((IEnergyStorage) tile); +// if (!sendingFace.contains(face)) { +// sendingFace.add(face); +// } +// } +// } else if (tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).isPresent()) { +// IEnergyStorage energyTile = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).orElse(null); +// if (energyTile != null && energyTile.canReceive()) { +// acceptors.add(energyTile); +// } +// } +// } +// +// if (acceptors.size() > 0 ) { +// for (IEnergyStorage tile : acceptors) { +// int drain = Math.min(power, transferRate); +// if (drain > 0 && tile.receiveEnergy(drain, true) > 0) { +// int move = tile.receiveEnergy(drain, false); +// extractEnergy(move, false); +// } +// } +// } } // IEnergyStorage diff --git a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java index 13c5db8c5..5e53dd5bb 100644 --- a/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java +++ b/src/main/java/techreborn/tiles/generator/TileBaseFluidGenerator.java @@ -32,13 +32,14 @@ import reborncore.api.IToolDrop; import reborncore.api.tile.ItemHandlerProvider; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.TilePowerAcceptor; -import reborncore.common.util.FluidUtils; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; +import reborncore.fluid.FluidStack; import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.FluidGeneratorRecipe; import techreborn.api.generator.FluidGeneratorRecipeList; import techreborn.api.generator.GeneratorRecipeHelper; +import techreborn.utils.FluidUtils; import javax.annotation.Nullable; diff --git a/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java b/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java index b7cb09f5e..0f8d1f3f1 100644 --- a/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java +++ b/src/main/java/techreborn/tiles/machine/iron/TileIronAlloyFurnace.java @@ -34,7 +34,7 @@ import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.common.crafting.RebornIngredient; -import reborncore.common.crafting.Recipe; +import reborncore.common.crafting.RebornRecipe; import reborncore.common.registration.RebornRegister; import reborncore.common.tile.TileMachineBase; import reborncore.common.util.Inventory; @@ -71,7 +71,7 @@ public class TileIronAlloyFurnace extends TileMachineBase if (stack.isEmpty()) { return 0; } else { - return FurnaceBlockEntity.getBurnTimes().getOrDefault(stack.getItem(), 0); + return FurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0); } } @@ -115,7 +115,7 @@ public class TileIronAlloyFurnace extends TileMachineBase } } - public boolean hasAllInputs(final Recipe recipeType) { + public boolean hasAllInputs(final RebornRecipe recipeType) { if (recipeType == null) { return false; } @@ -137,7 +137,7 @@ public class TileIronAlloyFurnace extends TileMachineBase return false; } else { ItemStack itemstack = null; - for (final Recipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { + for (final RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { if (this.hasAllInputs(recipeType)) { itemstack = recipeType.getOutputs().get(0); break; @@ -169,7 +169,7 @@ public class TileIronAlloyFurnace extends TileMachineBase public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = ItemStack.EMPTY; - for (final Recipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { + for (final RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { if (this.hasAllInputs(recipeType)) { itemstack = recipeType.getOutputs().get(0); break; @@ -185,7 +185,7 @@ public class TileIronAlloyFurnace extends TileMachineBase inventory.shrinkSlot(this.output, -itemstack.getAmount()); } - for (final Recipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { + for (final RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) { boolean hasAllRecipes = true; if (this.hasAllInputs(recipeType)) { diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java b/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java index 1667597fc..7e25d2826 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileFluidReplicator.java @@ -42,6 +42,7 @@ import techreborn.api.fluidreplicator.FluidReplicatorRecipeCrafter; import techreborn.init.TRContent; import techreborn.init.TRTileEntities; import techreborn.tiles.TileGenericMachine; +import techreborn.utils.FluidUtils; import javax.annotation.Nullable; diff --git a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java index 2537d6443..dadb2a084 100644 --- a/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java +++ b/src/main/java/techreborn/tiles/machine/multiblock/TileIndustrialGrinder.java @@ -38,7 +38,6 @@ import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.common.recipes.RecipeCrafter; import reborncore.common.registration.RebornRegister; import reborncore.common.registration.config.ConfigRegistry; -import reborncore.common.util.FluidUtils; import reborncore.common.util.IInventoryAccess; import reborncore.common.util.Inventory; import reborncore.common.util.Tank; @@ -47,6 +46,7 @@ import techreborn.init.ModRecipes; import techreborn.init.TRContent; import techreborn.init.TRTileEntities; import techreborn.tiles.TileGenericMachine; +import techreborn.utils.FluidUtils; import javax.annotation.Nullable; diff --git a/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java b/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java index 76b676c7a..f9f49a1e7 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TileAutoCraftingTable.java @@ -431,7 +431,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor // ItemHandlerProvider @Override - public IItemHandler getInventory() { + public Inventory getInventory() { return inventory; } diff --git a/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java b/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java index fe2dafed0..fb9248c1c 100644 --- a/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java +++ b/src/main/java/techreborn/tiles/machine/tier1/TilePlayerDectector.java @@ -39,6 +39,7 @@ import techreborn.init.TRContent; import techreborn.init.TRTileEntities; import java.util.Iterator; +import java.util.function.Consumer; @RebornRegister(TechReborn.MOD_ID) public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop { @@ -69,7 +70,7 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop boolean lastRedstone = redstone; redstone = false; if (canUseEnergy(euPerTick)) { - Iterator tIterator = super.world.playerEntities.iterator(); + Iterator tIterator = super.world.getPlayers().iterator(); while (tIterator.hasNext()) { PlayerEntity player = tIterator.next(); if (player.squaredEnvTypeanceTo((double) super.getPos().getX() + 0.5D, diff --git a/src/main/java/techreborn/utils/FluidUtils.java b/src/main/java/techreborn/utils/FluidUtils.java index 734fbc183..fd35f6b02 100644 --- a/src/main/java/techreborn/utils/FluidUtils.java +++ b/src/main/java/techreborn/utils/FluidUtils.java @@ -25,7 +25,11 @@ package techreborn.utils; import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import reborncore.common.util.Inventory; +import reborncore.common.util.Tank; import reborncore.fluid.Fluid; +import reborncore.fluid.FluidStack; import java.util.Collections; import java.util.List; @@ -44,4 +48,19 @@ public class FluidUtils { return null; } + public static void drainContainers(Tank tank, Inventory inventory, int i, int i1) { + + } + + public static void fillContainers(Tank tank, Inventory inventory, int i, int i1, Fluid fluidType) { + + } + + public static boolean fluidEquals(Fluid fluid, Fluid fluid1) { + return false; + } + + public static FluidStack getFluidStackInContainer(ItemStack invStack) { + return null; + } }