TileEntityCommandBlock .java

net.minecraft.tileentity.TileEntityCommandBlock (class, 93 lines): members: getCommandResultStats, getCommandBlockLogic, commandBlockLogic, func_183000_F.

net.minecraft.tileentityclass93 linescommonextends TileEntity2.9 KB

API Surface (14)

BlockPos getPosition()
Vec3 getPositionVector()
World getEntityWorld()
void setCommand(String command)
void updateCommand()
int func_145751_f()
void func_145757_a(ByteBuf p_145757_1_)
Entity getCommandSenderEntity()
void writeToNBT(NBTTagCompound compound)
void readFromNBT(NBTTagCompound compound)
Packet getDescriptionPacket()
boolean func_183000_F()
CommandBlockLogic getCommandBlockLogic()
CommandResultStats getCommandResultStats()

Fields & Constants (1)

commandBlockLogic

Full Source

TileEntityCommandBlock.java93 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.tileentity;
2
3
import io.netty.buffer.ByteBuf;
4
import net.minecraft.command.CommandResultStats;
5
import net.minecraft.command.server.CommandBlockLogic;
6
import net.minecraft.entity.Entity;
7
import net.minecraft.nbt.NBTTagCompound;
8
import net.minecraft.network.Packet;
9
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
10
import net.minecraft.util.BlockPos;
11
import net.minecraft.util.Vec3;
12
import net.minecraft.world.World;
13
14
public class TileEntityCommandBlock extends TileEntity
15
{
16
    private final CommandBlockLogic commandBlockLogic = new CommandBlockLogic()
17
    {
18
        public BlockPos getPosition()
19
        {
20
            return TileEntityCommandBlock.this.pos;
21
        }
22
        public Vec3 getPositionVector()
23
        {
24
            return new Vec3((double)TileEntityCommandBlock.this.pos.getX() + 0.5D, (double)TileEntityCommandBlock.this.pos.getY() + 0.5D, (double)TileEntityCommandBlock.this.pos.getZ() + 0.5D);
25
        }
26
        public World getEntityWorld()
27
        {
28
            return TileEntityCommandBlock.this.getWorld();
29
        }
30
        public void setCommand(String command)
31
        {
32
            super.setCommand(command);
33
            TileEntityCommandBlock.this.markDirty();
34
        }
35
        public void updateCommand()
36
        {
37
            TileEntityCommandBlock.this.getWorld().markBlockForUpdate(TileEntityCommandBlock.this.pos);
38
        }
39
        public int func_145751_f()
40
        {
41
            return 0;
42
        }
43
        public void func_145757_a(ByteBuf p_145757_1_)
44
        {
45
            p_145757_1_.writeInt(TileEntityCommandBlock.this.pos.getX());
46
            p_145757_1_.writeInt(TileEntityCommandBlock.this.pos.getY());
47
            p_145757_1_.writeInt(TileEntityCommandBlock.this.pos.getZ());
48
        }
49
        public Entity getCommandSenderEntity()
50
        {
51
            return null;
52
        }
53
    };
54
55
    public void writeToNBT(NBTTagCompound compound)
56
    {
57
        super.writeToNBT(compound);
58
        this.commandBlockLogic.writeDataToNBT(compound);
59
    }
60
61
    public void readFromNBT(NBTTagCompound compound)
62
    {
63
        super.readFromNBT(compound);
64
        this.commandBlockLogic.readDataFromNBT(compound);
65
    }
66
67
    /**
68
     * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the
69
     * server to the client easily. For example this is used by signs to synchronise the text to be displayed.
70
     */
71
    public Packet getDescriptionPacket()
72
    {
73
        NBTTagCompound nbttagcompound = new NBTTagCompound();
74
        this.writeToNBT(nbttagcompound);
75
        return new S35PacketUpdateTileEntity(this.pos, 2, nbttagcompound);
76
    }
77
78
    public boolean func_183000_F()
79
    {
80
        return true;
81
    }
82
83
    public CommandBlockLogic getCommandBlockLogic()
84
    {
85
        return this.commandBlockLogic;
86
    }
87
88
    public CommandResultStats getCommandResultStats()
89
    {
90
        return this.commandBlockLogic.getCommandResultStats();
91
    }
92
}
93

Deobfuscated MCP 1.8.9 source of TileEntityCommandBlock from Marcelektro/MavenMCP-1.8.9 (net/minecraft/tileentity/TileEntityCommandBlock.java), stored verbatim.