@SubscribeEvent public void blockPlaced(BlockEvent.PlaceEvent event){ if(event.block instanceof BlockNote){ TileEntityNote entity = (TileEntityNote) Minecraft.getMinecraft().theWorld.getTileEntity(event.x, event.y, event.z); Minecraft.getMinecraft().displayGuiScreen(new GuiSet(entity, Minecraft.getMinecraft().currentScreen)); } }
@SubscribeEvent(priority = EventPriority.HIGH) public void rightClick(PlayerInteractEvent event){ if(event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() instanceof ItemNoteblockFork){ if(Minecraft.getMinecraft().theWorld.getBlock(event.x, event.y, event.z) instanceof BlockNote){ if(!event.entityPlayer.isSneaking()){ event.setCanceled(true); TileEntityNote entity = (TileEntityNote) Minecraft.getMinecraft().theWorld.getTileEntity(event.x, event.y, event.z); Minecraft.getMinecraft().displayGuiScreen(new GuiSet(entity, Minecraft.getMinecraft().currentScreen)); } } } }
private static SoundEvent getInstrument(int id) { if (id == -1) { return SoundEvents.ENTITY_SHEEP_AMBIENT; } if (id < 0 || id >= BlockNote.INSTRUMENTS.size()) { id = 0; } return BlockNote.INSTRUMENTS.get(id); }
public static boolean canConnectVanilla(World world, BlockPos pos, ForgeDirection side, ForgeDirection face) { if (side == ForgeDirection.UNKNOWN) return false; Block block = world.getBlock(pos.getX(), pos.getY(), pos.getZ()); int meta = world.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ()); int d = Direction.getMovementDirection(side.offsetX, side.offsetZ); if ((block == Blocks.unpowered_repeater || block == Blocks.powered_repeater) && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN)) if (d % 2 == meta % 2) return true; if (block instanceof BlockLever) { meta = meta % 8; ForgeDirection leverFace = ((meta == 0 || meta == 7) ? ForgeDirection.UP : ((meta == 5 || meta == 6) ? ForgeDirection.DOWN : (meta == 1 ? ForgeDirection.WEST : (meta == 2 ? ForgeDirection.EAST : (meta == 3 ? ForgeDirection.NORTH : (meta == 4 ? ForgeDirection.SOUTH : ForgeDirection.UNKNOWN)))))); if (face != ForgeDirection.UNKNOWN && face != leverFace) return false; return side != leverFace.getOpposite(); } if (block instanceof BlockRedstoneComparator && (face == ForgeDirection.DOWN || face == ForgeDirection.UNKNOWN)) return side != ForgeDirection.UP; if (block instanceof BlockRedstoneWire) return face == ForgeDirection.UNKNOWN || face == ForgeDirection.DOWN; return block instanceof BlockDoor || block instanceof BlockRedstoneLight || block instanceof BlockTNT || block instanceof BlockDispenser || block instanceof BlockNote || block instanceof BlockPistonBase;// true; }
private static boolean isVanillaBlock(World world, BlockPos pos) { Block b = world.getBlock(pos.getX(), pos.getY(), pos.getZ()); return b instanceof BlockRedstoneRepeater || b instanceof BlockLever || b instanceof BlockRedstoneWire || b instanceof BlockRedstoneComparator || b instanceof BlockDoor || b instanceof BlockRedstoneLight || b instanceof BlockTNT || b instanceof BlockDispenser || b instanceof BlockNote || b instanceof BlockPistonBase; }