Refactor and import cleanup (Excluding network PR changed files)

This commit is contained in:
Justin Vitale 2020-07-09 23:04:42 +10:00
parent a36a0e6f4a
commit c4ef977f16
165 changed files with 1572 additions and 1625 deletions

View file

@ -30,13 +30,12 @@ import techreborn.client.GuiType;
/**
* @author modmuss50
*
*/
public class DataDrivenMachineBlock extends GenericMachineBlock {
private final DataDrivenBEProvider provider;
public DataDrivenMachineBlock(String ident){
public DataDrivenMachineBlock(String ident) {
super(GuiType.DATA_DRIVEN, null);
provider = DataDrivenBEProvider.create(this, new Identifier(ident));
blockEntityClass = provider;

View file

@ -34,11 +34,10 @@ import java.util.function.Supplier;
/**
* @author drcrazy
*
*/
public class GenericMachineBlock extends BlockMachineBase {
private IMachineGuiHandler gui;
private final IMachineGuiHandler gui;
Supplier<BlockEntity> blockEntityClass;
public GenericMachineBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
@ -62,7 +61,6 @@ public class GenericMachineBlock extends BlockMachineBase {
}
@Override
public IMachineGuiHandler getGui() {
return gui;

View file

@ -52,12 +52,12 @@ public final class CableShapeUtil {
}
private VoxelShape getStateShape(BlockState state) {
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
final double size = cableBlock.type != null ? cableBlock.type.cableThickness : 6;
final VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
final List<VoxelShape> connections = new ArrayList<>();
for(Direction dir : Direction.values()){
if(state.get(CableBlock.PROPERTY_MAP.get(dir))) {
for (Direction dir : Direction.values()) {
if (state.get(CableBlock.PROPERTY_MAP.get(dir))) {
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;

View file

@ -81,7 +81,7 @@ public class BlockFusionCoil extends Block {
@Environment(EnvType.CLIENT)
@Override
public void buildTooltip(ItemStack stack, @Nullable BlockView worldIn, List<Text> tooltip,
TooltipContext flagIn) {
TooltipContext flagIn) {
super.buildTooltip(stack, worldIn, tooltip, flagIn);
// TODO: Translate
tooltip.add(new LiteralText("Right click Fusion Control computer to auto place"));

View file

@ -52,23 +52,23 @@ public class BlockFusionControlComputer extends BlockMachineBase {
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
final FusionControlComputerBlockEntity blockEntityFusionControlComputer = (FusionControlComputerBlockEntity) 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(blockEntityFusionControlComputer.getPos(), blockEntityFusionControlComputer.size);
boolean placed = false;
for(BlockPos coil : coils){
if(playerIn.getStackInHand(hand).isEmpty()){
for (BlockPos coil : coils) {
if (playerIn.getStackInHand(hand).isEmpty()) {
return ActionResult.SUCCESS;
}
if(worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
if (worldIn.getBlockState(coil).canReplace(new ItemPlacementContext(new ItemUsageContext(playerIn, hand, hitResult)))
&& worldIn.getBlockState(pos).getBlock() != TRContent.Machine.FUSION_COIL.block) {
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
if(!playerIn.isCreative()){
if (!playerIn.isCreative()) {
playerIn.getStackInHand(hand).decrement(1);
}
placed = true;
}
}
if(placed){
if (placed) {
return ActionResult.SUCCESS;
}
@ -97,7 +97,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
public BlockEntity createBlockEntity(BlockView worldIn) {
return new FusionControlComputerBlockEntity();
}
@Override
public boolean isAdvanced() {
return true;

View file

@ -40,14 +40,14 @@ import techreborn.init.TRContent.SolarPanels;
* Created by modmuss50 on 25/02/2016.
*/
public class BlockSolarPanel extends BlockMachineBase {
public final SolarPanels panelType;
public BlockSolarPanel(SolarPanels panel) {
super();
this.panelType = panel;
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new SolarPanelBlockEntity(panelType);
@ -55,7 +55,7 @@ public class BlockSolarPanel extends BlockMachineBase {
@Override
public IMachineGuiHandler getGui() {
if(this.panelType == SolarPanels.CREATIVE){
if (this.panelType == SolarPanels.CREATIVE) {
return null;
}
return GuiType.SOLAR_PANEL;

View file

@ -39,17 +39,17 @@ import java.util.function.Supplier;
* for generators, like comparator output based on energy.
*/
public class GenericGeneratorBlock extends GenericMachineBlock {
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}
public GenericGeneratorBlock(IMachineGuiHandler gui, Supplier<BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return true;
}
@Override
public boolean hasComparatorOutput(BlockState state) {
return true;
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
}
@Override
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
}
}

View file

@ -56,8 +56,8 @@ public class BlockLamp extends BaseBlockEntityProvider {
public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape;
private int cost;
private static int brightness = 15;
private final int cost;
private static final int brightness = 15;
public BlockLamp(int cost, double depth, double width) {
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
@ -66,9 +66,9 @@ public class BlockLamp extends BaseBlockEntityProvider {
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));
BlockWrenchEventHandler.wrenableBlocks.add(this);
}
private VoxelShape[] genCuboidShapes(double depth, double width) {
double culling = (16.0D - width) / 2 ;
double culling = (16.0D - width) / 2;
return new VoxelShape[]{
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
@ -76,7 +76,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
};
};
}
@Override
@ -97,7 +97,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
}
public static void setActive(Boolean active, World world, BlockPos pos) {
Direction facing = (Direction)world.getBlockState(pos).get(FACING);
Direction facing = world.getBlockState(pos).get(FACING);
BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing);
world.setBlockState(pos, state, 3);
}
@ -105,12 +105,12 @@ public class BlockLamp extends BaseBlockEntityProvider {
public int getCost() {
return cost;
}
// BaseTileBlock
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LampBlockEntity();
}
}
// Block
@Override
@ -118,7 +118,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
ACTIVE = BooleanProperty.of("active");
builder.add(FACING, ACTIVE);
}
@Nullable
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
@ -135,7 +135,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);

View file

@ -40,7 +40,7 @@ import techreborn.client.GuiType;
import java.util.Random;
public class IronAlloyFurnaceBlock extends GenericMachineBlock {
public IronAlloyFurnaceBlock() {
super(GuiType.ALLOY_FURNACE, IronAlloyFurnaceBlockEntity::new);
}
@ -59,7 +59,7 @@ public class IronAlloyFurnaceBlock extends GenericMachineBlock {
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
Direction facing = (Direction) stateIn.get(FACING);
Direction facing = stateIn.get(FACING);
Direction.Axis facing$Axis = facing.getAxis();
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;

View file

@ -40,11 +40,11 @@ import techreborn.client.GuiType;
import java.util.Random;
public class IronFurnaceBlock extends GenericMachineBlock {
public IronFurnaceBlock() {
super(GuiType.IRON_FURNACE, IronFurnaceBlockEntity::new);
}
// Block
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
@ -59,7 +59,7 @@ public class IronFurnaceBlock extends GenericMachineBlock {
worldIn.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
Direction facing = (Direction) stateIn.get(FACING);
Direction facing = stateIn.get(FACING);
Direction.Axis facing$Axis = facing.getAxis();
double double_5 = rand.nextDouble() * 0.6D - 0.3D;
double deltaX = facing$Axis == Direction.Axis.X ? (double) facing.getOffsetX() * 0.52D : double_5;

View file

@ -68,30 +68,30 @@ public class BlockPlayerDetector extends BlockMachineBase {
public BlockEntity createBlockEntity(BlockView worldIn) {
return new PlayerDectectorBlockEntity();
}
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack stack) {
ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof PlayerDectectorBlockEntity) {
((PlayerDectectorBlockEntity) blockEntity).owenerUdid = placer.getUuid().toString();
}
}
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity == null) {
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
}
PlayerDetectorType type = state.get(TYPE);
PlayerDetectorType newType = type;
Formatting color = Formatting.GREEN;
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (ToolManager.INSTANCE.handleTool(stack, pos, worldIn, playerIn, hitResult.getSide(), false)) {
if (playerIn.isSneaking()) {
@ -126,22 +126,22 @@ public class BlockPlayerDetector extends BlockMachineBase {
if (worldIn.isClient) {
ChatUtils.sendNoSpamMessages(MessageIDs.playerDetectorID,
new TranslatableText("techreborn.message.detects")
.formatted(Formatting.GRAY)
.append(" ")
.append(
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
.formatted(color)
)
.formatted(Formatting.GRAY)
.append(" ")
.append(
new LiteralText(StringUtils.toFirstCapital(newType.asString()))
.formatted(color)
)
);
}
return ActionResult.SUCCESS;
}
@Override
public IMachineGuiHandler getGui() {
return null;
}
// Block
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
@ -171,13 +171,13 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
return 0;
}
public enum PlayerDetectorType implements StringIdentifiable {
ALL("all"), OTHERS("others"), YOU("you");
private final String name;
private PlayerDetectorType(String name) {
PlayerDetectorType(String name) {
this.name = name;
}

View file

@ -55,7 +55,7 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockAlarm extends BaseBlockEntityProvider {
public static DirectionProperty FACING = Properties.FACING;
public static DirectionProperty FACING = Properties.FACING;
public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape;
@ -65,9 +65,9 @@ public class BlockAlarm extends BaseBlockEntityProvider {
this.shape = GenCuboidShapes(3, 10);
BlockWrenchEventHandler.wrenableBlocks.add(this);
}
private VoxelShape[] GenCuboidShapes(double depth, double width) {
double culling = (16.0D - width) / 2 ;
double culling = (16.0D - width) / 2;
VoxelShape[] shapes = {
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
@ -78,13 +78,13 @@ public class BlockAlarm extends BaseBlockEntityProvider {
};
return shapes;
}
public static boolean isActive(BlockState state) {
return state.get(ACTIVE);
}
public static Direction getFacing(BlockState state) {
return (Direction) state.get(FACING);
return state.get(FACING);
}
public static void setFacing(Direction facing, World world, BlockPos pos) {
@ -96,21 +96,21 @@ public class BlockAlarm extends BaseBlockEntityProvider {
BlockState state = world.getBlockState(pos).with(ACTIVE, active).with(FACING, facing);
world.setBlockState(pos, state, 3);
}
// BaseTileBlock
@Nullable
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new AlarmBlockEntity();
}
// Block
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
ACTIVE = BooleanProperty.of("active");
builder.add(FACING, ACTIVE);
}
@Nullable
@Override
public BlockState getPlacementState(ItemPlacementContext context) {

View file

@ -47,7 +47,7 @@ public class BlockComputerCube extends BlockMachineBase {
public IMachineGuiHandler getGui() {
return null;
}
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
@ -63,8 +63,7 @@ public class BlockComputerCube extends BlockMachineBase {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return ActionResult.SUCCESS;
}
else {
} else {
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
return ActionResult.SUCCESS;
}

View file

@ -56,10 +56,10 @@ public class BlockNuke extends BaseBlock {
public void ignite(World worldIn, BlockPos pos, BlockState state, LivingEntity igniter) {
if (!worldIn.isClient) {
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
pos.getY(), (float) pos.getZ() + 0.5F, igniter);
worldIn.spawnEntity(entitynukeprimed);
worldIn.playSound((PlayerEntity) null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
worldIn.playSound(null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
@ -67,8 +67,8 @@ public class BlockNuke extends BaseBlock {
@Override
public void onDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
if (!worldIn.isClient) {
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), explosionIn.getCausingEntity());
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (float) pos.getX() + 0.5F,
pos.getY(), (float) pos.getZ() + 0.5F, explosionIn.getCausingEntity());
entitynukeprimed.setFuse(worldIn.random.nextInt(TechRebornConfig.nukeFuseTime / 4) + TechRebornConfig.nukeFuseTime / 8);
worldIn.spawnEntity(entitynukeprimed);
}
@ -105,7 +105,7 @@ public class BlockNuke extends BaseBlock {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
}
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(OVERLAY);

View file

@ -134,7 +134,9 @@ public class BlockRubberLog extends PillarBlock {
if (Energy.valid(stack)) {
Energy.of(stack).use(20);
} else {
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
stack.damage(1, playerIn, player -> {
player.sendToolBreakStatus(hand);
});
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberButtonBlock extends WoodButtonBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberDoorBlock extends DoorBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberPressurePlateBlock extends PressurePlateBlock {

View file

@ -29,7 +29,6 @@ import techreborn.utils.InitUtils;
/**
* @author drcrazy
*
*/
public class RubberTrapdoorBlock extends TrapdoorBlock {

View file

@ -30,7 +30,7 @@ import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.client.GuiType;
public class AdjustableSUBlock extends EnergyStorageBlock {
public AdjustableSUBlock() {
super("AESU", GuiType.AESU);
}

View file

@ -93,7 +93,7 @@ public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
@SuppressWarnings("deprecation")
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {

View file

@ -33,7 +33,7 @@ import techreborn.client.GuiType;
* Created by modmuss50 on 14/03/2016.
*/
public class HighVoltageSUBlock extends EnergyStorageBlock {
public HighVoltageSUBlock() {
super("high_voltage_su", GuiType.HIGH_VOLTAGE_SU);
}

View file

@ -36,7 +36,7 @@ import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.client.GuiType;
public class InterdimensionalSUBlock extends EnergyStorageBlock {
public InterdimensionalSUBlock() {
super("IDSU", GuiType.IDSU);
}

View file

@ -67,12 +67,12 @@ public class LSUStorageBlock extends BaseBlockEntityProvider {
}
super.onStateReplaced(state, worldIn, pos, newState, isMoving);
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new LSUStorageBlockEntity();
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack itemstack) {
super.onPlaced(world, pos, state, player, itemstack);

View file

@ -30,7 +30,7 @@ import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.client.GuiType;
public class LapotronicSUBlock extends EnergyStorageBlock {
public LapotronicSUBlock() {
super("LESU", GuiType.LESU);
}

View file

@ -33,7 +33,7 @@ import techreborn.client.GuiType;
* Created by modmuss50 on 14/03/2016.
*/
public class LowVoltageSUBlock extends EnergyStorageBlock {
public LowVoltageSUBlock() {
super("low_voltage_su", GuiType.LOW_VOLTAGE_SU);
}

View file

@ -33,7 +33,7 @@ import techreborn.client.GuiType;
* Created by modmuss50 on 14/03/2016.
*/
public class MediumVoltageSUBlock extends EnergyStorageBlock {
public MediumVoltageSUBlock() {
super("medium_voltage_su", GuiType.MEDIUM_VOLTAGE_SU);
}

View file

@ -28,10 +28,8 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@ -41,12 +39,10 @@ import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.RebornBucketItem;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.Tank;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.GuiType;
import techreborn.init.TRContent;
@ -76,17 +72,17 @@ public class TankUnitBlock extends BlockMachineBase {
// Assuming ItemFluidInfo is 1 BUCKET, for now only allow exact amount or less
if (tankUnitEntity != null && itemInHand instanceof ItemFluidInfo) {
ItemFluidInfo itemFluid = (ItemFluidInfo)itemInHand;
ItemFluidInfo itemFluid = (ItemFluidInfo) itemInHand;
Fluid fluid = itemFluid.getFluid(stackInHand);
int amount = stackInHand.getCount();
FluidValue fluidValue = FluidValue.BUCKET.multiply(amount);
Tank tankInstance = tankUnitEntity.getTank();
if(tankInstance.canFit(fluid, fluidValue)){
if(tankInstance.getFluidInstance().isEmptyFluid()){
if (tankInstance.canFit(fluid, fluidValue)) {
if (tankInstance.getFluidInstance().isEmptyFluid()) {
tankInstance.setFluidInstance(new FluidInstance(fluid, fluidValue));
}else{
} else {
tankInstance.getFluidInstance().addAmount(fluidValue);
}

View file

@ -38,7 +38,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.api.items.InventoryBase;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.WorldUtils;
@ -90,7 +89,7 @@ public class StorageUnitBlock extends BlockMachineBase {
public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) {
super.onBlockBreakStart(state, world, pos, player);
if(world.isClient) return;
if (world.isClient) return;
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
ItemStack stackInHand = player.getStackInHand(Hand.MAIN_HAND);
@ -100,10 +99,10 @@ public class StorageUnitBlock extends BlockMachineBase {
ItemStack out = inventory.getStack(StorageUnitBaseBlockEntity.OUTPUT_SLOT);
// Drop stack if sneaking
if(player.isSneaking()){
if (player.isSneaking()) {
WorldUtils.dropItem(new ItemStack(out.getItem()), world, player.getBlockPos());
out.decrement(1);
}else {
} else {
WorldUtils.dropItem(out, world, player.getBlockPos());
out.setCount(0);
}
@ -114,7 +113,6 @@ public class StorageUnitBlock extends BlockMachineBase {
}
@Override
public IMachineGuiHandler getGui() {
return GuiType.STORAGE_UNIT;

View file

@ -64,7 +64,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
public void setFacing(Direction facing, World world, BlockPos pos) {
world.setBlockState(pos, world.getBlockState(pos).with(FACING, facing));
}
public Direction getFacing(BlockState state) {
return state.get(FACING);
}
@ -72,7 +72,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
// BaseTileBlock
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack stack) {
ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
Direction facing = placer.getHorizontalFacing().getOpposite();
if (placer.pitch < -50) {
@ -98,7 +98,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
if (blockEntity == null) {
return ActionResult.FAIL;
}
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
return ActionResult.PASS;