-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
PatchTileEntity.java
77 lines (71 loc) · 2.54 KB
/
PatchTileEntity.java
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
package nallar.patched;
import nallar.tickthreading.Log;
import nallar.tickthreading.patcher.Declare;
import nallar.tickthreading.util.concurrent.NativeMutex;
import net.minecraft.block.Block;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInvBasic;
import net.minecraft.inventory.IInventory;
import net.minecraft.server.management.PlayerInstance;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
public abstract class PatchTileEntity extends TileEntity {
@Declare
public int lastTTX_;
@Declare
public int lastTTY_;
@Declare
public int lastTTZ_;
@Declare
public volatile nallar.tickthreading.minecraft.tickregion.TileEntityTickRegion tickRegion_;
@Declare
public final java.util.concurrent.locks.Lock lockManagementLock_ = null;
@Declare
public final java.util.concurrent.locks.Lock thisLock_ = null;
@Declare
public volatile java.util.concurrent.locks.Lock xMinusLock_;
@Declare
public volatile java.util.concurrent.locks.Lock zMinusLock_;
@Declare
public volatile java.util.concurrent.locks.Lock xPlusLock_;
@Declare
public volatile java.util.concurrent.locks.Lock zPlusLock_;
@Declare
public byte usedLocks_;
public void construct() {
lockManagementLock = new NativeMutex();
if (this instanceof IInventory || this instanceof ILiquidTank || this instanceof ICrafting || this instanceof IInvBasic || this instanceof ITankContainer) {
thisLock = new NativeMutex();
} else {
thisLock = null;
}
}
@Override
@Declare
public void sendTileWithNotify() {
WorldServer worldServer = ((WorldServer) worldObj);
if (worldServer == null) {
return;
}
Block blockType = getBlockType();
worldServer.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType == null ? worldServer.getBlockId(xCoord, yCoord, zCoord) : blockType.blockID);
PlayerInstance p = worldServer.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false);
if (p != null) {
p.updateTile(this);
}
}
@Override
@Declare
public void sendTile() {
PlayerInstance p = ((WorldServer) worldObj).getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false);
if (p != null) {
p.updateTile(this);
}
}
@Override
public String toString() {
return Log.classString(this) + '@' + System.identityHashCode(this) + " in " + Log.name(worldObj) + " at x, y, z: " + xCoord + ", " + yCoord + ", " + zCoord;
}
}