net.minecraft.block.BlockJukebox Java Examples
The following examples show how to use
net.minecraft.block.BlockJukebox.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftJukebox.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public boolean update(boolean force, boolean applyPhysics) { boolean result = super.update(force, applyPhysics); if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) { CraftWorld world = (CraftWorld) this.getWorld(); Material record = this.getPlaying(); if (record == Material.AIR) { world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()), Blocks.JUKEBOX.getDefaultState() .withProperty(BlockJukebox.HAS_RECORD, false), 3); } else { world.getHandle().setBlockState(new BlockPos(this.getX(), this.getY(), this.getZ()), Blocks.JUKEBOX.getDefaultState() .withProperty(BlockJukebox.HAS_RECORD, true), 3); } world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record.getId()); } return result; }
Example #2
Source File: CraftJukebox.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public boolean eject() { requirePlaced(); TileEntity tileEntity = this.getTileEntityFromWorld(); if (!(tileEntity instanceof TileEntityJukebox)) return false; TileEntityJukebox jukebox = (TileEntityJukebox) tileEntity; boolean result = !jukebox.getRecord().isEmpty(); CraftWorld world = (CraftWorld) this.getWorld(); ((BlockJukebox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPos(getX(), getY(), getZ()), null); return result; }
Example #3
Source File: CraftJukebox.java From Thermos with GNU General Public License v3.0 | 4 votes |
public boolean eject() { boolean result = isPlaying(); ((BlockJukebox) Blocks.jukebox).func_149925_e(world.getHandle(), getX(), getY(), getZ()); return result; }
Example #4
Source File: TileRequest.java From HoloInventory with MIT License | 4 votes |
@Override public ResponseMessage onMessage(TileRequest message, MessageContext ctx) { World world = DimensionManager.getWorld(message.dim); if (world == null) return null; TileEntity te = world.getTileEntity(message.pos); if (te == null) return null; if (Helper.banned.contains(te.getClass().getCanonicalName())) return null; if (te instanceof ILockableContainer && !ctx.getServerHandler().player.canOpen(((ILockableContainer) te).getLockCode())) return null; if (te instanceof TileEntityEnderChest) { return new PlainInventory(message.pos, ctx.getServerHandler().player.getInventoryEnderChest()); } else if (te instanceof BlockJukebox.TileEntityJukebox) { InventoryBasic ib = new InventoryBasic("minecraft:jukebox", false, 1); ib.setInventorySlotContents(0, ((BlockJukebox.TileEntityJukebox) te).getRecord()); return new PlainInventory(message.pos, ib).setName(Blocks.JUKEBOX.getUnlocalizedName()); } else if (te instanceof TileEntityChest) { Block b = world.getBlockState(message.pos).getBlock(); if (b instanceof BlockChest) { IInventory i = ((BlockChest) b).getLockableContainer(world, message.pos); if (i != null) return new PlainInventory(message.pos, i); return null; } return new PlainInventory(message.pos, ((TileEntityChest) te)); } else if (te instanceof IInventory) { return new PlainInventory(message.pos, (IInventory) te); } else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler iih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if (iih == null) { HoloInventory.getLogger().warn("Error: Block at {} (Class: {} Te: {} Block: {}) returned null after indicating the capability is available.", message.pos, te.getClass().getName(), te, te.getBlockType()); return null; } if (te instanceof INamedItemHandler) { INamedItemHandler namedHandler = (INamedItemHandler) te; return new PlainInventory(message.pos, namedHandler.getItemHandlerName(), iih); } return new PlainInventory(message.pos, te.getBlockType().getUnlocalizedName(), iih); } return null; }
Example #5
Source File: Helper.java From HoloInventory with MIT License | 4 votes |
public static boolean accept(TileEntity te) { return te != null && (te instanceof IInventory || te instanceof BlockJukebox.TileEntityJukebox || te instanceof TileEntityEnderChest || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)); }