Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
{
TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_);
if (p_149689_6_.hasDisplayName())
{
tileentitycommandblock.func_145993_a().func_145754_b(p_149689_6_.getDisplayName());
}
}
public static boolean setTileEntityNBT(World worldIn, EntityPlayer pos, BlockPos stack, ItemStack p_179224_3_)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver == null)
{
return false;
}
else
{
if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasKey("BlockEntityTag", 10))
{
TileEntity tileentity = worldIn.getTileEntity(stack);
if (tileentity != null)
{
if (!worldIn.isRemote && tileentity.func_183000_F() && !minecraftserver.getConfigurationManager().canSendCommands(pos.getGameProfile()))
{
return false;
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy();
tileentity.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound2 = (NBTTagCompound)p_179224_3_.getTagCompound().getTag("BlockEntityTag");
nbttagcompound.merge(nbttagcompound2);
nbttagcompound.setInteger("x", stack.getX());
nbttagcompound.setInteger("y", stack.getY());
nbttagcompound.setInteger("z", stack.getZ());
if (!nbttagcompound.equals(nbttagcompound1))
{
tileentity.readFromNBT(nbttagcompound);
tileentity.markDirty();
return true;
}
}
}
return false;
}
}
ItemStack istack = new ItemStack(Blocks.command_block); // Создали итемстак с блоком.
NBTTagCompound blockEntityTag = new NBTTagCompound(); // Теперь создали пустой НБТ
blockEntityTag.setString("Command", "команда"); // Записали в него команду
NBTTagCompound nbt = new NBTTagCompound(); // Создали еще один НБТ
nbt.setTag("BlockEntityTag", blockEntityTag); // Записали во второй НБТ тег "BlockEntityTag"
istack.setTagCompound(nbt); // Записали в итемстак НБТ