diff --git a/src/projectzombie/display/DisplayLighting.java b/src/projectzombie/display/DisplayLighting.java index 02089e6..8299c77 100755 --- a/src/projectzombie/display/DisplayLighting.java +++ b/src/projectzombie/display/DisplayLighting.java @@ -324,7 +324,7 @@ public class DisplayLighting float[] pixels = new float[width*height*3]; for(int i=0;i 1) { hydration = 1; } + + inventory.addItem(new ItemStack(Items.TORCH, 1)); } public int getAmmo() { diff --git a/src/projectzombie/init/ItemModifiers.java b/src/projectzombie/init/ItemModifiers.java index b2c1ce0..0448604 100644 --- a/src/projectzombie/init/ItemModifiers.java +++ b/src/projectzombie/init/ItemModifiers.java @@ -7,6 +7,7 @@ import projectzombie.items.modifier.ItemModifier; import projectzombie.items.modifier.ItemModifierDamage; import projectzombie.items.modifier.ItemModifierFluidStorage; import projectzombie.items.modifier.ItemModifierMeta; +import projectzombie.items.modifier.ItemModifierTimer; import projectzombie.items.modifier.ItemModifierWater; public class ItemModifiers @@ -31,5 +32,6 @@ public class ItemModifiers register(ItemModifierDamage.class); register(ItemModifierFluidStorage.class); register(ItemModifierWater.class); + register(ItemModifierTimer.class); } } diff --git a/src/projectzombie/init/Items.java b/src/projectzombie/init/Items.java index d19b439..2d02448 100755 --- a/src/projectzombie/init/Items.java +++ b/src/projectzombie/init/Items.java @@ -29,6 +29,7 @@ import projectzombie.items.ItemStoneHatchet; import projectzombie.items.ItemStonePick; import projectzombie.items.ItemStoneShovel; import projectzombie.items.ItemTnt; +import projectzombie.items.ItemTorch; import projectzombie.items.ItemWorkbench; import projectzombie.items.spawner.ItemSpawnDummy; import projectzombie.items.spawner.ItemSpawnZombie; @@ -74,6 +75,7 @@ public class Items register(BLAST_FURNACE); register(CLAY_POT); register(CLAY_POT_WET); + register(TORCH); } public static final Item AMMO = new ItemAmmo(); @@ -105,4 +107,5 @@ public class Items public static final Item BLAST_FURNACE = new ItemBlastFurnace(); public static final Item CLAY_POT = new ItemClayPot(); public static final Item CLAY_POT_WET = new ItemClayPotWet(); + public static final Item TORCH = new ItemTorch(); } diff --git a/src/projectzombie/init/Models.java b/src/projectzombie/init/Models.java index c1beef6..c9c4a98 100755 --- a/src/projectzombie/init/Models.java +++ b/src/projectzombie/init/Models.java @@ -153,6 +153,8 @@ public class Models public static final ModelItem ITEM_TNT = new ModelItem(Resources.ATLAS.get("/entity/tnt.png")); public static final ModelItem ITEM_FLARE = new ModelItem(Resources.ATLAS.get("/entity/flare.png")); public static final ModelItem ITEM_LANTERN = new ModelItem(Resources.ATLAS.get("/tile/lantern.png"), 4, 5); + public static final ModelItem ITEM_TORCH_LIT = new ModelItem(Resources.ATLAS.get("/item/torch_lit.png"), 4, 50); + public static final ModelItem ITEM_TORCH_UNLIT = new ModelItem(Resources.ATLAS.get("/item/torch_unlit.png")); public static final ModelItem ITEM_CLAY_POT_WET = new ModelItem(Resources.ATLAS.get("/item/clay_pot_wet.png")); public static final ModelItem ITEM_CLAY_POT_EMPTY = new ModelItem(Resources.ATLAS.get("/item/clay_pot_empty.png")); diff --git a/src/projectzombie/items/Item.java b/src/projectzombie/items/Item.java index b1a93c5..c9ecb90 100755 --- a/src/projectzombie/items/Item.java +++ b/src/projectzombie/items/Item.java @@ -69,4 +69,8 @@ public abstract class Item return (double)damage_modifier.getDamage() / (double)damage_modifier.getMaxDamage(); } + + public boolean isEmpty(ItemStack stack) { + return false; + } } diff --git a/src/projectzombie/items/ItemTorch.java b/src/projectzombie/items/ItemTorch.java new file mode 100644 index 0000000..16d97ae --- /dev/null +++ b/src/projectzombie/items/ItemTorch.java @@ -0,0 +1,79 @@ +package projectzombie.items; + +import gl_engine.vec.Vec2d; +import projectzombie.entity.player.EntityPlayer; +import projectzombie.init.Models; +import projectzombie.items.modifier.ItemModifier; +import projectzombie.items.modifier.ItemModifierDamage; +import projectzombie.items.modifier.ItemModifierMeta; +import projectzombie.items.modifier.ItemModifierTimer; +import projectzombie.model.ModelItem; +import projectzombie.util.math.ItemStack; +import projectzombie.world.layer.Layer; + +public class ItemTorch extends Item +{ + + @Override + public ModelItem getModel(ItemStack stack) + { + if(ItemModifierMeta.getStackMeta(stack) == 1) { + return Models.ITEM_TORCH_LIT; + } + + else { + return Models.ITEM_TORCH_UNLIT; + } + } + + @Override + public double getDamage(ItemStack stack) + { + ItemModifierTimer timer = (ItemModifierTimer)stack.getModifier(ItemModifierTimer.class); + + if(timer == null) { + return 0; + } + + return timer.getDamage(); + } + + @Override + public boolean onPlayerRightClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos) + { + if(ItemModifierMeta.getStackMeta(stack) == 1) { + return false; + } + + stack.modifiers = new ItemModifier[] { + new ItemModifierMeta(1), + new ItemModifierTimer(1000), + }; + + return true; + } + + @Override + public boolean isEmpty(ItemStack stack) + { + if(ItemModifierMeta.getStackMeta(stack) != 1) { + return false; + } + + ItemModifierTimer timer = (ItemModifierTimer)stack.getModifier(ItemModifierTimer.class); + + if(timer == null) { + return false; + } + + System.out.println(timer.getDamage()); + + return timer.getDamage() <= 0; + } + + @Override + public String getName(ItemStack stack) { + return "Torch"; + } + +} diff --git a/src/projectzombie/items/modifier/ItemModifierTimer.java b/src/projectzombie/items/modifier/ItemModifierTimer.java new file mode 100644 index 0000000..1a242f3 --- /dev/null +++ b/src/projectzombie/items/modifier/ItemModifierTimer.java @@ -0,0 +1,60 @@ +package projectzombie.items.modifier; + +import bdf.types.BdfNamedList; +import bdf.types.BdfObject; +import gl_engine.MathHelpers; +import projectzombie.time.GameTimer; + +public class ItemModifierTimer extends ItemModifier +{ + private long end; + private long start; + + public long getLeft() { + return GameTimer.getTime() - timer; + } + + public double getDamage() { + return 1 - (double)(timer - GameTimer.getTime()) / (double)timer; + } + + public ItemModifierTimer(long time) { + start = GameTimer.getTime(); + end = start + time; + } + + public ItemModifierTimer(BdfObject bdf) { + BdfClassLoad(bdf); + } + + @Override + public void BdfClassLoad(BdfObject bdf) + { + BdfNamedList nl = bdf.getNamedList(); + start = nl.get("start").getLong(); + end = nl.get("end").getLong(); + } + + @Override + public void BdfClassSave(BdfObject bdf) + { + BdfNamedList nl = bdf.getNamedList(); + nl.set("start", bdf.newObject().setLong(start)); + nl.set("end", bdf.newObject().setLong(end)); + } + + @Override + public boolean isEqual(ItemModifier other) { + return ((ItemModifierTimer)other).start == start && + ((ItemModifierTimer)other).end == end; + } + + @Override + public ItemModifier copy() { + ItemModifierTimer timer = new ItemModifierTimer(0); + timer.start = this.start; + timer.end = this.end; + return timer; + } + +} diff --git a/src/projectzombie/tiles/TileBlastFurnace.java b/src/projectzombie/tiles/TileBlastFurnace.java index 054d1f4..0d042bc 100644 --- a/src/projectzombie/tiles/TileBlastFurnace.java +++ b/src/projectzombie/tiles/TileBlastFurnace.java @@ -30,7 +30,7 @@ public class TileBlastFurnace extends Tile @Override public double getLightLevel(TileState state, Vec2i pos) { - return 1 - MathHelpers.squared(1 - state.meta / 16.0); + return (1 - MathHelpers.squared(1 - state.meta / 16.0)) / 2.0; } @Override diff --git a/src/projectzombie/util/math/ItemStack.java b/src/projectzombie/util/math/ItemStack.java index 88b38e6..8772e04 100755 --- a/src/projectzombie/util/math/ItemStack.java +++ b/src/projectzombie/util/math/ItemStack.java @@ -52,7 +52,7 @@ public class ItemStack implements IBdfClassManager if(count < 1) return true; if(item == null) return true; if(item == Items.EMPTY) return true; - return false; + return item.isEmpty(this); } public boolean hasModifier(Class modifier) { diff --git a/src/resources/texture/item/torch_lit.png b/src/resources/texture/item/torch_lit.png new file mode 100644 index 0000000..3a48601 Binary files /dev/null and b/src/resources/texture/item/torch_lit.png differ diff --git a/src/resources/texture/item/torch_unlit.png b/src/resources/texture/item/torch_unlit.png new file mode 100644 index 0000000..45cc431 Binary files /dev/null and b/src/resources/texture/item/torch_unlit.png differ diff --git a/src/resources/texture/list.txt b/src/resources/texture/list.txt index eedc4d6..679911f 100644 --- a/src/resources/texture/list.txt +++ b/src/resources/texture/list.txt @@ -1,239 +1,241 @@ -./text/char_question.png -./text/char_l_a.png -./text/char_u_j.png -./text/char_l_u.png -./text/char_u_s.png -./text/char_l_s.png -./text/char_apostrophe.png -./text/char_plus.png -./text/char_l_e.png -./text/char_7.png -./text/char_minus.png -./text/char_u_r.png -./text/char_u_l.png -./text/char_obracket.png -./text/char_pow.png -./text/char_u_m.png -./text/char_l_t.png -./text/char_percent.png -./text/char_l_y.png -./text/char_0.png -./text/char_4.png -./text/char_l_r.png -./text/char_l_m.png -./text/char_cbracket.png -./text/char_u_g.png -./text/char_u_q.png -./text/char_u_i.png -./text/char_tilde.png -./text/char_l_w.png -./text/char_l_v.png -./text/char_fslash.png -./text/char_u_p.png -./text/char_gthan.png -./text/char_8.png -./text/char_unknown.png -./text/char_and.png -./text/char_osbracket.png -./text/char_u_n.png -./text/char_l_i.png -./text/char_u_y.png -./text/char_l_p.png -./text/char_lthan.png -./text/char_l_g.png -./text/char_bslash.png -./text/char_1.png -./text/char_u_z.png -./text/char_l_f.png -./text/char_u_w.png -./text/char_9.png -./text/char_l_x.png -./text/char_ccbracket.png -./text/char_l_o.png -./text/char_equals.png -./text/char_l_d.png -./text/char_dollar.png -./text/char_hashtag.png -./text/char_l_q.png -./text/char_u_o.png -./text/char_6.png -./text/char_u_d.png -./text/char_u_e.png -./text/char_exclamation.png -./text/char_vertical.png -./text/char_ocbracket.png -./text/char_u_k.png -./text/char_u_c.png -./text/char_l_n.png -./text/char_semicolon.png -./text/char_u_b.png -./text/char_u_f.png -./text/char_l_h.png -./text/char_l_k.png -./text/char_u_t.png -./text/char_3.png -./text/char_u_v.png -./text/char_u_h.png -./text/char_quotation.png -./text/char_u_a.png -./text/char_l_b.png -./text/char_underscore.png -./text/char_u_x.png -./text/char_comma.png -./text/char_csbracket.png -./text/char_l_l.png -./text/char_5.png -./text/char_star.png -./text/char_colon.png -./text/char_l_z.png -./text/char_space.png -./text/char_2.png -./text/char_at.png -./text/char_grave.png -./text/char_l_j.png -./text/char_fullstop.png -./text/char_l_c.png -./text/char_u_u.png +./tile/hemp6.png +./tile/hemp7.png +./tile/hemp1.png +./tile/rock.png +./tile/rock_ice.png +./tile/sapling3.png +./tile/ladder.png +./tile/tree_leaves_snow.png +./tile/ice_wall.png +./tile/water.png +./tile/sandstone_wall.png +./tile/ladder_up.png +./tile/cactus4.png +./tile/tall_grass.png +./tile/cactus2.png +./tile/grass_infested.png +./tile/tree_branch_leaves.png +./tile/dirt.png +./tile/wall.png +./tile/tree_base.png +./tile/cactus1.png +./tile/sapling4.png +./tile/hemp3.png +./tile/cactus_top.png +./tile/tunnel_down.png +./tile/stone.png +./tile/snow.png +./tile/boss_portal.png +./tile/hemp4.png +./tile/sand.png +./tile/campfire.png +./tile/lantern.png +./tile/ice.png +./tile/sapling1.png +./tile/grass_burnt.png +./tile/chest.png +./tile/hemp2.png +./tile/hemp8.png +./tile/cactus3.png +./tile/lava.png +./tile/tree_leaves.png +./tile/hemp5.png +./tile/lava_flow.png +./tile/grass.png +./tile/tree_branch.png +./tile/sandstone.png +./tile/tree_branch_leaves_snow.png +./tile/rock_sandstone.png +./tile/sapling2.png ./list.txt -./player/player_white_front_moving.png -./player/player_white_back_moving.png -./player/player_black_back_moving.png -./player/player_black_back_still.png +./item/log.png +./item/rock.png +./item/acorn.png +./item/clay.png +./item/ammo_box.png +./item/plant_fibre.png +./item/torch_lit.png +./item/flint_hatchet.png +./item/hemp_seed.png +./item/shield_upgrade.png +./item/grappling_hook.png +./item/log_snow.png +./item/health_potion.png +./item/snow_pile.png +./item/torch_unlit.png +./item/gun_upgrade.png +./item/sandstone.png +./item/flint.png ./player/player_white_back_still.png ./player/player_white_front_still.png ./player/player_black_front_moving.png ./player/player_black_front_still.png -./particle/smoke_trail.png -./particle/water.png -./particle/smoke_0.png -./particle/smoke_1.png -./particle/blood.png -./particle/lava.png -./particle/bullet.png -./particle/smoke_2.png -./particle/snow.png -./particle/rain.png -./particle/smoke_4.png -./particle/smoke_3.png -./particle/smoke_5.png -./gui/temperature.png -./gui/slot_armor_chest.png -./gui/health_empty.png -./gui/button_hover.png +./player/player_black_back_moving.png +./player/player_black_back_still.png +./player/player_white_back_moving.png +./player/player_white_front_moving.png +./gui/selection_box_wide.png ./gui/item_slot_storage.png +./gui/text_box.png +./gui/pixel_white.png ./gui/water.png +./gui/gun.png +./gui/selection_box_storage.png +./gui/button_delete.png +./gui/button_delete_hover.png +./gui/slot_armor_chest.png +./gui/pixel_black.png +./gui/slot_clothing_shirt.png +./gui/button_play.png ./gui/slot_armor_legs.png -./gui/button_normal.png +./gui/inventory.png ./gui/label.png -./gui/hotbar.png +./gui/slot_clothing_pants.png +./gui/health_empty.png +./gui/label_recipe.png +./gui/hotbar_selected.png +./gui/health_full.png +./gui/temperature.png +./gui/button_play_hover.png +./gui/text_cursor.png ./gui/slot_armor_helmet.png ./gui/selection_box_crafting.png -./gui/button_delete.png -./gui/text_cursor.png -./gui/inventory.png -./gui/button_delete_hover.png -./gui/button_play_hover.png -./gui/health_full.png -./gui/hotbar_selected.png -./gui/slot_clothing_shirt.png -./gui/selection_box_storage.png -./gui/pixel_white.png -./gui/pixel_black.png -./gui/slot_clothing_pants.png -./gui/text_box.png -./gui/shield.png -./gui/label_recipe.png ./gui/slot_clothing_boots.png -./gui/selection_box_wide.png -./gui/gun.png -./gui/button_play.png -./tile/cactus4.png -./tile/hemp1.png -./tile/dirt.png -./tile/lantern.png -./tile/hemp8.png -./tile/wall.png -./tile/cactus_top.png -./tile/cactus2.png -./tile/rock.png -./tile/water.png -./tile/hemp4.png -./tile/stone.png -./tile/tree_leaves.png -./tile/sapling2.png -./tile/ladder_up.png -./tile/sapling3.png -./tile/lava_flow.png -./tile/ice_wall.png -./tile/grass.png -./tile/chest.png -./tile/sapling4.png -./tile/lava.png -./tile/tall_grass.png -./tile/hemp5.png -./tile/sapling1.png -./tile/snow.png -./tile/sandstone_wall.png -./tile/rock_sandstone.png -./tile/hemp6.png -./tile/cactus1.png -./tile/campfire.png -./tile/tree_branch_leaves.png -./tile/tunnel_down.png -./tile/tree_branch_leaves_snow.png -./tile/tree_leaves_snow.png -./tile/rock_ice.png -./tile/boss_portal.png -./tile/ladder.png -./tile/grass_burnt.png -./tile/hemp7.png -./tile/grass_infested.png -./tile/tree_branch.png -./tile/sand.png -./tile/tree_base.png -./tile/cactus3.png -./tile/sandstone.png -./tile/hemp3.png -./tile/hemp2.png -./tile/ice.png -./entity/flare.png -./entity/grappling_hook.png -./entity/zombie_back_moving.png -./entity/tnt.png +./gui/hotbar.png +./gui/button_normal.png +./gui/shield.png +./gui/button_hover.png +./text/char_bslash.png +./text/char_dollar.png +./text/char_l_w.png +./text/char_u_d.png +./text/char_u_t.png +./text/char_space.png +./text/char_l_x.png +./text/char_l_k.png +./text/char_6.png +./text/char_unknown.png +./text/char_comma.png +./text/char_obracket.png +./text/char_u_w.png +./text/char_7.png +./text/char_l_f.png +./text/char_vertical.png +./text/char_plus.png +./text/char_u_a.png +./text/char_star.png +./text/char_9.png +./text/char_u_k.png +./text/char_grave.png +./text/char_u_n.png +./text/char_percent.png +./text/char_u_m.png +./text/char_exclamation.png +./text/char_1.png +./text/char_l_q.png +./text/char_l_z.png +./text/char_l_h.png +./text/char_u_c.png +./text/char_l_g.png +./text/char_l_s.png +./text/char_fullstop.png +./text/char_u_j.png +./text/char_l_m.png +./text/char_l_t.png +./text/char_u_v.png +./text/char_colon.png +./text/char_l_i.png +./text/char_l_y.png +./text/char_semicolon.png +./text/char_u_l.png +./text/char_apostrophe.png +./text/char_u_e.png +./text/char_5.png +./text/char_2.png +./text/char_3.png +./text/char_l_p.png +./text/char_and.png +./text/char_fslash.png +./text/char_l_u.png +./text/char_u_f.png +./text/char_u_u.png +./text/char_at.png +./text/char_l_e.png +./text/char_l_l.png +./text/char_u_g.png +./text/char_u_q.png +./text/char_u_b.png +./text/char_l_o.png +./text/char_csbracket.png +./text/char_osbracket.png +./text/char_minus.png +./text/char_l_v.png +./text/char_lthan.png +./text/char_u_s.png +./text/char_equals.png +./text/char_8.png +./text/char_ccbracket.png +./text/char_underscore.png +./text/char_u_x.png +./text/char_0.png +./text/char_l_d.png +./text/char_l_c.png +./text/char_l_j.png +./text/char_u_z.png +./text/char_u_h.png +./text/char_pow.png +./text/char_hashtag.png +./text/char_gthan.png +./text/char_cbracket.png +./text/char_u_i.png +./text/char_question.png +./text/char_u_o.png +./text/char_u_y.png +./text/char_l_r.png +./text/char_l_b.png +./text/char_ocbracket.png +./text/char_l_a.png +./text/char_quotation.png +./text/char_l_n.png +./text/char_u_p.png +./text/char_tilde.png +./text/char_u_r.png +./text/char_4.png ./entity/armored_zombie_back_moving.png -./entity/armored_zombie_front_moving.png -./entity/player/hair_side.png -./entity/player/head_top.png -./entity/player/head_side.png -./entity/player/head_back.png -./entity/player/head_bottom.png -./entity/player/hair_front.png -./entity/player/head_front.png -./entity/player/hair_back.png -./entity/player/hair_top.png -./entity/dummy.png -./entity/armored_zombie_front_still.png -./entity/armored_zombie_back_still.png -./entity/zombie_front_moving.png -./entity/boss1/boss_walking_firing.png +./entity/zombie_front_still.png +./entity/tnt.png +./entity/flare.png +./entity/boss1/boss_walking.png ./entity/boss1/boss_firing.png ./entity/boss1/boss_still.png -./entity/boss1/boss_walking.png +./entity/boss1/boss_walking_firing.png +./entity/armored_zombie_back_still.png +./entity/armored_zombie_front_moving.png +./entity/player/head_back.png +./entity/player/hair_top.png +./entity/player/head_front.png +./entity/player/head_top.png +./entity/player/hair_side.png +./entity/player/head_side.png +./entity/player/hair_back.png +./entity/player/hair_front.png +./entity/player/head_bottom.png +./entity/grappling_hook.png ./entity/zombie_back_still.png -./entity/zombie_front_still.png -./item/acorn.png -./item/clay.png -./item/grappling_hook.png -./item/gun_upgrade.png -./item/shield_upgrade.png -./item/rock.png -./item/flint_hatchet.png -./item/log.png -./item/log_snow.png -./item/hemp_seed.png -./item/ammo_box.png -./item/plant_fibre.png -./item/health_potion.png -./item/snow_pile.png -./item/flint.png -./item/sandstone.png +./entity/dummy.png +./entity/zombie_back_moving.png +./entity/armored_zombie_front_still.png +./entity/zombie_front_moving.png +./particle/smoke_1.png +./particle/water.png +./particle/rain.png +./particle/blood.png +./particle/snow.png +./particle/smoke_3.png +./particle/smoke_4.png +./particle/smoke_2.png +./particle/smoke_0.png +./particle/bullet.png +./particle/lava.png +./particle/smoke_trail.png +./particle/smoke_5.png