chars, ...
This commit is contained in:
parent
eea23233f4
commit
3515fb1792
53 changed files with 688 additions and 543 deletions
|
@ -395,11 +395,8 @@ public class Game implements IThreadListener {
|
|||
@Variable(name = "con_autoclose", category = CVarCategory.CONSOLE, display = "Schließen")
|
||||
public boolean conAutoclose = true;
|
||||
public boolean interrupted;
|
||||
public List<DisplayMode> vid_modes = Lists.newArrayList();
|
||||
public List<Message> messages = Lists.newArrayList();
|
||||
@Variable(name = "gui_theme", category = CVarCategory.GUI, display = "Oberflächen-Design")
|
||||
public Style style = Style.DEFAULT;
|
||||
public List<Style> themes;
|
||||
@Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen")
|
||||
public int scrollLines = 3;
|
||||
|
||||
|
@ -550,7 +547,6 @@ public class Game implements IThreadListener {
|
|||
this.renderGlobal.onReload();
|
||||
EntityTexManager.loadNpcTextures();
|
||||
this.effectRenderer = new EffectRenderer(this.theWorld, this.textureManager);
|
||||
new File("skins").mkdirs();
|
||||
}
|
||||
|
||||
public void start()
|
||||
|
@ -2924,7 +2920,7 @@ public class Game implements IThreadListener {
|
|||
else if(field.getType() == String.class)
|
||||
cv = new StringVar(value.name(), value.display(), field, object, value.category(), (int)value.max(), (StringFunction)func, validator, (int)value.min() <= 0);
|
||||
else if(field.getType().isEnum())
|
||||
cv = new EnumVar(value.name(), value.display(), field, object, value.category(), (EnumFunction)func);
|
||||
cv = new EnumVar(value.name(), value.display(), field, object, value.category(), (EnumFunction)func, value.switched());
|
||||
else
|
||||
throw new IllegalArgumentException(value.name() + ": Unbekannter Variablen-Typ - " + field.getType());
|
||||
regVar(cv);
|
||||
|
@ -2951,6 +2947,7 @@ public class Game implements IThreadListener {
|
|||
regVars(this);
|
||||
regVars(Style.CUSTOM);
|
||||
regVars(GuiConnect.INSTANCE);
|
||||
regVars(GuiChar.INSTANCE);
|
||||
|
||||
if(!config.exists())
|
||||
return;
|
||||
|
|
|
@ -2,61 +2,21 @@ package game.entity.npc;
|
|||
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.item.RngLoot;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class CharacterInfo {
|
||||
public class CharacterInfo extends NpcInfo {
|
||||
public final boolean spawner;
|
||||
public final SpeciesInfo species;
|
||||
public final ClassInfo spclass;
|
||||
public final String name;
|
||||
public final String skin;
|
||||
public final String cape;
|
||||
public final int color1;
|
||||
public final int color2;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
|
||||
public CharacterInfo(SpeciesInfo species, ClassInfo spclass, String name, String skin, String cape, int color1, int color2, boolean spawner) {
|
||||
this.spawner = spawner; // ? SpeciesRegistry.CHARACTERS.size() : -1;
|
||||
public CharacterInfo(SpeciesInfo species, Enum type, String name, String skin, String cape, Alignment align, float height, int color1, int color2, boolean spawner) {
|
||||
super(type, name, skin, cape, align, height, (ItemStack[])null);
|
||||
this.spawner = spawner;
|
||||
this.species = species;
|
||||
this.spclass = spclass;
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.cape = cape;
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
SpeciesRegistry.SKINS.put(skin, species.renderer);
|
||||
if(!cape.isEmpty()) {
|
||||
if(!cape.isEmpty())
|
||||
SpeciesRegistry.CAPES.add(cape);
|
||||
}
|
||||
if(spclass != null)
|
||||
spclass.chars.add(this);
|
||||
// if(spawner)
|
||||
// SpeciesRegistry.CHARACTERS.add(this);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public ItemStack pickItem(int slot, Random rand) {
|
||||
WeightedList<RngLoot> list = this.items[slot];
|
||||
if(list.isEmpty()) {
|
||||
if(this.spclass != null) {
|
||||
list = this.spclass.getItems()[slot];
|
||||
}
|
||||
if(this.spclass == null || list.isEmpty()) {
|
||||
list = this.species.getItems()[slot];
|
||||
if(list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.pick(rand).getItem(rand);
|
||||
}
|
||||
}
|
|
@ -1,31 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.collect.Lists;
|
||||
|
||||
import game.item.RngLoot;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class ClassInfo {
|
||||
public final SpeciesInfo species;
|
||||
public final Enum type;
|
||||
public final List<CharacterInfo> chars;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
|
||||
public ClassInfo(SpeciesInfo species, Enum type) {
|
||||
this.species = species;
|
||||
public ClassInfo(Enum type) {
|
||||
this.type = type;
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
this.chars = Lists.newArrayList();
|
||||
// SpeciesRegistry.SPCLASSES.add(this);
|
||||
this.species.classmap.put(this.type, this);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public class EntityArachnoid extends EntityNPC
|
|||
return 0.25f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.EVIL, Alignment.LAWFUL, Alignment.NEUTRAL);
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,10 @@ public class EntityArachnoid extends EntityNPC
|
|||
return true;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.6f;
|
||||
}
|
||||
|
||||
public static class GroupData
|
||||
{
|
||||
public Potion potionEffectId;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -53,7 +55,11 @@ public class EntityBloodElf extends EntityNPC {
|
|||
return 0.3f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.9f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(50) ?
|
||||
(rand.chance(8) ? (rand.chance(5) ? Alignment.CHAOTIC : Alignment.LAWFUL) : Alignment.NEUTRAL) :
|
||||
(rand.chance(5) ? Alignment.EVIL : Alignment.LAWFUL_EVIL);
|
||||
|
@ -62,4 +68,8 @@ public class EntityBloodElf extends EntityNPC {
|
|||
public NameRegistry getNameType() {
|
||||
return NameRegistry.ELVEN;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return new ItemStack(this.rand.chance(4) ? this.rand.pick(Items.bow, Items.stone_sword) : Items.iron_sword);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,16 @@ import java.util.List;
|
|||
import game.collect.Lists;
|
||||
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.init.Items;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
public class EntityChaosMarine extends EntityNPC {
|
||||
public static enum Legion implements IStringSerializable {
|
||||
OTHER("other", "???", 0x000000, 0x000000, 2.15f, 200),
|
||||
OTHER("other", null, 0x000000, 0x000000, 2.15f, 200),
|
||||
EMPERORS_CHILDREN("emperorchild", "Emperors Children", 0xa224cc, 0xccb963, 2.43f, 300, "emperors_child");
|
||||
|
||||
public static final Object[] MARINES;
|
||||
|
@ -42,7 +44,7 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
|
||||
private Legion(String name, String display, int color1, int color2, float size, int health, String ... classes) {
|
||||
this.name = name;
|
||||
this.display = display + " Einheit";
|
||||
this.display = display == null ? "" : display + " Einheit";
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.size = size;
|
||||
|
@ -76,11 +78,15 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
return this.getLegion().health;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.15f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getLegion().size;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(Alignment.CHAOTIC_EVIL, Alignment.EVIL, 6);
|
||||
}
|
||||
|
||||
|
@ -115,4 +121,8 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.boltgun), null, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,15 @@ public class EntityCpu extends EntityNPC {
|
|||
// return 0.0f;
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
public boolean isBreedingItem(ItemStack stack) {
|
||||
return stack.getItem() == Items.nieh_fragment;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class EntityCultivator extends EntityNPC {
|
|||
return rand.range(25, 40);
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.values());
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,10 @@ public class EntityCultivator extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public void onStruckByLightning(EntityLightning lightningBolt) {
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,11 @@ public class EntityDarkMage extends EntityHoveringNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,11 @@ public class EntityDwarf extends EntityNPC {
|
|||
return 0.1f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.56f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.GOOD, Alignment.LAWFUL_GOOD, Alignment.NEUTRAL, Alignment.LAWFUL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -54,7 +56,11 @@ public class EntityElf extends EntityNPC {
|
|||
return 0.4f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.95f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(50) ?
|
||||
(rand.chance(8) ? (rand.chance(5) ? Alignment.CHAOTIC_EVIL : Alignment.EVIL) : Alignment.LAWFUL_EVIL) :
|
||||
(rand.chance(5) ? Alignment.NEUTRAL : Alignment.LAWFUL);
|
||||
|
@ -67,4 +73,8 @@ public class EntityElf extends EntityNPC {
|
|||
public boolean canAmbush(EntityLiving entity) {
|
||||
return (float)this.getHealth() >= ((float)this.getMaxHealth() / 5.0f);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return new ItemStack(this.rand.chance(Items.bow, Items.iron_sword, 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,11 @@ public class EntityFireDemon extends EntityFlyingNPC {
|
|||
return 0.35f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.55f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,11 @@ public class EntityGargoyle extends EntityFlyingNPC
|
|||
return 0.05f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,11 @@ public class EntityGoblin extends EntityNPC {
|
|||
return 0.1f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.4f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL, Alignment.LAWFUL_EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,10 @@ public class EntityHaunter extends EntityNPC {
|
|||
return 0x00ff00;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.55f;
|
||||
}
|
||||
|
||||
// public boolean isAggressive() {
|
||||
// return true;
|
||||
// }
|
||||
|
@ -333,7 +337,7 @@ public class EntityHaunter extends EntityNPC {
|
|||
// return 0.0f;
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import game.world.WorldServer;
|
|||
|
||||
public class EntityHuman extends EntityNPC {
|
||||
public static enum ClassType implements IStringSerializable {
|
||||
NONE("none", "???"),
|
||||
NONE("none", ""),
|
||||
KNIGHT("knight", "Krieger"),
|
||||
PEASANT("peasant", "Bauer"),
|
||||
MAGE("mage", "Magier"),
|
||||
|
@ -96,7 +96,11 @@ public class EntityHuman extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(ALIGNMENTS);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,11 @@ public class EntityMage extends EntityNPC
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.ItemRegistry;
|
||||
import game.init.MetalType;
|
||||
import game.item.ItemMetal;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
|
@ -55,7 +57,11 @@ public class EntityMetalhead extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.values());
|
||||
}
|
||||
|
||||
|
@ -66,4 +72,9 @@ public class EntityMetalhead extends EntityNPC {
|
|||
public boolean isMagnetic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ItemStack pickLoot(int slot) {
|
||||
MetalType metal = this.rand.pick(MetalType.values());
|
||||
return new ItemStack(ItemRegistry.getRegisteredItem(this.rand.chance(5) ? metal.name + "_block" : (metal.name + (metal.isPowder ? "_powder" : "_ingot"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.extraInventory = new InventoryBasic("Items", false, 8);
|
||||
// this.setCharacter("");
|
||||
if(this.species != null)
|
||||
this.setSize(this.species.size * this.species.renderer.width / this.species.renderer.height, this.species.size); // /* 0.6F, */ 1.8F);
|
||||
this.setSize(this.getSpeciesBaseSize() * this.species.renderer.width / this.species.renderer.height, this.getSpeciesBaseSize()); // /* 0.6F, */ 1.8F);
|
||||
if(this.getNavigator() instanceof PathNavigateGround) {
|
||||
((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
|
||||
((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
|
||||
|
@ -902,13 +902,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return this.species;
|
||||
}
|
||||
|
||||
public ClassInfo getSpClass() {
|
||||
if(this.species == null)
|
||||
return null;
|
||||
Enum type = this.getNpcClass();
|
||||
return type == null ? null : this.species.classmap.get(type);
|
||||
}
|
||||
|
||||
public void setAttackedBy(EntityLiving livingBase)
|
||||
{
|
||||
if(livingBase != null && /* livingBase.isPlayer() && */ this.isEntityAlive() && /* !this.isPeaceful() && */ this.getAttackedBy() != livingBase &&
|
||||
|
@ -1002,20 +995,20 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setItemInfo(CharacterInfo info) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
this.setItem(z, info.pickItem(z, this.rand));
|
||||
protected ItemStack pickItem() {
|
||||
return null;
|
||||
}
|
||||
int items = this.rand.zrange(4);
|
||||
ItemStack stack;
|
||||
this.extraInventory.clear();
|
||||
for(int z = 0; z < items; z++) {
|
||||
stack = info.pickItem(5, this.rand);
|
||||
if(stack == null) {
|
||||
break;
|
||||
|
||||
protected ItemStack pickArmor(int slot) {
|
||||
return null;
|
||||
}
|
||||
this.extraInventory.addStack(stack);
|
||||
|
||||
protected ItemStack pickLoot(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int pickItemAmount() {
|
||||
return this.rand.zrange(4);
|
||||
}
|
||||
|
||||
// public EntityNPC createChild(EntityLiving ageable)
|
||||
|
@ -1145,8 +1138,10 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
public abstract float getSpeciesBaseSize();
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.species.size;
|
||||
return this.getSpeciesBaseSize();
|
||||
}
|
||||
|
||||
public boolean isVisibleTo(EntityNPC player)
|
||||
|
@ -1154,7 +1149,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return this.connection == null || !this.connection.isInEditor();
|
||||
}
|
||||
|
||||
// public abstract Alignment getNaturalAlign(Random rand);
|
||||
// public abstract Alignment getNaturalAlign();
|
||||
|
||||
// public float getBaseSize(Random rand) {
|
||||
// return ;
|
||||
|
@ -1175,9 +1170,9 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return NameRegistry.FANTASY;
|
||||
}
|
||||
|
||||
public String pickRandomName(Random rand, Enum type)
|
||||
public String pickRandomName()
|
||||
{
|
||||
return this.getNameType().generate(rand, rand.chance(40) ? (rand.chance(15) ? 5 : 4) : (rand.chance() ? 3 : 2));
|
||||
return this.getNameType().generate(this.rand, this.rand.chance(40) ? (this.rand.chance(15) ? 5 : 4) : (this.rand.chance() ? 3 : 2));
|
||||
}
|
||||
|
||||
// public int getColor() {
|
||||
|
@ -3282,12 +3277,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
private void updateSize() {
|
||||
// ModelType model = this.getModel();
|
||||
// this.changeSize(this.getHeight() * this.species.renderer.width / this.species.renderer.height, this.getHeight());
|
||||
this.changeSize(this.getHeight() * this.species.renderer.width, this.getHeight() * this.species.renderer.height);
|
||||
this.changeSize(this.getHeight() / this.species.renderer.height * this.species.renderer.width, this.getHeight());
|
||||
}
|
||||
|
||||
public double getReachDistance()
|
||||
{
|
||||
return Math.max(1.5, 5.0 * (double)this.getHeight()); // / 1.8);
|
||||
return Math.max(1.5, 5.0 * (double)this.height / 1.8);
|
||||
}
|
||||
|
||||
public float getRenderScale()
|
||||
|
@ -3297,12 +3292,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
protected void handleJumpLava()
|
||||
{
|
||||
this.motionY += 0.03999999910593033D * (this.getHeight() * 1.8f + 2.2f) / 4.0f;
|
||||
this.motionY += 0.03999999910593033D * (this.height /* this.getHeight() * 1.8f */ + 2.2f) / 4.0f;
|
||||
}
|
||||
|
||||
protected float getJumpUpwardsMotion()
|
||||
{
|
||||
return 0.42F * (this.getHeight() * 1.8f + 2.2f) / 4.0f;
|
||||
return 0.42F * (this.height /* this.getHeight() * 1.8f */ + 2.2f) / 4.0f;
|
||||
}
|
||||
|
||||
public void setAIMoveSpeed(float speedIn)
|
||||
|
@ -3476,7 +3471,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// align = this.getNaturalAlign(this.rand);
|
||||
// }
|
||||
this.setAlignment(align);
|
||||
this.setHeight(tagCompund.hasKey("Height", 5) ? tagCompund.getFloat("Height") : (this.isPlayer() ? this.getBaseSize(this.rand) / this.species.renderer.height * this.species.size : this.getBaseSize(this.rand)));
|
||||
this.setManaPoints(tagCompund.getInteger("Mana"));
|
||||
Enum type = null;
|
||||
if(tagCompund.hasKey("ClassType", 8) && this.species != null && this.species.classEnum != null) {
|
||||
|
@ -3489,6 +3483,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// }
|
||||
}
|
||||
this.setNpcClass(type);
|
||||
this.setHeight(tagCompund.hasKey("Height", 5) ? tagCompund.getFloat("Height") : this.getBaseSize());
|
||||
|
||||
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
|
||||
|
||||
|
@ -4336,11 +4331,11 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public String getName()
|
||||
{
|
||||
if(this.isPlayer())
|
||||
return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : "<?>");
|
||||
// if(this.isPlayer())
|
||||
// return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : "<?>");
|
||||
String text = this.getPrefix();
|
||||
// Enum cls = this.getNpcClass();
|
||||
if(text == null) {
|
||||
if(text == null || text.isEmpty()) {
|
||||
text = this.getTypeName();
|
||||
}
|
||||
else {
|
||||
|
@ -4358,11 +4353,11 @@ public abstract class EntityNPC extends EntityLiving
|
|||
{
|
||||
if(!this.isPlayer())
|
||||
return 1.62F * this.height / 1.8f;
|
||||
float f = 1.62F * this.getHeight(); // / 1.8f;
|
||||
float f = 1.62F * this.height / 1.8f; // this.getHeight(); // / 1.8f;
|
||||
|
||||
if (this.isSneaking())
|
||||
if (this.isSneakingVisually())
|
||||
{
|
||||
f -= 0.08F * this.getHeight(); // / 1.8f;
|
||||
f -= 0.08F * this.height / 1.8f; // this.getHeight(); // / 1.8f;
|
||||
}
|
||||
|
||||
return f;
|
||||
|
@ -4468,18 +4463,61 @@ public abstract class EntityNPC extends EntityLiving
|
|||
CharacterInfo info = (livingdata instanceof CharacterTypeData) ? ((CharacterTypeData)livingdata).character :
|
||||
this.species.pickCharacter(this.worldObj.rand);
|
||||
AlignmentData align = livingdata instanceof AlignmentData ? ((AlignmentData)livingdata) : null;
|
||||
this.setNpcClass(info.spclass == null ? null : info.spclass.type);
|
||||
this.setChar(info.skin);
|
||||
this.setCape(info.cape);
|
||||
this.setCustomNameTag(info.name.isEmpty() ? this.pickRandomName(this.rand, info.spclass == null ? null :
|
||||
info.spclass.type) : info.name);
|
||||
if(!this.isPlayer())
|
||||
this.setItemInfo(info);
|
||||
this.setAlignment(align != null ? align.alignment : this.getNaturalAlign(this.rand));
|
||||
this.setHeight(this.isPlayer() ? this.getBaseSize(this.rand) / this.species.renderer.height * this.species.size : this.getBaseSize(this.rand));
|
||||
this.setStats(info);
|
||||
if(align != null)
|
||||
this.setAlignment(align.alignment);
|
||||
return align != null ? align : new AlignmentData(this.alignment);
|
||||
}
|
||||
|
||||
public void setStats(NpcInfo info) {
|
||||
this.setNpcClass(info.type == null ? this.pickRandomClass() : info.type);
|
||||
this.setChar(info.skin != null ? info.skin : this.pickRandomTexture());
|
||||
this.setCape(info.cape != null ? info.cape : this.pickRandomAccessory());
|
||||
this.setCustomNameTag(info.name.isEmpty() ? this.pickRandomName() : info.name);
|
||||
this.setAlignment(info.align != null ? info.align : this.getNaturalAlign());
|
||||
this.setHeight(info.height > 0.0f ? info.height : this.getBaseSize());
|
||||
if(!this.isPlayer()) {
|
||||
if(info.items != null) {
|
||||
for(ItemStack stack : info.items) {
|
||||
if(stack.getItem() instanceof ItemArmor)
|
||||
this.setItem(1 + ((ItemArmor)stack.getItem()).armorType, stack);
|
||||
else if(stack.getItem().canBeWielded())
|
||||
this.setItem(0, stack);
|
||||
else
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setItem(0, this.pickItem());
|
||||
for(int z = 0; z < 4; z++) {
|
||||
this.setItem(z + 1, this.pickArmor(z));
|
||||
}
|
||||
int items = this.pickItemAmount();
|
||||
ItemStack stack;
|
||||
this.extraInventory.clear();
|
||||
for(int z = 0; z < items; z++) {
|
||||
stack = this.pickLoot(z);
|
||||
if(stack == null) {
|
||||
break;
|
||||
}
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String pickRandomTexture() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String pickRandomAccessory() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Enum pickRandomClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean interactFirst(EntityNPC playerIn)
|
||||
{
|
||||
return !this.isPlayer() && super.interactFirst(playerIn);
|
||||
|
@ -4552,7 +4590,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public void setScaleForAge() {
|
||||
if(!this.isPlayer())
|
||||
this.setScale((float)((int)(100.0f * this.getHeight() * (this.getGrowingAge() < 0 ? 1.0f +
|
||||
this.setScale((float)((int)(100.0f * (this.getHeight() / this.getSpeciesBaseSize()) * (this.getGrowingAge() < 0 ? 1.0f +
|
||||
((float)Math.max(-24000, this.getGrowingAge()) / 24000.0f) * 0.6f : 1.0f))) / 100.0f);
|
||||
}
|
||||
|
||||
|
@ -4632,7 +4670,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// return 20;
|
||||
// }
|
||||
|
||||
public abstract Alignment getNaturalAlign(Random rand); // {
|
||||
public abstract Alignment getNaturalAlign(); // {
|
||||
// return Alignment.NEUTRAL;
|
||||
// }
|
||||
|
||||
|
@ -4640,12 +4678,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return !this.isPlayer() && this.getGrowingAge() <= -14000;
|
||||
}
|
||||
|
||||
public final float getBaseSize(Random rand) {
|
||||
return /* this.isPlayer() ? 1.8f : ( */ (this.getEntityBaseSize() + this.getHeightDeviation(rand)) / this.species.size; // );
|
||||
public final float getBaseSize() {
|
||||
return this.getEntityBaseSize() + this.getHeightDeviation(this.rand);
|
||||
}
|
||||
|
||||
public int getCurrentSize() {
|
||||
return (int)(this.species.renderer.height * this.getHeight() * 100.0f + 0.5f);
|
||||
return (int)(this.getHeight() * 100.0f + 0.5f);
|
||||
}
|
||||
|
||||
public int getDefaultSize() {
|
||||
|
@ -4675,12 +4713,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public LayerExtra getExtrasLayer()
|
||||
{
|
||||
return this.isPlayer() ? EntityTexManager.getLayer(this.getId(), this.species.renderer) : EntityTexManager.getNpcLayer(this.getChar(), this.species.renderer);
|
||||
return EntityTexManager.getLayer(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
|
||||
}
|
||||
|
||||
public String getLocationSkin()
|
||||
{
|
||||
return this.isPlayer() ? EntityTexManager.getSkin(this.getId(), this.species.renderer) : EntityTexManager.getNpcSkin(this.getChar(), this.species.renderer);
|
||||
return EntityTexManager.getSkin(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
|
||||
}
|
||||
|
||||
public void sendDeathMessage() {
|
||||
|
|
|
@ -54,7 +54,11 @@ public class EntityOrc extends EntityNPC {
|
|||
return 0.3f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.9f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import game.world.World;
|
|||
|
||||
public class EntityPrimarch extends EntityMobNPC {
|
||||
public static enum Founding implements IStringSerializable {
|
||||
OTHER("other", 0, 0x000000, 0x000000),
|
||||
OTHER("other", "", 0, 0x000000, 0x000000),
|
||||
DARK_ANGELS("darkangel", "Dark Angels", 1, 0xaf0000, 0x400000, "Lion El'Jonson:lion_el_jonson", 2.65f, 850, Alignment.GOOD),
|
||||
UNKNOWN_A("unkna", 2, 0xaf0000, 0x400000),
|
||||
UNKNOWN_A("unkna", "[Legion 2]", 2, 0xaf0000, 0x400000),
|
||||
EMPERORS_CHILDREN("emperorchild", "Emperors Children", 3, 0xaf0000, 0x400000, "Fulgrim", 2.65f, 1250, Alignment.NEUTRAL),
|
||||
IRON_WARRIORS("ironwarrior", "Iron Warriors", 4, 0xaf0000, 0x400000, "Perturabo", 2.65f, 450, Alignment.NEUTRAL),
|
||||
WHITE_SCARS("whitescar", "White Scars", 5, 0xaf0000, 0x400000, "Jaghatai Khan", 2.65f, 850, Alignment.NEUTRAL),
|
||||
|
@ -22,7 +22,7 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
NIGHT_LORDS("nightlord", "Night Lords", 8, 0xaf0000, 0x400000, "Konrad Curze", 2.65f, 850, Alignment.NEUTRAL),
|
||||
BLOOD_ANGELS("bloodangel", "Blood Angels", 9, 0xaf0000, 0x400000, "Sanguinius", 2.65f, 850, Alignment.CHAOTIC_GOOD),
|
||||
IRON_HANDS("ironhand", "Iron Hands", 10, 0xaf0000, 0x400000, "Ferrus Manus", 2.65f, 850, Alignment.NEUTRAL),
|
||||
UNKNOWN_B("unknb", 11, 0xaf0000, 0x400000),
|
||||
UNKNOWN_B("unknb", "[Legion 11]", 11, 0xaf0000, 0x400000),
|
||||
WORLD_EATERS("worldeater", "World Eaters", 12, 0xaf0000, 0x400000, "Angron", 2.65f, 850, Alignment.NEUTRAL),
|
||||
ULTRAMARINES("ultramarine", "Ultramarines", 13, 0xaf0000, 0x400000, "Roboute Guilliman", 2.65f, 850, Alignment.NEUTRAL),
|
||||
DEATH_GUARD("deathguard", "Death Guard", 14, 0xaf0000, 0x400000, "Mortarion", 2.65f, 850, Alignment.NEUTRAL),
|
||||
|
@ -59,8 +59,8 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
primarchs.clear();
|
||||
}
|
||||
|
||||
private Founding(String name, int num, int color1, int color2) {
|
||||
this(name, "???", num, color1, color2, null, 2.65f, 850, Alignment.NEUTRAL);
|
||||
private Founding(String name, String display, int num, int color1, int color2) {
|
||||
this(name, display, num, color1, color2, null, 2.65f, 850, Alignment.NEUTRAL);
|
||||
}
|
||||
|
||||
private Founding(String name, String display, int num, int color1, int color2, String primarch, float psize, int phealth,
|
||||
|
@ -125,6 +125,10 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
// return 0;
|
||||
// }
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.65f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getFounding().size;
|
||||
}
|
||||
|
@ -133,7 +137,7 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
// return 0.0f; // rand.frange(0.0f, 0.5f);
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return this.getFounding().align;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,11 @@ public class EntitySlime extends EntityNPC
|
|||
return 3.0f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@ import java.util.List;
|
|||
import game.collect.Lists;
|
||||
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.init.Items;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
public class EntitySpaceMarine extends EntityNPC {
|
||||
public static enum Legion implements IStringSerializable {
|
||||
OTHER("other", "???", 0x000000, 0x000000, 2.15f, 200),
|
||||
OTHER("other", null, 0x000000, 0x000000, 2.15f, 200),
|
||||
BLACK_TEMPLARS("blacktemplar", "Black Templars", 0x101010, 0xc0c0c0, 2.43f, 300, "black_templar");
|
||||
|
||||
public static final Object[] MARINES;
|
||||
|
@ -42,7 +44,7 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
|
||||
private Legion(String name, String display, int color1, int color2, float size, int health, String ... classes) {
|
||||
this.name = name;
|
||||
this.display = display + " Einheit";
|
||||
this.display = display == null ? "" : display + " Einheit";
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.size = size;
|
||||
|
@ -76,11 +78,15 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
return this.getLegion().health;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.15f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getLegion().size;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
|
@ -115,4 +121,8 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.boltgun), null, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.Items;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -48,7 +50,11 @@ public class EntitySpirit extends EntityNPC {
|
|||
return 0.1f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.65f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_GOOD, Alignment.GOOD);
|
||||
}
|
||||
|
||||
|
@ -77,6 +83,10 @@ public class EntitySpirit extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.snowball), null, 5);
|
||||
}
|
||||
|
||||
// public boolean canAmbush(EntityLiving entity) {
|
||||
// return true;
|
||||
// }
|
||||
|
|
|
@ -53,7 +53,11 @@ public class EntityTiefling extends EntityMobNPC {
|
|||
return 0.4f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL, Alignment.LAWFUL_EVIL,
|
||||
Alignment.NEUTRAL, Alignment.LAWFUL, Alignment.CHAOTIC);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import game.ai.EntityAIAvoidEntity;
|
|||
import game.entity.animal.EntityWolf;
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
import game.world.WorldServer;
|
||||
|
@ -96,7 +98,11 @@ public class EntityUndead extends EntityNPC
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.EVIL;
|
||||
}
|
||||
|
||||
|
@ -111,4 +117,8 @@ public class EntityUndead extends EntityNPC
|
|||
public boolean arePotionsInverted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.bow), null, 10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,11 @@ public class EntityVampire extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL, Alignment.CHAOTIC, Alignment.NEUTRAL, Alignment.CHAOTIC_GOOD);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -54,7 +56,11 @@ public class EntityWoodElf extends EntityNPC {
|
|||
return 0.25f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.75f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(5) ? (rand.chance(5) ? Alignment.CHAOTIC : Alignment.NEUTRAL) : Alignment.LAWFUL;
|
||||
}
|
||||
|
||||
|
@ -65,4 +71,8 @@ public class EntityWoodElf extends EntityNPC {
|
|||
public boolean canAmbush(EntityLiving entity) {
|
||||
return (float)this.getHealth() >= ((float)this.getMaxHealth() / 3.0f);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(null, new ItemStack(Items.bow), 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,7 +317,11 @@ public class EntityZombie extends EntityNPC
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
23
java/src/game/entity/npc/NpcInfo.java
Normal file
23
java/src/game/entity/npc/NpcInfo.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.item.ItemStack;
|
||||
|
||||
public class NpcInfo {
|
||||
public final Enum type;
|
||||
public final String name;
|
||||
public final String skin;
|
||||
public final String cape;
|
||||
public final Alignment align;
|
||||
public final float height;
|
||||
public final ItemStack[] items;
|
||||
|
||||
public NpcInfo(Enum type, String name, String skin, String cape, Alignment align, float height, ItemStack ... items) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.cape = cape;
|
||||
this.align = align;
|
||||
this.height = height;
|
||||
this.items = items;
|
||||
}
|
||||
}
|
|
@ -1,37 +1,19 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import game.collect.BiMap;
|
||||
import game.collect.HashBiMap;
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.init.SpeciesRegistry.ModelType;
|
||||
import game.item.Item;
|
||||
import game.item.ItemArmor;
|
||||
import game.item.ItemBow;
|
||||
import game.item.ItemGunBase;
|
||||
import game.item.ItemHoe;
|
||||
import game.item.ItemShears;
|
||||
import game.item.ItemStack;
|
||||
import game.item.ItemSword;
|
||||
import game.item.ItemTool;
|
||||
import game.item.RngLoot;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class SpeciesInfo {
|
||||
public final Map<Enum, ClassInfo> classmap;
|
||||
public final BiMap<String, Enum> classnames;
|
||||
public final Class<? extends EntityNPC> clazz;
|
||||
public final Class<? extends Enum> classEnum;
|
||||
public final ModelType renderer;
|
||||
public final float size;
|
||||
public final boolean prefix;
|
||||
public final String id;
|
||||
public final String origin;
|
||||
|
@ -39,46 +21,45 @@ public class SpeciesInfo {
|
|||
public final int color1;
|
||||
public final int color2;
|
||||
public final CharacterInfo[] chars;
|
||||
public final ClassInfo[] classes;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
private final int[] alignment = new int[Alignment.values().length];
|
||||
private final int[] energies = new int[Energy.values().length];
|
||||
private final int[] baseEnergy = new int[Energy.values().length];
|
||||
|
||||
public SpeciesInfo(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix, String origin, String name, ModelType renderer, float size, int color1, int color2,
|
||||
public SpeciesInfo(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix, String origin, String name, ModelType renderer, int color1, int color2,
|
||||
Object ... names) {
|
||||
this.classmap = classEnum == null ? null : Maps.newEnumMap(classEnum);
|
||||
this.classnames = classEnum == null ? null : HashBiMap.create();
|
||||
this.clazz = clazz; // name.toLowerCase().replace(' ', '_');
|
||||
this.clazz = clazz;
|
||||
this.classEnum = classEnum;
|
||||
this.renderer = renderer;
|
||||
this.size = size;
|
||||
this.prefix = prefix;
|
||||
this.id = id; // clazz.getSimpleName().substring(6);
|
||||
this.id = id;
|
||||
this.origin = origin;
|
||||
this.name = name;
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
List<CharacterInfo> chars = Lists.<CharacterInfo>newArrayList();
|
||||
List<ClassInfo> classes = Lists.<ClassInfo>newArrayList();
|
||||
ClassInfo spclass = null;
|
||||
Enum ctype = null;
|
||||
Alignment align = null;
|
||||
float height = 0.0f;
|
||||
for(int z = 0; z < names.length; z++) {
|
||||
if(names[z] == null) {
|
||||
spclass = null;
|
||||
ctype = null;
|
||||
align = null;
|
||||
height = 0.0f;
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Enum) {
|
||||
classes.add(spclass = new ClassInfo(this, (Enum)names[z]));
|
||||
ctype = (Enum)names[z];
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Alignment) {
|
||||
align = (Alignment)names[z];
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Float) {
|
||||
height = (Float)names[z];
|
||||
continue;
|
||||
}
|
||||
// String id = ((String)names[z]);
|
||||
// if(id.startsWith("$")) {
|
||||
// id = id.substring(1);
|
||||
// spclass = id.isEmpty() ? null : new ClassInfo(this, Enum.valueOf(this.classEnum, id.toUpperCase()));
|
||||
// if(spclass != null)
|
||||
// classes.add(spclass);
|
||||
// continue;
|
||||
// }
|
||||
String[] tok = ((String)names[z]).split(":", 3);
|
||||
int scolor1 = color1;
|
||||
int scolor2 = color2;
|
||||
|
@ -88,16 +69,10 @@ public class SpeciesInfo {
|
|||
scolor1 = scolor2;
|
||||
scolor2 = ((Integer)names[++z]).intValue();
|
||||
}
|
||||
chars.add(new CharacterInfo(this, spclass, tok[0], tok.length > 1 && !tok[1].isEmpty() ? tok[1] : (tok[0].isEmpty() ? this.id : tok[0]).toLowerCase().replace(' ', '_'),
|
||||
tok.length > 2 ? tok[2] : "", scolor1, scolor2, names.length > 1));
|
||||
chars.add(new CharacterInfo(this, ctype, tok[0], tok.length > 1 && !tok[1].isEmpty() ? tok[1] : (tok[0].isEmpty() ? this.id : tok[0]).toLowerCase().replace(' ', '_'),
|
||||
tok.length > 2 ? tok[2] : "", align, height, scolor1, scolor2, names.length > 1));
|
||||
}
|
||||
this.chars = chars.toArray(new CharacterInfo[chars.size()]);
|
||||
this.classes = classes.toArray(new ClassInfo[classes.size()]);
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
// SpeciesRegistry.SPECIES.put(this.id, this);
|
||||
SpeciesRegistry.CLASSES.put(this.clazz, this);
|
||||
if(this.classEnum != null) {
|
||||
for(Enum type : this.classEnum.getEnumConstants()) {
|
||||
|
@ -110,96 +85,6 @@ public class SpeciesInfo {
|
|||
return rand.pick(this.chars);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public void addItems(Object[] items) {
|
||||
WeightedList<RngLoot>[] lists = this.items;
|
||||
int curSlot = -1;
|
||||
ItemStack item;
|
||||
int chance = 1;
|
||||
int min = 1;
|
||||
int max = 1;
|
||||
for(int z = 0; z < items.length; z++) {
|
||||
Object stack = items[z];
|
||||
if(stack == null) {
|
||||
item = null;
|
||||
}
|
||||
else if(stack instanceof String) {
|
||||
String name = (String)stack;
|
||||
if(name.isEmpty()) {
|
||||
lists = this.items;
|
||||
continue;
|
||||
}
|
||||
if(name.startsWith("$")) {
|
||||
name = name.substring(1);
|
||||
Enum type = this.classnames.get(name);
|
||||
if(type == null) {
|
||||
throw new IllegalArgumentException("Item [" + z + "/" + name + "] is not a known class");
|
||||
}
|
||||
ClassInfo ci = this.classmap.get(type);
|
||||
// for(int c = 0; c < this.classes.length; c++) {
|
||||
// if(this.classnames.get(this.classes[c].type).equalsIgnoreCase(name)) {
|
||||
// ci = this.classes[c];
|
||||
// }
|
||||
// }
|
||||
lists = ci.getItems();
|
||||
continue;
|
||||
}
|
||||
CharacterInfo ch = null;
|
||||
for(int c = 0; c < this.chars.length; c++) {
|
||||
if(!this.chars[c].name.isEmpty() && this.chars[c].name.equals(name)) {
|
||||
ch = this.chars[c];
|
||||
}
|
||||
}
|
||||
if(ch == null) {
|
||||
throw new IllegalArgumentException("Item [" + z + "/" + name + "] is not a known character");
|
||||
}
|
||||
lists = ch.getItems();
|
||||
continue;
|
||||
}
|
||||
else if(stack instanceof Integer) {
|
||||
int n = (Integer)stack;
|
||||
if(n <= 0)
|
||||
curSlot = -n;
|
||||
else
|
||||
chance = n;
|
||||
continue;
|
||||
}
|
||||
else if(stack instanceof ItemStack) {
|
||||
item = (ItemStack)stack;
|
||||
max = item.stackSize;
|
||||
item.stackSize = 1;
|
||||
}
|
||||
else if(stack instanceof Item) {
|
||||
item = new ItemStack((Item)stack);
|
||||
}
|
||||
else if(stack instanceof Block) {
|
||||
item = new ItemStack((Block)stack);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Item [" + z + "] has to be a stack, item, block or null");
|
||||
}
|
||||
int slot = curSlot;
|
||||
if(slot == -1 && item == null) {
|
||||
slot = 0;
|
||||
}
|
||||
else if(slot == -1) {
|
||||
slot = ItemArmor.getArmorPosition(item);
|
||||
if(slot == 0 && !(item.getItem() instanceof ItemTool || item.getItem() instanceof ItemSword || item.getItem() instanceof ItemBow ||
|
||||
item.getItem() instanceof ItemHoe || item.getItem() instanceof ItemShears || item.getItem() instanceof ItemGunBase)) {
|
||||
slot = 5;
|
||||
}
|
||||
}
|
||||
lists[slot].add(new RngLoot(item, min, max, chance));
|
||||
curSlot = -1;
|
||||
chance = 1;
|
||||
min = 1;
|
||||
max = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public SpeciesInfo setEnergy(Energy type, int affinity, int base) {
|
||||
this.energies[type.ordinal()] = affinity;
|
||||
this.baseEnergy[type.ordinal()] = base;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.lwjgl.opengl.GL13;
|
|||
|
||||
import game.Game;
|
||||
import game.Game.FileMode;
|
||||
import game.collect.Lists;
|
||||
import game.dimension.DimType;
|
||||
import game.dimension.Dimension;
|
||||
import game.entity.npc.Alignment;
|
||||
|
@ -44,17 +45,22 @@ import game.network.Player;
|
|||
import game.packet.CPacketAction;
|
||||
import game.packet.CPacketMessage;
|
||||
import game.packet.CPacketSkin;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.renderer.entity.RenderManager;
|
||||
import game.renderer.texture.EntityTexManager;
|
||||
import game.renderer.texture.TextureUtil;
|
||||
import game.rng.Random;
|
||||
import game.util.Displayable;
|
||||
import game.util.FileCallback;
|
||||
import game.util.FileUtils;
|
||||
import game.util.SkinConverter;
|
||||
import game.util.Util;
|
||||
import game.vars.CVarCategory;
|
||||
import game.vars.EnumVar;
|
||||
import game.vars.EnumVar.EnumFunction;
|
||||
import game.vars.Variable;
|
||||
import game.window.Button;
|
||||
|
||||
public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
||||
|
@ -74,11 +80,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.charinfo = charinfo;
|
||||
this.id = id;
|
||||
this.model = model;
|
||||
if(this.skinFile != null)
|
||||
if(this.skinFile != null) {
|
||||
this.skinImage = image;
|
||||
else
|
||||
this.skinImage = null;
|
||||
if(this.skinImage != null) {
|
||||
int w = this.skinImage.getWidth();
|
||||
int h = this.skinImage.getHeight();
|
||||
int[] data = new int[w * h];
|
||||
|
@ -87,6 +90,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
EntityTexManager.setTexture(this.dynId, EntityTexManager.imageToComp(data, model), model);
|
||||
}
|
||||
else {
|
||||
this.skinImage = null;
|
||||
this.dynId = -1;
|
||||
}
|
||||
}
|
||||
|
@ -94,16 +98,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
String str =
|
||||
(this.skinFile != null ? this.skinFile.getName()
|
||||
: (this.charinfo == null ? "Standard" : (
|
||||
(this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ?
|
||||
this.charinfo.spclass.type.toString() :
|
||||
(this.skinFile != null ? this.skinFile.getName() : (
|
||||
(this.charinfo.species.prefix && this.charinfo.type != null && !this.charinfo.type.toString().isEmpty() ?
|
||||
this.charinfo.type.toString() :
|
||||
EntityRegistry.getEntityName(this.charinfo.species.id))
|
||||
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)))));
|
||||
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name))));
|
||||
|
||||
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
|
||||
(this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2));
|
||||
if(this.skinFile == null && this.charinfo != null)
|
||||
0xffffff : this.charinfo.color1 | this.charinfo.color2));
|
||||
if(this.charinfo != null)
|
||||
Drawing.drawText(this.charinfo.skin, x + 64 + 3, y + 18, 0xffc0c0c0);
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -111,18 +114,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
if (hovered)
|
||||
Drawing.drawRect(x, y, 64, 64, -1601138544);
|
||||
|
||||
if (this.dynId != -1)
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.model));
|
||||
}
|
||||
else if(this.charinfo == null)
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getDefault(this.model));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getNpcSkin(this.charinfo.skin, this.model));
|
||||
}
|
||||
this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.charinfo != null ? this.charinfo.skin : null, this.model));
|
||||
}
|
||||
|
||||
protected void drawTextureAt(int x, int y, String tex)
|
||||
|
@ -152,39 +144,31 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
BufferedImage img = this.skinImage;
|
||||
if(this.charinfo != null) {
|
||||
try {
|
||||
img = TextureUtil.readImage(FileUtils.getResource(
|
||||
EntityNPC.getSkinTexture(this.charinfo.skin)));
|
||||
}
|
||||
catch(IOException e) {
|
||||
if(e instanceof FileNotFoundException)
|
||||
Log.JNI.warn("Textur für Skin ist nicht vorhanden: " +
|
||||
EntityNPC.getSkinTexture(this.charinfo.skin));
|
||||
else
|
||||
Log.JNI.error(e, "Konnte Textur nicht laden");
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuiChar.this.templateButton.enabled = this.canCopy();
|
||||
GuiChar.this.selectSkin(img, this.model);
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return this.skinFile;
|
||||
// BufferedImage img = this.skinImage;
|
||||
// if(this.charinfo != null) {
|
||||
// try {
|
||||
// img = TextureUtil.readImage(FileUtils.getResource(
|
||||
// EntityNPC.getSkinTexture(this.charinfo.skin)));
|
||||
// }
|
||||
// catch(IOException e) {
|
||||
// if(e instanceof FileNotFoundException)
|
||||
// Log.JNI.warn("Textur für Skin ist nicht vorhanden: " +
|
||||
// EntityNPC.getSkinTexture(this.charinfo.skin));
|
||||
// else
|
||||
// Log.JNI.error(e, "Konnte Textur nicht laden");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
GuiChar.this.templateButton.enabled = this.charinfo != null;
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
GuiChar.this.currentSkin = this.skinFile != null ? this.skinFile.getName() : this.charinfo.skin;
|
||||
GuiChar.this.waiting = false;
|
||||
}
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return this.charinfo == null ? null : this.charinfo.skin;
|
||||
}
|
||||
|
||||
public boolean canCopy()
|
||||
{
|
||||
return this.charinfo != null;
|
||||
}
|
||||
}
|
||||
|
||||
private class DragAdjust extends Element {
|
||||
|
@ -221,7 +205,35 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
public static enum FilterType implements IStringSerializable, Displayable {
|
||||
ALL("all", "Alle anzeigen"), CUSTOM("custom", "Nur eigene"), NPC("preset", "Nur vorgegebene"), SPECIES("species", "Nur Spezies"), SPECIES_CUSTOM("species_custom", "Spezies und eigene");
|
||||
|
||||
private final String name;
|
||||
private final String display;
|
||||
|
||||
private FilterType(String name, String display) {
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FilterFunction implements EnumFunction<FilterType> {
|
||||
public void apply(EnumVar cv, FilterType value) {
|
||||
if(Game.getGame().open instanceof GuiChar)
|
||||
Game.getGame().displayGuiScreen(Game.getGame().open);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiChar INSTANCE = new GuiChar();
|
||||
private static final File TEXTURE_FOLDER = new File("skins");
|
||||
|
||||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
|
@ -231,6 +243,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
private float pitch = -15.0f;
|
||||
private boolean waiting = true;
|
||||
private int dimension;
|
||||
private String currentSkin;
|
||||
|
||||
@Variable(name = "char_filter_species", category = CVarCategory.GUI, display = "Filtern", callback = FilterFunction.class, switched = true)
|
||||
private FilterType filterSpecies = FilterType.ALL;
|
||||
|
||||
private GuiChar() {
|
||||
}
|
||||
|
@ -245,12 +261,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.adjust = null;
|
||||
return;
|
||||
}
|
||||
this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel());
|
||||
this.currentSkin = this.gm.thePlayer != null && !EntityTexManager.hasCustomSkin(this.gm.thePlayer.getId()) ? this.gm.thePlayer.getChar() : null;
|
||||
this.load(this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.thePlayer != null ? this.gm.thePlayer.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
|
||||
this.add(new ActButton(4, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", new File("skins"), new FileCallback() {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, new File("skins"), false))
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false))
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
}
|
||||
});
|
||||
|
@ -258,14 +275,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}, "Importieren: Standard"));
|
||||
this.add(new ActButton(202, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", new File("skins"), new FileCallback() {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, new File("skins"), true))
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true))
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Importieren: Schlank"));
|
||||
this.addSelector("char_filter_species", 400, 4, 300, 24);
|
||||
this.add(new ActButton(4, height - 28, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
|
@ -276,10 +294,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
SkinEntry skin = GuiChar.this.getSelected();
|
||||
if(skin != null && skin.getLocation() != null) {
|
||||
String loc = skin.getLocation();
|
||||
File file = new File(new File("skins"), loc + ".png");
|
||||
File file = new File(TEXTURE_FOLDER, loc + ".png");
|
||||
int z = 1;
|
||||
while(file.exists()) {
|
||||
file = new File(new File("skins"), loc + "_" + (++z) + ".png");
|
||||
file = new File(TEXTURE_FOLDER, loc + "_" + (++z) + ".png");
|
||||
}
|
||||
InputStream in = null;
|
||||
try {
|
||||
|
@ -307,8 +325,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}, "Vorlage kopieren"));
|
||||
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
|
||||
|
||||
this.add(new Label(width - 396, 36, 392, 20, this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name, true));
|
||||
this.add(new Label(width - 396, 36, 392, 20, "Spezies: " + (this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name), true));
|
||||
this.add(new NavButton(width - 396, 56, 392, 24, GuiSpecies.INSTANCE, "Spezies ändern"));
|
||||
this.add(new Label(width - 396, 36 + 92, 392, 20, "Klasse: " + (this.gm.thePlayer == null || this.gm.thePlayer.getSpecies().classEnum == null || this.gm.thePlayer.getNpcClass() == null || this.gm.thePlayer.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.thePlayer.getNpcClass().toString()), true))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
this.add(new NavButton(width - 396, 56 + 92, 392, 24, GuiClass.INSTANCE, "Klasse ändern"))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
|
||||
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
|
||||
for (int z = 0; z < Alignment.values().length; z++)
|
||||
|
@ -398,11 +420,6 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.setDimButton();
|
||||
}
|
||||
|
||||
public void selectSkin(BufferedImage img, ModelType model)
|
||||
{
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model));
|
||||
}
|
||||
|
||||
private void setDimButton() {
|
||||
Dimension dim = UniverseRegistry.getBaseDimensions().get(this.dimension);
|
||||
this.dimButton.setText((dim.getType() == DimType.PLANET ? "Heimplanet" : "Heimdimension") + ": " + dim.getFormattedName(false));
|
||||
|
@ -457,19 +474,20 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
return img;
|
||||
}
|
||||
|
||||
public void load(String currentSkin, ModelType model)
|
||||
public void load(ModelType model, SpeciesInfo speciesOnly)
|
||||
{
|
||||
this.unload();
|
||||
File[] files = new File("skins").listFiles(new FileFilter() {
|
||||
TEXTURE_FOLDER.mkdirs();
|
||||
File[] files = this.filterSpecies == FilterType.NPC || this.filterSpecies == FilterType.SPECIES ? null : TEXTURE_FOLDER.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.isFile() && pathname.getName().endsWith(".png");
|
||||
}
|
||||
});
|
||||
int pos = 0;
|
||||
this.elements.add(new SkinEntry("default", null, null, null, model));
|
||||
if("default".equals(currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
// this.elements.add(new SkinEntry("default", null, null, null, model));
|
||||
// if("default".equals(currentSkin))
|
||||
// this.setSelected(pos);
|
||||
// pos++;
|
||||
if(files != null) {
|
||||
Arrays.sort(files);
|
||||
for(File file : files)
|
||||
|
@ -478,18 +496,20 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
if(img != null) {
|
||||
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
|
||||
this.elements.add(new SkinEntry(file.getName(), file, null, img, model));
|
||||
if(file.getName().equals(currentSkin))
|
||||
if(file.getName().equals(this.currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
|
||||
if(this.filterSpecies == FilterType.CUSTOM)
|
||||
return;
|
||||
for(SpeciesInfo species : this.filterSpecies == FilterType.SPECIES || this.filterSpecies == FilterType.SPECIES_CUSTOM ? Lists.newArrayList(speciesOnly) : SpeciesRegistry.SPECIMEN) {
|
||||
for(CharacterInfo charinfo : species.chars) {
|
||||
if(charinfo.species.renderer == model) {
|
||||
this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer));
|
||||
if(charinfo.skin.equals(currentSkin))
|
||||
if(charinfo.skin.equals(this.currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
}
|
||||
|
|
77
java/src/game/gui/character/GuiClass.java
Normal file
77
java/src/game/gui/character/GuiClass.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package game.gui.character;
|
||||
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.ActButton.Mode;
|
||||
import game.gui.element.GuiList;
|
||||
import game.gui.element.ListEntry;
|
||||
import game.gui.element.NavButton;
|
||||
import game.packet.CPacketAction;
|
||||
import game.renderer.Drawing;
|
||||
|
||||
public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.Callback
|
||||
{
|
||||
protected class ClassEntry implements ListEntry
|
||||
{
|
||||
private final Enum clazz;
|
||||
|
||||
protected ClassEntry(Enum clazz)
|
||||
{
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(GuiClass.this.gm.thePlayer != null && this.clazz == GuiClass.this.gm.thePlayer.getNpcClass())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.clazz.toString().isEmpty() ? "<Keine>" : this.clazz.toString(), x + 3, y, 0xffffffff);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if((GuiClass.this.selectButton.enabled = GuiClass.this.gm.thePlayer == null || this.clazz != GuiClass.this.gm.thePlayer.getNpcClass()) && dclick)
|
||||
GuiClass.this.use(GuiClass.this.selectButton, Mode.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiClass INSTANCE = new GuiClass();
|
||||
|
||||
private ActButton selectButton;
|
||||
|
||||
private GuiClass() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(400, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
if(this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null)
|
||||
for(Enum clazz : this.gm.thePlayer.getSpecies().classEnum.getEnumConstants()) {
|
||||
this.elements.add(new ClassEntry(clazz));
|
||||
}
|
||||
this.add(new NavButton(width - 198 * 2, height - 28, 194, 24, GuiChar.INSTANCE, "Zurück"));
|
||||
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 24, this, "Klasse ändern"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Klasse wählen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 44 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, Mode action) {
|
||||
ClassEntry entry = this.getSelected();
|
||||
if(entry != null && GuiClass.this.gm.thePlayer != null) {
|
||||
GuiClass.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
|
||||
this.gm.displayGuiScreen(GuiChar.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
|
|||
if(GuiSpecies.this.gm.thePlayer != null && this.species == GuiSpecies.this.gm.thePlayer.getSpecies())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2);
|
||||
if(this.species.classEnum != null)
|
||||
Drawing.drawText(this.species.classEnum.getEnumConstants().length + " Klassen", x + 3, y + 18, 0xffc0c0c0);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
|
|
|
@ -115,6 +115,7 @@ public abstract class GuiContainer extends Gui
|
|||
private float currentScroll;
|
||||
private boolean isScrolling;
|
||||
private boolean wasClicking;
|
||||
private ItemStack cheatStack;
|
||||
|
||||
public void drawString(String text, int x, int y) {
|
||||
x = x * 2 + this.container_x;
|
||||
|
@ -175,6 +176,7 @@ public abstract class GuiContainer extends Gui
|
|||
public void init(int width, int height) {
|
||||
this.itemRender = this.gm.getRenderItem();
|
||||
this.tooltip = null;
|
||||
this.cheatStack = null;
|
||||
// this.width = width;
|
||||
// this.height = height;
|
||||
// this.initialize(this.gm.getGame());
|
||||
|
@ -361,6 +363,8 @@ public abstract class GuiContainer extends Gui
|
|||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
InventoryPlayer inventoryplayer = this.gm.thePlayer.inventory;
|
||||
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||
if(this.gm.itemCheat)
|
||||
itemstack = itemstack == null ? this.cheatStack : itemstack;
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
|
@ -383,6 +387,9 @@ public abstract class GuiContainer extends Gui
|
|||
s = "" + TextColor.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
else if(itemstack == this.cheatStack) {
|
||||
s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.stackSize);
|
||||
}
|
||||
|
||||
this.drawItemStack(itemstack, mouseX - j2, mouseY - k2, s);
|
||||
}
|
||||
|
@ -406,7 +413,7 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
// SKC.glPopMatrix();
|
||||
|
||||
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
if (inventoryplayer.getItemStack() == null && this.cheatStack == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = this.theSlot.getStack();
|
||||
this.renderToolTip(itemstack1, mouseX, mouseY);
|
||||
|
@ -635,9 +642,17 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
if(this.gm == null)
|
||||
return;
|
||||
if(mouseButton == 0) {
|
||||
if(this.clickSide(mouseX, mouseY, -1))
|
||||
if(this.cheatStack != null) {
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.thePlayer != null && slot.inventory == this.gm.thePlayer.inventory)
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1));
|
||||
if(mouseButton != 1 && !this.gm.ctrl())
|
||||
this.cheatStack = null;
|
||||
return;
|
||||
}
|
||||
if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(mouseX, mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2))
|
||||
return;
|
||||
if(mouseButton == 0) {
|
||||
if(this.gm.itemCheat && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) {
|
||||
for (CheatTab tab : CheatTab.values())
|
||||
{
|
||||
|
@ -757,7 +772,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void mouseDragged(int mouseX, int mouseY)
|
||||
{
|
||||
if(this.gm == null)
|
||||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack();
|
||||
|
@ -809,7 +824,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void mouseReleased(int mouseX, int mouseY, int state)
|
||||
{
|
||||
if(this.gm == null)
|
||||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
// int i = this.guiLeft;
|
||||
|
@ -1020,7 +1035,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void useHotbar(int slot)
|
||||
{
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
|
||||
{
|
||||
// for (int i = 0; i < 9; ++i)
|
||||
// {
|
||||
|
@ -1167,8 +1182,8 @@ public abstract class GuiContainer extends Gui
|
|||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
private boolean clickSide(int mouseX, int mouseY, int slot) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) {
|
||||
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null) {
|
||||
int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9;
|
||||
int j = (int)((double)(this.currentScroll * (float)i) + 0.5D);
|
||||
|
||||
|
@ -1182,7 +1197,13 @@ public abstract class GuiContainer extends Gui
|
|||
int i1 = sx + (sy + j) * 12;
|
||||
|
||||
if(i1 >= 0 && i1 < ITEM_LIST.size()) {
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, this.gm.ctrl()));
|
||||
if(slot >= 0 || instant) {
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
|
||||
}
|
||||
else {
|
||||
this.cheatStack = ITEM_LIST.get(i1).copy();
|
||||
this.cheatStack.stackSize = full ? this.cheatStack.getMaxStackSize() : 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ public enum MetalType {
|
|||
RADIUM("radium", 88, "Ra", "Radium", 6, 0.6f),
|
||||
URANIUM("uranium", 92, "U", "Uran", 7, 1.0f),
|
||||
NEPTUNIUM("neptunium", 93, "Np", "Neptunium", 8, 2.0f),
|
||||
PLUTONIUM("plutonium", 94, "Pu", "Plutonium", 9, 4.0f);
|
||||
PLUTONIUM("plutonium", 94, "Pu", "Plutonium", 9, 4.0f),
|
||||
|
||||
BLACK("black_metal", 666, "Bm", "Schwarzmetall", 5);
|
||||
|
||||
|
||||
public final int order;
|
||||
|
|
|
@ -11,9 +11,7 @@ public abstract class Registry {
|
|||
TileRegistry.register();
|
||||
CraftingRegistry.register();
|
||||
SmeltingRegistry.register();
|
||||
// StatRegistry.register();
|
||||
EntityRegistry.register();
|
||||
SpeciesRegistry.registerItems();
|
||||
DispenserRegistry.register();
|
||||
UniverseRegistry.register();
|
||||
RotationRegistry.register();
|
||||
|
|
|
@ -46,146 +46,96 @@ public abstract class SpeciesRegistry {
|
|||
HALFLING("halfling", 0.62f, 1.40f, 64, 52, "Winzling"),
|
||||
SPACE_MARINE("spacemarine", 1.3f, 3.1f, 128, 106, "Space Marine");
|
||||
|
||||
private static final Map<String, ModelType> LOOKUP = Maps.newHashMap();
|
||||
|
||||
public final float width;
|
||||
public final float height;
|
||||
public final int texWidth;
|
||||
public final int texHeight;
|
||||
public final String name;
|
||||
public final String display;
|
||||
|
||||
private ModelType(String name, float width, float height, int texWidth, int texHeight, String display) {
|
||||
this.name = name;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.texWidth = texWidth;
|
||||
this.texHeight = texHeight;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
// public String getIdString() {
|
||||
// return "modelType." + this.name;
|
||||
// }
|
||||
|
||||
public static ModelType getByName(String name) {
|
||||
ModelType type = LOOKUP.get(name.toLowerCase());
|
||||
return type == null ? HUMANOID : type;
|
||||
}
|
||||
|
||||
static {
|
||||
for(ModelType type : values()) {
|
||||
LOOKUP.put(type.name, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Map<String, ModelType> SKINS = Maps.newTreeMap();
|
||||
public static final Set<String> CAPES = Sets.newTreeSet();
|
||||
// public static final Map<String, SpeciesInfo> SPECIES = Maps.newHashMap();
|
||||
public static final Map<Class<? extends EntityNPC>, SpeciesInfo> CLASSES = Maps.newHashMap();
|
||||
// public static final List<CharacterInfo> CHARACTERS = Lists.<CharacterInfo>newArrayList();
|
||||
// public static final List<ClassInfo> SPCLASSES = Lists.<ClassInfo>newArrayList();
|
||||
public static final List<SpeciesInfo> SPECIMEN = Lists.<SpeciesInfo>newArrayList();
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, float size,
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name,
|
||||
int color1, int color2, Object ... names) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, size, color1, color2, names));
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, color1, color2, names));
|
||||
}
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, ModelType renderer,
|
||||
int color1, int color2) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, renderer, renderer.height, color1, color2, ""));
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, renderer, color1, color2, ""));
|
||||
}
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, ModelType renderer,
|
||||
float size, int color1, int color2) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, renderer, size, color1, color2, ""));
|
||||
}
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, float size, int color1,
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, String origin, String name, int color1,
|
||||
int color2) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, size, color1, color2, ""));
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, null, false, origin, name, ModelType.HUMANOID, color1, color2, ""));
|
||||
}
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, String origin,
|
||||
String name, float size, int color1, int color2, Object ... names) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, true, origin, name, ModelType.HUMANOID, size, color1, color2, names));
|
||||
String name, int color1, int color2, Object ... names) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, true, origin, name, ModelType.HUMANOID, color1, color2, names));
|
||||
}
|
||||
|
||||
private static void registerSpecies(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix,
|
||||
String origin, String name, ModelType renderer, float size, int color1, int color2, Object ... names) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, prefix, origin, name, renderer, size, color1, color2, names));
|
||||
}
|
||||
|
||||
private static void registerItems(Class<? extends EntityNPC> clazz, Object ... items) {
|
||||
CLASSES.get(clazz).addItems(items);
|
||||
String origin, String name, ModelType renderer, int color1, int color2, Object ... names) {
|
||||
SPECIMEN.add(new SpeciesInfo(id, clazz, classEnum, prefix, origin, name, renderer, color1, color2, names));
|
||||
}
|
||||
|
||||
static void register() {
|
||||
registerSpecies("Cpu", EntityCpu.class, null, "Test-NSC", 1.8f, 0x202020, 0x8000ff, "Sen", "Troll:trollface", "Hacker", "Herobrine");
|
||||
registerSpecies("Cultivator", EntityCultivator.class, "nienrath", "Kultivator", 1.85f, 0x000000, 0xff0000, "Wei Wuxian", 0x000000, 0xff0000,
|
||||
registerSpecies("Cpu", EntityCpu.class, null, "Test-NSC", 0x202020, 0x8000ff, "Sen", "Troll:trollface", "Hacker", "Herobrine");
|
||||
registerSpecies("Cultivator", EntityCultivator.class, "nienrath", "Kultivator", 0x000000, 0xff0000, "Wei Wuxian", 0x000000, 0xff0000,
|
||||
"Lan Wangji", 0xffffff, 0x80e0ff, "Jiang Cheng", 0x200000, 0xaf00ff, "Shen Qingqiu", 0xffffff, 0x80ff80,
|
||||
"Luo Binghe", 0x600000, 0x000000);
|
||||
registerSpecies("Metalhead", EntityMetalhead.class, "thedric", "Metalhead", 1.8f, 0x606060, 0xf0f0f0,
|
||||
registerSpecies("Metalhead", EntityMetalhead.class, "thedric", "Metalhead", 0x606060, 0xf0f0f0,
|
||||
":metalhead_1", ":metalhead_2", ":metalhead_3",
|
||||
":metalhead_4", ":metalhead_5", ":metalhead_6", ":metalhead_7", ":metalhead_8", ":metalhead_9", ":metalhead_10",
|
||||
":metalhead_11", ":metalhead_12", ":metalhead_13", ":metalhead_14");
|
||||
registerSpecies("Elf", EntityElf.class, "gharoth", "Elbe", 1.95f, 0x054100, 0xd2d2d2, ":highelf", "Thranduil", 0x82888b, 0xeae7bd);
|
||||
registerSpecies("WoodElf", EntityWoodElf.class, "gharoth", "Waldelbe", 1.75f, 0x054100, 0x00bb00);
|
||||
registerSpecies("BloodElf", EntityBloodElf.class, "kyroth", "Blutelbe", 1.9f, 0x054100, 0x960000, "::bloodelf");
|
||||
registerSpecies("Human", EntityHuman.class, EntityHuman.ClassType.class, "terra", "NSC", 1.8f, 0x4f7d9a, 0x034c7a,
|
||||
registerSpecies("Elf", EntityElf.class, "gharoth", "Elbe", 0x054100, 0xd2d2d2, ":highelf", "Thranduil", 0x82888b, 0xeae7bd);
|
||||
registerSpecies("WoodElf", EntityWoodElf.class, "gharoth", "Waldelbe", 0x054100, 0x00bb00);
|
||||
registerSpecies("BloodElf", EntityBloodElf.class, "kyroth", "Blutelbe", 0x054100, 0x960000, "::bloodelf");
|
||||
registerSpecies("Human", EntityHuman.class, EntityHuman.ClassType.class, "terra", "NSC", 0x4f7d9a, 0x034c7a,
|
||||
EntityHuman.ClassType.KNIGHT,
|
||||
":knight_1", ":knight_2", ":knight_3",
|
||||
":knight_4", ":knight_5", ":knight_6", ":knight_7", ":knight_8", EntityHuman.ClassType.PEASANT,
|
||||
":peasant_1", ":peasant_2", ":peasant_3",
|
||||
":peasant_4", ":peasant_5", ":peasant_6");
|
||||
registerSpecies("Spirit", EntitySpirit.class, "yrdinath", "Geist", 1.65f, 0xdfdfff, 0xbfbfff);
|
||||
registerSpecies("Haunter", EntityHaunter.class, "warp", "Verfolger", 1.55f, 0xffdfdf, 0xffbfbf);
|
||||
registerSpecies("FireDemon", EntityFireDemon.class, "ahrd", "Feuerdämon", 2.55f, 0xff0000, 0xff7f00);
|
||||
registerSpecies("Spirit", EntitySpirit.class, "yrdinath", "Geist", 0xdfdfff, 0xbfbfff);
|
||||
registerSpecies("Haunter", EntityHaunter.class, "warp", "Verfolger", 0xffdfdf, 0xffbfbf);
|
||||
registerSpecies("FireDemon", EntityFireDemon.class, "ahrd", "Feuerdämon", 0xff0000, 0xff7f00);
|
||||
|
||||
registerSpecies("DarkMage", EntityDarkMage.class, "kyroth", "Dunkler Magier", 1.85f, 0xf6b201, 0xfff87e);
|
||||
registerSpecies("Tiefling", EntityTiefling.class, "thedric", "Tiefling", 2.0f, 0xb01515, 0xb0736f);
|
||||
registerSpecies("Zombie", EntityZombie.class, "terra", "Zombie", 1.8f, 0x00afaf, 0x799c65, ":zombie_1", ":zombie_2", ":zombie_3",
|
||||
registerSpecies("DarkMage", EntityDarkMage.class, "kyroth", "Dunkler Magier", 0xf6b201, 0xfff87e);
|
||||
registerSpecies("Tiefling", EntityTiefling.class, "thedric", "Tiefling", 0xb01515, 0xb0736f);
|
||||
registerSpecies("Zombie", EntityZombie.class, "terra", "Zombie", 0x00afaf, 0x799c65, ":zombie_1", ":zombie_2", ":zombie_3",
|
||||
":zombie_4", ":zombie_5", ":zombie_6");
|
||||
registerSpecies("Undead", EntityUndead.class, "terra", "Untoter", 1.8f, 0xc1c1c1, 0x494949, ":undead_1", ":undead_2", ":undead_3",
|
||||
registerSpecies("Undead", EntityUndead.class, "terra", "Untoter", 0xc1c1c1, 0x494949, ":undead_1", ":undead_2", ":undead_3",
|
||||
":undead_4");
|
||||
registerSpecies("Arachnoid", EntityArachnoid.class, "tbd", "Arachnoidea", ModelType.ARACHNOID, 0x342d27, 0xa80e0e);
|
||||
registerSpecies("Mage", EntityMage.class, "terra", "Magier", 1.85f, 0x340000, 0x51a03e, ":mage_1", ":mage_2", ":mage_3",
|
||||
registerSpecies("Mage", EntityMage.class, "terra", "Magier", 0x340000, 0x51a03e, ":mage_1", ":mage_2", ":mage_3",
|
||||
":mage_4", ":mage_5", ":mage_6");
|
||||
registerSpecies("Gargoyle", EntityGargoyle.class, "tbd", "Gargoyle", 2.2f, 0x401010, 0x534437);
|
||||
registerSpecies("Gargoyle", EntityGargoyle.class, "tbd", "Gargoyle", 0x401010, 0x534437);
|
||||
registerSpecies("Slime", EntitySlime.class, "tbd", "Schleim", ModelType.SLIME, 0x51a03e, 0x7ebf6e);
|
||||
registerSpecies("Magma", EntityMagma.class, "thedric", "Magmaschleim", ModelType.SLIME, 0x340000, 0xfcfc00);
|
||||
registerSpecies("Orc", EntityOrc.class, "tbd", "Ork", 1.9f, 0x00af00, 0x004000, ":orc_1", ":orc_2", ":orc_3",
|
||||
registerSpecies("Orc", EntityOrc.class, "tbd", "Ork", 0x00af00, 0x004000, ":orc_1", ":orc_2", ":orc_3",
|
||||
":orc_4", ":orc_5", ":orc_6", ":orc_7", ":orc_8", ":orc_9", ":orc_10", ":orc_11", ":orc_12");
|
||||
registerSpecies("Vampire", EntityVampire.class, "transylvania", "Vampir", 1.8f, 0x7f0000, 0xff0000, ":vampire_1", ":vampire_2", ":vampire_3",
|
||||
registerSpecies("Vampire", EntityVampire.class, "transylvania", "Vampir", 0x7f0000, 0xff0000, ":vampire_1", ":vampire_2", ":vampire_3",
|
||||
":vampire_4", ":vampire_5", ":vampire_6", ":vampire_7", ":vampire_8", "Alucard:alucard_1", "Alucard:alucard_2",
|
||||
"Dracula:dracula_1", "Dracula:dracula_2", "Dracula:dracula_3", "Dracula:dracula_4", "Dracula:dracula_5",
|
||||
"Dracula:dracula_6");
|
||||
registerSpecies("Dwarf", EntityDwarf.class, "tbd", "Zwerg", ModelType.DWARF, 0x523925, 0x975b2b);
|
||||
registerSpecies("Primarch", EntityPrimarch.class, EntityPrimarch.Founding.class, false, "terra", "Primarch", ModelType.HUMANOID, 2.65f,
|
||||
registerSpecies("Primarch", EntityPrimarch.class, EntityPrimarch.Founding.class, false, "terra", "Primarch", ModelType.HUMANOID,
|
||||
0xaf0000, 0x400000, EntityPrimarch.Founding.PRIMARCHS);
|
||||
registerSpecies("SpaceMarine", EntitySpaceMarine.class, EntitySpaceMarine.Legion.class, true, "terra", "Space Marine", ModelType.SPACE_MARINE,
|
||||
2.15f, 0x000000, 0xffffff, EntitySpaceMarine.Legion.MARINES);
|
||||
0x000000, 0xffffff, EntitySpaceMarine.Legion.MARINES);
|
||||
registerSpecies("ChaosMarine", EntityChaosMarine.class, EntityChaosMarine.Legion.class, true, "warp", "Chaos Marine", ModelType.SPACE_MARINE,
|
||||
2.15f, 0x000000, 0xff0000, EntityChaosMarine.Legion.MARINES);
|
||||
0x000000, 0xff0000, EntityChaosMarine.Legion.MARINES);
|
||||
registerSpecies("Goblin", EntityGoblin.class, "luna", "Goblin", ModelType.HALFLING, 0x50af50, 0x504050);
|
||||
}
|
||||
|
||||
static void registerItems() {
|
||||
registerItems(EntityMetalhead.class,
|
||||
Blocks.iron_block, 5, Items.iron_ingot,
|
||||
Blocks.tin_block, 5, Items.tin_ingot,
|
||||
Blocks.aluminium_block, 5, Items.aluminium_ingot,
|
||||
Blocks.copper_block, 5, Items.copper_ingot,
|
||||
Blocks.lead_block, 5, Items.lead_ingot
|
||||
);
|
||||
registerItems(EntityElf.class, 3, Items.bow, 1, Items.iron_sword);
|
||||
registerItems(EntityWoodElf.class, 1, Items.bow, 2, null);
|
||||
registerItems(EntityBloodElf.class, 1, Items.bow, 3, Items.iron_sword, 1, Items.stone_sword);
|
||||
registerItems(EntityUndead.class, 9, Items.bow, 1, null);
|
||||
registerItems(EntitySpirit.class, 4, Items.snowball, 1, null);
|
||||
registerItems(EntitySpaceMarine.class, 2, Items.boltgun, 1, null);
|
||||
registerItems(EntityChaosMarine.class, 2, Items.boltgun, 1, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -648,6 +648,10 @@ public class Item
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getHotbarText(EntityNPC player, ItemStack stack) {
|
||||
return stack.getColoredName();
|
||||
}
|
||||
|
|
|
@ -151,4 +151,8 @@ public class ItemBow extends Item
|
|||
public ModelBlock getModel(String name, int meta) {
|
||||
return new ModelBlock(this.getTransform(), meta == 0 ? "bow" : ("bow_pulling_" + (meta - 1)));
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,4 +79,8 @@ public abstract class ItemGunBase extends Item
|
|||
public Transforms getTransform() {
|
||||
return Transforms.RANGED;
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,4 +110,8 @@ public class ItemHoe extends Item
|
|||
{
|
||||
return this.theToolMaterial;
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public class ItemNpcSpawner extends Item
|
|||
String item = "Erschaffe";
|
||||
CharacterInfo info = this.spawned; // SpeciesRegistry.CHARACTERS.get(stack.getMetadata() % SpeciesRegistry.CHARACTERS.size());
|
||||
String species = EntityRegistry.getEntityName(info.species.id);
|
||||
if(info.species.prefix && info.spclass != null && info.spclass.type != null)
|
||||
species = info.spclass.type.toString();
|
||||
if(info.species.prefix && info.type != null && !info.type.toString().isEmpty())
|
||||
species = info.type.toString();
|
||||
String character = info.name;
|
||||
item = item + " " + species + (character.isEmpty() ? "" : (" " + character));
|
||||
|
||||
|
|
|
@ -52,4 +52,8 @@ public class ItemShears extends Item
|
|||
public boolean isMagnetic() {
|
||||
return this.material.isMagnetic();
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,4 +164,8 @@ public class ItemSword extends Item
|
|||
public Transforms getTransform() {
|
||||
return Transforms.TOOL;
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,8 @@ public abstract class ItemTool extends Item
|
|||
public Transforms getTransform() {
|
||||
return Transforms.TOOL;
|
||||
}
|
||||
|
||||
public boolean canBeWielded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import game.inventory.IInventory;
|
|||
import game.inventory.InventoryPlayer;
|
||||
import game.inventory.Slot;
|
||||
import game.inventory.SlotCrafting;
|
||||
import game.item.ItemArmor;
|
||||
import game.item.ItemControl;
|
||||
import game.item.ItemStack;
|
||||
import game.log.Log;
|
||||
|
@ -2500,7 +2501,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
NetHandler.checkThread(packetIn, this, this.server);
|
||||
|
||||
CPacketAction.Action action = packetIn.getAction();
|
||||
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR)) // {
|
||||
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_CLASS || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR)) // {
|
||||
// if(this.local && action == Action.CLOSE_EDITOR)
|
||||
// this.server.setDone();
|
||||
return;
|
||||
|
@ -2630,7 +2631,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
// break;
|
||||
|
||||
case SET_HEIGHT:
|
||||
this.entity.setHeight(((float)ExtMath.clampi(packetIn.getAuxData(), this.entity.getMinSize(), this.entity.getMaxSize()) * 0.01f) / this.entity.getSpecies().renderer.height);
|
||||
this.entity.setHeight(((float)ExtMath.clampi(packetIn.getAuxData(), this.entity.getMinSize(), this.entity.getMaxSize()) * 0.01f));
|
||||
// Log.CONSOLE.info("" + this.entity.height + "(" + this.entity.getHeight() + ")");
|
||||
break;
|
||||
|
||||
|
@ -2855,6 +2856,14 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
// Log.CONSOLE.info("" + this.entity.height + "(" + this.entity.getHeight() + ")");
|
||||
break;
|
||||
|
||||
case SET_CLASS:
|
||||
if(this.entity.getSpecies().classEnum != null) {
|
||||
Enum<?>[] classes = this.entity.getSpecies().classEnum.getEnumConstants();
|
||||
if(packetIn.getAuxData() >= 0 && packetIn.getAuxData() < classes.length)
|
||||
this.entity.setNpcClass(classes[packetIn.getAuxData()]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Aktion!");
|
||||
}
|
||||
|
@ -2977,7 +2986,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
this.entity.inventory.addItemStackToInventory(itemstack);
|
||||
amount -= itemstack.stackSize;
|
||||
}
|
||||
else if(packetIn.getSlot() >= 0 && packetIn.getSlot() < 9) {
|
||||
else if(packetIn.getSlot() >= 0 && packetIn.getSlot() < this.entity.inventory.getSizeInventory() && (packetIn.getSlot() < this.entity.inventory.mainInventory.length || (itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType == packetIn.getSlot() - this.entity.inventory.mainInventory.length))) {
|
||||
ItemStack old = this.entity.inventory.getStackInSlot(packetIn.getSlot());
|
||||
if(old != null) {
|
||||
if(ItemStack.areItemsEqual(itemstack, old) && ItemStack.areItemStackTagsEqual(itemstack, old)) {
|
||||
|
@ -3079,6 +3088,8 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
// }
|
||||
// this.entity.setModel(packetIn.getModel());
|
||||
this.entity.setSkin(packetIn.getCompressed());
|
||||
if(packetIn.getCharacter() != null)
|
||||
this.entity.setChar(packetIn.getCharacter());
|
||||
this.server.sendPacket(new SPacketSkin(this.entity.getId(), packetIn.getCompressed())); // , packetIn.getModel()));
|
||||
// if(/* this.lastSkinUpdate != 0L && */ Config.sendSkinChange && !this.netManager.isLocalChannel()) {
|
||||
// String comp = "Dein Skin wurde geändert";
|
||||
|
|
|
@ -77,6 +77,7 @@ public class CPacketAction implements Packet<Player>
|
|||
// SET_MODELPARTS,
|
||||
SET_HEIGHT,
|
||||
SET_SPECIES,
|
||||
SET_CLASS,
|
||||
SELECT_TRADE,
|
||||
// SET_BEACON,
|
||||
INTERACT,
|
||||
|
|
|
@ -20,8 +20,7 @@ public class CPacketCheat implements Packet<Player>
|
|||
{
|
||||
this.stack = stackIn.copy();
|
||||
this.slot = slot;
|
||||
if(full)
|
||||
this.stack.stackSize = this.stack.getMaxStackSize();
|
||||
this.stack.stackSize = full ? this.stack.getMaxStackSize() : 1;
|
||||
}
|
||||
|
||||
public void processPacket(Player handler)
|
||||
|
|
|
@ -9,55 +9,56 @@ import game.network.Packet;
|
|||
import game.network.PacketBuffer;
|
||||
import game.renderer.texture.EntityTexManager;
|
||||
|
||||
public class CPacketSkin implements Packet<Player>
|
||||
{
|
||||
// private ModelType model;
|
||||
private byte[] comp;
|
||||
public class CPacketSkin implements Packet<Player> {
|
||||
private byte[] texture;
|
||||
private String character;
|
||||
|
||||
public CPacketSkin()
|
||||
{
|
||||
public CPacketSkin() {
|
||||
}
|
||||
|
||||
public CPacketSkin(BufferedImage image, ModelType model)
|
||||
{
|
||||
// this.model = model;
|
||||
public CPacketSkin(BufferedImage image, String character, ModelType model) {
|
||||
if(image == null) {
|
||||
this.comp = null;
|
||||
return;
|
||||
this.texture = null;
|
||||
this.character = character;
|
||||
}
|
||||
else {
|
||||
int[] img = new int[model.texWidth * model.texHeight];
|
||||
image.getRGB(0, 0, image.getWidth(), image.getHeight(), img, 0, image.getWidth());
|
||||
this.comp = EntityTexManager.imageToComp(img, model);
|
||||
this.texture = EntityTexManager.imageToComp(img, model);
|
||||
this.character = null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getCompressed() {
|
||||
return this.comp;
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
// public ModelType getModel() {
|
||||
// return this.model;
|
||||
// }
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
// this.model = buf.readEnumValue(ModelType.class);
|
||||
this.comp = buf.readByteArray();
|
||||
if(this.comp.length == 0) {
|
||||
this.comp = null;
|
||||
public String getCharacter() {
|
||||
return this.character;
|
||||
}
|
||||
else if(this.comp.length > EntityTexManager.MAX_SKIN_SIZE) {
|
||||
this.comp = new byte[EntityTexManager.MAX_SKIN_SIZE];
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
if(buf.readBoolean()) {
|
||||
this.texture = null;
|
||||
this.character = buf.readStringFromBuffer(64);
|
||||
}
|
||||
else {
|
||||
this.texture = buf.readByteArray();
|
||||
this.character = null;
|
||||
if(this.texture.length == 0 || this.texture.length > EntityTexManager.MAX_SKIN_SIZE)
|
||||
this.texture = new byte[EntityTexManager.MAX_SKIN_SIZE];
|
||||
}
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
// buf.writeEnumValue(this.model);
|
||||
buf.writeByteArray(this.comp == null ? new byte[0] : this.comp);
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeBoolean(this.texture == null);
|
||||
if(this.texture == null)
|
||||
buf.writeString(this.character);
|
||||
else
|
||||
buf.writeByteArray(this.texture);
|
||||
}
|
||||
|
||||
public void processPacket(Player handler)
|
||||
{
|
||||
public void processPacket(Player handler) {
|
||||
handler.processSkin(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,27 +149,24 @@ public abstract class EntityTexManager
|
|||
return "capes/" + name.toLowerCase() + "/dyn";
|
||||
}
|
||||
|
||||
public static LayerExtra getLayer(int id, ModelType model)
|
||||
public static LayerExtra getLayer(int id, String skin, ModelType model)
|
||||
{
|
||||
return altNpcLayer != null ? getNpcLayer(altNpcLayer, model) : (altLayer != -1 ? USER_LAYERS.get(altLayer) : (USER_TEXTURES.contains(id) ? USER_LAYERS.get(id) : DEF_LAYERS.get(model)));
|
||||
if(id == -1)
|
||||
return Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin)) != null ? NPC_LAYERS.get(skin.toLowerCase()) : DEF_LAYERS.get(model);
|
||||
return altNpcLayer != null ? Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(altNpcLayer)) != null ?
|
||||
NPC_LAYERS.get(altNpcLayer.toLowerCase()) : DEF_LAYERS.get(model) : (altLayer != -1 ? USER_LAYERS.get(altLayer) : (USER_TEXTURES.contains(id) ? USER_LAYERS.get(id) : (skin != null && Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin)) != null ? NPC_LAYERS.get(skin.toLowerCase()) : DEF_LAYERS.get(model))));
|
||||
}
|
||||
|
||||
public static LayerExtra getNpcLayer(String skin, ModelType model)
|
||||
public static String getSkin(int id, String skin, ModelType model)
|
||||
{
|
||||
return Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin)) != null ?
|
||||
NPC_LAYERS.get(skin.toLowerCase()) : DEF_LAYERS.get(model);
|
||||
}
|
||||
|
||||
public static String getSkin(int id, ModelType model)
|
||||
{
|
||||
String loc = altTexture != null ? altTexture : getSkinLocation(id);
|
||||
String loc = id != -1 ? (altTexture != null ? altTexture : getSkinLocation(id)) : getNpcSkinLocation(skin);
|
||||
if(id != -1 && skin != null && Game.getGame().getTextureManager().getTexture(loc) == null)
|
||||
loc = getNpcSkinLocation(skin);
|
||||
return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model);
|
||||
}
|
||||
|
||||
public static String getNpcSkin(String skin, ModelType model)
|
||||
{
|
||||
String loc = getNpcSkinLocation(skin);
|
||||
return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model);
|
||||
public static boolean hasCustomSkin(int id) {
|
||||
return Game.getGame().getTextureManager().getTexture(getSkinLocation(id)) != null;
|
||||
}
|
||||
|
||||
public static String getCape(String name)
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.lang.reflect.Field;
|
|||
|
||||
import game.color.TextColor;
|
||||
import game.gui.element.Dropdown;
|
||||
import game.gui.element.Element;
|
||||
import game.gui.element.Switch;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.util.Util;
|
||||
|
@ -16,10 +17,12 @@ public class EnumVar<T extends Enum> extends BaseVar {
|
|||
private final EnumFunction func;
|
||||
private final String values;
|
||||
private final T def;
|
||||
private final boolean useSwitch;
|
||||
|
||||
public EnumVar(String name, String display, Field field, Object object, CVarCategory category, EnumFunction<T> func) {
|
||||
public EnumVar(String name, String display, Field field, Object object, CVarCategory category, EnumFunction<T> func, boolean useSwitch) {
|
||||
super(name, display, field, object, category);
|
||||
this.func = func;
|
||||
this.useSwitch = useSwitch;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(T value : (T[])field.getType().getEnumConstants()) {
|
||||
if(sb.length() > 0)
|
||||
|
@ -41,6 +44,8 @@ public class EnumVar<T extends Enum> extends BaseVar {
|
|||
|
||||
public boolean parse(String str) {
|
||||
T value = (T)Util.parseEnum((Class<T>)this.field.getType(), str);
|
||||
if(value == null)
|
||||
return false;
|
||||
try {
|
||||
this.field.set(this.object, value);
|
||||
}
|
||||
|
@ -70,7 +75,9 @@ public class EnumVar<T extends Enum> extends BaseVar {
|
|||
return this.values;
|
||||
}
|
||||
|
||||
public Dropdown selector(int x, int y, int w, int h) {
|
||||
public Element selector(int x, int y, int w, int h) {
|
||||
if(this.useSwitch)
|
||||
return this.switcher(x, y, w, h);
|
||||
try {
|
||||
return new Dropdown<T>(x, y, w, h, false, (T[])this.field.getType().getEnumConstants(), this.def, (T)this.field.get(this.object), new Dropdown.Callback<T>() {
|
||||
public void use(Dropdown<T> elem, T value) {
|
||||
|
|
|
@ -24,6 +24,7 @@ public @interface Variable {
|
|||
IntType type() default IntType.INT;
|
||||
int precision() default 0;
|
||||
String unit() default "";
|
||||
boolean switched() default false;
|
||||
Class<? extends VarFunction> callback() default VarFunction.class;
|
||||
Class<? extends CharValidator> validator() default CharValidator.class;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue