Skip to content

Commit 32445c9

Browse files
committed
Ready for release 1.0.2!
Merge branch 'master' of github.com:K-4U/Hydraulicraft Conflicts: java/k4unl/minecraft/Hydraulicraft/baseClasses/entities/TileTransporter.java java/pneumaticCraft/api/tileentity/AirHandlerSupplier.java
2 parents 399857d + 2c0b39b commit 32445c9

File tree

5 files changed

+215
-195
lines changed

5 files changed

+215
-195
lines changed

java/k4unl/minecraft/Hydraulicraft/TileEntities/TileHydraulicHose.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ public void writeToNBT(NBTTagCompound tagCompound){
2121
public int getStorage() {
2222
return FluidContainerRegistry.BUCKET_VOLUME * (2 * (getTier()+1));
2323
}
24+
25+
@Override
26+
public void onBlockBreaks() {
27+
}
2428
}

java/k4unl/minecraft/Hydraulicraft/baseClasses/entities/TileTransporter.java

Lines changed: 99 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -5,162 +5,130 @@
55

66
import k4unl.minecraft.Hydraulicraft.baseClasses.MachineEntity;
77
import k4unl.minecraft.Hydraulicraft.lib.config.Constants;
8-
import net.minecraft.entity.item.EntityItem;
9-
import net.minecraft.item.ItemStack;
108
import net.minecraft.nbt.NBTTagCompound;
119
import net.minecraft.tileentity.TileEntity;
10+
import net.minecraft.util.AxisAlignedBB;
1211
import net.minecraftforge.common.ForgeDirection;
1312

