Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("unused")
- @SubscribeEvent
- public void onPlayerPlaceEvent(RightClickBlock event)
- {
- ItemStack bagGold = new ItemStack(ItemIndex.coins, 1, 15);
- EntityPlayer playerIn = event.getEntityPlayer();
- BlockPos pos = event.getPos();
- World worldIn = event.getWorld();
- IBlockState state = worldIn.getBlockState(pos);
- Block block = state.getBlock();
- Logger.info("Event Triggered");
- if(!event.getEntityPlayer().getHeldItemMainhand().isEmpty())
- {
- Logger.info("Hand is not empty");
- if(event.getEntityPlayer().getHeldItemMainhand().getItem() == bagGold.getItem())
- {
- Logger.info("Attempted to Place");
- EnumFacing facing = EnumFacing.getDirectionFromEntityLiving(pos, playerIn);
- if(worldIn.mayPlace(block, pos, false, facing, (Entity)null))//is Valid place?
- {
- worldIn.setBlockState(pos.up(), BlockIndex.statues.getDefaultState().withProperty(BlockStatues.TYPE, EnumStatueBlocks.BAG_G));
- playerIn.getHeldItemMainhand().shrink(1);
- event.hasResult();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement