use of net.minecraft.item.ItemRecord in project SpongeCommon by SpongePowered.
the class MixinTileEntityJukebox method insertRecord.
@Override
public void insertRecord(ItemStack record) {
net.minecraft.item.ItemStack itemStack = (net.minecraft.item.ItemStack) checkNotNull(record, "record");
if (!(itemStack.getItem() instanceof ItemRecord)) {
return;
}
IBlockState block = this.world.getBlockState(this.pos);
if (block.getBlock() == Blocks.JUKEBOX) {
// Don't use BlockJukebox#insertRecord - it looses item data
this.setRecord(itemStack);
this.world.setBlockState(this.pos, block.withProperty(BlockJukebox.HAS_RECORD, true), 2);
}
}
use of net.minecraft.item.ItemRecord 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);
}
Aggregations