use of net.minecraft.block.BlockJukebox in project SpongeCommon by SpongePowered.
the class JukeboxDataProcessor method remove.
private boolean remove(BlockJukebox.TileEntityJukebox jukebox) {
((Jukebox) jukebox).ejectRecord();
IBlockState block = jukebox.getWorld().getBlockState(jukebox.getPos());
return block.getBlock() instanceof BlockJukebox && !block.getValue(BlockJukebox.HAS_RECORD);
}
use of net.minecraft.block.BlockJukebox in project SpongeCommon by SpongePowered.
the class MixinTileEntityJukebox method ejectRecord.
@Override
public void ejectRecord() {
IBlockState block = this.world.getBlockState(this.pos);
if (block.getBlock() == Blocks.JUKEBOX) {
((BlockJukebox) block.getBlock()).dropRecord(this.world, this.pos, block);
this.world.setBlockState(this.pos, block.withProperty(BlockJukebox.HAS_RECORD, false), 2);
}
}
use of net.minecraft.block.BlockJukebox in project SpongeCommon by SpongePowered.
the class JukeboxDataProcessor method set.
@Override
protected boolean set(BlockJukebox.TileEntityJukebox jukebox, ItemStackSnapshot stackSnapshot) {
IBlockState block = jukebox.getWorld().getBlockState(jukebox.getPos());
if (stackSnapshot == ItemStackSnapshot.NONE) {
if (jukebox.getRecord() == null) {
return true;
}
return remove(jukebox);
}
if (!(stackSnapshot.getType() instanceof ItemRecord)) {
return false;
}
((Jukebox) jukebox).insertRecord(stackSnapshot.createStack());
block = jukebox.getWorld().getBlockState(jukebox.getPos());
return block.getBlock() instanceof BlockJukebox && block.getValue(BlockJukebox.HAS_RECORD);
}
use of net.minecraft.block.BlockJukebox in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemKKRecord method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState iblockstate = world.getBlockState(pos);
if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean) iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) {
if (!world.isRemote) {
((BlockJukebox) Blocks.JUKEBOX).insertRecord(world, pos, iblockstate, player.getActiveItemStack());
world.playEvent((EntityPlayer) null, 1010, pos, Item.getIdFromItem(this));
player.getActiveItemStack().setCount(player.getActiveItemStack().getCount() - 1);
player.addStat(StatList.RECORD_PLAYED);
}
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.PASS;
}
Aggregations