Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override//This meathod sets the pos etc...
- public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
- {
- if (!worldIn.isRemote)
- {
- if(!playerIn.isSneaking())
- {
- if(stack.getTagCompound() == null)
- {
- stack.setTagCompound(new NBTTagCompound());
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && stack.getItemDamage() < stack.getMaxDamage())//Set coords (ctrl)
- {
- NBTTagCompound nbt = new NBTTagCompound();
- nbt.setInteger("dim", playerIn.dimension);
- nbt.setInteger("posX", pos.getX());
- nbt.setInteger("posY", pos.getY());
- nbt.setInteger("posZ", pos.getZ());
- stack.getTagCompound().setTag("coords", nbt);
- stack.setStackDisplayName(EnumChatFormatting.DARK_PURPLE + "Personal Teleporter");
- playerIn.addChatMessage(new ChatComponentText("Coordinates set, press shift + control and right click to clear them, press shift and right click to teleport."));
- System.out.println(
- "\nItem can damage: " + stack.isItemStackDamageable() +
- "\nDamage: " + stack.getItemDamage() +
- "\nMax Damage: " + stack.getMaxDamage() +
- "\nDamage: " + stack.getItemDamage()
- );
- stack.damageItem(1, playerIn);
- if (stack.getItemDamage() >= stack.getMaxDamage())
- {
- playerIn.addChatMessage(new ChatComponentText("Battery has run out"));
- clearCoords(stack, worldIn, playerIn);
- }
- else
- {
- playerIn.addChatMessage(new ChatComponentText("Press control and click on a block to store the coordinates"));
- }
- Random rand = new Random();
- String UID = "" + rand.nextDouble();
- System.out.println("UID: " + UID);
- }
- else
- {
- if (stack.getItemDamage() >= stack.getMaxDamage())
- {
- playerIn.addChatMessage(new ChatComponentText("Battery has run out"));
- clearCoords(stack, worldIn, playerIn);
- }
- else
- {
- playerIn.addChatMessage(new ChatComponentText("Press control and click on a block to store the coordinates"));
- }
- }
- }
- }
- return false;
- }
- //My modified basic packet
- @Override
- public IMessage onMessage(SimpleMessage message, MessageContext ctx)
- {
- // just to make sure that the side is correct
- if (ctx.side.isClient())
- {
- int integer = message.simpleInt;
- boolean bool = message.simpleBool;
- System.out.println(
- "\nItems recieved on client: " +
- "\nInt: " + integer +
- "\nbool: " + bool
- );
- }
- if (ctx.side.isServer())
- {
- int integer = message.simpleInt;
- boolean bool = message.simpleBool;
- System.out.println(
- "\nItems recieved on Server: " +
- "\nInt: " + integer +
- "\nbool: " + bool
- );
- }
- return message;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement