This commit is contained in:
modmuss50 2019-06-04 12:05:18 +01:00
parent e8396dbc33
commit d18d1b820e
65 changed files with 287 additions and 520 deletions

View file

@ -24,18 +24,12 @@
package techreborn; 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.block.DispenserBlock;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; 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.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import reborncore.common.multiblock.MultiblockEventHandler; import reborncore.common.multiblock.MultiblockEventHandler;
@ -55,10 +49,8 @@ import techreborn.tiles.fusionReactor.TileFusionControlComputer;
import techreborn.utils.BehaviorDispenseScrapbox; import techreborn.utils.BehaviorDispenseScrapbox;
import techreborn.utils.StackWIPHandler; import techreborn.utils.StackWIPHandler;
import techreborn.world.village.ModLootTables; import techreborn.world.village.ModLootTables;
import techreborn.world.village.VillagePlantaionHandler;
@Mod("techreborn") public class TechReborn implements ModInitializer {
public class TechReborn {
public static final String MOD_ID = "techreborn"; public static final String MOD_ID = "techreborn";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
@ -72,14 +64,8 @@ public class TechReborn {
} }
}; };
@Override
public TechReborn() { public void onInitialize() {
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::setup);
eventBus.addListener(this::loadComplete);
}
private void setup(FMLCommonSetupEvent event) {
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
INSTANCE = this; INSTANCE = this;
@ -131,47 +117,13 @@ public class TechReborn {
} }
Torus.genSizeMap(TileFusionControlComputer.maxCoilSize); Torus.genSizeMap(TileFusionControlComputer.maxCoilSize);
LOGGER.info("TechReborn setup done!");
}
private void loadComplete(FMLLoadCompleteEvent event) {
proxy.postInit(); proxy.postInit();
ModRecipes.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!");
} }
} }

View file

@ -26,9 +26,10 @@ package techreborn.api.fluidreplicator;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import reborncore.common.util.FluidUtils; import reborncore.fluid.Fluid;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.tiles.machine.multiblock.TileFluidReplicator; import techreborn.tiles.machine.multiblock.TileFluidReplicator;
import techreborn.utils.FluidUtils;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -27,6 +27,8 @@ package techreborn.api.fluidreplicator;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import reborncore.common.util.FluidUtils; import reborncore.common.util.FluidUtils;
import reborncore.fluid.Fluid;
import techreborn.utils.FluidUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Optional; import java.util.Optional;

View file

@ -25,8 +25,8 @@
package techreborn.api.generator; package techreborn.api.generator;
import reborncore.common.util.FluidUtils;
import reborncore.fluid.Fluid; import reborncore.fluid.Fluid;
import techreborn.utils.FluidUtils;
public class FluidGeneratorRecipe { public class FluidGeneratorRecipe {
private final EFluidGenerator generatorType; private final EFluidGenerator generatorType;

View file

@ -26,7 +26,6 @@ package techreborn.api.generator;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import reborncore.common.util.FluidUtils;
import reborncore.fluid.Fluid; import reborncore.fluid.Fluid;
import java.util.HashSet; import java.util.HashSet;

View file

@ -28,15 +28,17 @@ import com.google.gson.JsonObject;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper; import net.minecraft.util.JsonHelper;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.Recipe; import reborncore.common.crafting.Recipe;
import reborncore.common.crafting.RecipeType; import reborncore.common.crafting.RecipeType;
import techreborn.tiles.machine.multiblock.TileIndustrialBlastFurnace; import techreborn.tiles.machine.multiblock.TileIndustrialBlastFurnace;
public class BlastFurnaceRecipe extends Recipe { public class BlastFurnaceRecipe extends RebornRecipe {
int heat; int heat;
public BlastFurnaceRecipe(RecipeType<?> type, Identifier name) { public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name); super(type, name);
} }

View file

@ -27,15 +27,17 @@ package techreborn.api.recipe.recipes;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.fluid.FluidStack; import reborncore.fluid.FluidStack;
import techreborn.tiles.machine.multiblock.TileIndustrialGrinder; import techreborn.tiles.machine.multiblock.TileIndustrialGrinder;
public class IndustrialGrinderRecipe extends Recipe { public class IndustrialGrinderRecipe extends RebornRecipe {
//TODO 1.14 fluids //TODO 1.14 fluids
FluidStack fluidStack = null; FluidStack fluidStack = null;
public IndustrialGrinderRecipe(RecipeType<?> type, Identifier name) { public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name); super(type, name);
} }

View file

@ -27,15 +27,17 @@ package techreborn.api.recipe.recipes;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.fluid.FluidStack; import reborncore.fluid.FluidStack;
import techreborn.tiles.machine.multiblock.TileIndustrialSawmill; import techreborn.tiles.machine.multiblock.TileIndustrialSawmill;
public class IndustrialSawmillRecipe extends Recipe { public class IndustrialSawmillRecipe extends RebornRecipe {
//TODO 1.14 fluids //TODO 1.14 fluids
FluidStack fluidStack = null; FluidStack fluidStack = null;
public IndustrialSawmillRecipe(RecipeType<?> type, Identifier name) { public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name) {
super(type, name); super(type, name);
} }

View file

@ -41,6 +41,7 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
@ -130,7 +131,7 @@ public class BlockAlarm extends BaseTileBlock {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -140,7 +141,7 @@ public class BlockAlarm extends BaseTileBlock {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 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 @Override

View file

@ -31,6 +31,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.BlockRotation; import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -56,11 +57,11 @@ public class BlockComputerCube extends BlockMachineBase {
} }
@Override @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); ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { 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()) { if (playerIn.isSneaking()) {
ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1); ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1);
dropStack(worldIn, pos, drop); dropStack(worldIn, pos, drop);
@ -72,7 +73,7 @@ public class BlockComputerCube extends BlockMachineBase {
return true; return true;
} }
else { else {
rotate(worldIn.getBlockState(pos), worldIn, pos, BlockRotation.CLOCKWISE_90); rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
return true; return true;
} }
} }

View file

@ -24,6 +24,7 @@
package techreborn.blocks; package techreborn.blocks;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.GlassBlock; import net.minecraft.block.GlassBlock;
@ -38,12 +39,8 @@ import java.util.Random;
public class BlockReinforcedGlass extends GlassBlock { public class BlockReinforcedGlass extends GlassBlock {
public BlockReinforcedGlass() { 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)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this));
} }
@Override
public int quantityDropped(BlockState state, Random random) {
return 1;
}
} }

View file

@ -24,6 +24,7 @@
package techreborn.blocks; package techreborn.blocks;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -42,7 +43,7 @@ import techreborn.init.TRContent;
public class BlockRubberLeaves extends LeavesBlock { public class BlockRubberLeaves extends LeavesBlock {
public BlockRubberLeaves() { 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); ((FireBlock) Blocks.FIRE).registerFlammableBlock(this, 30, 60);
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, EnvTypeANCE, PERSISTENT)); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, EnvTypeANCE, PERSISTENT));
} }

View file

@ -44,6 +44,7 @@ import net.minecraft.tag.BlockTags;
import net.minecraft.tag.Tag; import net.minecraft.tag.Tag;
import net.minecraft.util.DefaultedList; import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -92,7 +93,7 @@ public class BlockRubberLog extends LogBlock {
int i = 4; int i = 4;
int j = i + 1; int j = i + 1;
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) { 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); BlockState state1 = worldIn.getBlockState(blockpos);
if (state1.matches(BlockTags.LEAVES)) { if (state1.matches(BlockTags.LEAVES)) {
state1.scheduledTick(worldIn, blockpos, worldIn.getRandom()); state1.scheduledTick(worldIn, blockpos, worldIn.getRandom());
@ -123,9 +124,9 @@ public class BlockRubberLog extends LogBlock {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) { Hand hand, BlockHitResult hitResult) {
super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); super.activate(state, worldIn, pos, playerIn, hand, hitResult);
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
if (stack.isEmpty()) { if (stack.isEmpty()) {
return false; return false;
@ -135,7 +136,7 @@ public class BlockRubberLog extends LogBlock {
capEnergy = new ItemPowerManager(stack); capEnergy = new ItemPowerManager(stack);
} }
if ((capEnergy != null && capEnergy.getEnergyStored() > 20) || stack.getItem() instanceof ItemTreeTap) { 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.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, worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS,
0.6F, 1F); 0.6F, 1F);
@ -148,7 +149,7 @@ public class BlockRubberLog extends LogBlock {
playerIn.getStackInHand(Hand.MAIN_HAND).damageItem(1, playerIn); playerIn.getStackInHand(Hand.MAIN_HAND).damageItem(1, playerIn);
} }
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) { 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) { if (playerIn instanceof ServerPlayerEntity) {
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn); TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);

View file

@ -36,6 +36,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.AbstractProperty; import net.minecraft.state.property.AbstractProperty;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -126,7 +127,7 @@ public class BlockCable extends BlockWithEntity {
// Block // Block
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -136,11 +137,11 @@ public class BlockCable extends BlockWithEntity {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 true;
} }
} }
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
@Override @Override

View file

@ -36,6 +36,7 @@ import net.minecraft.network.chat.TextComponent;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -59,8 +60,8 @@ public class BlockFusionCoil extends Block {
} }
@Override @Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) { Hand hand, BlockHitResult hitResult) {
ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND); ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) { if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {

View file

@ -29,6 +29,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -54,8 +55,8 @@ public class BlockFusionControlComputer extends BlockMachineBase {
} }
@Override @Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, Direction side, float hitX, float hitY, float hitZ) { Hand hand, BlockHitResult hitResult) {
final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getBlockEntity(pos); final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getBlockEntity(pos);
if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){ if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){
List<BlockPos> coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size); List<BlockPos> coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size);
@ -78,7 +79,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
} }
tileFusionControlComputer.checkCoils(); tileFusionControlComputer.checkCoils();
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
@Override @Override

View file

@ -40,6 +40,7 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
@ -143,28 +144,9 @@ public class BlockLamp extends BaseTileBlock {
return BlockRenderLayer.CUTOUT; 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") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -174,11 +156,11 @@ public class BlockLamp extends BaseTileBlock {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 true;
} }
} }
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
} }

View file

@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -102,7 +103,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -112,7 +113,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 true;
} }
} }
@ -122,7 +123,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
return true; return true;
} }
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
@Override @Override

View file

@ -33,6 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList; import net.minecraft.util.DefaultedList;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -93,7 +94,7 @@ public class BlockLSUStorage extends BaseTileBlock {
// Block // Block
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -103,12 +104,12 @@ public class BlockLSUStorage extends BaseTileBlock {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 true;
} }
} }
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
@Override @Override

View file

@ -38,6 +38,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateFactory;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -90,12 +91,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
} }
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity == null) { 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); String type = state.get(TYPE);
@ -103,7 +104,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
ChatFormat color = ChatFormat.GREEN; ChatFormat color = ChatFormat.GREEN;
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 (playerIn.isSneaking()) {
if (tileEntity instanceof IToolDrop) { if (tileEntity instanceof IToolDrop) {
ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(playerIn); ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(playerIn);

View file

@ -34,9 +34,9 @@ import techreborn.TechReborn;
import techreborn.client.EGui; import techreborn.client.EGui;
import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower; import techreborn.tiles.machine.multiblock.TileEnvTypeillationTower;
public class BlockEnvTypeillationTower extends BlockMachineBase { public class BlockDistillationTower extends BlockMachineBase {
public BlockEnvTypeillationTower() { public BlockDistillationTower() {
super(); super();
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier2_machines")); RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier2_machines"));
} }

View file

@ -35,6 +35,7 @@ import net.minecraft.state.StateFactory;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -92,7 +93,7 @@ public abstract class BlockTransformer extends BaseTileBlock {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @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); ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity tileEntity = worldIn.getBlockEntity(pos); BlockEntity tileEntity = worldIn.getBlockEntity(pos);
@ -102,11 +103,11 @@ public abstract class BlockTransformer extends BaseTileBlock {
} }
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) { 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 true;
} }
} }
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
} }
} }

View file

