Adding wood walls, fully implemented wood floors

This commit is contained in:
jsrobson10 2020-09-24 14:22:46 +10:00
parent 02355bfedc
commit 6ef6277148
19 changed files with 218 additions and 20 deletions

View File

@ -32,6 +32,7 @@ import projectzombie.items.ItemStoneShovel;
import projectzombie.items.ItemTnt; import projectzombie.items.ItemTnt;
import projectzombie.items.ItemTorch; import projectzombie.items.ItemTorch;
import projectzombie.items.ItemWoodPlanks; import projectzombie.items.ItemWoodPlanks;
import projectzombie.items.ItemWoodWall;
import projectzombie.items.ItemWorkbench; import projectzombie.items.ItemWorkbench;
import projectzombie.items.spawner.ItemSpawnDummy; import projectzombie.items.spawner.ItemSpawnDummy;
import projectzombie.items.spawner.ItemSpawnZombie; import projectzombie.items.spawner.ItemSpawnZombie;
@ -80,6 +81,7 @@ public class Items
register(TORCH); register(TORCH);
register(COAL); register(COAL);
register(WOOD_PLANKS); register(WOOD_PLANKS);
register(WOOD_WALL);
} }
public static final Item AMMO = new ItemAmmo(); public static final Item AMMO = new ItemAmmo();
@ -114,4 +116,5 @@ public class Items
public static final Item TORCH = new ItemTorch(); public static final Item TORCH = new ItemTorch();
public static final Item COAL = new ItemCoal(); public static final Item COAL = new ItemCoal();
public static final Item WOOD_PLANKS = new ItemWoodPlanks(); public static final Item WOOD_PLANKS = new ItemWoodPlanks();
public static final Item WOOD_WALL = new ItemWoodWall();
} }

View File

@ -213,8 +213,8 @@ public class Models
public static final ModelItem ITEM_LOG_SNOW = new ModelItem(Resources.ATLAS.get("/item/log_snow.png")); public static final ModelItem ITEM_LOG_SNOW = new ModelItem(Resources.ATLAS.get("/item/log_snow.png"));
public static final ModelItem ITEM_CHARCOAL = new ModelItem(Resources.ATLAS.get("/item/charcoal.png")); public static final ModelItem ITEM_CHARCOAL = new ModelItem(Resources.ATLAS.get("/item/charcoal.png"));
public static final ModelItem ITEM_ASH = new ModelItem(Resources.ATLAS.get("/item/ash.png")); public static final ModelItem ITEM_ASH = new ModelItem(Resources.ATLAS.get("/item/ash.png"));
public static final ModelItem ITEM_WOOD_FLOOR = new ModelItem(Resources.ATLAS.get("/item/wood_floor.png")); public static final ModelItem ITEM_WOOD_WALL = new ModelItem(Resources.ATLAS.get("/item/wood_wall.png"));
public static final ModelItem ITEM_WOOD_SNOW_FLOOR = new ModelItem(Resources.ATLAS.get("/item/wood_snow_floor.png")); public static final ModelItem ITEM_WOOD_SNOW_WALL = new ModelItem(Resources.ATLAS.get("/item/wood_snow_wall.png"));
public static final ModelItem ITEM_WOOD_PLANKS = new ModelItem(Resources.ATLAS.get("/item/wood_planks.png")); public static final ModelItem ITEM_WOOD_PLANKS = new ModelItem(Resources.ATLAS.get("/item/wood_planks.png"));
public static final ModelItem ITEM_WOOD_SNOW_PLANKS = new ModelItem(Resources.ATLAS.get("/item/wood_snow_planks.png")); public static final ModelItem ITEM_WOOD_SNOW_PLANKS = new ModelItem(Resources.ATLAS.get("/item/wood_snow_planks.png"));

View File

@ -48,6 +48,13 @@ public class Recipes
Crafting.BASIC, Crafting.BASIC,
}, new ItemStack(Items.WOOD_PLANKS, 2))); }, new ItemStack(Items.WOOD_PLANKS, 2)));
recipies.add(new RecipeBasic(
new ItemStack[] {
new ItemStack(Items.LOG, 2),
}, new Crafting[] {
Crafting.BASIC,
}, new ItemStack(Items.WOOD_WALL, 1)));
recipies.add(new RecipeBasic( recipies.add(new RecipeBasic(
new ItemStack[] { new ItemStack[] {
new ItemStack(Items.FLINT, 2), new ItemStack(Items.FLINT, 2),

View File

@ -36,6 +36,7 @@ import projectzombie.tiles.TileTree;
import projectzombie.tiles.TileVoid; import projectzombie.tiles.TileVoid;
import projectzombie.tiles.TileWall; import projectzombie.tiles.TileWall;
import projectzombie.tiles.TileWater; import projectzombie.tiles.TileWater;
import projectzombie.tiles.TileWoodFloor;
import projectzombie.tiles.TileWorkbench; import projectzombie.tiles.TileWorkbench;
public class Tiles public class Tiles
@ -88,6 +89,7 @@ public class Tiles
register(CLAY_POT); register(CLAY_POT);
register(ORE); register(ORE);
register(COAL); register(COAL);
register(WOOD_FLOOR);
} }
public static final Tile GRASS = new TileGrass(); public static final Tile GRASS = new TileGrass();
@ -124,4 +126,5 @@ public class Tiles
public static final Tile CLAY_POT = new TileClayPot(); public static final Tile CLAY_POT = new TileClayPot();
public static final Tile ORE = new TileOre(); public static final Tile ORE = new TileOre();
public static final Tile COAL = new TileCoal(); public static final Tile COAL = new TileCoal();
public static final Tile WOOD_FLOOR = new TileWoodFloor();
} }

View File

@ -1,11 +1,15 @@
package projectzombie.items; package projectzombie.items;
import gl_engine.vec.Vec2d;
import gl_engine.vec.Vec2i; import gl_engine.vec.Vec2i;
import projectzombie.entity.player.EntityPlayer;
import projectzombie.init.Models; import projectzombie.init.Models;
import projectzombie.init.Tiles;
import projectzombie.items.modifier.ItemModifierMeta; import projectzombie.items.modifier.ItemModifierMeta;
import projectzombie.model.Model; import projectzombie.model.Model;
import projectzombie.model.ModelItem; import projectzombie.model.ModelItem;
import projectzombie.util.ItemStack; import projectzombie.util.ItemStack;
import projectzombie.util.TileState;
import projectzombie.world.layer.Layer; import projectzombie.world.layer.Layer;
public class ItemWoodPlanks extends Item public class ItemWoodPlanks extends Item
@ -24,13 +28,29 @@ public class ItemWoodPlanks extends Item
@Override @Override
public boolean showPlaceModel(Layer layer, Vec2i pos, ItemStack stack) { public boolean showPlaceModel(Layer layer, Vec2i pos, ItemStack stack) {
return true; return layer.getBackTile(pos).tile.isNaturalFloorItem && layer.getFrontTile(pos).tile.isNaturalFloorItem;
} }
@Override @Override
public Model getPlaceModel(ItemStack stack) { public Model getPlaceModel(ItemStack stack) {
return Models.TILE_WOOD_FLOOR; return Models.TILE_WOOD_FLOOR;
} }
@Override
public boolean onPlayerRightClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos)
{
Vec2i pos = place_pos.toInt();
if(!layer.getBackTile(pos).tile.isNaturalFloorItem || !layer.getFrontTile(pos).tile.isNaturalFloorItem) {
return false;
}
stack.count -= 1;
layer.setBackTile(new TileState(Tiles.WOOD_FLOOR, ItemModifierMeta.getStackMeta(stack)), pos);
layer.setFrontTile(Tiles.VOID.getDefaultState(), pos);
return true;
}
@Override @Override
public String getName(ItemStack stack) { public String getName(ItemStack stack) {

View File

@ -0,0 +1,30 @@
package projectzombie.items;
import gl_engine.MathHelpers;
import projectzombie.Main;
import projectzombie.init.Models;
import projectzombie.model.Model;
import projectzombie.model.ModelItem;
import projectzombie.util.ItemStack;
public class ItemWoodWall extends Item
{
@Override
public Model getPlaceModel(ItemStack stack)
{
int angle = (int)MathHelpers.mod(Main.player.angle / 90 + 0.5, 4);
return Models.TILE_WOOD_WALL[angle];
}
@Override
public ModelItem getModel(ItemStack stack) {
return Models.ITEM_WOOD_WALL;
}
@Override
public String getName(ItemStack stack) {
return "Wood Wall";
}
}

View File

@ -48,34 +48,78 @@ public class ModelWall extends Model
@Override @Override
public float[] getVerticies() public float[] getVerticies()
{ {
float x1 = 0.5f, z1 = 0.5f, x2 = 0.25f, z2 = -0.5f; float x1=0, x2=0, x3=0, x4=0, z1=0, z2=0, z3=0, z4=0;
switch(rotation)
{
case 0:
z1 = -0.5f;
z2 = -0.5f;
z3 = -0.25f;
z4 = -0.25f;
x1 = 0.5f;
x2 = 0.5f;
x3 = -0.5f;
x4 = -0.5f;
break;
case 1:
x1 = -0.5f;
x2 = -0.5f;
x3 = -0.25f;
x4 = -0.25f;
z1 = 0.5f;
z2 = 0.5f;
z3 = -0.5f;
z4 = -0.5f;
break;
case 2:
z1 = 0.5f;
z2 = 0.5f;
z3 = 0.25f;
z4 = 0.25f;
x1 = 0.5f;
x2 = 0.5f;
x3 = -0.5f;
x4 = -0.5f;
break;
case 3:
x1 = 0.5f;
x2 = 0.5f;
x3 = 0.25f;
x4 = 0.25f;
z1 = 0.5f;
z2 = 0.5f;
z3 = -0.5f;
z4 = -0.5f;
break;
}
return new float[] return new float[]
{ {
x1, 0, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 0, z1, 0, 0, 0, 0, 1,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, 0, 1, 1, 1, 0, 0, x1, 1, z1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x1, 0, z2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 0, z3, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x2, 0, z2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x3, 0, z4, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x2, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x3, 1, z4, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x1, 1, z2, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 1, z3, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x1, 1, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 1, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x2, 1, z1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x3, 1, z1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x2, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x3, 1, z3, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
x1, 1, z2, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 1, z3, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,
}; };
} }

View File

@ -20,6 +20,7 @@ public abstract class Tile
protected double light_dissipation = 1/8.0; protected double light_dissipation = 1/8.0;
public boolean emitsLight = false; public boolean emitsLight = false;
public boolean passNaturalLight = true; public boolean passNaturalLight = true;
public boolean isNaturalFloorItem = false;
public int hardness = -1; public int hardness = -1;
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity, TileState state) { public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity, TileState state) {

View File

@ -5,6 +5,9 @@ import projectzombie.model.Model;
public class TileDirt extends Tile public class TileDirt extends Tile
{ {
public TileDirt() {
isNaturalFloorItem = true;
}
@Override @Override
public Model getModel(byte meta) { public Model getModel(byte meta) {

View File

@ -10,6 +10,9 @@ import projectzombie.world.layer.Layer;
public class TileGrass extends Tile public class TileGrass extends Tile
{ {
public TileGrass() {
isNaturalFloorItem = true;
}
@Override @Override
public Model getModel(byte meta) { public Model getModel(byte meta) {

View File

@ -5,6 +5,10 @@ import projectzombie.model.Model;
public class TileGrassBurnt extends Tile public class TileGrassBurnt extends Tile
{ {
public TileGrassBurnt() {
isNaturalFloorItem = true;
}
@Override @Override
public Model getModel(byte meta) { public Model getModel(byte meta) {
return Models.TILE_GRASS_BURNT; return Models.TILE_GRASS_BURNT;

View File

@ -10,6 +10,10 @@ import projectzombie.world.layer.Layer;
public class TileGrassInfested extends Tile public class TileGrassInfested extends Tile
{ {
public TileGrassInfested() {
isNaturalFloorItem = true;
}
@Override @Override
public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) { public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) {
super.tickRandomly(layer, chunk, state, pos); super.tickRandomly(layer, chunk, state, pos);

View File

@ -6,6 +6,10 @@ import projectzombie.util.TileState;
public class TileIce extends TileStone public class TileIce extends TileStone
{ {
public TileIce() {
isNaturalFloorItem = true;
}
@Override @Override
public Model getModel(byte meta) { public Model getModel(byte meta) {
return Models.TILE_ICE; return Models.TILE_ICE;

View File

@ -5,7 +5,10 @@ import projectzombie.model.Model;
public class TileStone extends Tile public class TileStone extends Tile
{ {
public TileStone() {
isNaturalFloorItem = true;
}
@Override @Override
public Model getModel(byte meta) { public Model getModel(byte meta) {
return Models.TILE_STONE; return Models.TILE_STONE;

View File

@ -11,6 +11,7 @@ public class TileTallGrass extends Tile
{ {
public TileTallGrass() { public TileTallGrass() {
this.hardness = 200; this.hardness = 200;
this.isNaturalFloorItem = true;
} }
@Override @Override

View File

@ -10,6 +10,7 @@ public class TileVoid extends Tile {
// Set some settings // Set some settings
this.tileSolid = false; this.tileSolid = false;
this.tileWalkable = true; this.tileWalkable = true;
isNaturalFloorItem = true;
} }
@Override @Override

View File

@ -22,6 +22,7 @@ public class TileWater extends Tile
this.slowness = 0.5; this.slowness = 0.5;
this.unbreakable = true; this.unbreakable = true;
this.hardness = 800; this.hardness = 800;
this.isNaturalFloorItem = true;
} }
@Override @Override

View File

@ -0,0 +1,20 @@
package projectzombie.tiles;
import projectzombie.init.Models;
import projectzombie.model.Model;
public class TileWoodFloor extends Tile
{
@Override
public Model getModel(byte meta)
{
switch(meta)
{
case 0: return Models.TILE_WOOD_FLOOR;
case 1: return Models.TILE_WOOD_SNOW_FLOOR;
default: return Models.EMPTY;
}
}
}

View File

@ -0,0 +1,46 @@
package projectzombie.tiles;
import projectzombie.init.Items;
import projectzombie.init.Models;
import projectzombie.items.ItemTool;
import projectzombie.items.ItemToolType;
import projectzombie.items.modifier.ItemModifierMeta;
import projectzombie.model.Model;
import projectzombie.util.ItemStack;
import projectzombie.util.TileState;
public class TileWoodWall extends Tile
{
public TileWoodWall()
{
tileSolid = true;
}
@Override
public boolean canTileBreak(TileState state, ItemStack stack, ItemTool tool) {
return tool.toolType(stack) == ItemToolType.HATCHET;
}
@Override
public boolean canTileSpeedBreak(TileState state, ItemStack stack, ItemTool tool) {
return canTileBreak(state, stack, tool);
}
@Override
public ItemStack[] getTileDrops(TileState state) {
return new ItemStack[] {new ItemStack(Items.WOOD_WALL, 1, new ItemModifierMeta(state.meta / 4))};
}
@Override
public Model getModel(byte meta)
{
switch(meta / 4)
{
case 0: return Models.TILE_WOOD_WALL[meta];
case 1: return Models.TILE_WOOD_SNOW_WALL[meta - 4];
default: return Models.EMPTY;
}
}
}