mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
throw an exception when a spot gets added to the wrong chunk
This commit is contained in:
parent
c6f0086d09
commit
ca3fca7eac
1 changed files with 13 additions and 3 deletions
|
@ -98,14 +98,24 @@ public class AuraChunk implements IAuraChunk {
|
||||||
MutableInt spot = this.drainSpots.get(pos);
|
MutableInt spot = this.drainSpots.get(pos);
|
||||||
if (spot == null) {
|
if (spot == null) {
|
||||||
spot = new MutableInt();
|
spot = new MutableInt();
|
||||||
this.drainSpots.put(pos, spot);
|
this.addDrainSpot(pos, spot);
|
||||||
}
|
}
|
||||||
return spot;
|
return spot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDrainSpot(BlockPos pos, MutableInt spot) {
|
||||||
|
int expX = pos.getX() >> 4;
|
||||||
|
int expZ = pos.getZ() >> 4;
|
||||||
|
if (expX != this.chunk.x || expZ != this.chunk.z)
|
||||||
|
throw new IllegalArgumentException("Tried to add drain spot " + pos + " to chunk at " + this.chunk.x + ", " + this.chunk.z + " when it should've been added to chunk at " + expX + ", " + expZ);
|
||||||
|
|
||||||
|
this.drainSpots.put(pos, spot);
|
||||||
|
}
|
||||||
|
|
||||||
public void setSpots(Map<BlockPos, MutableInt> spots) {
|
public void setSpots(Map<BlockPos, MutableInt> spots) {
|
||||||
this.drainSpots.clear();
|
this.drainSpots.clear();
|
||||||
this.drainSpots.putAll(spots);
|
for (Map.Entry<BlockPos, MutableInt> entry : spots.entrySet())
|
||||||
|
this.addDrainSpot(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,7 +196,7 @@ public class AuraChunk implements IAuraChunk {
|
||||||
NBTTagList list = compound.getTagList("drain_spots", 10);
|
NBTTagList list = compound.getTagList("drain_spots", 10);
|
||||||
for (NBTBase base : list) {
|
for (NBTBase base : list) {
|
||||||
NBTTagCompound tag = (NBTTagCompound) base;
|
NBTTagCompound tag = (NBTTagCompound) base;
|
||||||
this.drainSpots.put(
|
this.addDrainSpot(
|
||||||
BlockPos.fromLong(tag.getLong("pos")),
|
BlockPos.fromLong(tag.getLong("pos")),
|
||||||
new MutableInt(tag.getInteger("amount")));
|
new MutableInt(tag.getInteger("amount")));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue