summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityFallingBlock.java
blob: 72ab660f0bc0cff0f3ef3364c8682799148c2996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package net.minecraft.server;

public class EntityFallingBlock extends Entity {

    public int id;
    public int data; // CraftBukkit
    public int b = 0;

    public EntityFallingBlock(World world) {
        super(world);
    }

    // CraftBukkit - changed method signature
    public EntityFallingBlock(World world, double d0, double d1, double d2, int i, int data) {
        super(world);
        this.id = i;
        this.bf = true;
        this.data = data; // CraftBukkit
        this.b(0.98F, 0.98F);
        this.height = this.length / 2.0F;
        this.setPosition(d0, d1, d2);
        this.motX = 0.0D;
        this.motY = 0.0D;
        this.motZ = 0.0D;
        this.lastX = d0;
        this.lastY = d1;
        this.lastZ = d2;
    }

    protected boolean g_() {
        return false;
    }

    protected void b() {}

    public boolean o_() {
        return !this.dead;
    }

    public void G_() {
        if (this.id == 0) {
            this.die();
        } else {
            this.lastX = this.locX;
            this.lastY = this.locY;
            this.lastZ = this.locZ;
            ++this.b;
            this.motY -= 0.03999999910593033D;
            this.move(this.motX, this.motY, this.motZ);
            this.motX *= 0.9800000190734863D;
            this.motY *= 0.9800000190734863D;
            this.motZ *= 0.9800000190734863D;
            int i = MathHelper.floor(this.locX);
            int j = MathHelper.floor(this.locY);
            int k = MathHelper.floor(this.locZ);

            if (this.b == 1 && this.world.getTypeId(i, j, k) == this.id) {
                this.world.setTypeId(i, j, k, 0);
            } else if (!this.world.isStatic && this.b == 1) {
                this.die();
            }

            if (this.onGround) {
                this.motX *= 0.699999988079071D;
                this.motZ *= 0.699999988079071D;
                this.motY *= -0.5D;
                if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) {
                    this.die();
                    // CraftBukkit - setTypeId => setTypeIdAndData
                    if ((!this.world.mayPlace(this.id, i, j, k, true, 1) || BlockSand.canFall(this.world, i, j - 1, k) || !this.world.setTypeIdAndData(i, j, k, this.id, this.data)) && !this.world.isStatic) {
                        this.b(this.id, 1);
                    }
                }
            } else if (this.b > 100 && !this.world.isStatic && (j < 1 || j > 256) || this.b > 600) {
                this.b(this.id, 1);
                this.die();
            }
        }
    }

    protected void b(NBTTagCompound nbttagcompound) {
        nbttagcompound.setByte("Tile", (byte) this.id);
        nbttagcompound.setByte("Data", (byte) this.data); // CraftBukkit
    }

    protected void a(NBTTagCompound nbttagcompound) {
        this.id = nbttagcompound.getByte("Tile") & 255;
        this.data = nbttagcompound.getByte("Data") & 15; // CraftBukkit
    }
}