use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ItemSystemLinker method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
NBTTagCompound stackCompound = stack.getTagCompound();
if (stackCompound == null) {
stackCompound = new NBTTagCompound();
stack.setTagCompound(stackCompound);
}
if (block instanceof BlockHovercraftController) {
if (!worldIn.isRemote) {
NBTUtils.writeBlockPosToNBT("controllerPos", pos, stackCompound);
playerIn.addChatMessage(new TextComponentString("ControllerPos set <" + pos.getX() + ":" + pos.getY() + ":" + pos.getZ() + ">"));
} else {
return EnumActionResult.SUCCESS;
}
}
if (block instanceof BlockEtherCompressor) {
if (!worldIn.isRemote) {
BlockPos controllerPos = NBTUtils.readBlockPosFromNBT("controllerPos", stackCompound);
if (controllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("No selected Controller"));
} else {
PhysicsWrapperEntity controllerWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, controllerPos);
PhysicsWrapperEntity engineWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
if (controllerWrapper != engineWrapper) {
playerIn.addChatMessage(new TextComponentString("Controller and Engine are on seperate ships"));
return EnumActionResult.SUCCESS;
}
TileEntity worldTile = worldIn.getTileEntity(pos);
if (worldTile instanceof TileEntityEtherCompressor) {
TileEntityEtherCompressor tileEntity = (TileEntityEtherCompressor) worldTile;
BlockPos gravControllerPos = tileEntity.controllerPos;
if (gravControllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("Set Controller To " + controllerPos.toString()));
} else {
playerIn.addChatMessage(new TextComponentString("Replaced controller position from: " + gravControllerPos.toString() + " to: " + controllerPos.toString()));
}
tileEntity.setController(controllerPos);
}
}
} else {
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
use of net.minecraft.util.text.TextComponentString in project Overloaded by CJ-MC-Mods.
the class AbstractBlockHyperReceiver method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.getItem().equals(ModItems.linkingCard)) {
NBTTagCompound tag = heldItem.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
}
int worldId = worldIn.provider.getDimension();
writeNodeData(tag, worldId, pos);
heldItem.setTagCompound(tag);
if (worldIn.isRemote) {
playerIn.sendStatusMessage(new TextComponentString(String.format("Recorded: World: %d Position: %s", worldId, pos.toString())), false);
}
return true;
} else {
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
}
use of net.minecraft.util.text.TextComponentString 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 net.minecraft.util.text.TextComponentString in project AgriCraft by AgriCraft.
the class ItemMagnifyingGlass method onItemUseFirst.
//this is called when you right click with this item in hand
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote) {
List<String> list = new ArrayList<>();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
TileEntity te = world.getTileEntity(pos);
// Add a separator.
list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");
// Add lighting information.
list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");
// Add block information.
if (block instanceof IAgriDisplayable) {
((IAgriDisplayable) block).addDisplayInfo(list::add);
}
// Add tile information.
if (te instanceof IAgriDisplayable) {
((IAgriDisplayable) te).addDisplayInfo(list::add);
}
// Display information.
for (String msg : list) {
player.addChatComponentMessage(new TextComponentString(msg));
}
}
return EnumActionResult.SUCCESS;
}
use of net.minecraft.util.text.TextComponentString in project ConvenientAdditions by Necr0.
the class ItemPlayerChannelModule method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack item = player.getHeldItem(hand);
if (!world.isRemote) {
if (!item.hasTagCompound())
item.setTagCompound(new NBTTagCompound());
NBTTagCompound t = item.getTagCompound();
if (!player.isSneaking()) {
t.setString("MATCHER_PLAYER_ID", player.getUniqueID().toString());
t.setString("MATCHER_PLAYER_NAME", player.getDisplayNameString());
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerSetTo", player.getDisplayNameString())));
new ActionResult<>(EnumActionResult.SUCCESS, item);
} else {
t.removeTag("MATCHER_PLAYER_ID");
t.removeTag("MATCHER_PLAYER_NAME");
player.sendMessage(new TextComponentString(Helper.localize("message." + ModConstants.Mod.MODID + ":playerReset")));
new ActionResult<>(EnumActionResult.SUCCESS, item);
}
}
return new ActionResult<>(EnumActionResult.PASS, item);
}
Aggregations