Updated onBlockActivated

This commit is contained in:
drcrazy 2019-02-21 13:35:54 +03:00
parent 8489259672
commit bdb8834a3e
13 changed files with 31 additions and 127 deletions

View file

@ -110,8 +110,7 @@ public class BlockAlarm extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -132,21 +131,7 @@ public class BlockAlarm extends BaseTileBlock {
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override
public int getMetaFromState(IBlockState state) {
int facingInt = state.getValue(FACING).getIndex();
int activeInt = state.getValue(ACTIVE) ? 8 : 0;
return facingInt + activeInt;
}
@Override
public IBlockState getStateFromMeta(int meta) {
Boolean active = (meta & 8) == 8;
EnumFacing facing = EnumFacing.byIndex(meta & 7);
return this.getDefaultState().with(FACING, facing).with(ACTIVE, active);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
@Nullable

View file

@ -55,8 +55,7 @@ public class BlockComputerCube extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack tool = playerIn.getHeldItem(EnumHand.MAIN_HAND);
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {

View file

@ -110,12 +110,6 @@ public class BlockNuke extends BaseBlock {
}
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
return false;
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(OVERLAY) ? 1 : 0;

View file

@ -161,9 +161,8 @@ public class BlockRubberLog extends Block {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
if (stack.isEmpty()) {
return false;

View file

@ -31,7 +31,6 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import reborncore.api.tile.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import java.util.List;
@ -41,8 +40,6 @@ import javax.annotation.Nullable;
public class BlockSupercondensator extends BlockMachineBase {
public BlockSupercondensator(Material material) {
super();
setTranslationKey("techreborn.supercondensator");
// setCreativeTab(TechRebornCreativeTab.instance);
}
@Override

View file

@ -56,9 +56,9 @@ public class BlockFusionCoil extends Block {
super(Block.Properties.create(Material.IRON).hardnessAndResistance(2f).sound(SoundType.METAL));
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/generators"));
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack tool = playerIn.getHeldItem(EnumHand.MAIN_HAND);
@ -78,12 +78,13 @@ public class BlockFusionCoil extends Block {
}
return false;
}
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip,
ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
//TODO: Translate
// TODO: Translate
tooltip.add(new TextComponentString("Right click Fusion Control computer to auto place"));
}
}

View file

@ -55,21 +55,20 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(final World world, final BlockPos pos, final IBlockState state,
final EntityPlayer player, final EnumHand hand, final EnumFacing side,
final float hitX, final float hitY, final float hitZ) {
final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) world.getTileEntity(pos);
if(!player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() == Item.getItemFromBlock(TRContent.Machine.FUSION_COIL.block)){
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
final TileFusionControlComputer tileFusionControlComputer = (TileFusionControlComputer) worldIn.getTileEntity(pos);
if(!playerIn.getHeldItem(hand).isEmpty() && playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(TRContent.Machine.FUSION_COIL.block)){
List<BlockPos> coils = Torus.generate(tileFusionControlComputer.getPos(), tileFusionControlComputer.size);
boolean placed = false;
for(BlockPos coil : coils){
if(player.getHeldItem(hand).isEmpty()){
if(playerIn.getHeldItem(hand).isEmpty()){
return true;
}
if(world.isAirBlock(coil) && !tileFusionControlComputer.isCoil(coil)){
world.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
if(!player.isCreative()){
player.getHeldItem(hand).shrink(1);
if(worldIn.isAirBlock(coil) && !tileFusionControlComputer.isCoil(coil)){
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
if(!playerIn.isCreative()){
playerIn.getHeldItem(hand).shrink(1);
}
placed = true;
}
@ -80,7 +79,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
}
tileFusionControlComputer.checkCoils();
return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override

View file

@ -137,16 +137,6 @@ public class BlockLamp extends BaseTileBlock {
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullBlock(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
@ -167,8 +157,7 @@ public class BlockLamp extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -183,7 +172,7 @@ public class BlockLamp extends BaseTileBlock {
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override

View file

@ -150,8 +150,7 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -193,18 +192,6 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
setFacing(facing, worldIn, pos);
}
@Override
public int getMetaFromState(IBlockState state) {
int facingInt = getSideFromEnum(state.getValue(FACING));
return facingInt;
}
@Override
public IBlockState getStateFromMeta(int meta) {
EnumFacing facing = getSideFromint(meta);
return this.getDefaultState().with(FACING, facing);
}
public enum Facings implements Predicate<EnumFacing>, Iterable<EnumFacing> {
ALL;

View file

@ -89,8 +89,7 @@ public class BlockLSUStorage extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -105,7 +104,7 @@ public class BlockLSUStorage extends BaseTileBlock {
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override

View file

@ -24,11 +24,8 @@
package techreborn.blocks.tier1;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import reborncore.api.tile.IMachineGuiHandler;
import reborncore.client.models.ModelCompound;
import reborncore.client.models.RebornModelRegistry;
@ -40,25 +37,10 @@ import techreborn.tiles.machine.tier1.TileAutoCraftingTable;
public class BlockAutoCraftingTable extends BlockMachineBase {
public BlockAutoCraftingTable() {
super(true);
super();
RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, "machines/tier1_machines"));
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this);
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState();
}
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileAutoCraftingTable();

View file

@ -94,13 +94,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity == null) {
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
String type = state.getValue(TYPE);
@ -152,19 +151,6 @@ public class BlockPlayerDetector extends BlockMachineBase {
return new BlockStateContainer(this, TYPE);
}
@Override
public IBlockState getStateFromMeta(int meta) {
if (meta > types.length) {
meta = 0;
}
return getBlockState().getBaseState().with(TYPE, typeNamesList.get(meta));
}
@Override
public int getMetaFromState(IBlockState state) {
return typeNamesList.indexOf(state.getValue(TYPE));
}
@Override
public IMachineGuiHandler getGui() {
return null;

View file

@ -156,8 +156,7 @@ public abstract class BlockTransformer extends BaseTileBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -172,7 +171,7 @@ public abstract class BlockTransformer extends BaseTileBlock {
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override
@ -193,18 +192,6 @@ public abstract class BlockTransformer extends BaseTileBlock {
return false;
}
@Override
public int getMetaFromState(IBlockState state) {
int facingInt = getSideFromEnum(state.getValue(FACING));
return facingInt;
}
@Override
public IBlockState getStateFromMeta(int meta) {
EnumFacing facing = getSideFromint(meta);
return this.getDefaultState().with(FACING, facing);
}
public enum Facings implements Predicate<EnumFacing>, Iterable<EnumFacing> {
ALL;