@ -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_) { protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
this.drawDefaultBackground(); this.drawDefaultBackground();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); 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 k = (this.width - this.containerWidth) / 2;
final int l = (this.height - this.containerHeight) / 2; final int l = (this.height - this.containerHeight) / 2;
this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight);

View file

@ -24,6 +24,7 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;

View file

@ -53,8 +53,8 @@ public class GuiChunkLoader extends AbstractContainerScreen {
} }
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
this.left = this.width / 2 - this.containerWidth / 2; this.left = this.width / 2 - this.containerWidth / 2;
this.top = this.height / 2 - this.containerHeight / 2; this.top = this.height / 2 - this.containerHeight / 2;
this.plusOneButton = new GuiButtonSimple(0, this.left + 5, this.top + 37, 40, 20, "+1"); 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_) { protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
this.drawDefaultBackground(); this.drawDefaultBackground();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); 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 k = (this.width - this.containerWidth) / 2;
final int l = (this.height - this.containerHeight) / 2; final int l = (this.height - this.containerHeight) / 2;
this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight);

View file

@ -24,6 +24,7 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;

View file

@ -57,8 +57,8 @@ public class GuiFluidReplicator extends GuiBase {
// GuiBase // GuiBase
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
ClientProxy.multiblockRenderEvent.setMultiblock(null); ClientProxy.multiblockRenderEvent.setMultiblock(null);
} }

View file

@ -100,8 +100,8 @@ public class GuiFusionReactor extends GuiBase {
} }
} }
builder.drawUpDownButtons(this, 121, 79, layer); builder.drawUpDownButtons(this, 121, 79, layer);
draw("Size: " + tile.size, 83, 81, 0xFFFFFF, layer); drawString("Size: " + tile.size, 83, 81, 0xFFFFFF, layer);
draw("" + tile.getPowerMultiplier() + "x", 10, 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(300, 121, 79, this, GuiBase.Layer.FOREGROUND));
buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, GuiBase.Layer.FOREGROUND)); buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, GuiBase.Layer.FOREGROUND));

View file

@ -24,7 +24,7 @@
package techreborn.client.gui; package techreborn.client.gui;
import net.minecraft.client.renderer.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;

View file

@ -49,8 +49,8 @@ public class GuiImplosionCompressor extends GuiBase {
} }
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
ClientProxy.multiblockRenderEvent.setMultiblock(null); ClientProxy.multiblockRenderEvent.setMultiblock(null);
} }

View file

@ -49,8 +49,8 @@ public class GuiIndustrialGrinder extends GuiBase {
} }
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
ClientProxy.multiblockRenderEvent.setMultiblock(null); ClientProxy.multiblockRenderEvent.setMultiblock(null);
} }

View file

@ -24,6 +24,7 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -52,7 +53,7 @@ public class GuiIronFurnace extends GuiBase {
drawDefaultBackground(); drawDefaultBackground();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
builder.drawSlotTab(this, left - 24, top + 6, new ItemStack(TRContent.WRENCH)); 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 k = (this.width - containerWidth) / 2;
final int l = (this.height - containerHeight) / 2; final int l = (this.height - containerHeight) / 2;
blit(k, l, 0, 0, containerWidth, containerHeight); blit(k, l, 0, 0, containerWidth, containerHeight);

View file

@ -25,7 +25,6 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;

View file

@ -25,7 +25,6 @@
package techreborn.client.gui; package techreborn.client.gui;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;

View file

@ -24,19 +24,18 @@
package techreborn.client.gui; 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.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.client.gui.builder.widget.GuiButtonExtended;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import techreborn.items.ItemManual; import techreborn.items.ItemManual;
import techreborn.packets.ServerboundPackets; import techreborn.packets.ServerboundPackets;
import java.awt.*; 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 { public class GuiManual extends Screen {
@ -61,7 +60,7 @@ public class GuiManual extends Screen {
} }
@Override @Override
public void initGui() { public void init() {
int y = height / 4; 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(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"))); 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 @Override
public void render(int mouseX, int mouseY, float partialTicks) { public void render(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground(); drawDefaultBackground();
mc.getTextureManager().bindTexture(GuiManual.texture); minecraft.getTextureManager().bindTexture(GuiManual.texture);
int centerX = (width / 2) - guiWidth / 2; int centerX = (width / 2) - guiWidth / 2;
int centerY = (height / 2) - guiHeight / 2; int centerY = (height / 2) - guiHeight / 2;
blit(centerX, centerY, 0, 0, guiWidth, guiHeight); 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){ public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
switch (button.id) { switch (button.id) {
case 1: 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; break;
case 2: 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; break;
case 3: case 3:
mc.displayGuiScreen(null); minecraft.openScreen(null);
NetworkManager.sendToServer(ServerboundPackets.createRefundPacket()); NetworkManager.sendToServer(ServerboundPackets.createRefundPacket());
break; break;
} }
@ -112,7 +111,7 @@ public class GuiManual extends Screen {
System.err.print(e); System.err.print(e);
} }
}else { }else {
mc.displayGuiScreen(this); minecraft.openScreen(this);
} }
break; break;
case 2: case 2:
@ -123,7 +122,7 @@ public class GuiManual extends Screen {
System.err.print(e); System.err.print(e);
} }
}else { }else {
mc.displayGuiScreen(this); minecraft.openScreen(this);
} }
break; break;
} }

View file

@ -47,8 +47,8 @@ public class GuiVacuumFreezer extends GuiBase {
} }
@Override @Override
public void initGui() { public void init() {
super.initGui(); super.init();
ClientProxy.multiblockRenderEvent.setMultiblock(null); ClientProxy.multiblockRenderEvent.setMultiblock(null);
} }

View file

