Fixed item info on hover, changed item meta to a modifier system.
This commit is contained in:
parent
6e69fe2fcd
commit
d5815eef50
|
|
@ -14,9 +14,10 @@ import projectzombie.display.DisplayWindow;
|
||||||
import projectzombie.entity.EntityEventHandler;
|
import projectzombie.entity.EntityEventHandler;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Entities;
|
import projectzombie.init.Entities;
|
||||||
|
import projectzombie.init.ItemModifiers;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.LayerGenerators;
|
import projectzombie.init.LayerGenerators;
|
||||||
import projectzombie.init.Recipies;
|
import projectzombie.init.Recipes;
|
||||||
import projectzombie.init.Resources;
|
import projectzombie.init.Resources;
|
||||||
import projectzombie.init.Sounds;
|
import projectzombie.init.Sounds;
|
||||||
import projectzombie.init.Tasks;
|
import projectzombie.init.Tasks;
|
||||||
|
|
@ -65,11 +66,12 @@ public class Main
|
||||||
Cheats.init(args);
|
Cheats.init(args);
|
||||||
|
|
||||||
Items.init();
|
Items.init();
|
||||||
|
ItemModifiers.init();
|
||||||
Entities.init();
|
Entities.init();
|
||||||
Tasks.init();
|
Tasks.init();
|
||||||
Tiles.init();
|
Tiles.init();
|
||||||
LayerGenerators.init();
|
LayerGenerators.init();
|
||||||
Recipies.init();
|
Recipes.init();
|
||||||
|
|
||||||
// Create the display
|
// Create the display
|
||||||
window = new DisplayWindow();
|
window = new DisplayWindow();
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class DisplayRenderUI
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model_item = stack.item.getModel(stack.meta).getGuiModel();
|
Model model_item = stack.item.getModel(stack).getGuiModel();
|
||||||
double item_offset = (Models.UI_ACTIVE_SLOT.getHeight() - model_item.getHeight()) / 2;
|
double item_offset = (Models.UI_ACTIVE_SLOT.getHeight() - model_item.getHeight()) / 2;
|
||||||
|
|
||||||
Matrix4 matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + item_offset, item_offset, 0));
|
Matrix4 matrix_item = Matrix4.multiply(matrix, Matrix4.translate(i * offset + item_offset, item_offset, 0));
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import projectzombie.display.bossbar.IBossBar;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.init.Tiles;
|
import projectzombie.init.Tiles;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.time.GameTimer;
|
import projectzombie.time.GameTimer;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
@ -233,10 +234,11 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
||||||
|
|
||||||
// Spawn the loot
|
// Spawn the loot
|
||||||
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
||||||
Items.HEALTH_POTION, RandomHelpers.randrange(rand, 20), (byte)50)));
|
Items.HEALTH_POTION, RandomHelpers.randrange(rand, 20), new ItemModifierMeta(50))));
|
||||||
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
||||||
Items.AMMO, RandomHelpers.randrange(rand, 200), (byte)50)));
|
Items.AMMO, RandomHelpers.randrange(rand, 200), new ItemModifierMeta(50))));
|
||||||
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(Items.GRAPPLING_HOOK, 1, (byte)2)));
|
layer.spawnEntity(new EntityItem(getPos(), getVelocity(), new ItemStack(
|
||||||
|
Items.GRAPPLING_HOOK, 1, new ItemModifierMeta(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,7 @@ public class EntityItem extends EntityParticle
|
||||||
EntityItem ei = (EntityItem) e;
|
EntityItem ei = (EntityItem) e;
|
||||||
|
|
||||||
if(
|
if(
|
||||||
ei.stack.meta == this.stack.meta &&
|
ei.stack.stackEquals(this.stack) &&
|
||||||
ei.stack.item == this.stack.item &&
|
|
||||||
ei.stack.count + this.stack.count <= this.stack.item.max &&
|
ei.stack.count + this.stack.count <= this.stack.item.max &&
|
||||||
ei.age > this.age
|
ei.age > this.age
|
||||||
) {
|
) {
|
||||||
|
|
@ -121,7 +120,7 @@ public class EntityItem extends EntityParticle
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityParticlePart getParticleAt(int id) {
|
public EntityParticlePart getParticleAt(int id) {
|
||||||
ModelItem model = stack.item.getModel(stack.meta);
|
ModelItem model = stack.item.getModel(stack);
|
||||||
EntityParticlePart particle = new EntityParticlePart(model.tex, getPos().add(new Vec3d(0, 0.25, 0)), 0.5, 0b1000);
|
EntityParticlePart particle = new EntityParticlePart(model.tex, getPos().add(new Vec3d(0, 0.25, 0)), 0.5, 0b1000);
|
||||||
particle.animationSize = model.animationSize;
|
particle.animationSize = model.animationSize;
|
||||||
particle.animationSpeed = model.animationSpeed;
|
particle.animationSpeed = model.animationSpeed;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public class EntityPlayer extends Entity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAmmo() {
|
public int getAmmo() {
|
||||||
return inventory.getItemCount(Items.AMMO);
|
return inventory.getItemCount(new ItemStack(Items.AMMO, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -385,7 +385,10 @@ public class EntityPlayer extends Entity implements
|
||||||
|
|
||||||
if(!i.isEmpty())
|
if(!i.isEmpty())
|
||||||
{
|
{
|
||||||
EntityItem e = new EntityItem(getPos(), getVelocity(), new ItemStack(i.item, 1, i.meta), Math.toRadians(angle));
|
ItemStack stack = i.copy();
|
||||||
|
stack.count = 1;
|
||||||
|
|
||||||
|
EntityItem e = new EntityItem(getPos(), getVelocity(), stack, Math.toRadians(angle));
|
||||||
Main.world.getLayer().spawnEntity(e);
|
Main.world.getLayer().spawnEntity(e);
|
||||||
i.count -= 1;
|
i.count -= 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package projectzombie.init;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import bdf.types.BdfObject;
|
||||||
|
import projectzombie.items.modifier.ItemModifier;
|
||||||
|
import projectzombie.items.modifier.ItemModifierDamage;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
|
|
||||||
|
public class ItemModifiers
|
||||||
|
{
|
||||||
|
public static final ArrayList<Class<? extends ItemModifier>> MODIFIERS = new ArrayList<>();
|
||||||
|
|
||||||
|
private static void register(Class<? extends ItemModifier> m)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
m.getConstructor(BdfObject.class);
|
||||||
|
} catch (NoSuchMethodException | SecurityException err) {
|
||||||
|
err.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MODIFIERS.add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init()
|
||||||
|
{
|
||||||
|
register(ItemModifierMeta.class);
|
||||||
|
register(ItemModifierDamage.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,9 +5,10 @@ import java.util.ArrayList;
|
||||||
import projectzombie.inventory.Crafting;
|
import projectzombie.inventory.Crafting;
|
||||||
import projectzombie.inventory.recipe.Recipe;
|
import projectzombie.inventory.recipe.Recipe;
|
||||||
import projectzombie.inventory.recipe.RecipeBasic;
|
import projectzombie.inventory.recipe.RecipeBasic;
|
||||||
|
import projectzombie.items.modifier.ItemModifierDamage;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class Recipies
|
public class Recipes
|
||||||
{
|
{
|
||||||
public static ArrayList<Recipe> recipies;
|
public static ArrayList<Recipe> recipies;
|
||||||
|
|
||||||
|
|
@ -39,19 +40,19 @@ public class Recipies
|
||||||
|
|
||||||
recipies.add(new RecipeBasic(
|
recipies.add(new RecipeBasic(
|
||||||
new ItemStack[] {
|
new ItemStack[] {
|
||||||
new ItemStack(Items.FLINT, 2, (short)0),
|
new ItemStack(Items.FLINT, 2),
|
||||||
new ItemStack(Items.PLANT_FIBRE, 5, (short)0),
|
new ItemStack(Items.PLANT_FIBRE, 5),
|
||||||
}, new Crafting[] {
|
}, new Crafting[] {
|
||||||
Crafting.BASIC,
|
Crafting.BASIC,
|
||||||
}, new ItemStack(Items.FLINT_HATCHET, 1, (short)0)));
|
}, new ItemStack(Items.FLINT_HATCHET, 1, new ItemModifierDamage(0, 10))));
|
||||||
|
|
||||||
recipies.add(new RecipeBasic(
|
recipies.add(new RecipeBasic(
|
||||||
new ItemStack[] {
|
new ItemStack[] {
|
||||||
new ItemStack(Items.FLINT, 1, (short)0),
|
new ItemStack(Items.FLINT, 1),
|
||||||
new ItemStack(Items.PLANT_FIBRE, 1, (short)0),
|
new ItemStack(Items.PLANT_FIBRE, 1),
|
||||||
}, new Crafting[] {
|
}, new Crafting[] {
|
||||||
Crafting.BASIC,
|
Crafting.BASIC,
|
||||||
}, new ItemStack(Items.FLINT_HATCHET, 1, (short)0)));
|
}, new ItemStack(Items.FLINT_HATCHET, 1)));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package projectzombie.inventory;
|
package projectzombie.inventory;
|
||||||
|
|
||||||
import projectzombie.items.Item;
|
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public interface IInventory
|
public interface IInventory
|
||||||
|
|
@ -13,5 +12,4 @@ public interface IInventory
|
||||||
|
|
||||||
public ItemStack removeItem(int slot);
|
public ItemStack removeItem(int slot);
|
||||||
public void removeItem(ItemStack stack);
|
public void removeItem(ItemStack stack);
|
||||||
public void removeItem(Item item, int count);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import bdf.types.BdfArray;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import projectzombie.items.Item;
|
import projectzombie.items.Item;
|
||||||
|
import projectzombie.items.modifier.ItemModifier;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class Inventory implements IInventory, IBdfClassManager
|
public class Inventory implements IInventory, IBdfClassManager
|
||||||
|
|
@ -47,7 +48,7 @@ public class Inventory implements IInventory, IBdfClassManager
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for(ItemStack check : items) {
|
for(ItemStack check : items) {
|
||||||
if(item.stackEquals(check) && !check.isEmpty()) {
|
if(check.stackAbstractEquals(item) && !check.isEmpty()) {
|
||||||
count += check.count;
|
count += check.count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,19 +56,6 @@ public class Inventory implements IInventory, IBdfClassManager
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemCount(Item item)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for(ItemStack check : items) {
|
|
||||||
if(item == check.item && !check.isEmpty()) {
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addItem(ItemStack stack)
|
public void addItem(ItemStack stack)
|
||||||
{
|
{
|
||||||
if(stack.isEmpty()) {
|
if(stack.isEmpty()) {
|
||||||
|
|
@ -93,10 +81,17 @@ public class Inventory implements IInventory, IBdfClassManager
|
||||||
|
|
||||||
for(ItemStack check : items)
|
for(ItemStack check : items)
|
||||||
{
|
{
|
||||||
if(check.isEmpty()) {
|
if(check.isEmpty())
|
||||||
|
{
|
||||||
|
ItemModifier[] modifiers = new ItemModifier[stack.modifiers.length];
|
||||||
|
|
||||||
|
for(int i=0;i<modifiers.length;i++) {
|
||||||
|
modifiers[i] = stack.modifiers[i].copy();
|
||||||
|
}
|
||||||
|
|
||||||
check.item = stack.item;
|
check.item = stack.item;
|
||||||
check.count = stack.count;
|
check.count = stack.count;
|
||||||
check.meta = stack.meta;
|
check.modifiers = modifiers;
|
||||||
stack.count = 0;
|
stack.count = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +101,7 @@ public class Inventory implements IInventory, IBdfClassManager
|
||||||
public void removeItem(ItemStack stack)
|
public void removeItem(ItemStack stack)
|
||||||
{
|
{
|
||||||
for(ItemStack check : items) {
|
for(ItemStack check : items) {
|
||||||
if(stack.stackEquals(check) && !stack.isEmpty())
|
if(check.stackAbstractEquals(stack) && !stack.isEmpty())
|
||||||
{
|
{
|
||||||
if(check.count < stack.count) {
|
if(check.count < stack.count) {
|
||||||
stack.count -= check.count;
|
stack.count -= check.count;
|
||||||
|
|
@ -122,24 +117,6 @@ public class Inventory implements IInventory, IBdfClassManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeItem(Item item, int count)
|
|
||||||
{
|
|
||||||
for(ItemStack check : items) {
|
|
||||||
if(item == check.item)
|
|
||||||
{
|
|
||||||
if(check.count < count) {
|
|
||||||
count -= check.count;
|
|
||||||
check.count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
check.count -= count;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BdfClassLoad(BdfObject bdf)
|
public void BdfClassLoad(BdfObject bdf)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public abstract class Item
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ public abstract class Item
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ModelItem getModel(short meta);
|
public abstract ModelItem getModel(ItemStack stack);
|
||||||
|
|
||||||
public void onPickedUp(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
|
public void onPickedUp(ItemStack stack, Layer layer, Chunk chunk, Entity entity)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ public class ItemAcorn extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_ACORN;
|
return Models.ITEM_ACORN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Acorn";
|
return "Acorn";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,18 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class ItemAmmo extends Item
|
public class ItemAmmo extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_AMMO_BOX;
|
return Models.ITEM_AMMO_BOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Ammo";
|
return "Ammo";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public class ItemEmpty extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_EMPTY;
|
return Models.ITEM_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class ItemFlare extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_FLARE;
|
return Models.ITEM_FLARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class ItemFlare extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Flare";
|
return "Flare";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,18 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class ItemFlint extends Item
|
public class ItemFlint extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_FLINT;
|
return Models.ITEM_FLINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Flint";
|
return "Flint";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package projectzombie.items;
|
package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifier;
|
||||||
|
import projectzombie.items.modifier.ItemModifierDamage;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
|
|
@ -31,12 +34,29 @@ public class ItemFlintHatchet extends Item implements ItemTool
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toolOnUse(ItemStack stack) {
|
public void toolOnUse(ItemStack stack)
|
||||||
|
{
|
||||||
|
ItemModifierDamage modifier = (ItemModifierDamage) stack.getModifier(ItemModifierDamage.class);
|
||||||
|
|
||||||
|
if(modifier == null) {
|
||||||
|
modifier = new ItemModifierDamage(0, 10);
|
||||||
|
stack.addModifier(modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
modifier.damage(1);
|
||||||
|
|
||||||
|
if(modifier.isBroken()) {
|
||||||
|
stack.count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
|
return "Flint Hatchet";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_FLINT_HATCHET;
|
return Models.ITEM_FLINT_HATCHET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.EntityGrapplingHook;
|
import projectzombie.entity.EntityGrapplingHook;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifier;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -12,18 +14,19 @@ public class ItemGrapplingHook extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_GRAPPLING_HOOK;
|
return Models.ITEM_GRAPPLING_HOOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Grappling Hook";
|
return "Grappling Hook";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player)
|
||||||
layer.spawnEntity(new EntityGrapplingHook(player.getPos(), stack.meta, player));
|
{
|
||||||
|
layer.spawnEntity(new EntityGrapplingHook(player.getPos(), ItemModifierMeta.getStackMeta(stack), player));
|
||||||
stack.count -= 1;
|
stack.count -= 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -11,18 +12,18 @@ public class ItemHealthPotion extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_HEALTH_POTION;
|
return Models.ITEM_HEALTH_POTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Health Potion "+meta+" HP";
|
return "Health Potion "+ItemModifierMeta.getStackMeta(stack)+" HP";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
player.addHealth(stack.meta);
|
player.addHealth(ItemModifierMeta.getStackMeta(stack));
|
||||||
stack.count -= 1;
|
stack.count -= 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ public class ItemHempSeed extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_HEMP_SEED;
|
return Models.ITEM_HEMP_SEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Hemp Seed";
|
return "Hemp Seed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class ItemInfestation extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_ROCK;
|
return Models.ITEM_ROCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class ItemLantern extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_LANTERN;
|
return Models.ITEM_LANTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class ItemLantern extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Lantern";
|
return "Lantern";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
package projectzombie.items;
|
package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class ItemLog extends Item
|
public class ItemLog extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta)
|
public ModelItem getModel(ItemStack stack)
|
||||||
{
|
{
|
||||||
switch(meta)
|
switch(ItemModifierMeta.getStackMeta(stack))
|
||||||
{
|
{
|
||||||
case 1: return Models.ITEM_LOG_SNOW;
|
case 1: return Models.ITEM_LOG_SNOW;
|
||||||
default: return Models.ITEM_LOG;
|
default: return Models.ITEM_LOG;
|
||||||
|
|
@ -17,7 +19,7 @@ public class ItemLog extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Log";
|
return "Log";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,17 @@ package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
public class ItemPlantFibre extends Item
|
public class ItemPlantFibre extends Item
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_PLANT_FIBRE;
|
return Models.ITEM_PLANT_FIBRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "Plant Fibre";
|
return "Plant Fibre";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package projectzombie.items;
|
package projectzombie.items;
|
||||||
|
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
|
|
@ -8,9 +9,9 @@ public class ItemRock extends Item
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta)
|
public ModelItem getModel(ItemStack stack)
|
||||||
{
|
{
|
||||||
switch(meta) {
|
switch(ItemModifierMeta.getStackMeta(stack)) {
|
||||||
case 1: return Models.ITEM_SNOW_PILE;
|
case 1: return Models.ITEM_SNOW_PILE;
|
||||||
case 2: return Models.ITEM_SANDSTONE;
|
case 2: return Models.ITEM_SANDSTONE;
|
||||||
default: return Models.ITEM_ROCK;
|
default: return Models.ITEM_ROCK;
|
||||||
|
|
@ -18,9 +19,9 @@ public class ItemRock extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta)
|
public String getName(ItemStack stack)
|
||||||
{
|
{
|
||||||
switch(meta) {
|
switch(ItemModifierMeta.getStackMeta(stack)) {
|
||||||
case 1: return "Snow";
|
case 1: return "Snow";
|
||||||
case 2: return "Sandstone";
|
case 2: return "Sandstone";
|
||||||
default: return "Rock";
|
default: return "Rock";
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.items;
|
||||||
import projectzombie.entity.EntityTnt;
|
import projectzombie.entity.EntityTnt;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -11,18 +12,19 @@ import projectzombie.world.layer.Layer;
|
||||||
public class ItemTnt extends Item
|
public class ItemTnt extends Item
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_TNT;
|
return Models.ITEM_TNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName(short meta) {
|
public String getName(ItemStack stack) {
|
||||||
return "TNT";
|
return "TNT";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
public boolean onPlayerRightClick(ItemStack stack, Layer layer, Chunk chunk, EntityPlayer player) {
|
||||||
layer.spawnEntity(new EntityTnt(player.getPos(), player.getVelocity(), player.angle, stack.meta, 5000));
|
layer.spawnEntity(new EntityTnt(player.getPos(), player.getVelocity(),
|
||||||
|
player.angle, ItemModifierMeta.getStackMeta(stack), 5000));
|
||||||
stack.count -= 1;
|
stack.count -= 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package projectzombie.items.modifier;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import bdf.classes.IBdfClassManager;
|
||||||
|
import bdf.types.BdfNamedList;
|
||||||
|
import bdf.types.BdfObject;
|
||||||
|
import projectzombie.entity.Entity;
|
||||||
|
import projectzombie.init.ItemModifiers;
|
||||||
|
import projectzombie.init.Tasks;
|
||||||
|
import projectzombie.task.Task;
|
||||||
|
|
||||||
|
public abstract class ItemModifier implements IBdfClassManager
|
||||||
|
{
|
||||||
|
public abstract boolean isEqual(ItemModifier other);
|
||||||
|
public abstract ItemModifier copy();
|
||||||
|
|
||||||
|
public int getID() {
|
||||||
|
for(int i=0;i<ItemModifiers.MODIFIERS.size();i++) {
|
||||||
|
Class<? extends ItemModifier> tc = ItemModifiers.MODIFIERS.get(i);
|
||||||
|
if(tc == this.getClass()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemModifier loadModifier(BdfObject bdf)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Load the task id
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
int id = nl.get("id").getInteger();
|
||||||
|
|
||||||
|
// Send back null if the id is out of range
|
||||||
|
if(id < 0 || id >= ItemModifiers.MODIFIERS.size()) {
|
||||||
|
System.out.println("Invalid modifier ID found: " + id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the class and the constructor
|
||||||
|
Class<? extends ItemModifier> tcl = ItemModifiers.MODIFIERS.get(id);
|
||||||
|
Constructor<? extends ItemModifier> tcon = tcl.getConstructor(BdfObject.class);
|
||||||
|
|
||||||
|
// Send back the new entity
|
||||||
|
return tcon.newInstance(bdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(
|
||||||
|
NoSuchMethodException |
|
||||||
|
SecurityException |
|
||||||
|
InstantiationException |
|
||||||
|
IllegalAccessException |
|
||||||
|
IllegalArgumentException |
|
||||||
|
InvocationTargetException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// Send null if there was an issue
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
package projectzombie.items.modifier;
|
||||||
|
|
||||||
|
import bdf.types.BdfNamedList;
|
||||||
|
import bdf.types.BdfObject;
|
||||||
|
|
||||||
|
public class ItemModifierDamage extends ItemModifier
|
||||||
|
{
|
||||||
|
private int damage;
|
||||||
|
private int max;
|
||||||
|
|
||||||
|
public ItemModifierDamage(int damage, int max) {
|
||||||
|
this.damage = damage;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemModifierDamage(BdfObject bdf) {
|
||||||
|
BdfClassLoad(bdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repair() {
|
||||||
|
damage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repair(int amount) {
|
||||||
|
damage -= amount;
|
||||||
|
if(damage < 0) {
|
||||||
|
damage = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void damage(int amount) {
|
||||||
|
damage += amount;
|
||||||
|
if(damage > max) {
|
||||||
|
damage = max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBroken() {
|
||||||
|
return damage == max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassLoad(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
damage = nl.get("damage").getInteger();
|
||||||
|
max = nl.get("max").getInteger();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassSave(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
nl.set("damage", bdf.newObject().setInteger(damage));
|
||||||
|
nl.set("max", bdf.newObject().setInteger(max));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEqual(ItemModifier other) {
|
||||||
|
return ((other instanceof ItemModifierDamage) &&
|
||||||
|
((ItemModifierDamage)other).damage == damage &&
|
||||||
|
((ItemModifierDamage)other).max == max);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemModifierDamage copy() {
|
||||||
|
return new ItemModifierDamage(damage, max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package projectzombie.items.modifier;
|
||||||
|
|
||||||
|
import bdf.types.BdfNamedList;
|
||||||
|
import bdf.types.BdfObject;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
|
|
||||||
|
public class ItemModifierMeta extends ItemModifier
|
||||||
|
{
|
||||||
|
private int meta;
|
||||||
|
|
||||||
|
public ItemModifierMeta(int meta) {
|
||||||
|
this.meta = meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemModifierMeta(BdfObject bdf) {
|
||||||
|
BdfClassLoad(bdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getStackMeta(ItemStack stack)
|
||||||
|
{
|
||||||
|
ItemModifier modifier = stack.getModifier(ItemModifierMeta.class);
|
||||||
|
|
||||||
|
if(modifier != null && modifier instanceof ItemModifierMeta) {
|
||||||
|
return ((ItemModifierMeta)modifier).meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassLoad(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
meta = nl.get("meta").getInteger();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void BdfClassSave(BdfObject bdf) {
|
||||||
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
|
nl.set("meta", bdf.newObject().setInteger(meta));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEqual(ItemModifier other) {
|
||||||
|
return (other instanceof ItemModifierMeta) && ((ItemModifierMeta)other).meta == meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemModifier copy() {
|
||||||
|
return new ItemModifierMeta(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import projectzombie.entity.EntityDummy;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemSpawn;
|
import projectzombie.items.ItemSpawn;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ public class ItemSpawnDummy extends ItemSpawn
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_SPAWN_DUMMY;
|
return Models.ITEM_SPAWN_DUMMY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import projectzombie.entity.EntityZombie;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemSpawn;
|
import projectzombie.items.ItemSpawn;
|
||||||
import projectzombie.model.ModelItem;
|
import projectzombie.model.ModelItem;
|
||||||
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.layer.Layer;
|
import projectzombie.world.layer.Layer;
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ public class ItemSpawnZombie extends ItemSpawn
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelItem getModel(short meta) {
|
public ModelItem getModel(ItemStack stack) {
|
||||||
return Models.ITEM_SPAWN_ZOMBIE;
|
return Models.ITEM_SPAWN_ZOMBIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.init.Recipies;
|
import projectzombie.init.Recipes;
|
||||||
import projectzombie.inventory.Crafting;
|
import projectzombie.inventory.Crafting;
|
||||||
import projectzombie.inventory.Inventory;
|
import projectzombie.inventory.Inventory;
|
||||||
import projectzombie.inventory.recipe.Recipe;
|
import projectzombie.inventory.recipe.Recipe;
|
||||||
|
|
@ -23,7 +23,7 @@ public class MenuInventoryBasic extends MenuInventory
|
||||||
public MenuInventoryBasic(Menu parent, Crafting tool) {
|
public MenuInventoryBasic(Menu parent, Crafting tool) {
|
||||||
super(parent);
|
super(parent);
|
||||||
|
|
||||||
Recipe[] recipies = Recipies.getCraftableRecipies(tool);
|
Recipe[] recipies = Recipes.getCraftableRecipies(tool);
|
||||||
inventory = Main.player.getInventory();
|
inventory = Main.player.getInventory();
|
||||||
|
|
||||||
slider = new GUIContainerSlider(new Vec2d(
|
slider = new GUIContainerSlider(new Vec2d(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class GUIItemHolder implements GUIComponent
|
||||||
{
|
{
|
||||||
Matrix4 holding_matrix = Matrix4.multiply(matrix, Matrix4.translate(-0.425, -0.425, 0));
|
Matrix4 holding_matrix = Matrix4.multiply(matrix, Matrix4.translate(-0.425, -0.425, 0));
|
||||||
|
|
||||||
Model model = holding.item.getModel(holding.meta).getGuiModel();
|
Model model = holding.item.getModel(holding).getGuiModel();
|
||||||
|
|
||||||
model.setModel(holding_matrix);
|
model.setModel(holding_matrix);
|
||||||
model.render();
|
model.render();
|
||||||
|
|
@ -44,24 +44,24 @@ public class GUIItemHolder implements GUIComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hover != null || !holding.isEmpty())
|
if(hover != null && holding.isEmpty())
|
||||||
{
|
{
|
||||||
ItemStack stack;
|
ItemStack stack = hover.getItemStack();
|
||||||
|
|
||||||
if(!holding.isEmpty()) {
|
|
||||||
stack = holding;
|
|
||||||
} else {
|
|
||||||
stack = hover.getItemStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!stack.isEmpty())
|
if(!stack.isEmpty())
|
||||||
{
|
{
|
||||||
String name = stack.item.getName(stack.meta);
|
String name = stack.item.getName(stack);
|
||||||
|
|
||||||
Matrix4 container_matrix = matrix;
|
Matrix4 container_matrix = matrix;
|
||||||
|
double distance = 0.5;
|
||||||
|
double offset = -0.6 - distance;
|
||||||
|
|
||||||
|
if(Matrix4.multiply(matrix, new Vec3d(0, offset - 0.8, 0)).y < -10) {
|
||||||
|
offset = 0.2 + distance;
|
||||||
|
}
|
||||||
|
|
||||||
container_matrix = Matrix4.multiply(container_matrix, Matrix4.translate(
|
container_matrix = Matrix4.multiply(container_matrix, Matrix4.translate(
|
||||||
-0.4 * name.length() / 2, -1, 0));
|
-0.4 * name.length() / 2, offset, 0));
|
||||||
|
|
||||||
Matrix4 text_matrix = container_matrix;
|
Matrix4 text_matrix = container_matrix;
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ public class GUIItemHolder implements GUIComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
holding.count += hover.count;
|
holding.count += hover.count;
|
||||||
holding.meta = hover.meta;
|
holding.modifiers = hover.copyModifiers();
|
||||||
holding.item = hover.item;
|
holding.item = hover.item;
|
||||||
|
|
||||||
hover.count = 0;
|
hover.count = 0;
|
||||||
|
|
@ -118,7 +118,7 @@ public class GUIItemHolder implements GUIComponent
|
||||||
|
|
||||||
layer.spawnEntity(new EntityItem(
|
layer.spawnEntity(new EntityItem(
|
||||||
Main.player.getPos(), Main.player.getVelocity(),
|
Main.player.getPos(), Main.player.getVelocity(),
|
||||||
new ItemStack(holding.item, 1, holding.meta),
|
new ItemStack(holding.item, 1, holding.copyModifiers()),
|
||||||
Math.toRadians(Main.player.angle)));
|
Math.toRadians(Main.player.angle)));
|
||||||
|
|
||||||
holding.count -= 1;
|
holding.count -= 1;
|
||||||
|
|
@ -138,7 +138,7 @@ public class GUIItemHolder implements GUIComponent
|
||||||
if(holding.isEmpty())
|
if(holding.isEmpty())
|
||||||
{
|
{
|
||||||
holding.item = hover.item;
|
holding.item = hover.item;
|
||||||
holding.meta = hover.meta;
|
holding.modifiers = hover.copyModifiers();
|
||||||
|
|
||||||
holding.count = (int)Math.ceil(hover.count / 2.0);
|
holding.count = (int)Math.ceil(hover.count / 2.0);
|
||||||
hover.count = (int)Math.floor(hover.count / 2.0);
|
hover.count = (int)Math.floor(hover.count / 2.0);
|
||||||
|
|
@ -166,7 +166,7 @@ public class GUIItemHolder implements GUIComponent
|
||||||
stack_to.count -= 1;
|
stack_to.count -= 1;
|
||||||
|
|
||||||
stack_from.item = stack_to.item;
|
stack_from.item = stack_to.item;
|
||||||
stack_from.meta = stack_to.meta;
|
stack_from.modifiers = stack_to.copyModifiers();
|
||||||
|
|
||||||
this.hover.setItemStack(hover);
|
this.hover.setItemStack(hover);
|
||||||
this.hover.getter.onRemoveItemStack();
|
this.hover.getter.onRemoveItemStack();
|
||||||
|
|
@ -235,11 +235,11 @@ public class GUIItemHolder implements GUIComponent
|
||||||
|
|
||||||
holding.count = hover.count;
|
holding.count = hover.count;
|
||||||
holding.item = hover.item;
|
holding.item = hover.item;
|
||||||
holding.meta = hover.meta;
|
holding.modifiers = hover.copyModifiers();
|
||||||
|
|
||||||
hover.count = stack.count;
|
hover.count = stack.count;
|
||||||
hover.item = stack.item;
|
hover.item = stack.item;
|
||||||
hover.meta = stack.meta;
|
hover.modifiers = stack.copyModifiers();
|
||||||
|
|
||||||
this.hover.setItemStack(hover);
|
this.hover.setItemStack(hover);
|
||||||
this.hover.getter.onRemoveItemStack();
|
this.hover.getter.onRemoveItemStack();
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,10 @@ public class GUIItemSlot implements GUIComponent
|
||||||
public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover)
|
public void render(Matrix4 matrix, Vec2d mousePos, boolean canHover)
|
||||||
{
|
{
|
||||||
ItemStack stack = getter.getItemStack();
|
ItemStack stack = getter.getItemStack();
|
||||||
|
boolean hover = checkMouseHover(mousePos) && canHover;
|
||||||
|
|
||||||
matrix = Matrix4.multiply(Matrix4.translate(pos.x, pos.y, 0), matrix);
|
matrix = Matrix4.multiply(Matrix4.translate(pos.x, pos.y, 0), matrix);
|
||||||
Model model = stack.item.getModel(stack.meta).getGuiModel();
|
Model model = stack.item.getModel(stack).getGuiModel();
|
||||||
|
|
||||||
if(stack.isEmpty()) {
|
if(stack.isEmpty()) {
|
||||||
model = model_empty;
|
model = model_empty;
|
||||||
|
|
@ -65,7 +66,7 @@ public class GUIItemSlot implements GUIComponent
|
||||||
model.render();
|
model.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getter.isReadOnly() && checkMouseHover(mousePos) && canHover)
|
if(!getter.isReadOnly() && hover)
|
||||||
{
|
{
|
||||||
double offset = (0.85 - hitboxSize) / 2;
|
double offset = (0.85 - hitboxSize) / 2;
|
||||||
Matrix4 hover_matrix = Matrix4.multiply(matrix, Matrix4.translate(offset, offset, 0));
|
Matrix4 hover_matrix = Matrix4.multiply(matrix, Matrix4.translate(offset, offset, 0));
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import projectzombie.entity.Entity;
|
||||||
import projectzombie.entity.EntityItem;
|
import projectzombie.entity.EntityItem;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
|
|
@ -42,38 +43,38 @@ public class TileChest extends Tile implements TileBulletBreakable
|
||||||
if(state.meta == CHEST_CAVES)
|
if(state.meta == CHEST_CAVES)
|
||||||
{
|
{
|
||||||
// Ammo
|
// Ammo
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.AMMO, RandomHelpers.randrange(rand, 100), (short)1));
|
spawnItem(chunk, tpos, new ItemStack(Items.AMMO, RandomHelpers.randrange(rand, 100), new ItemModifierMeta(1)));
|
||||||
|
|
||||||
// Tnt
|
// Tnt
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.TNT, RandomHelpers.randrange(rand, 2), (short)10));
|
spawnItem(chunk, tpos, new ItemStack(Items.TNT, RandomHelpers.randrange(rand, 2), new ItemModifierMeta(10)));
|
||||||
|
|
||||||
// Flare
|
// Flare
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.FLARE, RandomHelpers.randrange(rand, 5), (byte)0));
|
spawnItem(chunk, tpos, new ItemStack(Items.FLARE, RandomHelpers.randrange(rand, 5)));
|
||||||
|
|
||||||
// Lantern
|
// Lantern
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.LANTERN, RandomHelpers.randrange(rand, 5), (byte)0));
|
spawnItem(chunk, tpos, new ItemStack(Items.LANTERN, RandomHelpers.randrange(rand, 5)));
|
||||||
|
|
||||||
// Health potions
|
// Health potions
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.HEALTH_POTION, RandomHelpers.randrange(rand, 4), (short)50));
|
spawnItem(chunk, tpos, new ItemStack(Items.HEALTH_POTION, RandomHelpers.randrange(rand, 4), new ItemModifierMeta(50)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.meta == CHEST_LAVA_CAVES)
|
if(state.meta == CHEST_LAVA_CAVES)
|
||||||
{
|
{
|
||||||
// Ammo
|
// Ammo
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.AMMO, RandomHelpers.randrange(rand, 250), (short)1));
|
spawnItem(chunk, tpos, new ItemStack(Items.AMMO, RandomHelpers.randrange(rand, 250), new ItemModifierMeta(1)));
|
||||||
|
|
||||||
// Tnt
|
// Tnt
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.TNT, RandomHelpers.randrange(rand, 2), (short)10));
|
spawnItem(chunk, tpos, new ItemStack(Items.TNT, RandomHelpers.randrange(rand, 2), new ItemModifierMeta(10)));
|
||||||
|
|
||||||
// Health potions
|
// Health potions
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.HEALTH_POTION, RandomHelpers.randrange(rand, 4), (short)50));
|
spawnItem(chunk, tpos, new ItemStack(Items.HEALTH_POTION, RandomHelpers.randrange(rand, 4), new ItemModifierMeta(50)));
|
||||||
|
|
||||||
// Flare
|
// Flare
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.FLARE, RandomHelpers.randrange(rand, 5), (byte)0));
|
spawnItem(chunk, tpos, new ItemStack(Items.FLARE, RandomHelpers.randrange(rand, 5)));
|
||||||
|
|
||||||
// Lantern
|
// Lantern
|
||||||
spawnItem(chunk, tpos, new ItemStack(Items.LANTERN, RandomHelpers.randrange(rand, 5), (byte)0));
|
spawnItem(chunk, tpos, new ItemStack(Items.LANTERN, RandomHelpers.randrange(rand, 5)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,10 @@ public class TileHemp extends Tile
|
||||||
int fibre = (int)(Math.random() * (state.meta - 3) * 2) + (state.meta - 3) * 2;
|
int fibre = (int)(Math.random() * (state.meta - 3) * 2) + (state.meta - 3) * 2;
|
||||||
|
|
||||||
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0), new ItemStack(
|
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0), new ItemStack(
|
||||||
Items.HEMP_SEED, seeds, (short)0)));
|
Items.HEMP_SEED, seeds)));
|
||||||
|
|
||||||
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0), new ItemStack(
|
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0), new ItemStack(
|
||||||
Items.PLANT_FIBRE, fibre, (short)0)));
|
Items.PLANT_FIBRE, fibre)));
|
||||||
|
|
||||||
layer.setFrontTile(new TileState(Tiles.HEMP, (byte)3), tpos);
|
layer.setFrontTile(new TileState(Tiles.HEMP, (byte)3), tpos);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class TileLantern extends Tile
|
||||||
|
|
||||||
layer.setFrontTile(Tiles.VOID.getDefaultState(), tpos);
|
layer.setFrontTile(Tiles.VOID.getDefaultState(), tpos);
|
||||||
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0),
|
layer.spawnEntity(new EntityItem(tpos.toDouble().xny(), new Vec3d(0, 0, 0),
|
||||||
new ItemStack(Items.LANTERN, 1, (byte)0)));
|
new ItemStack(Items.LANTERN, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.tiles;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemTool;
|
import projectzombie.items.ItemTool;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
|
|
@ -36,8 +37,8 @@ public class TileRock extends Tile implements TileBulletBreakable
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] getTileDrops(TileState state) {
|
public ItemStack[] getTileDrops(TileState state) {
|
||||||
return new ItemStack[] {
|
return new ItemStack[] {
|
||||||
new ItemStack(Items.ROCK, 1, state.meta),
|
new ItemStack(Items.ROCK, 1, new ItemModifierMeta(state.meta)),
|
||||||
new ItemStack(Items.FLINT, state.meta == 0 && Math.random() > 0.8 ? 1 : 0, (short)0),
|
new ItemStack(Items.FLINT, state.meta == 0 && Math.random() > 0.8 ? 1 : 0),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class TileTallGrass extends Tile
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] getTileDrops(TileState state) {
|
public ItemStack[] getTileDrops(TileState state) {
|
||||||
return new ItemStack[] {
|
return new ItemStack[] {
|
||||||
new ItemStack(Items.PLANT_FIBRE, Math.random() > 0.9 ? 1 : 0, (short)0),
|
new ItemStack(Items.PLANT_FIBRE, Math.random() > 0.9 ? 1 : 0),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package projectzombie.tiles;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.init.Models;
|
import projectzombie.init.Models;
|
||||||
import projectzombie.items.ItemTool;
|
import projectzombie.items.ItemTool;
|
||||||
|
import projectzombie.items.modifier.ItemModifierMeta;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
import projectzombie.util.math.ItemStack;
|
import projectzombie.util.math.ItemStack;
|
||||||
import projectzombie.util.math.TileState;
|
import projectzombie.util.math.TileState;
|
||||||
|
|
@ -31,8 +32,8 @@ public class TileTree extends Tile implements TileBulletBreakable
|
||||||
public ItemStack[] getTileDrops(TileState state)
|
public ItemStack[] getTileDrops(TileState state)
|
||||||
{
|
{
|
||||||
return new ItemStack[] {
|
return new ItemStack[] {
|
||||||
new ItemStack(Items.ACORN, (int)(Math.random() * 3) + 1, (short)0),
|
new ItemStack(Items.ACORN, (int)(Math.random() * 3) + 1),
|
||||||
new ItemStack(Items.LOG, (int)(Math.random() * 4) + 2, (short)state.meta),
|
new ItemStack(Items.LOG, (int)(Math.random() * 4) + 2, new ItemModifierMeta(state.meta)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,51 @@
|
||||||
package projectzombie.util.math;
|
package projectzombie.util.math;
|
||||||
|
|
||||||
import bdf.classes.IBdfClassManager;
|
import bdf.classes.IBdfClassManager;
|
||||||
|
import bdf.types.BdfArray;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import projectzombie.init.Items;
|
import projectzombie.init.Items;
|
||||||
import projectzombie.items.Item;
|
import projectzombie.items.Item;
|
||||||
|
import projectzombie.items.modifier.ItemModifier;
|
||||||
|
|
||||||
public class ItemStack implements IBdfClassManager
|
public class ItemStack implements IBdfClassManager
|
||||||
{
|
{
|
||||||
public short meta;
|
public ItemModifier[] modifiers;
|
||||||
public Item item;
|
public Item item;
|
||||||
public int count;
|
public int count;
|
||||||
|
|
||||||
public ItemStack(Item item, int count, short meta) {
|
public ItemStack(Item item, int count, ItemModifier ... modifiers) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.meta = meta;
|
this.modifiers = modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack copy() {
|
public ItemStack copy() {
|
||||||
return new ItemStack(item, count, meta);
|
return new ItemStack(item, count, copyModifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemModifier[] copyModifiers()
|
||||||
|
{
|
||||||
|
ItemModifier[] modifiers = new ItemModifier[this.modifiers.length];
|
||||||
|
|
||||||
|
for(int i=0;i<modifiers.length;i++) {
|
||||||
|
modifiers[i] = this.modifiers[i].copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addModifier(ItemModifier modifier)
|
||||||
|
{
|
||||||
|
ItemModifier[] modifiers = new ItemModifier[this.modifiers.length + 1];
|
||||||
|
|
||||||
|
for(int i=0;i<this.modifiers.length;i++) {
|
||||||
|
modifiers[i] = this.modifiers[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiers[modifiers.length - 1] = modifier;
|
||||||
|
|
||||||
|
this.modifiers = modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
|
|
@ -29,30 +55,99 @@ public class ItemStack implements IBdfClassManager
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasModifier(Class<? extends ItemModifier> modifier) {
|
||||||
|
return getModifier(modifier) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemModifier getModifier(Class<? extends ItemModifier> modifier)
|
||||||
|
{
|
||||||
|
for(int i=0;i<modifiers.length;i++) {
|
||||||
|
if(modifiers[i].getClass() == modifier) {
|
||||||
|
return modifiers[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean stackEquals(ItemStack other)
|
public boolean stackEquals(ItemStack other)
|
||||||
{
|
{
|
||||||
if(other.item != item)
|
if(other.item != item)
|
||||||
return false;
|
return false;
|
||||||
if(other.meta == -1 || meta == -1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return (other.meta == meta);
|
for(int i=0;i<other.modifiers.length;i++)
|
||||||
|
{
|
||||||
|
ItemModifier modifier = getModifier(other.modifiers[i].getClass());
|
||||||
|
|
||||||
|
if(modifier == null || !modifier.isEqual(other.modifiers[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0;i<modifiers.length;i++)
|
||||||
|
{
|
||||||
|
ItemModifier modifier = other.getModifier(modifiers[i].getClass());
|
||||||
|
|
||||||
|
if(modifier == null || !modifier.isEqual(modifiers[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stackAbstractEquals(ItemStack other)
|
||||||
|
{
|
||||||
|
if(other.item != item)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(int i=0;i<other.modifiers.length;i++)
|
||||||
|
{
|
||||||
|
ItemModifier modifier = getModifier(other.modifiers[i].getClass());
|
||||||
|
|
||||||
|
if(modifier == null || !modifier.isEqual(other.modifiers[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BdfClassLoad(BdfObject bdf) {
|
public void BdfClassLoad(BdfObject bdf)
|
||||||
|
{
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
meta = nl.get("meta").getShort();
|
|
||||||
count = nl.get("count").getInteger();
|
count = nl.get("count").getInteger();
|
||||||
item = Items.items.get(nl.get("item").getInteger());
|
item = Items.items.get(nl.get("item").getInteger());
|
||||||
|
|
||||||
|
BdfArray modifiers = nl.get("modifiers").getArray();
|
||||||
|
this.modifiers = new ItemModifier[modifiers.size()];
|
||||||
|
|
||||||
|
for(int i=0;i<this.modifiers.length;i++) {
|
||||||
|
this.modifiers[i] = ItemModifier.loadModifier(modifiers.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BdfClassSave(BdfObject bdf) {
|
public void BdfClassSave(BdfObject bdf)
|
||||||
|
{
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
nl.set("meta", bdf.newObject().setShort(meta));
|
|
||||||
nl.set("count", bdf.newObject().setInteger(count));
|
nl.set("count", bdf.newObject().setInteger(count));
|
||||||
nl.set("item", bdf.newObject().setInteger(item.id));
|
nl.set("item", bdf.newObject().setInteger(item.id));
|
||||||
|
|
||||||
|
BdfArray modifiers = bdf.newArray();
|
||||||
|
nl.set("modifiers", bdf.newObject().setArray(modifiers));
|
||||||
|
|
||||||
|
for(int i=0;i<this.modifiers.length;i++)
|
||||||
|
{
|
||||||
|
BdfObject modifier = bdf.newObject();
|
||||||
|
this.modifiers[i].BdfClassSave(modifier);
|
||||||
|
|
||||||
|
BdfNamedList modifier_nl = modifier.getNamedList();
|
||||||
|
modifier_nl.set("id", bdf.newObject().setInteger(this.modifiers[i].getID()));
|
||||||
|
|
||||||
|
modifiers.add(modifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack(BdfObject bdf) {
|
public ItemStack(BdfObject bdf) {
|
||||||
|
|
@ -60,6 +155,6 @@ public class ItemStack implements IBdfClassManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack getEmpty() {
|
public static ItemStack getEmpty() {
|
||||||
return new ItemStack(Items.EMPTY, 0, (short)0);
|
return new ItemStack(Items.EMPTY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue