Fixed off hand handling in block activation
This commit is contained in:
parent
f74e99c926
commit
8e7b6d235c
23 changed files with 115 additions and 26 deletions
|
@ -47,6 +47,10 @@ public class BlockLaser extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityLaser) {
|
||||
|
|
|
@ -65,6 +65,10 @@ public class BlockLaserMedium extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityLaserMedium) {
|
||||
|
|
|
@ -34,6 +34,10 @@ public class BlockAcceleratorControlPoint extends BlockAbstractAccelerator imple
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entityPlayer.getHeldItem(EnumHand.MAIN_HAND) == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@ public class BlockAcceleratorController extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (!(tileEntity instanceof TileEntityAcceleratorController)) {
|
||||
return false;
|
||||
|
|
|
@ -82,10 +82,14 @@ public class BlockAirGenerator extends BlockAbstractContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || hand == EnumHand.OFF_HAND) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityAirGenerator) {
|
||||
TileEntityAirGenerator airGenerator = (TileEntityAirGenerator)tileEntity;
|
||||
|
|
|
@ -92,10 +92,14 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || hand == EnumHand.OFF_HAND) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityAirGenerator) {
|
||||
TileEntityAirGenerator airGenerator = (TileEntityAirGenerator)tileEntity;
|
||||
|
|
|
@ -78,6 +78,10 @@ public class BlockShipScanner extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityShipScanner) {
|
||||
|
|
|
@ -76,6 +76,10 @@ public class BlockLaserTreeFarm extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityLaserTreeFarm) {
|
||||
|
|
|
@ -76,6 +76,10 @@ public class BlockMiningLaser extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityMiningLaser) {
|
||||
|
|
|
@ -45,6 +45,10 @@ public class BlockCamera extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityCamera) {
|
||||
|
|
|
@ -80,6 +80,10 @@ public class BlockCloakingCore extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityCloakingCore) {
|
||||
TileEntityCloakingCore cloakingCore = (TileEntityCloakingCore) tileEntity;
|
||||
|
|
|
@ -43,6 +43,10 @@ public class BlockMonitor extends BlockAbstractRotatingContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
|
||||
|
|
|
@ -81,6 +81,10 @@ public class BlockRadar extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityRadar) {
|
||||
|
|
|
@ -157,9 +157,6 @@ public class BlockEnergyBank extends BlockAbstractContainer implements IExplosio
|
|||
final Item item = Item.getItemFromBlock(this);
|
||||
ClientProxy.modelInitialisation(item);
|
||||
|
||||
// Bind our TESR to our tile entity
|
||||
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityForceFieldProjector.class, new TileEntityForceFieldProjectorRenderer());
|
||||
|
||||
// register (smart) baked model
|
||||
for (final EnumDisabledInputOutput enumDisabledInputOutput : CONFIG.getAllowedValues()) {
|
||||
for (final EnumTier enumTier : BlockProperties.TIER.getAllowedValues()) {
|
||||
|
@ -197,11 +194,15 @@ public class BlockEnergyBank extends BlockAbstractContainer implements IExplosio
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (!(tileEntity instanceof TileEntityEnergyBank)) {
|
||||
return false;
|
||||
|
@ -216,22 +217,22 @@ public class BlockEnergyBank extends BlockAbstractContainer implements IExplosio
|
|||
}
|
||||
final ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(blockState));
|
||||
switch (tileEntityEnergyBank.getMode(facing)) {
|
||||
case INPUT:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix")
|
||||
.appendSibling(new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToInput", facing.name())) );
|
||||
return true;
|
||||
case OUTPUT:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix")
|
||||
.appendSibling(new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToOutput", facing.name())) );
|
||||
return true;
|
||||
case DISABLED:
|
||||
default:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix")
|
||||
.appendSibling(new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToDisabled", facing.name())) );
|
||||
return true;
|
||||
case INPUT:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix",
|
||||
new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToInput", facing.name())) );
|
||||
return true;
|
||||
case OUTPUT:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix",
|
||||
new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToOutput", facing.name())) );
|
||||
return true;
|
||||
case DISABLED:
|
||||
default:
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.guide.prefix",
|
||||
new TextComponentTranslation(itemStack.getUnlocalizedName() + ".name"))
|
||||
.appendSibling(new TextComponentTranslation("warpdrive.energy.side.changedToDisabled", facing.name())) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,8 +267,7 @@ public class BlockEnergyBank extends BlockAbstractContainer implements IExplosio
|
|||
tileEntityEnergyBank.dismountUpgrade(enumComponentType);
|
||||
// upgrade dismounted
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.upgrade.result.dismounted", enumComponentType.name()));
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (itemStackHeld == null) {// no sneaking and no item in hand => show status
|
||||
|
@ -304,6 +304,7 @@ public class BlockEnergyBank extends BlockAbstractContainer implements IExplosio
|
|||
tileEntityEnergyBank.mountUpgrade(enumComponentType);
|
||||
// upgrade mounted
|
||||
Commons.addChatMessage(entityPlayer, new TextComponentTranslation("warpdrive.upgrade.result.mounted", enumComponentType.name()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -35,13 +35,16 @@ public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer {
|
|||
return new TileEntityIC2reactorLaserMonitor();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityIC2reactorLaserMonitor) {
|
||||
|
|
|
@ -208,6 +208,10 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (!(tileEntity instanceof TileEntityForceFieldProjector)) {
|
||||
return false;
|
||||
|
|
|
@ -88,6 +88,10 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (!(tileEntity instanceof TileEntityForceFieldRelay)) {
|
||||
return false;
|
||||
|
|
|
@ -70,10 +70,14 @@ public class BlockLift extends BlockAbstractContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote || hand == EnumHand.OFF_HAND) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityLift) {
|
||||
|
|
|
@ -45,6 +45,10 @@ public class BlockShipController extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityShipController) {
|
||||
|
|
|
@ -108,6 +108,10 @@ public class BlockShipCore extends BlockAbstractContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityShipCore) {
|
||||
|
|
|
@ -63,6 +63,10 @@ public class BlockTransporter extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityTransporter) {
|
||||
|
|
|
@ -44,6 +44,10 @@ public class BlockLaserCamera extends BlockAbstractContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (!ClientCameraHandler.isOverlayEnabled) {
|
||||
|
|
|
@ -43,11 +43,16 @@ public class BlockWeaponController extends BlockAbstractContainer {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStackHeld, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hand != EnumHand.MAIN_HAND) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemStackHeld == null) {
|
||||
final TileEntity tileEntity = world.getTileEntity(blockPos);
|
||||
if (tileEntity instanceof TileEntityWeaponController) {
|
||||
|
|
Loading…
Add table
Reference in a new issue