@ -29,6 +29,7 @@ import net.minecraft.entity.MovementType;
import net.minecraft.entity.PrimedTntEntity; import net.minecraft.entity.PrimedTntEntity;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.explosion.RebornExplosion; import reborncore.common.explosion.RebornExplosion;
import reborncore.common.registration.RebornRegister; import reborncore.common.registration.RebornRegister;
@ -66,21 +67,28 @@ public class EntityNukePrimed extends PrimedTntEntity {
this.prevY = this.y; this.prevY = this.y;
this.prevZ = this.z; this.prevZ = this.z;
Vec3d velocity = getVelocity();
double motionX = velocity.x;
double motionY = velocity.y;
double motionZ = velocity.z;
if (!this.hasNoGravity()) { if (!this.hasNoGravity()) {
this.motionY -= 0.03999999910593033D; motionY -= 0.03999999910593033D;
} }
this.move(MovementType.SELF, this.motionX, this.motionY, this.motionZ); this.move(MovementType.SELF, new Vec3d(motionX, motionZ, motionY));
this.motionX *= 0.9800000190734863D; motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D; motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D; motionZ *= 0.9800000190734863D;
if (this.onGround) { if (this.onGround) {
this.motionX *= 0.699999988079071D; motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D; motionZ *= 0.699999988079071D;
this.motionY *= -0.5D; motionY *= -0.5D;
} }
setVelocity(new Vec3d(motionX, motionZ, motionY));
setFuse(getFuseTimer() - 1); setFuse(getFuseTimer() - 1);
if (getFuseTimer() <= 0) { if (getFuseTimer() <= 0) {

View file

@ -34,7 +34,6 @@ import net.fabricmc.api.Environment;
import reborncore.client.models.ModelCompound; import reborncore.client.models.ModelCompound;
import reborncore.client.models.RebornModelRegistry; import reborncore.client.models.RebornModelRegistry;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.client.render.ModelDynamicCell;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.init.TRContent.*; import techreborn.init.TRContent.*;
@ -46,15 +45,12 @@ import java.util.Arrays;
* *
*/ */
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Mod.EventBusSubscriber(modid = TechReborn.MOD_ID)
public class ModelRegistryEventHandler { public class ModelRegistryEventHandler {
@SubscribeEvent public static void registerModels() {
public static void registerModels(ModelRegistryEvent event) {
registerBlocks(); registerBlocks();
registerFluidBlocks(); registerFluidBlocks();
registerItems(); registerItems();
ModelDynamicCell.init();
//RebornModelRegistry.registerModels(TechReborn.MOD_ID); //RebornModelRegistry.registerModels(TechReborn.MOD_ID);
} }

View file

@ -28,6 +28,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.RecipeManager; import reborncore.common.crafting.RecipeManager;
import reborncore.common.registration.RebornRegister; import reborncore.common.registration.RebornRegister;
import techreborn.TechReborn; import techreborn.TechReborn;
@ -39,23 +40,23 @@ import techreborn.api.recipe.recipes.IndustrialSawmillRecipe;
public class ModRecipes { public class ModRecipes {
public static final RecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:alloy_smelter")); public static final RebornRecipeType<RebornRecipe> ALLOY_SMELTER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:alloy_smelter"));
public static final RecipeType<Recipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:assembling_machine")); public static final RebornRecipeType<RebornRecipe> ASSEMBLING_MACHINE = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:assembling_machine"));
public static final RecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new Identifier("techreborn:blast_furnace")); public static final RebornRecipeType<BlastFurnaceRecipe> BLAST_FURNACE = RecipeManager.newRecipeType(BlastFurnaceRecipe.class, new Identifier("techreborn:blast_furnace"));
public static final RecipeType<Recipe> CENTRIFUGE = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:centrifuge")); public static final RebornRecipeType<RebornRecipe> CENTRIFUGE = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:centrifuge"));
public static final RecipeType<Recipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:chemical_reactor")); public static final RebornRecipeType<RebornRecipe> CHEMICAL_REACTOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:chemical_reactor"));
public static final RecipeType<Recipe> COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:compressor")); public static final RebornRecipeType<RebornRecipe> COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:compressor"));
public static final RecipeType<Recipe> EnvTypeILLATION_TOWER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:EnvTypeillation_tower")); public static final RebornRecipeType<RebornRecipe> EnvTypeILLATION_TOWER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:EnvTypeillation_tower"));
public static final RecipeType<Recipe> EXTRACTOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:extractor")); public static final RebornRecipeType<RebornRecipe> EXTRACTOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:extractor"));
public static final RecipeType<Recipe> GRINDER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:grinder")); public static final RebornRecipeType<RebornRecipe> GRINDER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:grinder"));
public static final RecipeType<Recipe> IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:implosion_compressor")); public static final RebornRecipeType<RebornRecipe> IMPLOSION_COMPRESSOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:implosion_compressor"));
public static final RecipeType<Recipe> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:industrial_electrolyzer")); public static final RebornRecipeType<RebornRecipe> INDUSTRIAL_ELECTROLYZER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:industrial_electrolyzer"));
public static final RecipeType<IndustrialGrinderRecipe> INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new Identifier("techreborn:industrial_grinder")); public static final RebornRecipeType<IndustrialGrinderRecipe> INDUSTRIAL_GRINDER = RecipeManager.newRecipeType(IndustrialGrinderRecipe.class, new Identifier("techreborn:industrial_grinder"));
public static final RecipeType<IndustrialSawmillRecipe> INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new Identifier("techreborn:industrial_sawmill")); public static final RebornRecipeType<IndustrialSawmillRecipe> INDUSTRIAL_SAWMILL = RecipeManager.newRecipeType(IndustrialSawmillRecipe.class, new Identifier("techreborn:industrial_sawmill"));
public static final RecipeType<Recipe> RECYCLER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:recycler")); public static final RebornRecipeType<RebornRecipe> RECYCLER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:recycler"));
public static final RecipeType<Recipe> SCRAPBOX = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:scrapbox")); public static final RebornRecipeType<RebornRecipe> SCRAPBOX = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:scrapbox"));
public static final RecipeType<Recipe> VACUUM_FREEZER = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:vacuum_freezer")); public static final RebornRecipeType<RebornRecipe> VACUUM_FREEZER = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:vacuum_freezer"));
public static final RecipeType<Recipe> FLUID_REPLICATOR = RecipeManager.newRecipeType(Recipe.class, new Identifier("techreborn:fluid_replicator")); public static final RebornRecipeType<RebornRecipe> FLUID_REPLICATOR = RecipeManager.newRecipeType(RebornRecipe.class, new Identifier("techreborn:fluid_replicator"));

