|
@@ -4,6 +4,7 @@ import java.util.HashSet;
|
|
|
import me.hammerle.supersnuvi.entity.Entity;
|
|
|
import me.hammerle.supersnuvi.entity.EntityBuilder;
|
|
|
import me.hammerle.supersnuvi.gamelogic.Level;
|
|
|
+import me.hammerle.supersnuvi.util.BlockDataStorage;
|
|
|
import me.hammerle.supersnuvi.util.CollisionBox;
|
|
|
import me.hammerle.supersnuvi.util.CollisionObject;
|
|
|
import me.hammerle.supersnuvi.util.Face;
|
|
@@ -12,46 +13,44 @@ import me.hammerle.supersnuvi.util.Utils;
|
|
|
|
|
|
public class CrumblingStoneTile extends BaseTile
|
|
|
{
|
|
|
- private final HashSet<Long> states;
|
|
|
+ private final BlockDataStorage states = new BlockDataStorage();
|
|
|
|
|
|
public CrumblingStoneTile()
|
|
|
{
|
|
|
super(0.1875f, 0.125f, 0.25f, 0.1875f);
|
|
|
- states = new HashSet<>();
|
|
|
super.setCollisionBox(CollisionBox.createScaledTileBox(0.0f, 0.0f, 1.0f, 0.6f));
|
|
|
super.setMovementBox(CollisionBox.createScaledTileBox(0.0f, 0.0f, 1.0f, 0.6f));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CollisionObject getCollisionBox(int x, int y)
|
|
|
+ public CollisionObject getCollisionBox(int x, int y, Level l)
|
|
|
{
|
|
|
- if(states.contains(getKey(x, y)))
|
|
|
+ if(states.contains(x, y, l))
|
|
|
{
|
|
|
return CollisionObject.NULL_BOX;
|
|
|
}
|
|
|
- return super.getCollisionBox(x, y);
|
|
|
+ return super.getCollisionBox(x, y, l);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CollisionObject getMovementBox(int x, int y)
|
|
|
+ public CollisionObject getMovementBox(int x, int y, Level l)
|
|
|
{
|
|
|
- if(states.contains(getKey(x, y)))
|
|
|
+ if(states.contains(x, y, l))
|
|
|
{
|
|
|
return CollisionObject.NULL_BOX;
|
|
|
}
|
|
|
- return super.getMovementBox(x, y);
|
|
|
+ return super.getMovementBox(x, y, l);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onEntityCollide(Entity ent, int x, int y, Face face)
|
|
|
+ public void onEntityCollide(Entity ent, int x, int y, Face face, Level l)
|
|
|
{
|
|
|
- super.onEntityCollide(ent, x, y, face);
|
|
|
+ super.onEntityCollide(ent, x, y, face, l);
|
|
|
if(face == Face.UP)
|
|
|
{
|
|
|
- if(states.add(getKey(x, y)))
|
|
|
+ if(states.add(x, y, l))
|
|
|
{
|
|
|
- ent.getLevel().updateTile(x, y);
|
|
|
- Level l = ent.getLevel();
|
|
|
+ ent.getLevel().updateTile(x, y);
|
|
|
l.spawnEntity(EntityBuilder.buildCrumblingStone(l, Utils.toCoord(x), Utils.toCoord(y)));
|
|
|
SoundUtils.playSound(SoundUtils.Sound.STONE_CRUMBLING);
|
|
|
}
|
|
@@ -59,14 +58,14 @@ public class CrumblingStoneTile extends BaseTile
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean shouldRender(int x, int y)
|
|
|
+ public boolean shouldRender(int x, int y, Level l)
|
|
|
{
|
|
|
- return !states.contains(getKey(x, y));
|
|
|
+ return !states.contains(x, y, l);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void reset()
|
|
|
+ public void reset(Level l)
|
|
|
{
|
|
|
- states.clear();
|
|
|
+ states.clear(l);
|
|
|
}
|
|
|
}
|