37 lines
910 B
Java
37 lines
910 B
Java
package projectzombie.items;
|
|
|
|
import projectzombie.entity.Entity;
|
|
import projectzombie.init.Textures;
|
|
import projectzombie.init.Tiles;
|
|
import projectzombie.util.math.ItemStack;
|
|
import projectzombie.util.math.MathHelpers;
|
|
import projectzombie.util.math.vec.Vec2i;
|
|
import projectzombie.world.chunk.Chunk;
|
|
import projectzombie.world.layer.Layer;
|
|
|
|
public class ItemLantern extends Item
|
|
{
|
|
|
|
public ItemLantern(String id) {
|
|
super(id);
|
|
|
|
this.texture = Textures.TILE_LANTERN;
|
|
}
|
|
|
|
@Override
|
|
public void onAction(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
|
|
{
|
|
Vec2i tpos = new Vec2i(MathHelpers.floor(entity.pos.x), MathHelpers.floor(entity.pos.y));
|
|
if(layer.getFrontTile(tpos).tile == Tiles.VOID) {
|
|
layer.setFrontTile(Tiles.LANTERN.getDefaultState(), tpos);
|
|
super.onAction(stack, layer, chunk, entity);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getName(short meta) {
|
|
return "Lantern";
|
|
}
|
|
|
|
}
|