View file

@ -334,7 +334,7 @@ public class TRContent {
AUTO_CRAFTING_TABLE(new BlockAutoCraftingTable()), AUTO_CRAFTING_TABLE(new BlockAutoCraftingTable()),
CHEMICAL_REACTOR(new BlockChemicalReactor()), CHEMICAL_REACTOR(new BlockChemicalReactor()),
COMPRESSOR(new BlockCompressor()), COMPRESSOR(new BlockCompressor()),
EnvTypeILLATION_TOWER(new BlockEnvTypeillationTower()), EnvTypeILLATION_TOWER(new BlockDistillationTower()),
EXTRACTOR(new BlockExtractor()), EXTRACTOR(new BlockExtractor()),
FLUID_REPLICATOR(new BlockFluidReplicator()), FLUID_REPLICATOR(new BlockFluidReplicator()),
GRINDER(new BlockGrinder()), GRINDER(new BlockGrinder()),

View file

@ -25,6 +25,7 @@
package techreborn.init.recipes; package techreborn.init.recipes;
import reborncore.fluid.Fluid;
import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.generator.GeneratorRecipeHelper;
import techreborn.init.ModFluids; import techreborn.init.ModFluids;

View file

@ -24,31 +24,17 @@
package techreborn.items; 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.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DefaultedList; 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 net.minecraft.world.World;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import reborncore.common.util.StringUtils; import reborncore.fluid.Fluid;
import reborncore.fluid.FluidStack;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.events.TRRecipeHandler; import techreborn.events.TRRecipeHandler;
import techreborn.init.TRContent; import techreborn.init.TRContent;
@ -59,7 +45,7 @@ import techreborn.utils.FluidUtils;
*/ */
public class DynamicCell extends Item { public class DynamicCell extends Item {
public static final int CAPACITY = Fluid.BUCKET_VOLUME; public static final int CAPACITY = 1000;
public DynamicCell() { public DynamicCell() {
super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP)); super(new Item.Settings().itemGroup(TechReborn.ITEMGROUP));
@ -81,64 +67,6 @@ public class DynamicCell extends Item {
} }
} }
@Override
public TypedActionResult<ItemStack> 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) { public boolean tryAddCellToInventory(PlayerEntity player, ItemStack stack, Fluid fluid) {
if (player.inventory.insertStack(DynamicCell.getCellWithFluid(fluid))) { if (player.inventory.insertStack(DynamicCell.getCellWithFluid(fluid))) {
@ -159,22 +87,19 @@ public class DynamicCell extends Item {
} }
} }
@Override // @Override
public String getTranslationKey(ItemStack stack) { // public String getTranslationKey(ItemStack stack) {
FluidStack fluidStack = getFluidHandler(stack).getFluid(); // FluidStack fluidStack = getFluidHandler(stack).getFluid();
if (fluidStack == null) // if (fluidStack == null)
return super.getTranslationKey(stack); // return super.getTranslationKey(stack);
return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName()); // return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName());
} // }
//
@Override // @Override
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) { // public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) {
return getFluidHandler(stack); // return getFluidHandler(stack);
} // }
//
public static FluidHandler getFluidHandler(ItemStack stack) {
return new FluidHandler(stack, CAPACITY);
}
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) { public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {
Validate.notNull(fluid); Validate.notNull(fluid);
@ -192,61 +117,5 @@ public class DynamicCell extends Item {
return getCellWithFluid(fluid, 1); 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);
}
}
} }

View file

@ -119,11 +119,6 @@ public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
// IEnergyItemInfo // IEnergyItemInfo
@Override @Override

View file

@ -38,6 +38,7 @@ import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
@ -45,7 +46,7 @@ import techreborn.init.TRContent;
import javax.annotation.Nullable; 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. // 400M FE maxCharge and 100k FE\t charge rate. Fully charged in 3 mins.
public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; public static final int maxCharge = ConfigTechReborn.LapotronPackCharge;
@ -92,13 +93,6 @@ public class ItemLapotronicOrbpack extends ArmorItem implements IEnergyItemInfo
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)

View file

