Search in sources :

Example 1 with BlockJukebox

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);
}
Also used : TileEntityJukebox(net.minecraft.block.BlockJukebox.TileEntityJukebox) Jukebox(org.spongepowered.api.block.tileentity.Jukebox) BlockJukebox(net.minecraft.block.BlockJukebox) IBlockState(net.minecraft.block.state.IBlockState) BlockJukebox(net.minecraft.block.BlockJukebox)

Example 2 with BlockJukebox

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);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockJukebox(net.minecraft.block.BlockJukebox)

Example 3 with BlockJukebox

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);
}
Also used : TileEntityJukebox(net.minecraft.block.BlockJukebox.TileEntityJukebox) Jukebox(org.spongepowered.api.block.tileentity.Jukebox) BlockJukebox(net.minecraft.block.BlockJukebox) IBlockState(net.minecraft.block.state.IBlockState) BlockJukebox(net.minecraft.block.BlockJukebox) ItemRecord(net.minecraft.item.ItemRecord)

Example 4 with BlockJukebox

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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockJukebox(net.minecraft.block.BlockJukebox)

Aggregations

BlockJukebox (net.minecraft.block.BlockJukebox)4 IBlockState (net.minecraft.block.state.IBlockState)4 TileEntityJukebox (net.minecraft.block.BlockJukebox.TileEntityJukebox)2 Jukebox (org.spongepowered.api.block.tileentity.Jukebox)2 ItemRecord (net.minecraft.item.ItemRecord)1