TileEntityMobSpawner .java

net.minecraft.tileentity.TileEntityMobSpawner (class, 85 lines): members: getSpawnerBaseLogic, spawnerLogic, func_183000_F, receiveClientEvent, update.

net.minecraft.tileentityclass85 linescommonextends TileEntity2.5 KB

Implements

API Surface (11)

void func_98267_a(int id)
World getSpawnerWorld()
BlockPos getSpawnerPosition()
void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart p_98277_1_)
void readFromNBT(NBTTagCompound compound)
void writeToNBT(NBTTagCompound compound)
void update()
Packet getDescriptionPacket()
boolean receiveClientEvent(int id, int type)
boolean func_183000_F()
MobSpawnerBaseLogic getSpawnerBaseLogic()

Fields & Constants (1)

spawnerLogic

String literals (1)

"SpawnPotentials"

Full Source

TileEntityMobSpawner.java85 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.tileentity;
2
3
import net.minecraft.init.Blocks;
4
import net.minecraft.nbt.NBTTagCompound;
5
import net.minecraft.network.Packet;
6
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
7
import net.minecraft.util.BlockPos;
8
import net.minecraft.util.ITickable;
9
import net.minecraft.world.World;
10
11
public class TileEntityMobSpawner extends TileEntity implements ITickable
12
{
13
    private final MobSpawnerBaseLogic spawnerLogic = new MobSpawnerBaseLogic()
14
    {
15
        public void func_98267_a(int id)
16
        {
17
            TileEntityMobSpawner.this.worldObj.addBlockEvent(TileEntityMobSpawner.this.pos, Blocks.mob_spawner, id, 0);
18
        }
19
        public World getSpawnerWorld()
20
        {
21
            return TileEntityMobSpawner.this.worldObj;
22
        }
23
        public BlockPos getSpawnerPosition()
24
        {
25
            return TileEntityMobSpawner.this.pos;
26
        }
27
        public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart p_98277_1_)
28
        {
29
            super.setRandomEntity(p_98277_1_);
30
31
            if (this.getSpawnerWorld() != null)
32
            {
33
                this.getSpawnerWorld().markBlockForUpdate(TileEntityMobSpawner.this.pos);
34
            }
35
        }
36
    };
37
38
    public void readFromNBT(NBTTagCompound compound)
39
    {
40
        super.readFromNBT(compound);
41
        this.spawnerLogic.readFromNBT(compound);
42
    }
43
44
    public void writeToNBT(NBTTagCompound compound)
45
    {
46
        super.writeToNBT(compound);
47
        this.spawnerLogic.writeToNBT(compound);
48
    }
49
50
    /**
51
     * Like the old updateEntity(), except more generic.
52
     */
53
    public void update()
54
    {
55
        this.spawnerLogic.updateSpawner();
56
    }
57
58
    /**
59
     * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the
60
     * server to the client easily. For example this is used by signs to synchronise the text to be displayed.
61
     */
62
    public Packet getDescriptionPacket()
63
    {
64
        NBTTagCompound nbttagcompound = new NBTTagCompound();
65
        this.writeToNBT(nbttagcompound);
66
        nbttagcompound.removeTag("SpawnPotentials");
67
        return new S35PacketUpdateTileEntity(this.pos, 1, nbttagcompound);
68
    }
69
70
    public boolean receiveClientEvent(int id, int type)
71
    {
72
        return this.spawnerLogic.setDelayToMin(id) ? true : super.receiveClientEvent(id, type);
73
    }
74
75
    public boolean func_183000_F()
76
    {
77
        return true;
78
    }
79
80
    public MobSpawnerBaseLogic getSpawnerBaseLogic()
81
    {
82
        return this.spawnerLogic;
83
    }
84
}
85

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