@ -37,8 +37,8 @@ import net.fabricmc.api.Environment;
import reborncore.api.power.IEnergyItemInfo; import reborncore.api.power.IEnergyItemInfo;
import reborncore.common.powerSystem.ExternalPowerSystems; import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
@ -46,7 +46,7 @@ import techreborn.init.TRContent;
import javax.annotation.Nullable; 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. // 8M FE maxCharge and 2k FE\t charge rate. Fully charged in 3 mins.
public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge;
@ -93,12 +93,6 @@ public class ItemLithiumIonBatpack extends ArmorItem implements IEnergyItemInfo
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {

View file

@ -29,6 +29,7 @@ import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial; import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.events.TRRecipeHandler; import techreborn.events.TRRecipeHandler;
@ -36,7 +37,7 @@ import techreborn.events.TRRecipeHandler;
/** /**
* Created by modmuss50 on 26/02/2016. * Created by modmuss50 on 26/02/2016.
*/ */
public class ItemTRArmour extends ArmorItem { public class ItemTRArmour extends ArmorItem implements ItemDurabilityExtensions {
String repairOreDict = ""; String repairOreDict = "";

View file

@ -80,14 +80,6 @@ public class ItemBattery extends Item implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
// IEnergyItemInfo // IEnergyItemInfo
@Override @Override
public int getCapacity() { public int getCapacity() {

View file

@ -43,13 +43,14 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; 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 maxCharge = 1;
public int cost = 250; public int cost = 250;
@ -120,14 +121,6 @@ public class ItemChainsaw extends AxeItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) {
return !(newStack.isEqualIgnoreTags(oldStack)); return !(newStack.isEqualIgnoreTags(oldStack));

View file

@ -42,13 +42,14 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; 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 maxCharge = 1;
public int cost = 250; public int cost = 250;
@ -115,14 +116,6 @@ public class ItemDrill extends PickaxeItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) {
return !(newStack.isEqualIgnoreTags(oldStack)); return !(newStack.isEqualIgnoreTags(oldStack));

View file

@ -43,6 +43,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.utils.TagUtils; import techreborn.utils.TagUtils;
@ -50,7 +51,7 @@ import techreborn.utils.TagUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; 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 maxCharge = 1;
public int cost = 250; public int cost = 250;
@ -118,14 +119,6 @@ public class ItemJackhammer extends PickaxeItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) {
return !(newStack.isEqualIgnoreTags(oldStack)); return !(newStack.isEqualIgnoreTags(oldStack));

View file

@ -27,6 +27,7 @@ package techreborn.items.tool;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -45,7 +46,7 @@ public class ItemWrench extends Item implements IToolHandler {
@Override @Override
public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) { public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) {
if (damage) { if (damage) {
stack.damageItem(1, player); stack.applyDamage(1, player.world.random, (ServerPlayerEntity) player);
} }
return true; return true;
} }

View file

@ -43,6 +43,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
@ -51,7 +52,7 @@ import techreborn.init.TRContent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; 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 static final int maxCharge = ConfigTechReborn.RockCutterCharge;
public int transferLimit = 1_000; public int transferLimit = 1_000;
@ -130,12 +131,6 @@ public class ItemRockCutter extends PickaxeItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Override @Override
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) {
return !(newStack.isEqualIgnoreTags(oldStack)); return !(newStack.isEqualIgnoreTags(oldStack));

View file

@ -39,6 +39,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.api.TechRebornAPI; import techreborn.api.TechRebornAPI;
@ -49,7 +50,7 @@ import javax.annotation.Nullable;
/** /**
* Created by modmuss50 on 05/11/2016. * 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 static final int maxCharge = 10_000;
public int cost = 20; public int cost = 20;
@ -88,12 +89,6 @@ public class ItemElectricTreetap extends Item implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Override @Override
public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) { public void appendItemsForGroup(ItemGroup par2ItemGroup, DefaultedList<ItemStack> itemList) {

View file

@ -51,6 +51,7 @@ import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ChatUtils; import reborncore.common.util.ChatUtils;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
@ -60,7 +61,7 @@ import techreborn.utils.MessageIDs;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; 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 static final int maxCharge = ConfigTechReborn.nanoSaberCharge;
public int transferLimit = 1_000; public int transferLimit = 1_000;
public int cost = 250; public int cost = 250;
@ -188,14 +189,6 @@ public class ItemNanosaber extends SwordItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack,
@Nullable
CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Override @Override
public void appendItemsForGroup( public void appendItemsForGroup(

View file

@ -46,6 +46,7 @@ import reborncore.common.powerSystem.ExternalPowerSystems;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider; import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.ItemPowerManager; import reborncore.common.powerSystem.ItemPowerManager;
import reborncore.common.util.ItemDurabilityExtensions;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import reborncore.common.util.TorchHelper; import reborncore.common.util.TorchHelper;
import techreborn.TechReborn; import techreborn.TechReborn;
@ -55,7 +56,7 @@ import techreborn.init.TRContent;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; 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 static final int maxCharge = ConfigTechReborn.OmniToolCharge;
public int transferLimit = 1_000; public int transferLimit = 1_000;
@ -153,12 +154,6 @@ public class ItemOmniTool extends PickaxeItem implements IEnergyItemInfo {
return PowerSystem.getDisplayPower().colour; return PowerSystem.getDisplayPower().colour;
} }
@Override
@Nullable
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
return new PoweredItemContainerProvider(stack);
}
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Override @Override
public void appendItemsForGroup( public void appendItemsForGroup(

View file

@ -24,10 +24,15 @@
package techreborn.packets; 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.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import reborncore.common.network.ExtendedPacketBuffer; import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import reborncore.common.network.NetworkPacket; import reborncore.common.network.NetworkPacket;
@ -40,7 +45,6 @@ import techreborn.tiles.storage.TileAdjustableSU;
import techreborn.tiles.storage.idsu.TileInterdimensionalSU; import techreborn.tiles.storage.idsu.TileInterdimensionalSU;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class ServerboundPackets { public class ServerboundPackets {
@ -52,43 +56,43 @@ public class ServerboundPackets {
public static final Identifier REFUND = new Identifier("techreborn", "refund"); public static final Identifier REFUND = new Identifier("techreborn", "refund");
public static void init() { public static void init() {
NetworkManager.registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { registerPacketHandler(AESU, (extendedPacketBuffer, context) -> {
BlockPos pos = extendedPacketBuffer.readBlockPos(); BlockPos pos = extendedPacketBuffer.readBlockPos();
int buttonID = extendedPacketBuffer.readInt(); int buttonID = extendedPacketBuffer.readInt();
context.enqueueWork(() -> { context.getTaskQueue().execute(() -> {
TileEntity tile = context.getSender().world.getTileEntity(pos); BlockEntity tile = context.getPlayer().world.getBlockEntity(pos);
if (tile instanceof TileAdjustableSU) { if (tile instanceof TileAdjustableSU) {
((TileAdjustableSU) tile).handleGuiInputFromClient(buttonID, false, false); ((TileAdjustableSU) tile).handleGuiInputFromClient(buttonID, false, false);
} }
}); });
}); });
NetworkManager.registerPacketHandler(AUTO_CRAFTING_LOCK, (extendedPacketBuffer, context) -> { registerPacketHandler(AUTO_CRAFTING_LOCK, (extendedPacketBuffer, context) -> {
BlockPos machinePos = extendedPacketBuffer.readBlockPos(); BlockPos machinePos = extendedPacketBuffer.readBlockPos();
boolean locked = extendedPacketBuffer.readBoolean(); boolean locked = extendedPacketBuffer.readBoolean();
context.enqueueWork(() -> { context.getTaskQueue().execute(() -> {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos); BlockEntity BlockEntity = context.getPlayer().world.getBlockEntity(machinePos);
if (tileEntity instanceof TileAutoCraftingTable) { if (BlockEntity instanceof TileAutoCraftingTable) {
((TileAutoCraftingTable) tileEntity).locked = locked; ((TileAutoCraftingTable) BlockEntity).locked = locked;
} }
}); });
}); });
NetworkManager.registerPacketHandler(FUSION_CONTROL_SIZE, (extendedPacketBuffer, context) -> { registerPacketHandler(FUSION_CONTROL_SIZE, (extendedPacketBuffer, context) -> {
int sizeDelta = extendedPacketBuffer.readInt(); int sizeDelta = extendedPacketBuffer.readInt();
BlockPos pos = extendedPacketBuffer.readBlockPos(); BlockPos pos = extendedPacketBuffer.readBlockPos();
context.enqueueWork(() -> { context.getTaskQueue().execute(() -> {
TileEntity tile = context.getSender().world.getTileEntity(pos); BlockEntity tile = context.getPlayer().world.getBlockEntity(pos);
if (tile instanceof TileFusionControlComputer) { if (tile instanceof TileFusionControlComputer) {
((TileFusionControlComputer) tile).changeSize(sizeDelta); ((TileFusionControlComputer) tile).changeSize(sizeDelta);
} }
}); });
}); });
NetworkManager.registerPacketHandler(IDSU, (extendedPacketBuffer, context) -> { registerPacketHandler(IDSU, (extendedPacketBuffer, context) -> {
BlockPos pos = extendedPacketBuffer.readBlockPos(); BlockPos pos = extendedPacketBuffer.readBlockPos();
int buttonID = extendedPacketBuffer.readInt(); 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 //TODO was commented out when I ported it, so ill leave it here, needs looking into tho
// if (!pos.getWorld().isRemote) { // if (!pos.getWorld().isRemote) {
// pos.handleGuiInputFromClient(buttonID); // 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(); BlockPos machinePos = extendedPacketBuffer.readBlockPos();
boolean locked = extendedPacketBuffer.readBoolean(); boolean locked = extendedPacketBuffer.readBoolean();
context.enqueueWork(() -> { context.getTaskQueue().execute(() -> {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos); BlockEntity BlockEntity = context.getPlayer().world.getBlockEntity(machinePos);
if (tileEntity instanceof TileRollingMachine) { if (BlockEntity instanceof TileRollingMachine) {
((TileRollingMachine) tileEntity).locked = locked; ((TileRollingMachine) BlockEntity).locked = locked;
} }
}); });
}); });
NetworkManager.registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> { registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> {
if(!ItemManual.allowRefund){ if(!ItemManual.allowRefund){
return; return;
} }
context.enqueueWork(() -> { context.getTaskQueue().execute(() -> {
EntityPlayerMP playerMP = context.getSender(); PlayerEntity playerMP = context.getPlayer();
for (int i = 0; i < playerMP.inventory.getSizeInventory(); i++) { for (int i = 0; i < playerMP.inventory.getInvSize(); i++) {
ItemStack stack = playerMP.inventory.getStackInSlot(i); ItemStack stack = playerMP.inventory.getInvStack(i);
if (stack.getItem() == TRContent.MANUAL) { if (stack.getItem() == TRContent.MANUAL) {
playerMP.inventory.removeStackFromSlot(i); playerMP.inventory.removeInvStack(i);
playerMP.inventory.addItemStackToInventory(new ItemStack(Items.BOOK)); playerMP.inventory.addItemStackToInventory(new ItemStack(Items.BOOK));
//TODO 1.13 //TODO 1.13
//playerMP.inventory.addItemStackToInventory(OreUtil.getStackFromName("ingotRefinedIron")); //playerMP.inventory.addItemStackToInventory(OreUtil.getStackFromName("ingotRefinedIron"));
@ -128,6 +132,10 @@ public class ServerboundPackets {
}); });
} }
private static void registerPacketHandler(Identifier identifier, BiConsumer<ExtendedPacketBuffer, PacketContext> consumer){
ServerSidePacketRegistry.INSTANCE.register(identifier, (packetContext, packetByteBuf) -> consumer.accept(new ExtendedPacketBuffer(packetByteBuf), packetContext));
}
public static NetworkPacket createPacketAesu(int buttonID, TileAdjustableSU tile) { public static NetworkPacket createPacketAesu(int buttonID, TileAdjustableSU tile) {
return NetworkManager.createPacket(AESU, extendedPacketBuffer -> { return NetworkManager.createPacket(AESU, extendedPacketBuffer -> {
extendedPacketBuffer.writeBlockPos(tile.getPos()); extendedPacketBuffer.writeBlockPos(tile.getPos());

View file

@ -218,22 +218,6 @@ public class TileTechStorageBase extends TileMachineBase
return tagCompound; return tagCompound;
} }
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return LazyOptional.of(new NonNullSupplier<T>() {
@Nonnull
@Override
public T get() {
return (T) inventory;
}
});
}
return super.getCapability(cap);
}
// ItemHandlerProvider // ItemHandlerProvider
@Override @Override
public Inventory<TileTechStorageBase> getInventory() { public Inventory<TileTechStorageBase> getInventory() {

View file

@ -34,7 +34,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.ClientConnection; import net.minecraft.network.ClientConnection;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.ITickable; import net.minecraft.util.Tickable;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@ -57,7 +57,7 @@ import java.util.List;
*/ */
public class TileCable extends BlockEntity public class TileCable extends BlockEntity
implements ITickable, IEnergyStorage, IListInfoProvider, IToolDrop { implements Tickable, IEnergyStorage, IListInfoProvider, IToolDrop {
public int power = 0; public int power = 0;
private int transferRate = 0; private int transferRate = 0;
@ -85,14 +85,6 @@ public class TileCable extends BlockEntity
return canReceive(); return canReceive();
} }
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability) {
if (capability == CapabilityEnergy.ENERGY) {
return LazyOptional.of(() -> (T)this);
}
return super.getCapability(capability);
}
@Override @Override
public CompoundTag toInitialChunkDataTag() { public CompoundTag toInitialChunkDataTag() {
return toTag(new CompoundTag()); return toTag(new CompoundTag());
@ -151,37 +143,39 @@ public class TileCable extends BlockEntity
return; return;
} }
ArrayList<IEnergyStorage> acceptors = new ArrayList<IEnergyStorage>(); //TODO needs a full recode to not use a specific power net
for (Direction face : Direction.values()) {
BlockEntity tile = world.getBlockEntity(pos.offset(face));
if (tile == null) { // ArrayList<IEnergyStorage> acceptors = new ArrayList<IEnergyStorage>();
continue; // for (Direction face : Direction.values()) {
} else if (tile instanceof TileCable) { // BlockEntity tile = world.getBlockEntity(pos.offset(face));
TileCable cable = (TileCable) tile; //
if (power > cable.power && cable.canReceiveFromFace(face.getOpposite())) { // if (tile == null) {
acceptors.add((IEnergyStorage) tile); // continue;
if (!sendingFace.contains(face)) { // } else if (tile instanceof TileCable) {
sendingFace.add(face); // TileCable cable = (TileCable) tile;
} // if (power > cable.power && cable.canReceiveFromFace(face.getOpposite())) {
} // acceptors.add((IEnergyStorage) tile);
} else if (tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).isPresent()) { // if (!sendingFace.contains(face)) {
IEnergyStorage energyTile = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite()).orElse(null); // sendingFace.add(face);
if (energyTile != null && energyTile.canReceive()) { // }
acceptors.add(energyTile); // }
} // } 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); // if (acceptors.size() > 0 ) {
extractEnergy(move, false); // 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 // IEnergyStorage

View file

@ -32,13 +32,14 @@ import reborncore.api.IToolDrop;
import reborncore.api.tile.ItemHandlerProvider; import reborncore.api.tile.ItemHandlerProvider;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
import reborncore.fluid.FluidStack;
import techreborn.api.generator.EFluidGenerator; import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.FluidGeneratorRecipe; import techreborn.api.generator.FluidGeneratorRecipe;
import techreborn.api.generator.FluidGeneratorRecipeList; import techreborn.api.generator.FluidGeneratorRecipeList;
import techreborn.api.generator.GeneratorRecipeHelper; import techreborn.api.generator.GeneratorRecipeHelper;
import techreborn.utils.FluidUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View file

@ -34,7 +34,7 @@ import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.client.containerBuilder.builder.ContainerBuilder;
import reborncore.common.crafting.RebornIngredient; import reborncore.common.crafting.RebornIngredient;
import reborncore.common.crafting.Recipe; import reborncore.common.crafting.RebornRecipe;
import reborncore.common.registration.RebornRegister; import reborncore.common.registration.RebornRegister;
import reborncore.common.tile.TileMachineBase; import reborncore.common.tile.TileMachineBase;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
@ -71,7 +71,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
if (stack.isEmpty()) { if (stack.isEmpty()) {
return 0; return 0;
} else { } 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) { if (recipeType == null) {
return false; return false;
} }
@ -137,7 +137,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
return false; return false;
} else { } else {
ItemStack itemstack = null; 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)) { if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutputs().get(0); itemstack = recipeType.getOutputs().get(0);
break; break;
@ -169,7 +169,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
public void smeltItem() { public void smeltItem() {
if (this.canSmelt()) { if (this.canSmelt()) {
ItemStack itemstack = ItemStack.EMPTY; 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)) { if (this.hasAllInputs(recipeType)) {
itemstack = recipeType.getOutputs().get(0); itemstack = recipeType.getOutputs().get(0);
break; break;
@ -185,7 +185,7 @@ public class TileIronAlloyFurnace extends TileMachineBase
inventory.shrinkSlot(this.output, -itemstack.getAmount()); 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; boolean hasAllRecipes = true;
if (this.hasAllInputs(recipeType)) { if (this.hasAllInputs(recipeType)) {

View file

@ -42,6 +42,7 @@ import techreborn.api.fluidreplicator.FluidReplicatorRecipeCrafter;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.init.TRTileEntities; import techreborn.init.TRTileEntities;
import techreborn.tiles.TileGenericMachine; import techreborn.tiles.TileGenericMachine;
import techreborn.utils.FluidUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View file

@ -38,7 +38,6 @@ import reborncore.client.containerBuilder.builder.ContainerBuilder;
import reborncore.common.recipes.RecipeCrafter; import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.registration.RebornRegister; import reborncore.common.registration.RebornRegister;
import reborncore.common.registration.config.ConfigRegistry; import reborncore.common.registration.config.ConfigRegistry;
import reborncore.common.util.FluidUtils;
import reborncore.common.util.IInventoryAccess; import reborncore.common.util.IInventoryAccess;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import reborncore.common.util.Tank; import reborncore.common.util.Tank;
@ -47,6 +46,7 @@ import techreborn.init.ModRecipes;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.init.TRTileEntities; import techreborn.init.TRTileEntities;
import techreborn.tiles.TileGenericMachine; import techreborn.tiles.TileGenericMachine;
import techreborn.utils.FluidUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View file

@ -431,7 +431,7 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
// ItemHandlerProvider // ItemHandlerProvider
@Override @Override
public IItemHandler getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }

View file

@ -39,6 +39,7 @@ import techreborn.init.TRContent;
import techreborn.init.TRTileEntities; import techreborn.init.TRTileEntities;
import java.util.Iterator; import java.util.Iterator;
import java.util.function.Consumer;
@RebornRegister(TechReborn.MOD_ID) @RebornRegister(TechReborn.MOD_ID)
public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop { public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop {
@ -69,7 +70,7 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop
boolean lastRedstone = redstone; boolean lastRedstone = redstone;
redstone = false; redstone = false;
if (canUseEnergy(euPerTick)) { if (canUseEnergy(euPerTick)) {
Iterator<PlayerEntity> tIterator = super.world.playerEntities.iterator(); Iterator<PlayerEntity> tIterator = super.world.getPlayers().iterator();
while (tIterator.hasNext()) { while (tIterator.hasNext()) {
PlayerEntity player = tIterator.next(); PlayerEntity player = tIterator.next();
if (player.squaredEnvTypeanceTo((double) super.getPos().getX() + 0.5D, if (player.squaredEnvTypeanceTo((double) super.getPos().getX() + 0.5D,

View file

@ -25,7 +25,11 @@
package techreborn.utils; package techreborn.utils;
import net.minecraft.block.Block; 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.Fluid;
import reborncore.fluid.FluidStack;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -44,4 +48,19 @@ public class FluidUtils {
return null; 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;
}
} }