use of com.cjm721.overloaded.block.tile.hyperTransfer.base.AbstractTileHyperSender in project Overloaded by CJ-MC-Mods.
the class AbstractBlockHyperSender method onBlockActivated.
@Override
public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (hand == EnumHand.MAIN_HAND) {
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.isEmpty()) {
// Should find a cleaner way of showing all of this
if (!worldIn.isRemote) {
String message = ((AbstractTileHyperSender) worldIn.getTileEntity(pos)).getRightClickMessage();
playerIn.sendStatusMessage(new TextComponentString(message), false);
}
} else if (heldItem.getItem().equals(ModItems.linkingCard)) {
NBTTagCompound tag = heldItem.getTagCompound();
if (tag != null) {
if (tag.getString("TYPE").equals(this.getType())) {
int worldID = tag.getInteger("WORLD");
int x = tag.getInteger("X");
int y = tag.getInteger("Y");
int z = tag.getInteger("Z");
bindToPartner(worldIn, pos, worldID, new BlockPos(x, y, z));
heldItem.setTagCompound(null);
if (worldIn.isRemote) {
playerIn.sendStatusMessage(new TextComponentString("Bound Hyper Nodes"), true);
}
} else {
if (worldIn.isRemote) {
playerIn.sendStatusMessage(new TextComponentString("Incorrect Hyper Node Type to bind."), true);
}
}
}
}
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
use of com.cjm721.overloaded.block.tile.hyperTransfer.base.AbstractTileHyperSender in project Overloaded by CJ-MC-Mods.
the class AbstractBlockHyperSender method use.
@Override
@Nonnull
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
if (hand == Hand.MAIN_HAND) {
ItemStack heldItem = player.getItemInHand(hand);
if (heldItem.isEmpty()) {
// Should find a cleaner way of showing all of this
if (!world.isClientSide) {
String message = ((AbstractTileHyperSender) world.getBlockEntity(pos)).getRightClickMessage();
player.displayClientMessage(new StringTextComponent(message), false);
}
return ActionResultType.SUCCESS;
} else if (heldItem.getItem().equals(ModItems.linkingCard)) {
CompoundNBT tag = heldItem.getTag();
if (tag != null) {
if (tag.getString("TYPE").equals(this.getType())) {
String worldID = tag.getString("WORLD");
int x = tag.getInt("X");
int y = tag.getInt("Y");
int z = tag.getInt("Z");
bindToPartner(world, pos, worldID, new BlockPos(x, y, z));
if (world.isClientSide) {
player.displayClientMessage(new StringTextComponent("Bound Hyper Nodes"), true);
}
} else {
if (world.isClientSide) {
player.displayClientMessage(new StringTextComponent("Incorrect Hyper Node Type to bind."), true);
}
}
}
return ActionResultType.SUCCESS;
}
}
return super.use(state, world, pos, player, hand, rayTraceResult);
}
Aggregations