14-
public abstract class TileTransporter extends MachineEntity {
15-
private int storedLiquid = 0;
16-
private Map<ForgeDirection, TileEntity> connectedSides;
17-
18-
public TileTransporter() {
19-
20-
}
21-
22-
@Override
23-
public void onBlockBreaks(){
24-
25-
}
26-
27-
/*!
28-
* @author Koen Beckers
29-
* @date 14-12-2013
30-
* This will return the max ammount of bar this consumer can handle.
31-
*/
32-
@Override
33-
public float getMaxPressure(){
34-
if(isOilStored()){
35-
switch(getTier()){
36-
case 0:
37-
return Constants.MAX_MBAR_OIL_TIER_1;
38-
case 1:
39-
return Constants.MAX_MBAR_OIL_TIER_2;
40-
case 2:
41-
return Constants.MAX_MBAR_OIL_TIER_3;
42-
}
43-
}else{
44-
switch(getTier()){
45-
case 0:
46-
return Constants.MAX_MBAR_WATER_TIER_1;
47-
case 1:
48-
return Constants.MAX_MBAR_WATER_TIER_2;
49-
case 2:
50-
return Constants.MAX_MBAR_WATER_TIER_3;
51-
}
52-
}
53-
return 0;
54-
}
55-
56-
public int getTier(){
57-
return worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
58-
}
59-
60-
61-
private boolean shouldConnectTo(TileEntity entity){
62-
return (entity instanceof MachineEntity);
63-
}
64-
65-
public void checkConnectedSides(){
66-
if(connectedSides == null){
67-
connectedSides = new HashMap<ForgeDirection, TileEntity>();
68-
}
69-
Map<ForgeDirection, TileEntity> retList = new HashMap<ForgeDirection, TileEntity>();
70-
71-
retList.put(ForgeDirection.WEST, getBlockTileEntity(xCoord+1, yCoord, zCoord));
72-
retList.put(ForgeDirection.EAST, getBlockTileEntity(xCoord-1, yCoord, zCoord));
73-
74-
retList.put(ForgeDirection.UP, getBlockTileEntity(xCoord, yCoord+1, zCoord));
75-
retList.put(ForgeDirection.DOWN, getBlockTileEntity(xCoord, yCoord-1, zCoord));
76-
77-
retList.put(ForgeDirection.NORTH, getBlockTileEntity(xCoord, yCoord, zCoord+1));
78-
retList.put(ForgeDirection.SOUTH, getBlockTileEntity(xCoord, yCoord, zCoord-1));
79-
80-
for(Map.Entry<ForgeDirection, TileEntity> entry : retList.entrySet()){
81-
if(shouldConnectTo(entry.getValue())){
82-
connectedSides.put(entry.getKey(), entry.getValue());
83-
}
84-
}
8513

86-
updateBlock();
87-
}
88-
89-
@Override
90-
public void validate(){
91-
//super.validate();
92-
//checkConnectedSides();
93-
}
94-
95-
public Map<ForgeDirection, TileEntity> getConnectedSides(){
96-
if(connectedSides == null){
97-
checkConnectedSides();
98-
}
99-
return connectedSides;
100-
}
14+
public abstract class TileTransporter extends MachineEntity{
15+
private final int storedLiquid = 0;
16+
private Map<ForgeDirection, TileEntity> connectedSides;
17+
private final boolean[] connectedSideFlags = new boolean[6];
18+
private boolean needToCheckNeighbors;
10119

20+
public TileTransporter(){
10221

103-
private void readConnectedSidesFromNBT(NBTTagCompound tagCompound){
104-
connectedSides = new HashMap<ForgeDirection, TileEntity>();
105-
NBTTagCompound ourCompound = tagCompound.getCompoundTag
106-
("connectedSides");
107-
108-
for(ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS){
109-
int x = xCoord;
110-
int y = yCoord;
111-
int z = zCoord;
112-
113-
if(ourCompound.getBoolean(dir.toString())){
114-
if(dir == ForgeDirection.WEST){
115-
x+=1;
116-
}else if(dir == ForgeDirection.EAST){
117-
x-=1;
118-
}
22+
}
11923

120-
if(dir == ForgeDirection.UP){
121-
y+=1;
122-
}else if(dir == ForgeDirection.DOWN){
123-
y-=1;
24+
@Override
25+
public void updateEntity(){
26+
if(needToCheckNeighbors) {
27+
needToCheckNeighbors = false;
28+
connectedSides = new HashMap<ForgeDirection, TileEntity>();
29+
for(int i = 0; i < 6; i++) {
30+
if(connectedSideFlags[i]) {
31+
ForgeDirection dir = ForgeDirection.getOrientation(i);
32+
connectedSides.put(dir, getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ));
12433
}
34+
}
35+
}
36+
super.updateEntity();
37+
}
12538

126-
if(dir == ForgeDirection.NORTH){
127-
z+=1;
128-
}else if(dir == ForgeDirection.SOUTH){
129-
z-=1;
130-
}
39+
/*!
40+
* @author Koen Beckers
41+
* @date 14-12-2013
42+
* This will return the max ammount of bar this consumer can handle.
43+
*/
44+
@Override
45+
public float getMaxPressure(){
46+
if(isOilStored()) {
47+
switch(getTier()){
48+
case 0:
49+
return Constants.MAX_MBAR_OIL_TIER_1;
50+
case 1:
51+
return Constants.MAX_MBAR_OIL_TIER_2;
52+
case 2:
53+
return Constants.MAX_MBAR_OIL_TIER_3;
54+
}
55+
} else {
56+
switch(getTier()){
57+
case 0:
58+
return Constants.MAX_MBAR_WATER_TIER_1;
59+
case 1:
60+
return Constants.MAX_MBAR_WATER_TIER_2;
61+
case 2:
62+
return Constants.MAX_MBAR_WATER_TIER_3;
63+
}
64+
}
65+
return 0;
66+
}
13167

132-
connectedSides.put(dir, getBlockTileEntity(x, y, z));
68+
public int getTier(){
69+
return worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
70+
}
71+
72+
private boolean shouldConnectTo(TileEntity entity){
73+
return entity instanceof MachineEntity;
74+
}
75+
76+
public void checkConnectedSides(){
77+
connectedSides = new HashMap<ForgeDirection, TileEntity>();
78+
79+
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
80+
TileEntity te = getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
81+
if(shouldConnectTo(te)) {
82+
connectedSides.put(dir, te);
13383
}
13484
}
85+
86+
updateBlock();
13587
}
13688

137-
private void writeConnectedSidesToNBT(NBTTagCompound tagCompound){
138-
if(connectedSides == null){
139-
connectedSides = new HashMap<ForgeDirection, TileEntity>();
89+
public Map<ForgeDirection, TileEntity> getConnectedSides(){
90+
if(connectedSides == null) {
91+
checkConnectedSides();
92+
}
93+
return connectedSides;
94+
}
95+
96+
private void readConnectedSidesFromNBT(NBTTagCompound tagCompound){
97+
NBTTagCompound ourCompound = tagCompound.getCompoundTag("connectedSides");
98+
99+
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
100+
connectedSideFlags[dir.ordinal()] = ourCompound.getBoolean(dir.name());
140101
}
102+
needToCheckNeighbors = true;
103+
}
141104

142-
NBTTagCompound ourCompound = tagCompound.getCompoundTag
143-
("connectedSides");
144-
if(ourCompound == null){
145-
ourCompound = new NBTTagCompound();
105+
private void writeConnectedSidesToNBT(NBTTagCompound tagCompound){
106+
if(connectedSides == null) {
107+
connectedSides = new HashMap<ForgeDirection, TileEntity>();
146108
}
147109

148-
for(Map.Entry<ForgeDirection, TileEntity> entry : connectedSides.entrySet()){
110+
NBTTagCompound ourCompound = new NBTTagCompound();
111+
for(Map.Entry<ForgeDirection, TileEntity> entry : connectedSides.entrySet()) {
149112
ourCompound.setBoolean(entry.getKey().name(), true);
150113
}
151114
tagCompound.setCompoundTag("connectedSides", ourCompound);
152115
}
153116

154-
@Override
155-
public void readFromNBT(NBTTagCompound tagCompound){
156-
super.readFromNBT(tagCompound);
117+
@Override
118+
public void readFromNBT(NBTTagCompound tagCompound){
119+
super.readFromNBT(tagCompound);
157120
readConnectedSidesFromNBT(tagCompound);
158-
}
159-
160-
@Override
161-
public void writeToNBT(NBTTagCompound tagCompound){
162-
super.writeToNBT(tagCompound);
121+
}
122+
123+
@Override
124+
public void writeToNBT(NBTTagCompound tagCompound){
125+
super.writeToNBT(tagCompound);
163126

164127
writeConnectedSidesToNBT(tagCompound);
165-
}
128+
}
129+
130+
@Override
131+
public AxisAlignedBB getRenderBoundingBox(){
132+
return AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
133+
}
166134
}

0 commit comments

Comments
 (0)