use of com.bluepowermod.tile.TileBPMicroblock in project BluePower by Qmunity.
the class BlockBPMicroblock method getCloneItemStack.
@Override
public ItemStack getCloneItemStack(IBlockReader world, BlockPos pos, BlockState state) {
TileEntity tileentity = world.getBlockEntity(pos);
ItemStack stack = ItemStack.EMPTY;
if (tileentity instanceof TileBPMultipart) {
tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
}
if (tileentity instanceof TileBPMicroblock) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", ((TileBPMicroblock) tileentity).getBlock().getRegistryName().toString());
stack = new ItemStack(this);
stack.setTag(nbt);
stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
}
return stack;
}
use of com.bluepowermod.tile.TileBPMicroblock in project BluePower by Qmunity.
the class BlockBPMicroblock method setPlacedBy.
@Override
public void setPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
super.setPlacedBy(worldIn, pos, state, placer, stack);
TileEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof TileBPMicroblock && stack.hasTag() && stack.getTag().contains("block")) {
// Update Microblock Type based on Stack
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(stack.getTag().getString("block")));
((TileBPMicroblock) tileentity).setBlock(block);
} else if (tileentity instanceof TileBPMultipart && stack.hasTag() && stack.getTag().contains("block")) {
// Update Multipart Microblock Type based on Stack
TileBPMicroblock tile = (TileBPMicroblock) ((TileBPMultipart) tileentity).getTileForState(state);
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(stack.getTag().getString("block")));
tile.setBlock(block);
}
}
use of com.bluepowermod.tile.TileBPMicroblock in project BluePower by Qmunity.
the class BlockBPMicroblock method getDrops.
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity tileentity = builder.getParameter(LootParameters.BLOCK_ENTITY);
List<ItemStack> itemStacks = new ArrayList<>();
if (tileentity instanceof TileBPMultipart) {
tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
}
if (tileentity instanceof TileBPMicroblock) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", ((TileBPMicroblock) tileentity).getBlock().getRegistryName().toString());
ItemStack stack = new ItemStack(this);
stack.setTag(nbt);
stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
itemStacks.add(stack);
}
return itemStacks;
}
Aggregations