Energy storage should drop inventory. Closes #1919
This commit is contained in:
parent
2afca5534b
commit
6dc1124bc6
11 changed files with 50 additions and 59 deletions
|
@ -29,9 +29,9 @@ import net.minecraft.world.BlockView;
|
|||
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
|
||||
import techreborn.client.EGui;
|
||||
|
||||
public class BlockAdjustableSU extends BlockEnergyStorage {
|
||||
public class AdjustableSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockAdjustableSU() {
|
||||
public AdjustableSUBlock() {
|
||||
super("AESU", EGui.AESU);
|
||||
}
|
||||
|
|
@ -46,19 +46,19 @@ import reborncore.api.blockentity.IMachineGuiHandler;
|
|||
import reborncore.common.BaseBlockEntityProvider;
|
||||
import reborncore.common.blocks.BlockWrenchEventHandler;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemHandlerUtils;
|
||||
import reborncore.common.util.WrenchUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public abstract class BlockEnergyStorage extends BaseBlockEntityProvider {
|
||||
public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
|
||||
public static DirectionProperty FACING = Properties.FACING;
|
||||
public String name;
|
||||
public IMachineGuiHandler gui;
|
||||
|
||||
public BlockEnergyStorage(String name, IMachineGuiHandler gui) {
|
||||
public EnergyStorageBlock(String name, IMachineGuiHandler gui) {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build());
|
||||
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
|
||||
this.name = name;
|
||||
|
@ -74,26 +74,17 @@ public abstract class BlockEnergyStorage extends BaseBlockEntityProvider {
|
|||
return state.get(FACING);
|
||||
}
|
||||
|
||||
public String getSimpleName(String fullName) {
|
||||
if (fullName.equalsIgnoreCase("Batbox")) {
|
||||
return "lv_storage";
|
||||
// BaseBlockEntityProvider
|
||||
@Override
|
||||
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
|
||||
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||
Direction facing = placer.getHorizontalFacing().getOpposite();
|
||||
if (placer.pitch < -50) {
|
||||
facing = Direction.DOWN;
|
||||
} else if (placer.pitch > 50) {
|
||||
facing = Direction.UP;
|
||||
}
|
||||
if (fullName.equalsIgnoreCase("MEDIUM_VOLTAGE_SU")) {
|
||||
return "mv_storage";
|
||||
}
|
||||
if (fullName.equalsIgnoreCase("HIGH_VOLTAGE_SU")) {
|
||||
return "hv_storage";
|
||||
}
|
||||
if (fullName.equalsIgnoreCase("AESU")) {
|
||||
return "ev_storage_adjust";
|
||||
}
|
||||
if (fullName.equalsIgnoreCase("IDSU")) {
|
||||
return "ev_storage_transmitter";
|
||||
}
|
||||
if (fullName.equalsIgnoreCase("LESU")) {
|
||||
return "ev_multi";
|
||||
}
|
||||
return fullName.toLowerCase(Locale.ROOT);
|
||||
setFacing(facing, worldIn, pos);
|
||||
}
|
||||
|
||||
// Block
|
||||
|
@ -102,6 +93,7 @@ public abstract class BlockEnergyStorage extends BaseBlockEntityProvider {
|
|||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
|
@ -126,24 +118,22 @@ public abstract class BlockEnergyStorage extends BaseBlockEntityProvider {
|
|||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
|
||||
ItemStack stack) {
|
||||
super.onPlaced(worldIn, pos, state, placer, stack);
|
||||
Direction facing = placer.getHorizontalFacing().getOpposite();
|
||||
if (placer.pitch < -50) {
|
||||
facing = Direction.DOWN;
|
||||
} else if (placer.pitch > 50) {
|
||||
facing = Direction.UP;
|
||||
public void onBlockRemoved(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
ItemHandlerUtils.dropContainedItems(worldIn, pos);
|
||||
super.onBlockRemoved(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
setFacing(facing, worldIn, pos);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean hasComparatorOutput(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int getComparatorOutput(BlockState state, World world, BlockPos pos) {
|
||||
return PowerAcceptorBlockEntity.calculateComparatorOutputFromEnergy(world.getBlockEntity(pos));
|
|
@ -32,9 +32,9 @@ import techreborn.client.EGui;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockHighVoltageSU extends BlockEnergyStorage {
|
||||
public class HighVoltageSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockHighVoltageSU() {
|
||||
public HighVoltageSUBlock() {
|
||||
super("high_voltage_su", EGui.HIGH_VOLTAGE_SU);
|
||||
}
|
||||
|
|
@ -35,9 +35,9 @@ import net.minecraft.world.World;
|
|||
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
|
||||
import techreborn.client.EGui;
|
||||
|
||||
public class BlockInterdimensionalSU extends BlockEnergyStorage {
|
||||
public class InterdimensionalSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockInterdimensionalSU() {
|
||||
public InterdimensionalSUBlock() {
|
||||
super("IDSU", EGui.IDSU);
|
||||
}
|
||||
|
|
@ -46,9 +46,9 @@ import techreborn.blockentity.storage.lesu.LSUStorageBlockEntity;
|
|||
/**
|
||||
* Energy storage block for LESU
|
||||
*/
|
||||
public class BlockLSUStorage extends BaseBlockEntityProvider {
|
||||
public class LSUStorageBlock extends BaseBlockEntityProvider {
|
||||
|
||||
public BlockLSUStorage() {
|
||||
public LSUStorageBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build());
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
|
@ -29,9 +29,9 @@ import net.minecraft.world.BlockView;
|
|||
import techreborn.blockentity.storage.lesu.LapotronicSUBlockEntity;
|
||||
import techreborn.client.EGui;
|
||||
|
||||
public class BlockLapotronicSU extends BlockEnergyStorage {
|
||||
public class LapotronicSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockLapotronicSU() {
|
||||
public LapotronicSUBlock() {
|
||||
super("LESU", EGui.LESU);
|
||||
}
|
||||
|
|
@ -32,9 +32,9 @@ import techreborn.blockentity.storage.LowVoltageSUBlockEntity;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockLowVoltageSU extends BlockEnergyStorage {
|
||||
public class LowVoltageSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockLowVoltageSU() {
|
||||
public LowVoltageSUBlock() {
|
||||
super("low_voltage_su", EGui.LOW_VOLTAGE_SU);
|
||||
}
|
||||
|
|
@ -32,9 +32,9 @@ import techreborn.client.EGui;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class BlockMediumVoltageSU extends BlockEnergyStorage {
|
||||
public class MediumVoltageSUBlock extends EnergyStorageBlock {
|
||||
|
||||
public BlockMediumVoltageSU() {
|
||||
public MediumVoltageSUBlock() {
|
||||
super("medium_voltage_su", EGui.MEDIUM_VOLTAGE_SU);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue