Advertisement
Guest User

place block problem

a guest
May 29th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. package com.tomasforsman.letseat.items.utility;
  2.  
  3. import com.tomasforsman.letseat.Logger;
  4. import com.tomasforsman.letseat.init.ModBlocks;
  5. import com.tomasforsman.letseat.items.ItemBase;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraft.tileentity.TileEntity;
  11. import net.minecraft.util.EnumActionResult;
  12. import net.minecraft.util.EnumFacing;
  13. import net.minecraft.util.EnumHand;
  14. import net.minecraft.util.math.BlockPos;
  15. import net.minecraft.world.World;
  16.  
  17. public class MergeWand extends ItemBase {
  18.    
  19.     public MergeWand(String name) {
  20.         super(name);
  21.     }
  22.    
  23.     @Override
  24.     public EnumActionResult onItemUse(final EntityPlayer playerIn, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) {
  25.             final IBlockState iBlockState = worldIn.getBlockState(pos);
  26.             final IBlockState state = iBlockState.getActualState(worldIn, pos);
  27.             Logger.info("Block at %d,%d,%d: %s", pos.getX(), pos.getY(), pos.getZ(), state);
  28.             final BlockPos addPos = pos.up();
  29.            
  30.             final TileEntity tileEntity = worldIn.getTileEntity(pos);
  31.             if (tileEntity != null) {
  32.                 Logger.info("TileEntity data: %s", tileEntity.serializeNBT());
  33.                 if (state.getBlock().isReplaceable(worldIn, addPos)) {
  34.                     Block blk = ModBlocks.RUBY_BLOCK;
  35.                     IBlockState blkState = blk.getDefaultState();
  36.                     worldIn.setBlockState(addPos, blkState);
  37.                     System.out.println("hello");
  38.                    
  39.                    
  40.                 }
  41.             }
  42.             return EnumActionResult.SUCCESS;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement