perromercenary00
Members-
Posts
849 -
Joined
-
Last visited
-
Days Won
5
Everything posted by perromercenary00
-
hay thanks i take the idea to full fill needs but find another trouble the basic idea is to save the fantasmaMercenario values to the the watched entity in the save part of an IExtendedEntityProperties class to later when the load part is called and is the turn for the watched entity, get back the values from the watched, create a new fantasmaMercenario entity and load the values and set again the shooting entity and all the other stuff. but for some reason the entity fantasmaMercenario don't spawn in the world, but its is triyng i see the output in console package mercenarymod.entidades; import java.util.UUID; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ExtendedPropertiesEntityLiving implements IExtendedEntityProperties { public final static String extendedPropertiesName = "extendedFantasmaMercenario"; protected EntityLivingBase theEntity; protected World theWorld; @Override public void saveNBTData(NBTTagCompound parCompound) { // DEBUG //System.out.println(("ExtendedProperties EntityLivingBase saveNBTData()")); // good idea to keep your extended properties in a sub-compound to // avoid conflicts with other possible extended properties, // even from other mods (like if a mod extends all EntityAnimal) if ((theEntity instanceof fantasmaMercenario)) { fantasmaMercenario fantasma = (fantasmaMercenario) theEntity; EntityLivingBase shootingEntity = (EntityLivingBase) fantasma.getShootingEntity(); if (shootingEntity != null) { theEntity.getEntityData().setBoolean("hasGHOST", true); NBTTagCompound compound = new NBTTagCompound(); // not relevant for now // compound.setString("OwnerUUID", // theEntity.getEntityData().getString("OwnerUUID") ); // compound.setString("GhostUUID", // theEntity.getEntityData().getString("GhostUUID") ); // compound.setString("ShootUUID", // theEntity.getEntityData().getString("ShootUUID") ); // compound.setBoolean("hasGHOST", // theEntity.getEntityData().getBoolean("hasGHOST") ); parCompound.setTag(extendedPropertiesName, compound); // set as sub-compound } } } @Override public void loadNBTData(NBTTagCompound parCompound) { // DEBUG //System.out.println(("ExtendedPropertiesH EntityLivingBase loadNBTData()")); // Get the sub-compound NBTTagCompound compound = (NBTTagCompound) parCompound.getTag(extendedPropertiesName); if (compound != null) { theEntity.getEntityData().setBoolean("hasGHOST", true); NBTTagCompound entityNBT = theEntity.getEntityData(); //the new fantasmaMercenario entity is conjured here onEntityConjureGhost(theEntity); } } // ########################################################################################################################3 // conjurar espiritu // @SubscribeEvent public void onEntityConjureGhost(EntityLivingBase shootingEntity) { NBTTagCompound compound = shootingEntity.getEntityData(); System.out.println("\n\n######\n on IEEP Conjuring Ghost"); World worldIn = shootingEntity.getEntityWorld(); System.out.println("### Mundo=" + worldIn.isRemote ); if (!worldIn.isRemote) { String GhostUUID = compound.getString("GhostUUID"); int GhostID = compound.getInteger("GhostID"); boolean doSomething = true; Entity oldGhost = worldIn.getEntityByID(GhostID); //check is there an ghost to avoid multiple watchers over the same entity if (oldGhost != null) { if (oldGhost instanceof fantasmaMercenario) { fantasmaMercenario oldFantasma = (fantasmaMercenario) oldGhost; EntityLivingBase ghostShootingEntity = (EntityLivingBase) oldFantasma.getShootingEntity(); if (ghostShootingEntity != null) { int comparacion = ghostShootingEntity.getUniqueID().compareTo(shootingEntity.getUniqueID()); if (comparacion == 0) { doSomething = false; System.out.println("### El fantasma ya existe "); //there is an alredy loaded ghost } } } } //############### if (doSomething){ //if reach this is because //there is no ghost and its gona create a new one System.out.println("### El fantasma no existe y va a crear uno nuevo"); mercenarymod.entidades.fantasmaMercenario fantasma = new mercenarymod.entidades.fantasmaMercenario(worldIn); fantasma.setShootingEntity(shootingEntity); double x = shootingEntity.posX; double y = shootingEntity.posY + shootingEntity.height;// shootingEntity.getEyeHeight(); double z = shootingEntity.posZ; float yaw = shootingEntity.rotationYaw; // getRotationYawHead(); // rotationYaw; float pitch = shootingEntity.rotationPitch; if (pitch < 0) { y = shootingEntity.posY; } fantasma.setPositionAndRotation(x, y, z, yaw, pitch); //Main point the shoting entity fantasma.setShootingEntity(shootingEntity); int fantasmaID = fantasma.getEntityId(); String fantasmaUUID = fantasma.getUniqueID().toString(); // \/ \/ \/ //i could se this in the console System.out.println("### El fantasma fue Creado con ID="+fantasmaID); compound.setString("GhostUUID", fantasmaUUID); compound.setInteger("GhostID", fantasmaID); //Here \/ \/ \/ \/ //but this spawn is not happend and dont see any error worldIn.spawnEntityInWorld(fantasma); } } } // ########################################################################################################################3 @Override public void init(Entity entity, World world) { // DEBUG // System.out.println(("ExtendedProperties EntityLivingBase init()"); theEntity = (EntityLivingBase) entity; theWorld = world; } } all this becase is heavy load to resinc wathed entity whit watcher entity thanks for reading
-
Goo days during the last weeks i been working in an custom entity (fantasmaMercenario) that watch over others (vanilla or modded) entities healing then over time if their are hurt and shooting the guns from mi mod for them, this is the only way i found to make vanilla skeletons to use mi rifles and guns. several troubles i find and the most important is : if you close/save the world the wacherEntity(fantasmaMercenario) lost the values from the shootingEntity it is watching for for example this (fantasmaMercenario) is watching an vanilla skeleton raging around the village in the norther part, inside the code of fantasmamercenario the skeleton reference is saved as "shootingEntity" the code from the ghost its working properly, the ghost is causing regeneration over the skeleton and if i put some herb in a tactical vest and put it on the skeleton chest slot the ghost use them to health the skeleton if life goes under 25% but if i close/reopen the minecraft game , the ghost and the skeleton still exist in nortern part of the village but the ghost is watching no more the skeleton coz has lost the variable values and betwin them the shootingEntity reference to the skeleton is now null. private EntityLiving Base shootingEntity = thisWachedEntity; ### i could save all the variables to nbts/datawacher in the ghost no trouble with it , but the reference to an entity is other thing. *first i try saving the UUID from shootingEntity but because shooting entity is a mob and not a player i have to make mi own method to check the area around the ghost and search for an entity with a maching UUID this works but i don't want use it coz when the game gets thousens of watched entities its gonna lags ugly at the load of the world. //#########################################################################3 public static Entity getEntityFromUUID(World worldIn, EntityLivingBase referenceEntity ,UUID euuid){ //System.out.println("\n\n#####################################################################################"); //System.out.println("getEntityFromUUID"); //System.out.println("referenceEntity="+referenceEntity.getName()); //List entidadesTodas = worldIn.loadedEntityList; //int entidadesTodasSize = entidadesTodas.size(); //System.out.println("entidadesTodas="+entidadesTodasSize ); EntityLivingBase uuu = null; UUID uuuid = null; BlockPos nucleo = referenceEntity.getPosition(); List entidades=null; int f=5; //reach BlockPos posMin = nucleo.add( -f, -f, -f); BlockPos posMax = nucleo.add( f, f, f); AxisAlignedBB boundingBox=new AxisAlignedBB(posMin, posMax); entidades = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); int entidadesSize=entidades.size(); for (int u = 0 ; u < entidadesSize ; u ++) { uuu = (EntityLivingBase) entidades.get(u); //System.out.println("entidades["+u+"]="+uuu.getName()); if ( (euuid.compareTo(uuu.getUniqueID()) == 0 ) ) { return uuu; } } return null; } //#########################################################################3 * the other thing i try was to use events to set dead the fantasmamercenario when the world close/save and make another event to cast a brand new ghost when "LivingSpawnEvent event", but this fail becoze LivingSpawnEvent event only hapens once when the skeleton is first time casted unto the world, not everytime the world loads //########################################################################################################################3 // conjurar espiritu @SubscribeEvent public void onEntitySpawnsConjureGhost(LivingSpawnEvent event) { if ( (event.entity instanceof EntityLivingBase) & !(event.entity instanceof fantasmaMercenario) ) { NBTTagCompound compound = event.entity.getEntityData(); Boolean hasGHOST = compound.getBoolean("hasGHOST"); if (hasGHOST) { System.out.println("\n\n######\n onEntityConjureGhost"); World worldIn = event.entity.getEntityWorld(); EntityLivingBase shootingEntity = (EntityLivingBase) event.entity; if (!worldIn.isRemote) { mercenarymod.entidades.fantasmaMercenario fantasma = new mercenarymod.entidades.fantasmaMercenario(worldIn); fantasma.setShootingEntity(shootingEntity); double x = shootingEntity.posX; double y = shootingEntity.posY + shootingEntity.height;// shootingEntity.getEyeHeight(); double z = shootingEntity.posZ; float yaw = shootingEntity.rotationYaw; // getRotationYawHead(); // rotationYaw; float pitch = shootingEntity.rotationPitch; fantasma.setPositionAndRotation(x, y, z, yaw, pitch); fantasma.setShootingEntity(shootingEntity); int fantasmaID = fantasma.getEntityId(); String fantasmaUUID = fantasma.getUniqueID().toString(); shootingEntity.getEntityData().setString("GhostUUID", fantasmaUUID); shootingEntity.getEntityData().setInteger("GhostID", fantasmaID); shootingEntity.getEntityData().setBoolean("hasGHOST", true); worldIn.spawnEntityInWorld(fantasma); } } } } //########################################################################################################################3 someOne has try some like this before, or well know how to store an entity reference, not all the entity to an nbt soo you could recalled again even if the worlds close/save and the entityes ID's change. but not searching the entity again every time using whith UUID's other thing im curious is that i have declared in the ghost constructor this.isEntityInvulnerable(DamageSource.inWall); but the entity is still taken damage when in wall fantasmaMercenario.class package mercenarymod.entidades; import java.util.ArrayList; import java.util.List; import java.util.UUID; import mercenarymod.Mercenary; import mercenarymod.eventos.mensajeMercenarioalServidor; import mercenarymod.gui.NotificationMercenaria; import mercenarymod.items.MercenaryModItems; import mercenarymod.items.armasdefuego.cargadormf9x.cargadorFM9X; import mercenarymod.utilidades.chat; import mercenarymod.utilidades.util; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class fantasmaMercenario extends EntityTameable { private int ticksExisted; private int texturajson = 0; private int accion = 0; private boolean leftClick = false; private boolean rigthClick = false; private int ticksMaximos = 0; private EntityLivingBase shootingEntity; private int shootingEntityId = 0; private float maxHealth = 0.0F; private float health = 0.0F; private Entity targetEntity; private int targetEntityId = 0; private int fantasmaId = 0; private ItemStack heldItemStack; private Item heldItem; private ItemStack subArma; private Item subArmaItem; private ItemStack pistola00; private Item pistolaItem00; private ItemStack pistola01; private Item pistolaItem01; private String OwnerUUID = ""; private String ShootUUID = ""; private int tipoDePistola = 0; private int numerodeserie = 0; private int lmuniciondisponible = 0; private int municiondisponible = 0; private int municion = 0; private int municionmaxima = 0; private int tipodisparo = 0; private int tipomunicion = 0; private int tipocargador = 0; private int tipocargadorcambio = 0; private int lmunicion = 0; private int lmunicionmaxima = 0; private int ltipodisparo = 0; private int ltipomunicion = 0; private int ltipocargador = 0; private int ltipocargadorcambio = 0; private int nDeDisparos = 0; private int cuantosDisparos; private boolean hacerNada = false; private boolean exorcisar = false; private boolean eselhumano = false; private boolean recargar = false; private boolean stapp = false; private int comandos[] = { 0, 0, 0 }; private int[] ignorar = { 0 }; // inventario de la armadura private int inventarioSize = 36; private ItemStack[] inventario = new ItemStack[inventarioSize]; private ItemStack chestItem = null; // inventario de la shootingEntity private int mainInventorySize = 36; private ItemStack[] mainInventory = new ItemStack[mainInventorySize]; private int ghostInventorySize = 36; private ItemStack[] ghostInventory = new ItemStack[mainInventorySize]; private int conteodeEtiquetas = 0; private World worldIn = null; private String customName = "algo"; static Item cargadoresCompatibles[] = { MercenaryModItems.cargador55645 }; static Item municionesCompatibles[] = { MercenaryModItems.bala55645mm_Standar, MercenaryModItems.bala55645mm_Redstone, MercenaryModItems.bala55645mm_Obsidiana }; // static Item curativasCompatibles[] = { MercenaryModItems.hierba, // MercenaryModItems.hierbaVerdePlanta, MercenaryModItems.papa_cocida, // MercenaryModItems.yuca_cocida }; private int cargadorListo = -1; private int cargadorVacio = -1; private int MunicionLista = -1; private int hierba = -1; // private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, // 1.0D, 20, 10, 30.0F); private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityMob.class, 1.2D, false); // ################################################################################################################# public fantasmaMercenario(World worldIn) { super(worldIn); this.setSize(0.0F, 0.0F); this.isEntityInvulnerable(DamageSource.drown); this.isEntityInvulnerable(DamageSource.fall); this.isEntityInvulnerable(DamageSource.generic); this.isEntityInvulnerable(DamageSource.inWall); this.isEntityInvulnerable(DamageSource.lava); this.isEntityInvulnerable(DamageSource.fallingBlock); } // ################################################################################################################# @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(9999.0D); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D); } // ################################################################################################################# @Override protected void entityInit() { super.entityInit(); ticksExisted = 0; // 0 1 2 3 4 6 7 8 9 12 15 16 17 this.dataWatcher.addObject(5, 0); // int R 000Municion this.dataWatcher.addObject(10, 0); // R int 0tipodisparo 0tipomunicion // 0cargador 0cargadordereemplazo // 000municionMax 000municionMin, // tipoDeArma_BCMG this.dataWatcher.addObject(11, 0); // int L 000Municion this.dataWatcher.addObject(13, 0); // L int 0tipodisparo 0tipomunicion // 0cargador 0cargadordereemplazo // 000municionMax 000municionMin this.dataWatcher.addObject(14, 0); // Booleans this.dataWatcher.addObject(31, ""); // "ShootUUID" // this.dataWatcher.addObject(17, ""); // "OwnerUUID" this.dataWatcher.addObject(18, Byte.valueOf((byte) 0)); this.dataWatcher.addObject(19, 0.0F); // this.posX this.dataWatcher.addObject(20, 0.0F); // this.posY this.dataWatcher.addObject(21, 0.0F); // this.posZ this.dataWatcher.addObject(22, 0.0F); // this.rotationPitch this.dataWatcher.addObject(23, 0.0F); // this.rotationYaw this.dataWatcher.addObject(24, 0); // this.hacerNada this.dataWatcher.addObject(25, 0); // this.exorcisar this.dataWatcher.addObject(26, 0.0F); // MotionX this.dataWatcher.addObject(27, 0.0F); // MotionY this.dataWatcher.addObject(28, 0.0F); // MotionZ this.dataWatcher.addObject(29, 0); // this.ShootingEntityId this.dataWatcher.addObject(30, 0); // this.TargetEntityId } // ################################################################################################################# // actualiza shooting entity y extrae el arma que sostiene void actualizarValoresEstablesDesdeShootingEntity() { // System.out.println("actualizarValoresEstablesDesdeShootingEntity()"); if (shootingEntity != null & !this.worldObj.isRemote) { this.getEntityData().setString("ShootUUID", shootingEntity.getUniqueID().toString() ); ShootUUID = shootingEntity.getUniqueID().toString(); eselhumano = false; if (shootingEntity instanceof EntityPlayer) { OwnerUUID = ShootUUID; eselhumano = true; } else { OwnerUUID = util.getEntityOwnerUUID(shootingEntity); } this.dataWatcher.updateObject(31, ShootUUID);// "ShootUUID" this.dataWatcher.updateObject(17, OwnerUUID);// "OwnerUUID" shootingEntityId = shootingEntity.getEntityId(); this.dataWatcher.updateObject(29, shootingEntityId); // this.ShootingEntityId heldItemStack = shootingEntity.getHeldItem(); heldItem = null; } if (this.worldObj.isRemote) { ShootUUID = this.dataWatcher.getWatchableObjectString(31);// "ShootUUID" OwnerUUID = this.dataWatcher.getWatchableObjectString(17);// "OwnerUUID" shootingEntityId = this.dataWatcher.getWatchableObjectInt(29); // this.ShootingEntityId shootingEntity = null; if (shootingEntityId > 0) { Entity tempEntity00 = this.worldObj.getEntityByID(shootingEntityId); if (tempEntity00 != null) { if (tempEntity00 instanceof EntityLivingBase) { shootingEntity = (EntityLivingBase) tempEntity00; heldItemStack = shootingEntity.getHeldItem(); heldItem = null; } } } } if (shootingEntity != null) { shootingEntity.getEntityData().setString("OwnerUUID", OwnerUUID); eselhumano = false; if (shootingEntity instanceof EntityPlayer) { eselhumano = true; } } if (heldItemStack != null) { heldItem = heldItemStack.getItem(); boolean esDisparable = armasDisparables.esDisparable(heldItemStack); if (esDisparable) { pistola00 = heldItemStack; pistolaItem00 = pistola00.getItem(); tipoDePistola = armasDisparables.tipodePistola(pistola00); numerodeserie = util.getInttag(pistola00, "numerodeserie"); municiondisponible = util.getInttag(pistola00, "municiondisponible"); lmuniciondisponible = util.getInttag(pistola00, "lmuniciondisponible"); municion = util.getInttag(pistola00, "municion"); municionmaxima = util.getInttag(pistola00, "municionmaxima"); tipodisparo = util.getInttag(pistola00, "tipodisparo"); tipomunicion = util.getInttag(pistola00, "tipomunicion"); tipocargador = util.getInttag(pistola00, "tipocargador"); tipocargadorcambio = util.getInttag(pistola00, "tipocargadorcambio"); lmunicion = util.getInttag(pistola00, "lmunicion"); lmunicionmaxima = util.getInttag(pistola00, "lmunicionmaxima"); ltipodisparo = util.getInttag(pistola00, "ltipodisparo"); ltipomunicion = util.getInttag(pistola00, "ltipomunicion"); ltipocargador = util.getInttag(pistola00, "ltipocargador"); ltipocargadorcambio = util.getInttag(pistola00, "ltipocargadorcambio"); util.setInttag(pistola00, "fantasmaID", this.getEntityId()); } } } // ################################################################################################################# // actualiza todos los valores del arma y la posicion del fantasma void leerEscribirElDatawacherTodo() { if (!this.worldObj.isRemote) { this.dataWatcher.updateObject(5, municion); // int R 000Municion int BCMG = 0; BCMG = tipoDePistola; BCMG = BCMG + (tipodisparo * 100); BCMG = BCMG + (tipomunicion * 1000); BCMG = BCMG + (tipocargador * 10000); BCMG = BCMG + (tipocargadorcambio * 100000); BCMG = BCMG + (municionmaxima * 1000000); this.dataWatcher.updateObject(10, BCMG); // R int 00tipoDePistola // 0tipodisparo // 0tipomunicion // 0tipocargador // 0tipocargadorcambio // 000municionmaxima , this.dataWatcher.updateObject(11, lmunicion); // int L 000Municion int LBCMG = 0; LBCMG = tipoDePistola; LBCMG = LBCMG + (ltipodisparo * 100); LBCMG = LBCMG + (ltipomunicion * 1000); LBCMG = LBCMG + (ltipocargador * 10000); LBCMG = LBCMG + (ltipocargadorcambio * 100000); LBCMG = LBCMG + (lmunicionmaxima * 1000000); this.dataWatcher.updateObject(13, LBCMG); // L int 0tipodisparo // 0tipomunicion // 0cargador // 0cargadordereemplazo // 000municionMax // 000municionMin int BOOL = 0; if (stapp) { BOOL = 1; } this.dataWatcher.updateObject(14, BOOL); // Booleans if (hacerNada) { this.dataWatcher.updateObject(24, 1); // this.hacerNada } else { this.dataWatcher.updateObject(24, 0); // this.hacerNada } if (exorcisar) { this.dataWatcher.updateObject(25, 1); // this.exorcisar } else { this.dataWatcher.updateObject(25, 0); // this.exorcisar } this.dataWatcher.updateObject(17, "OwnerUUID"); // "OwnerUUID" if (shootingEntity != null & ticksExisted < 20) { shootingEntityId = shootingEntity.getEntityId(); heldItemStack = shootingEntity.getHeldItem(); } this.dataWatcher.updateObject(29, shootingEntityId); // this.ShootingEntityId if (shootingEntity != null) { double x = shootingEntity.posX; double y = shootingEntity.posY + shootingEntity.height;// shootingEntity.getEyeHeight();// // shootingEntity.posY double z = shootingEntity.posZ; float yaw = shootingEntity.rotationYaw; // getRotationYawHead(); // rotationYaw; float pitch = shootingEntity.rotationPitch; if (pitch < 0) { y = shootingEntity.posY; } this.motionX = shootingEntity.motionX; this.motionY = shootingEntity.motionY; this.motionZ = shootingEntity.motionZ; this.setPositionAndRotation(x, y, z, yaw, pitch); this.dataWatcher.updateObject(19, (float) x); // this.posX this.dataWatcher.updateObject(20, (float) y); // this.posY this.dataWatcher.updateObject(21, (float) z); // this.posZ this.dataWatcher.updateObject(22, (float) pitch); // this.rotationPitch this.dataWatcher.updateObject(23, (float) yaw); // this.rotationYaw this.dataWatcher.updateObject(26, (float) this.motionX); // MotionX this.dataWatcher.updateObject(27, (float) this.motionY); // MotionY this.dataWatcher.updateObject(28, (float) this.motionZ); // MotionZ } } else { municion = this.dataWatcher.getWatchableObjectInt(5); // int R // 000Municion int BCMG = this.dataWatcher.getWatchableObjectInt(10);// R int // 00tipoDePistola // 0tipodisparo // 0tipomunicion // 0tipocargador // 0tipocargadorcambio // 000municionmaxima // , tipoDePistola = (BCMG % 100); tipodisparo = (BCMG % 1000) / 100; tipomunicion = (BCMG % 10000) / 1000; tipocargador = (BCMG % 100000) / 10000; tipocargadorcambio = (BCMG % 100000) / 10000; municionmaxima = (BCMG / 1000000); lmunicion = this.dataWatcher.getWatchableObjectInt(11); // int l // 000Municion int LBCMG = this.dataWatcher.getWatchableObjectInt(13);// L int // 0tipodisparo // 0tipomunicion // 0cargador // 0cargadordereemplazo // 000municionMax // 000municionMin // tipoDePistola = (BCMG % 100); ltipodisparo = (LBCMG % 1000) / 100; ltipomunicion = (LBCMG % 10000) / 1000; ltipocargador = (LBCMG % 100000) / 10000; ltipocargadorcambio = (LBCMG % 100000) / 10000; lmunicionmaxima = (LBCMG / 1000000); int BOOL = this.dataWatcher.getWatchableObjectInt(14);// Booleans stapp = false; if ((BOOL % 10) == 1) { stapp = true; } hacerNada = false; if (this.dataWatcher.getWatchableObjectInt(24) > 0) { hacerNada = true; } exorcisar = false; if (this.dataWatcher.getWatchableObjectInt(25) > 0) { exorcisar = true; } OwnerUUID = this.dataWatcher.getWatchableObjectString(17);// "OwnerUUID" shootingEntityId = this.dataWatcher.getWatchableObjectInt(29); // this.ShootingEntityId if (shootingEntity == null & shootingEntityId > 0 & ticksExisted < 20) { Entity tempEntity00 = this.worldObj.getEntityByID(shootingEntityId); if (tempEntity00 != null) { if (tempEntity00 instanceof EntityLivingBase) { shootingEntity = (EntityLivingBase) tempEntity00; heldItemStack = shootingEntity.getHeldItem(); } } } this.posX = (float) this.dataWatcher.getWatchableObjectFloat(19); // this.posX this.posY = (float) this.dataWatcher.getWatchableObjectFloat(20); // this.posY this.posZ = (float) this.dataWatcher.getWatchableObjectFloat(21); // this.posZ this.rotationPitch = (float) this.dataWatcher.getWatchableObjectFloat(22); this.rotationYaw = (float) this.dataWatcher.getWatchableObjectFloat(23); this.motionX = (float) this.dataWatcher.getWatchableObjectFloat(26); // MotionX this.motionY = (float) this.dataWatcher.getWatchableObjectFloat(27); // MotionY this.motionZ = (float) this.dataWatcher.getWatchableObjectFloat(28); // MotionZ } } // ################################################################################################################# // solo actualiza cantidad de municion y posicion del fantasma void leerEscribirElDatawacher() { if (!this.worldObj.isRemote) { this.dataWatcher.updateObject(5, municion); // int R 000Municion this.dataWatcher.updateObject(11, lmunicion); // int L 000Municion int BOOL = 0; if (stapp) { BOOL = 1; } this.dataWatcher.updateObject(14, BOOL); // Booleans if (hacerNada) { this.dataWatcher.updateObject(24, 1); // this.hacerNada } else { this.dataWatcher.updateObject(24, 0); // this.hacerNada } if (exorcisar) { this.dataWatcher.updateObject(25, 1); // this.exorcisar } else { this.dataWatcher.updateObject(25, 0); // this.exorcisar } if (shootingEntity != null) { double x = shootingEntity.posX; double y = shootingEntity.posY + 2; //shootingEntity.height ;// shootingEntity.getEyeHeight();// double z = shootingEntity.posZ; float yaw = shootingEntity.rotationYaw; // getRotationYawHead(); float pitch = shootingEntity.rotationPitch; if (pitch < 0) { y = shootingEntity.posY; } this.motionX = shootingEntity.motionX; this.motionY = shootingEntity.motionY; this.motionZ = shootingEntity.motionZ; this.setPositionAndRotation(x, y, z, yaw, pitch); this.dataWatcher.updateObject(19, (float) x); // this.posX this.dataWatcher.updateObject(20, (float) y); // this.posY this.dataWatcher.updateObject(21, (float) z); // this.posZ this.dataWatcher.updateObject(22, (float) pitch); // this.rotationPitch this.dataWatcher.updateObject(23, (float) yaw); // this.rotationYaw this.dataWatcher.updateObject(26, (float) this.motionX); // MotionX this.dataWatcher.updateObject(27, (float) this.motionY); // MotionY this.dataWatcher.updateObject(28, (float) this.motionZ); // MotionZ this.fallDistance = 0; } } else { municion = this.dataWatcher.getWatchableObjectInt(5); // int R // 000Municion lmunicion = this.dataWatcher.getWatchableObjectInt(11); // int l // 000Municion int BOOL = this.dataWatcher.getWatchableObjectInt(14);// Booleans stapp = false; if ((BOOL % 10) == 1) { stapp = true; } hacerNada = false; if (this.dataWatcher.getWatchableObjectInt(24) > 0) { hacerNada = true; } exorcisar = false; if (this.dataWatcher.getWatchableObjectInt(25) > 0) { exorcisar = true; } this.posX = (float) this.dataWatcher.getWatchableObjectFloat(19); // this.posX this.posY = (float) this.dataWatcher.getWatchableObjectFloat(20); // this.posY this.posZ = (float) this.dataWatcher.getWatchableObjectFloat(21); // this.posZ this.rotationPitch = (float) this.dataWatcher.getWatchableObjectFloat(22); this.rotationYaw = (float) this.dataWatcher.getWatchableObjectFloat(23); this.motionX = (float) this.dataWatcher.getWatchableObjectFloat(26); // MotionX this.motionY = (float) this.dataWatcher.getWatchableObjectFloat(27); // MotionY this.motionZ = (float) this.dataWatcher.getWatchableObjectFloat(28); // MotionZ this.fallDistance = 0; } } // ################################################################################################################# public String getOwnerId() { return this.dataWatcher.getWatchableObjectString(17); } public void setOwnerId(String ownerUuid) { this.dataWatcher.updateObject(17, ownerUuid); } // ################################################################################################################# @Override /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { System.out.println("\n\n########################################################"); System.out.println("cause ="+cause.getDamageType()); //System.out.println("cause ="+cause.getEntity().getName()); } // ################################################################################################################# @Override /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return null;//"mob.wolf.hurt" } // ################################################################################################################# @Override /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.wolf.death"; } // ################################################################################################################# @Override /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } // ################################################################################################################# @Override protected Item getDropItem() { return Item.getItemById(-1); } // ################################################################################################################# @Override /** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); } // ################################################################################################################# /** * sets this entity's combat AI. */ public void setCombatTask() { } // ################################################################################################################# /** * sets this entity's combat AI. */ boolean getTarget() { if (shootingEntity != null) { ArrayList<Entity> entidades = util.getAquienLeEstoyApuntando(this.worldObj, shootingEntity, 15, 3); if (entidades.size() > 0) { if (OwnerUUID.length() > 0) { // //System.out.println("################### // entidades.size("+entidades.size()+")"); for (int e = 0; e < entidades.size(); e++) { if ((entidades.get(e) != null) & (entidades.get(e) instanceof EntityLivingBase)) { EntityLivingBase entityE = (EntityLivingBase) entidades.get(e); String EOwnerUUID = util.getEntityOwnerUUID(entityE); if ((OwnerUUID.equals(EOwnerUUID))) { targetEntity = null; return false; } } } } if (entidades.get(0) != null) { targetEntity = entidades.get(0); } else { targetEntity = null; } return true; } targetEntity = null; return true; } targetEntity = null; return false; } // ################################################################################################################# @Override /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if ( ticksExisted < 2 || shootingEntity == null ) { // ticksExisted == 0 //System.out.println(">>> actualizarValoresEstablesDesdeShootingEntity()"); //updates the values form server side to client side using the ghost Datawacher actualizarValoresEstablesDesdeShootingEntity(); } //actualiza the ghost position to match shootinEntity position leerEscribirElDatawacher(); if ( ((ticksExisted % 40) == 0)) { System.out.println("\n######"); System.out.println("Mundo=" + this.worldObj.isRemote + " ticksExisted"+ticksExisted); System.out.println("Ghostpos X=" + this.posX + " Y"+ this.posY + " Z"+ this.posZ); System.out.println("this.getHealth()=" + this.getHealth() ); if (this.getHealth() < 5000) { this.setHealth(9999); } if (shootingEntity != null) { System.out.println("shootingEntity()=" + shootingEntity.getName() ); } getTarget(); if (targetEntity != null) { System.out.println("targetEntity()=" + targetEntity.getName() ); } } // Show the shootingEntity Heal if (shootingEntity != null & ((ticksExisted % 20) == 0)) { maxHealth = shootingEntity.getMaxHealth(); health = shootingEntity.getHealth(); //System.out.println("\nMundo=" + this.worldObj.isRemote + " ticksExisted"+ticksExisted); //System.out.println("entity=" + shootingEntity.getName() + " HP=" + health + "/" + maxHealth); } hacerNada = true; if (shootingEntity != null) { if (heldItemStack != null) { hacerNada = false; } eselhumano = false; // Heal the shootingEntity if it has whith it a curative item if (!eselhumano & !this.worldObj.isRemote) { if ((ticksExisted % 40) == 0) { maxHealth = shootingEntity.getMaxHealth(); health = shootingEntity.getHealth(); if (health < (maxHealth / 4)) { // buscar healtItem this.readFromNBT(); this.buscar(); //System.out.println("hierba=" + hierba); if (hierba > -1) { if (ghostInventory[hierba] != null) { float curar = armasDisparables.esCurativo(ghostInventory[hierba]); if (curar > 9) { curar = curar - 10; shootingEntity.curePotionEffects(new ItemStack(Items.milk_bucket, 1, 0)); } float nhealth = shootingEntity.getHealth() + (maxHealth * curar); if (nhealth > maxHealth) { nhealth = maxHealth; } shootingEntity.setHealth(nhealth); if (shootingEntity instanceof EntityPlayer) { ((EntityPlayer) shootingEntity).getFoodStats().addStats((int) (10 * curar), (int) (10 * curar)); } //System.out.println("hierba=" + ghostInventory[hierba].getUnlocalizedName()); decrStackSize(hierba, 1); } } } } // regeng 1/4 hearth every two minutes if ((ticksExisted % 2400) == 0) { maxHealth = shootingEntity.getMaxHealth(); health = shootingEntity.getHealth(); if (health < maxHealth) { shootingEntity.setHealth(shootingEntity.getHealth() + 0.5F); } } } } /* accion 0 estandBy 1 shoot R 2 unload R 3 reload R 4 unload/reload R 5 shoot L 6 unload L 7 reload L 8 unload/reload L */ // detener la accion if (stapp) { texturajson = 0; accion = 0; stapp = false; } // System.out.println("hacerNada="+hacerNada); // System.out.println("rigthClick="+rigthClick); // System.out.println("leftClick="+leftClick); if (!hacerNada) { if (rigthClick) { accion = 1; texturajson = 0; System.out.println("rigthClick###"); // if (!this.worldObj.isRemote) { if (getTarget()) { accion = 1; } else { stapp = true; } if (targetEntity != null) { //System.out.println("targetEntity=" + targetEntity.getName()); } else { //System.out.println("targetEntity=NULL"); } } if (this.worldObj.isRemote) { NotificationMercenaria.setconteo100Zero(); } rigthClick = false; } // Accion 1 rafaga de 5 disaparos if (accion == 1) { int conteo = 0; if (this.worldObj.isRemote) { conteo = NotificationMercenaria.getconteo100(); } // //System.out.println("ConteoLocal=" + conteo); if (conteo % 2 == 0) { texturajson = 0; } else { texturajson = 1; } if (conteo > 10) { if (this.worldObj.isRemote) { Mercenary.network.sendToServer(new mensajeMercenarioalServidor("stapp_" + this.getEntityId())); } } } if (leftClick) { accion = 2; texturajson = 9; System.out.println("leftClick###"); if (this.worldObj.isRemote) { NotificationMercenaria.setconteo100Zero(); } leftClick = false; } // Accion 2 Sierra de redstone por 2 seg if (accion == 2) { int conteo = 0; if (this.worldObj.isRemote) { conteo = NotificationMercenaria.getconteo100(); } // //System.out.println("ConteoLocal=" + conteo); texturajson = 9; if (this.worldObj.isRemote) { int lconteo = NotificationMercenaria.getlconteo(); // //System.out.println("lconteo=" + lconteo); if (lconteo < 1 & conteo > 20) { texturajson = 0; { Mercenary.network.sendToServer(new mensajeMercenarioalServidor("stapp_" + this.getEntityId())); } } } } } // fin de hacerAlgo // terminar la entidad si contados 180 ticks no a sido inicializado shooting entity o esta muerto if (ticksExisted > 180 & !this.worldObj.isRemote) { if (shootingEntity == null) { //System.out.println("entity is NULL"); exorcisar = true; } else if (!shootingEntity.isEntityAlive()) { //System.out.println("Entity is Not Alive"); exorcisar = true; } } if (exorcisar) { System.out.println("\nMundo=" + this.worldObj.isRemote); System.out.println("######This has been killled likke kenny t=" + ticksExisted ); System.out.println("Dead UUID=" + this.entityUniqueID.toString()); this.setDead(); } ticksExisted++; } // ################################################################################################################# void sacarCargador() { } // ################################################################################################################# void meterCargador() { } // ################################################################################################################# void searchValues() { } // ################################################################################################################# //Shoot bullet public static void disparo(World worldIn, EntityLivingBase shooter, int shootingEntityId, ItemStack pistola, int tipomunicion, int tipocargador, int municion, int tipoDePistola, int[] ignorar) { // World worldIn = shootingEntity.getEntityWorld(); Item bala = null; // bala = MercenaryModItems.bala9mm_Standar; // bala = MercenaryModItems.bala9mm_Standar; int spell0 = 0; int spell1 = 0; int spell2 = 0; int spell3 = 0; int spell4 = 0; int R = 0; int knockback = 0; float f = 0.0F; boolean modo = false; boolean flame = false; boolean poison = false; boolean headShoot = false; int cantDeEntidadesAfectadas = 1; float damageM = 0.0F; float damageI = 0.0F; float precision = 8.0F; switch (tipomunicion) { default: damageM = 0.0F; damageI = 0.0F; cantDeEntidadesAfectadas = 0; break; // Empty bullet case 1: damageM = 2.55F; damageI = 0.0F; cantDeEntidadesAfectadas = 1; break; // bala9mm_Hierro case 2: damageM = 3.00F; damageI = 0.0F; cantDeEntidadesAfectadas = 1; break; // bala9mm_redstone case 3: damageM = 3.50F; damageI = 0.0F; cantDeEntidadesAfectadas = 1; break; // bala9mm_obisidana } // conjuros if (!worldIn.isRemote) { spell0 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, pistola); spell1 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, pistola); spell2 = EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, pistola); spell3 = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, pistola); spell4 = EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, pistola); R = ((int) (Math.random() * 20)) + spell3; // power if (spell0 > 0) { damageM = damageM + (float) spell0 * 0.5F + 0.5F; } // punch and knockback if ((spell1 > 0) | (spell4 > 0)) { knockback = (spell1 + spell4); } if (tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, pistola) > 0) { flame = true; } if (tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, pistola) > 0) { flame = true; } } // fuerza del disparo y modo de disparo if (R > 15) { damageM = damageM * 2.0F; } if (damageM > 26.1F) { damageM = 26.1F; } mercenarymod.items.armasdefuego.balas.bala9mm_entity bala9mm = new mercenarymod.items.armasdefuego.balas.bala9mm_entity(worldIn, shooter, 10F, precision); if (R < 15) { bala9mm.setHeadShoot(false); } bala9mm.setKnockbackStrength(knockback); bala9mm.setIsOnFire(flame); bala9mm.setIsVenomus(poison); bala9mm.setPrecision(precision); bala9mm.setDamage(damageM); bala9mm.setDamageI(damageI); bala9mm.setCantDamage(cantDeEntidadesAfectadas); bala9mm.setSEntityB(shootingEntityId); bala9mm.setIgnorar(ignorar); if (tipoDePistola == 2) { worldIn.playSoundAtEntity(shooter, "modmercenario:subfusilMP5T5_disparo", 0.4F, 0.4F); } else { worldIn.playSoundAtEntity(shooter, "modmercenario:pistolaFM92_disparo", 0.4F, 0.4F); } worldIn.spawnEntityInWorld(bala9mm); if (!worldIn.isRemote) { municion = util.getInttag(pistola, "municion") - 1; if (municion < 0) { municion = 0; } util.setInttag(pistola, "municion", municion); } } // fin de disparar // ################################################################################################################# @Override public float getEyeHeight() { return 1.74F; } // #########################################################################3 public static ArrayList<Integer> cuantosHayCuantosCaben(EntityPlayer playerIn, Item cosa) { ArrayList<Integer> salida = new ArrayList<Integer>(); ArrayList<Integer> vacio = new ArrayList<Integer>(); ArrayList<Integer> conteos = new ArrayList<Integer>(); conteos.clear(); vacio.clear(); vacio.add(0); salida.clear(); salida.add(0); int cantidad = 0; int invSize = (playerIn.inventory.getSizeInventory()) - 4; ItemStack invStack = null; Item invItem = null; for (int invSlot = 0; invSlot < invSize; invSlot++) { invStack = playerIn.inventory.getStackInSlot(invSlot); if (invStack != null) { invItem = invStack.getItem(); if (invItem.equals(cosa)) { salida.add(invSlot); cantidad += (invStack.stackSize); } } else { vacio.add(invSlot); } } salida.set(0, cantidad); vacio.set(0, (vacio.size() - 1)); int maxStaacksize = cosa.getItemStackLimit(); int cantidadUbicable = (((salida.size() - 1) * maxStaacksize) - cantidad) + (maxStaacksize * (vacio.get(0))); // chat.chatda(playerIn, "cantidadUbicable="+cantidadUbicable ); // chat.chatda(playerIn, "vacios="+(vacio.get(0)) ); conteos.add(cantidad); conteos.add(cantidadUbicable); return conteos; } // ################################################################################################################# // se ejecuta cuando hace ataque intercambio fisico normal a una criatura @Override public boolean attackEntityAsMob(Entity p_70652_1_) { boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue())); if (flag) { this.func_174815_a(this, p_70652_1_); } p_70652_1_.setFire(10); return flag; } // ################################################################################################################# @Override public void setTamed(boolean tamed) { super.setTamed(tamed); if (tamed) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); } this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D); } // ################################################################################################################# @Override /** * Called when a player interacts with a mob. e.g. gets milk from a cow, * gets into the saddle on a pig. */ public boolean interact(EntityPlayer player) { return super.interact(player); } // ################################################################################################################# @Override /** * Will return how many at most can spawn in a chunk at once. */ public int getMaxSpawnedInChunk() { return 20; } // ################################################################################################################# @Override /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return true; } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } // ################################################################################################################# public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } // ################################################################################################### /** * Returns the number of slots in the inventory. */ public int getinventarioSize() // ItemStack pistola { return inventarioSize;// inventarioSize; } // ################################################################################################### public void setinventarioSize(int z) // ItemStack pistola { this.inventarioSize = z;// inventarioSize; } // ################################################################################################### public int getMainInventorySize() // ItemStack pistola { return mainInventorySize;// inventarioSize; } // ################################################################################################### public void setMainInventorySize(int z) // ItemStack pistola { this.mainInventorySize = z;// inventarioSize; } // ################################################################################################### public NBTTagCompound getthisCompound() { NBTTagCompound compound = new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < inventario.length; ++i) { if (inventario[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); inventario[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } compound.setTag("Inventory", nbttaglist); // this.pistola.setTagCompound(compound); if (this.hasCustomName()) { compound.setString("CustomName", this.customName); } return compound; } // #########################################################################3 // @Override ItemStack decrStackSize(int index, int count) { if (ghostInventory[index] != null) { ItemStack itemstack; if (ghostInventory[index].stackSize <= count) { itemstack = ghostInventory[index]; ghostInventory[index] = null; this.writeToNBT(); return itemstack; } else { itemstack = ghostInventory[index].splitStack(count); if (ghostInventory[index].stackSize <= 0) { ghostInventory[index] = null; } else { // Just to show that changes happened // this.setInventorySlotContents(index, // this.getStackInSlot(index)); } this.writeToNBT(); return itemstack; } } else { return null; } } // #########################################################################3 // @Override public void clear() { for (int i = 0; i < inventario.length; ++i) { inventario[i] = null; } for (int i = 0; i < mainInventory.length; ++i) { mainInventory[i] = null; } // //System.out.println("$$$ clear()"); } // #########################################################################3 // @Override void buscar() { MunicionLista = -1; cargadorVacio = -1; cargadorListo = -1; hierba = -1; for (int i = 0; i < ghostInventorySize; ++i) { // ##### ItemStack ghostItemStack = ghostInventory[i]; Item ghostItem = null; if (ghostItemStack != null) { ghostItem = ghostItemStack.getItem(); // ###### for (int pc = 0; pc < municionesCompatibles.length; pc++) { if (ghostItem == municionesCompatibles[pc]) { MunicionLista = i; } } // ###### for (int pc = 0; pc < cargadoresCompatibles.length; pc++) { if (ghostItem == cargadoresCompatibles[pc]) { cargadorVacio = i; municion = util.getInttag(ghostItemStack, "municion"); if (municion > 0) { cargadorListo = i; } } } // ###### if (armasDisparables.esCurativo(ghostItemStack) > 0.0F) { hierba = i; } /* * for (int pc = 0; pc < curativasCompatibles.length; pc++) { * * if (ghostItem == curativasCompatibles[pc]) { * * if (pc == 0) { int ghostmeta = ghostItemStack.getMetadata(); * * if (ghostmeta > 2) { hierba = i; } } else { hierba = i; } * * } } */ // ###### } } } // #########################################################################3 // @Override public void readFromNBT() { this.clear(); // Shoting Entity Inventory if (shootingEntity != null) { NBTTagCompound compound3 = shootingEntity.getEntityData(); if (shootingEntity instanceof EntityPlayer) { EntityPlayer playerIn = (EntityPlayer) shootingEntity; mainInventorySize = playerIn.inventory.getSizeInventory(); this.mainInventory = new ItemStack[mainInventorySize];// playerIn.Inventory.mainInventory; for (int i = 0; i < mainInventorySize; ++i) { ItemStack plInvStack = playerIn.inventory.getStackInSlot(i); mainInventory[i] = plInvStack; if (mainInventory[i] != null) { // //System.out.println("inventario[" + i + "]" + // mainInventory[i].getUnlocalizedName()); // chat.chatga(shootingEntity, "mainInventory[" + i + // "]" + mainInventory[i].getUnlocalizedName()); } } } else { // 33 if (compound3 != null) { mainInventorySize = 36; this.mainInventory = new ItemStack[mainInventorySize]; NBTTagList nbttaglist3 = compound3.getTagList("Inventory", 10); for (int i = 0; i < nbttaglist3.tagCount(); ++i) { NBTTagCompound nbttagcompound3 = nbttaglist3.getCompoundTagAt(i); int j = nbttagcompound3.getByte("Slot") & 255; if (j >= 0 && j < mainInventorySize) { mainInventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound3); if (mainInventory[j] != null) { // //System.out.println("mainInventory[" + j + "]" // + mainInventory[j].getUnlocalizedName()); // chat.chatga(shootingEntity, "mainInventory[" // + j + "]" + // mainInventory[j].getUnlocalizedName()); } } } } // 33 } chestItem = this.shootingEntity.getEquipmentInSlot(3);// getCurrentArmor(2);chest // inventario en la armadura if (chestItem != null) { //System.out.println("===> chestItem=" + chestItem.getUnlocalizedName()); NBTTagCompound compound2 = chestItem.getTagCompound(); if (compound2 != null) { inventarioSize = armasDisparables.tieneBolsillos(chestItem) + 5; inventario = new ItemStack[inventarioSize]; NBTTagList nbttaglist2 = compound2.getTagList("Items", 10); for (int i = 0; i < nbttaglist2.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist2.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < inventarioSize) { inventario[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); if (inventario[j] != null) { // //System.out.println("inventario[" + j + "]" + // inventario[j].getUnlocalizedName()); // chat.chatga(shootingEntity, "inventario[" + j // + "]" + inventario[j].getUnlocalizedName()); } } } } } ghostInventorySize = inventarioSize + mainInventorySize; ghostInventory = new ItemStack[ghostInventorySize]; for (int i = 0; i < ghostInventorySize; ++i) { if (i < inventarioSize) { ghostInventory[i] = inventario[i]; } else { ghostInventory[i] = mainInventory[i - inventarioSize]; } } } } // #########################################################################3 // @Override public void writeToNBT() { if (shootingEntity != null) { // ghostInventorySize = inventarioSize + mainInventorySize; // ghostInventory = new ItemStack[ghostInventorySize]; for (int i = 0; i < ghostInventorySize; ++i) { if (i < inventarioSize) { inventario[i] = ghostInventory[i]; } else { mainInventory[i - inventarioSize] = ghostInventory[i]; } } // mainInventory if (shootingEntity instanceof EntityPlayer) { EntityPlayer playerIn = (EntityPlayer) shootingEntity; int playerInvSize = playerIn.inventory.getSizeInventory(); int mainInvSize = mainInventory.length; if (playerInvSize < mainInvSize) { mainInvSize = playerInvSize; } for (int i = 0; i < mainInvSize; ++i) { playerIn.inventory.setInventorySlotContents(i, mainInventory[i]); if (mainInventory[i] != null) { // //System.out.println("inventario[" + i + "]" + // mainInventory[i].getUnlocalizedName()); // chat.chatga(shootingEntity, "mainInventory[" + i + // "]" + mainInventory[i].getUnlocalizedName()); } } // playerIn.inventory.mainInventory = this.mainInventory; } else { NBTTagList nbttaglist3 = new NBTTagList(); for (int i = 0; i < mainInventory.length; ++i) { if (mainInventory[i] != null) { NBTTagCompound nbttagcompound3 = new NBTTagCompound(); nbttagcompound3.setByte("Slot", (byte) i); inventario[i].writeToNBT(nbttagcompound3); nbttaglist3.appendTag(nbttagcompound3); } } NBTTagCompound shootingEntityData = shootingEntity.getEntityData(); shootingEntityData.setTag("Inventory", nbttaglist3); } // inventario en la armadura chestItem = this.shootingEntity.getEquipmentInSlot(3);// getCurrentArmor(2);chest if (chestItem != null) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < inventario.length; ++i) { if (inventario[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); inventario[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } NBTTagCompound chestcompound = chestItem.getTagCompound(); if (chestcompound == null) { chestcompound = new NBTTagCompound(); } chestcompound.setTag("Items", nbttaglist); chestItem.setTagCompound(chestcompound); this.inventario[3] = chestItem; this.shootingEntity.setCurrentItemOrArmor(3, inventario[3]); } } } // #########################################################################3 // #########################################################################3 public void setShootingEntity(EntityLivingBase entidad) { shootingEntity = entidad; } // #########################################################################3 public Entity getShootingEntity() { return shootingEntity; } // #########################################################################3 public Entity getTargetEntity() { return targetEntity; } // #########################################################################3 public void setTargetEntity(EntityLivingBase entidad) { targetEntity = entidad; } // #########################################################################3 public void setHeldItemStack(ItemStack p) { heldItemStack = p; } // #########################################################################3 public ItemStack getHeldItemStack() { return heldItemStack; } // #########################################################################3 public int getTicksExisted() { return this.ticksExisted; } // #########################################################################3 public int getTexturajson() { return texturajson; } // #########################################################################3 public void setTexturajson(int t) { texturajson = t; } // #########################################################################3 public int getAccion() { return accion; } // #########################################################################3 public void setAccion(int t) { accion = t; } // #########################################################################3 public boolean getLeftClick() { return leftClick; } // #########################################################################3 public void setLeftClick(boolean l) { leftClick = l; } // #########################################################################3 public boolean getRigthClick() { return rigthClick; } // #########################################################################3 public void setRigthClick(boolean r) { rigthClick = r; } // #########################################################################3 public boolean getStapp() { return stapp; } // #########################################################################3 public void setStapp(boolean s) { stapp = s; } // ##########################################################################3 public String getOwnerUUID() { return OwnerUUID; } // ##########################################################################3 public void setOwnerUUID(String uu) { OwnerUUID = uu; } // ##########################################################################3 public String getShootUUID() { return ShootUUID; } // ##########################################################################3 public void setShootUUID(String uu) { ShootUUID = uu; } // ################################################################################################################# } Thanks for reading
-
[1.8] Make entity die on world close/save <Close>
perromercenary00 replied to perromercenary00's topic in Modder Support
i know see thath buth now i gonna try a diferent aproach gonna set this for close -
im trying to make an Ghost entity to watch over other entityes healt them if there have are healing items and control the use of some guns from mi mod i have triying some tings but i dont like the outcomig arrr anyway i need the ghostEntity to die when you close minecraft, i think i must use some kin of onClose/save event but du not find what could work for this what could i use ? thanks for reading
-
[1.8] Help solving error caused by mi entity <SOLVED>
perromercenary00 replied to perromercenary00's topic in Modder Support
ñaa i founded and wass mi error the int entityID = EntityRegistry.findGlobalUniqueEntityId(); for some reason it only retrun 3 all mi entityes was register whith nunber 3 i remove the unique EntityId and set manualy numbers from 1 to 8 and then is now fixed -
good days this is anoying me the game crash whenever try to spawn mi customcreeper only leting me this error i dont get the error only happend in the minecraft game whit the alredy compiled mod, but not when run in eclipse this thing says than java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer at net.minecraft.entity.DataWatcher.func_75679_c(SourceFile:100) at mercenarymod.entidades.hostiles.akCreeper.func_70071_h_(akCreeper.java:361) thats is the datawacher, in the akCreeper.class the datawacher value (21) is set to int and in the values is loaded whith an int i alredy change the value of the datawacher from 21 to 22 but fails the same actually im thinking that someone else mod is using the datawachers from entityliving or from tameable thos afecting this entity ### is some way to chekit ? the error ---- Minecraft Crash Report ---- WARNING: coremods are present: Mine and Blade: Battlegear2 (1.8-MB_Battlegear2-Bullseye-1.0.9.0.jar) MMMCoremod (LittleMaidMobNX-NX3B111-1.8-F1450.jar) RenderPlayerAPIPlugin (RenderPlayerAPI-1.8-1.5.jar) PlayerAPIPlugin (PlayerAPI-1.8-1.4.jar) LoadingPlugin (Bloodmoon-1.3.jar) DLFMLCorePlugin (DynamicLights-1.8.jar) SmartCorePlugin (SmartMoving-1.8-16.2.jar) BOPLoadingPlugin (BiomesOPlenty-1.8-3.0.0.1461-universal.jar) Contact their authors BEFORE contacting forge // Oops. Time: 8/11/15 05:03 PM Description: Ticking entity java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer at net.minecraft.entity.DataWatcher.func_75679_c(SourceFile:100) at mercenarymod.entidades.hostiles.akCreeper.func_70071_h_(akCreeper.java:361) at net.minecraft.world.World.func_72866_a(World.java:1880) at net.minecraft.world.World.func_72870_g(World.java:1850) at net.minecraft.world.World.func_72939_s(World.java:1679) at net.minecraft.client.Minecraft.func_71407_l(Unknown Source) at net.minecraft.client.Minecraft.func_71411_J(Unknown Source) at net.minecraft.client.Minecraft.func_99999_d(Unknown Source) at net.minecraft.client.main.Main.main(SourceFile:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.entity.DataWatcher.func_75679_c(SourceFile:100) at mercenarymod.entidades.hostiles.akCreeper.func_70071_h_(akCreeper.java:361) at net.minecraft.world.World.func_72866_a(World.java:1880) at net.minecraft.world.World.func_72870_g(World.java:1850) -- Entity being ticked -- Details: Entity Type: modmercenario.akCreeper (mercenarymod.entidades.hostiles.akCreeper) Entity ID: 4252 Entity Name: entity.modmercenario.akCreeper.name Entity's Exact location: -59,97, 68,00, 63,66 Entity's Block location: -60,00,68,00,63,00 - World: (-60,68,63), Chunk: (at 4,4,15 in -4,3; contains blocks -64,0,48 to -49,255,63), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0,00, 0,00, 0,00 Entity's Rider: ~~ERROR~~ NullPointerException: null Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace: at net.minecraft.world.World.func_72939_s(World.java:1679) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player'/1253, l='MpServer', x=-59,95, y=68,00, z=63,67]] Chunk stats: MultiplayerChunkCache: 81, 81 Level seed: 0 Level generator: ID 06 - BIOMESOP, ver 0. Features enabled: false Level generator options: Level spawn location: 7,00,64,00,-29,00 - World: (7,64,-29), Chunk: (at 7,4,3 in 0,-2; contains blocks 0,0,-32 to 15,255,-17), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 9489 game time, 9489 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Forced entities: 168 total; [EntityItem['item.item.bread'/771, l='MpServer', x=-20,88, y=30,00, z=66,28], EntityItem['item.item.compass'/772, l='MpServer', x=-19,25, y=30,00, z=68,13], EntityGib['desconocido'/4100, l='MpServer', x=-21,94, y=41,50, z=78,41], EntityItem['item.item.zss.sword_ordon'/773, l='MpServer', x=-20,88, y=30,00, z=68,13], EntityGib['desconocido'/4101, l='MpServer', x=-21,84, y=41,28, z=78,74], EntityItem['item.item.arrow'/774, l='MpServer', x=-20,88, y=35,00, z=70,59], EntityGib['desconocido'/4102, l='MpServer', x=-22,03, y=41,28, z=78,07], EntityItem['item.item.arrow'/775, l='MpServer', x=-18,13, y=35,00, z=68,13], EntitySkeleton['Esqueleto'/3079, l='MpServer', x=-55,78, y=50,00, z=68,28], EntityCreeper['Creeper'/3591, l='MpServer', x=-104,50, y=23,00, z=27,50], EntityItem['item.item.zss.potion_red'/776, l='MpServer', x=-18,66, y=35,00, z=68,13], EntityFish['Fish'/777, l='MpServer', x=-16,50, y=56,41, z=78,09], EntityFish['Fish'/778, l='MpServer', x=-19,09, y=56,00, z=80,44], EntityGib['desconocido'/3082, l='MpServer', x=-55,78, y=51,50, z=68,28], EntityFish['Fish'/779, l='MpServer', x=-18,75, y=55,47, z=84,41], EntityGib['desconocido'/3083, l='MpServer', x=-55,66, y=51,28, z=68,61], EntityFish['Fish'/780, l='MpServer', x=-16,78, y=55,00, z=81,28], EntityGib['desconocido'/3084, l='MpServer', x=-55,90, y=51,28, z=67,95], EntityCreeper['Creeper'/2830, l='MpServer', x=-7,50, y=20,02, z=9,50], EntityCreeper['Creeper'/2832, l='MpServer', x=-9,44, y=20,02, z=12,41], EntityZombie['Zombi'/3603, l='MpServer', x=-37,31, y=50,00, z=75,44], EntityZombie['Zombi'/3604, l='MpServer', x=-24,86, y=50,00, z=66,66], EntityItem['item.item.zss.arrow_ice'/789, l='MpServer', x=-9,06, y=30,00, z=64,47], EntityItem['item.item.emerald'/790, l='MpServer', x=-7,66, y=30,00, z=64,88], EntityGib['desconocido'/3606, l='MpServer', x=-37,31, y=51,50, z=75,44], EntityItem['item.item.zss.deku_nut'/791, l='MpServer', x=-7,59, y=30,00, z=66,31], EntityGib['desconocido'/3607, l='MpServer', x=-37,26, y=51,28, z=75,09], EntityItem['item.item.zss.hammer'/792, l='MpServer', x=-10,41, y=30,00, z=64,88], EntityGib['desconocido'/3608, l='MpServer', x=-37,36, y=51,28, z=75,78], EntityItem['item.item.zss.heart_piece'/793, l='MpServer', x=-6,81, y=30,00, z=66,22], EntityCreeper['Creeper'/2841, l='MpServer', x=-12,50, y=33,02, z=-7,50], EntityItem['item.item.ingotIron'/794, l='MpServer', x=-7,56, y=30,00, z=66,88], EntityCreeper['Creeper'/2842, l='MpServer', x=-62,50, y=33,02, z=81,50], EntityGib['desconocido'/3610, l='MpServer', x=-24,98, y=51,50, z=66,66], EntityGib['desconocido'/3611, l='MpServer', x=-25,02, y=51,28, z=66,31], EntityGib['desconocido'/3612, l='MpServer', x=-24,94, y=51,28, z=67,00], EntityFish['Fish'/797, l='MpServer', x=-6,47, y=57,25, z=85,56], EntityFish['Fish'/798, l='MpServer', x=-8,75, y=57,44, z=84,47], EntityBat['Murciélago'/804, l='MpServer', x=13,84, y=17,28, z=81,88], EntityZombie['Zombi'/4135, l='MpServer', x=-38,56, y=31,00, z=56,94], EntityZombie['Zombi'/4137, l='MpServer', x=-37,84, y=30,00, z=60,75], EntityGib['desconocido'/4142, l='MpServer', x=-38,56, y=32,50, z=56,94], EntityGib['desconocido'/4143, l='MpServer', x=-38,91, y=32,28, z=56,90], EntityGib['desconocido'/4144, l='MpServer', x=-38,21, y=32,28, z=56,97], EntityGib['desconocido'/4146, l='MpServer', x=-37,84, y=31,50, z=60,75], EntityGib['desconocido'/4147, l='MpServer', x=-37,65, y=31,28, z=61,04], EntityCreeper['Creeper'/3380, l='MpServer', x=-55,50, y=20,00, z=49,50], EntityBat['Murciélago'/3636, l='MpServer', x=-10,00, y=21,17, z=5,30], EntityGib['desconocido'/4148, l='MpServer', x=-38,04, y=31,28, z=60,46], EntityCreeper['Creeper'/3381, l='MpServer', x=-52,50, y=20,00, z=49,50], EntityBat['Murciélago'/3637, l='MpServer', x=-10,25, y=20,05, z=6,38], EntityBat['Murciélago'/3641, l='MpServer', x=-9,96, y=21,10, z=7,89], EntityBat['Murciélago'/829, l='MpServer', x=17,63, y=17,81, z=78,59], EntityCreeper['Creeper'/3134, l='MpServer', x=-1,13, y=30,00, z=42,72], EntityFish['Fish'/830, l='MpServer', x=19,51, y=54,29, z=76,67], EntityCreeper['Creeper'/3135, l='MpServer', x=4,50, y=30,00, z=53,50], EntityFish['Fish'/831, l='MpServer', x=17,69, y=53,69, z=67,50], EntityCow['Vaca'/320, l='MpServer', x=-118,06, y=69,00, z=59,59], EntityCreeper['Creeper'/3136, l='MpServer', x=4,50, y=30,00, z=56,50], EntityFish['Fish'/832, l='MpServer', x=19,01, y=53,22, z=70,71], EntityBat['Murciélago'/4161, l='MpServer', x=-30,88, y=21,75, z=60,94], EntityBat['Murciélago'/4162, l='MpServer', x=-55,28, y=19,84, z=72,28], EntityEnderman['Enderman'/3140, l='MpServer', x=-2,50, y=30,00, z=46,50], EntityBat['Murciélago'/4171, l='MpServer', x=14,79, y=30,40, z=-9,69], EntityBat['Murciélago'/2916, l='MpServer', x=-40,75, y=40,22, z=18,50], EntitySpider['Araña'/1892, l='MpServer', x=-47,84, y=20,00, z=-12,50], EntitySkeleton['Esqueleto'/3685, l='MpServer', x=-26,50, y=20,00, z=9,50], EntityCreeper['Creeper'/1894, l='MpServer', x=-43,50, y=20,00, z=-12,50], EntityGib['desconocido'/3688, l='MpServer', x=-26,50, y=21,50, z=9,50], EntityGib['desconocido'/3689, l='MpServer', x=-26,31, y=21,28, z=9,80], EntityGib['desconocido'/3690, l='MpServer', x=-26,69, y=21,28, z=9,20], EntitySkeleton['Esqueleto'/4205, l='MpServer', x=-10,50, y=50,00, z=32,50], EntitySkeleton['Esqueleto'/4206, l='MpServer', x=-12,50, y=50,00, z=32,50], EntitySkeleton['Esqueleto'/4207, l='MpServer', x=-12,50, y=50,00, z=31,50], EntityZombie['Zombi'/2160, l='MpServer', x=4,50, y=30,00, z=43,50], EntitySkeleton['Esqueleto'/4208, l='MpServer', x=-14,50, y=50,00, z=33,50], EntityZombie['Zombi'/4209, l='MpServer', x=-25,50, y=40,00, z=51,50], EntitySkeleton['Esqueleto'/4210, l='MpServer', x=-23,50, y=40,00, z=50,50], EntitySkeleton['Esqueleto'/4211, l='MpServer', x=-24,53, y=40,02, z=48,19], EntityZombie['Zombi'/4212, l='MpServer', x=-21,50, y=40,00, z=45,50], EntityGib['desconocido'/2165, l='MpServer', x=4,50, y=31,50, z=43,50], EntityGib['desconocido'/2166, l='MpServer', x=4,53, y=31,28, z=43,15], EntityBat['Murciélago'/2934, l='MpServer', x=-55,25, y=27,10, z=90,25], EntityGib['desconocido'/4214, l='MpServer', x=-10,50, y=51,50, z=32,50], EntityGib['desconocido'/2167, l='MpServer', x=4,47, y=31,28, z=43,85], EntityGib['desconocido'/4215, l='MpServer', x=-10,15, y=51,28, z=32,53], EntityGib['desconocido'/4216, l='MpServer', x=-10,85, y=51,28, z=32,47], EntityGib['desconocido'/4218, l='MpServer', x=-12,50, y=51,50, z=32,50], EntityZombie['Zombi'/1915, l='MpServer', x=-57,50, y=10,00, z=14,50], EntityGib['desconocido'/4219, l='MpServer', x=-12,15, y=51,28, z=32,51], EntityGib['desconocido'/4220, l='MpServer', x=-12,85, y=51,28, z=32,49], EntityGib['desconocido'/4222, l='MpServer', x=-12,50, y=51,50, z=31,50], EntityGib['desconocido'/4223, l='MpServer', x=-12,15, y=51,28, z=31,52], EntityGib['desconocido'/4224, l='MpServer', x=-12,85, y=51,28, z=31,48], EntityGib['desconocido'/4226, l='MpServer', x=-14,50, y=51,50, z=33,50], EntityGib['desconocido'/4227, l='MpServer', x=-14,15, y=51,28, z=33,53], EntityGib['desconocido'/4228, l='MpServer', x=-14,85, y=51,28, z=33,47], EntityGib['desconocido'/4230, l='MpServer', x=-25,50, y=41,50, z=51,50], EntityGib['desconocido'/4231, l='MpServer', x=-25,70, y=41,28, z=51,79], EntityGib['desconocido'/4232, l='MpServer', x=-25,30, y=41,28, z=51,21], EntityGib['desconocido'/4234, l='MpServer', x=-23,50, y=41,50, z=50,50], EntityGib['desconocido'/4235, l='MpServer', x=-23,16, y=41,28, z=50,43], EntityGib['desconocido'/4236, l='MpServer', x=-23,84, y=41,28, z=50,57], EntityGib['desconocido'/4238, l='MpServer', x=-24,53, y=41,56, z=48,22], EntityGib['desconocido'/4239, l='MpServer', x=-24,88, y=41,34, z=48,22], EntityGib['desconocido'/1936, l='MpServer', x=-57,50, y=11,50, z=14,50], EntityGib['desconocido'/4240, l='MpServer', x=-24,18, y=41,34, z=48,22], EntityGib['desconocido'/1937, l='MpServer', x=-57,80, y=11,28, z=14,32], EntityGib['desconocido'/1938, l='MpServer', x=-57,20, y=11,28, z=14,68], EntityGib['desconocido'/4242, l='MpServer', x=-21,50, y=41,50, z=45,50], EntityCreeper['Creeper'/3987, l='MpServer', x=-31,34, y=30,00, z=-10,00], EntityGib['desconocido'/4243, l='MpServer', x=-21,15, y=41,28, z=45,50], EntityGib['desconocido'/4244, l='MpServer', x=-21,85, y=41,28, z=45,50], EntityZombie['Zombi'/2198, l='MpServer', x=-8,50, y=40,02, z=9,50], EntitySkeleton['Esqueleto'/3990, l='MpServer', x=-23,50, y=27,00, z=140,50], EntityGib['desconocido'/4246, l='MpServer', x=-23,50, y=28,50, z=140,50], EntityGib['desconocido'/4247, l='MpServer', x=-23,15, y=28,28, z=140,51], EntityCreeper['Creeper'/3991, l='MpServer', x=-20,50, y=27,00, z=140,50], EntityGib['desconocido'/4248, l='MpServer', x=-23,85, y=28,28, z=140,49], EntityGib['desconocido'/2202, l='MpServer', x=-8,50, y=41,52, z=9,50], EntityGib['desconocido'/2203, l='MpServer', x=-8,15, y=41,29, z=9,48], EntityGib['desconocido'/2204, l='MpServer', x=-8,85, y=41,29, z=9,52], akCreeper['entity.modmercenario.akCreeper.name'/4252, l='MpServer', x=-59,97, y=68,00, z=63,66], EntityCreeper['Creeper'/2975, l='MpServer', x=-9,50, y=30,00, z=23,50], EntityCreeper['Creeper'/2976, l='MpServer', x=-4,50, y=30,00, z=17,50], EntityCreeper['Creeper'/2209, l='MpServer', x=-46,03, y=20,00, z=-12,50], EntityFish['Fish'/2468, l='MpServer', x=2,06, y=51,69, z=97,06], EntityBat['Murciélago'/3752, l='MpServer', x=-105,75, y=29,13, z=141,28], EntityZombie['Zombi'/2986, l='MpServer', x=-9,50, y=50,00, z=32,50], EntityZombie['Zombi'/2987, l='MpServer', x=-8,50, y=50,00, z=33,50], EntityPatronEffect['desconocido'/1452, l='MpServer', x=-59,95, y=68,00, z=63,67], EntityCreeper['Creeper'/1966, l='MpServer', x=6,50, y=30,00, z=63,50], EntityCreeper['Creeper'/431, l='MpServer', x=-99,44, y=35,00, z=29,53], EntityZombie['Zombi'/2223, l='MpServer', x=-28,00, y=20,00, z=56,41], EntityZombie['Zombi'/2224, l='MpServer', x=-25,50, y=20,00, z=53,50], EntityConcussionCreeper['Concussion Creeper'/433, l='MpServer', x=-97,50, y=34,00, z=33,50], EntityChicken['Pollo'/435, l='MpServer', x=-104,50, y=63,00, z=63,50], EntityChicken['Pollo'/436, l='MpServer', x=-104,50, y=63,00, z=63,50], EntityCow['Vaca'/437, l='MpServer', x=-111,50, y=68,00, z=62,38], EntityCow['Vaca'/438, l='MpServer', x=-111,50, y=68,00, z=61,03], EntityGib['desconocido'/2998, l='MpServer', x=-9,50, y=51,50, z=32,50], EntityCow['Vaca'/439, l='MpServer', x=-111,50, y=68,00, z=63,53], EntityGib['desconocido'/2999, l='MpServer', x=-9,85, y=51,28, z=32,46], EntityGib['desconocido'/3000, l='MpServer', x=-9,15, y=51,28, z=32,54], EntityChicken['Pollo'/441, l='MpServer', x=-104,50, y=63,00, z=64,50], EntityChicken['Pollo'/442, l='MpServer', x=-108,19, y=64,00, z=64,78], EntityGib['desconocido'/3002, l='MpServer', x=-8,50, y=51,50, z=33,50], EntityGib['desconocido'/3003, l='MpServer', x=-8,20, y=51,28, z=33,31], EntityGib['desconocido'/3004, l='MpServer', x=-8,80, y=51,28, z=33,69], EntityItem['item.item.emerald'/723, l='MpServer', x=-56,69, y=50,00, z=63,66], EntityItem['item.item.apple'/725, l='MpServer', x=-58,13, y=50,00, z=68,00], EntityItem['item.item.zss.bomb_standard'/726, l='MpServer', x=-58,50, y=54,00, z=69,31], EntityItem['item.item.zss.arrow_fire'/727, l='MpServer', x=-61,88, y=54,00, z=66,25], EntityItem['item.item.arrow'/728, l='MpServer', x=-61,88, y=54,00, z=66,13], EntityItem['item.item.zss.key_small'/729, l='MpServer', x=-61,88, y=54,00, z=66,53], EntityItem['item.item.zss.heart_piece'/730, l='MpServer', x=-61,38, y=54,00, z=69,88], EntityGib['desconocido'/2273, l='MpServer', x=-28,00, y=21,50, z=56,41], EntityGib['desconocido'/2274, l='MpServer', x=-27,78, y=21,28, z=56,14], EntityGib['desconocido'/2275, l='MpServer', x=-28,22, y=21,28, z=56,68], EntityGib['desconocido'/2277, l='MpServer', x=-25,50, y=21,50, z=53,50], EntityPlayerSP['Player'/1253, l='MpServer', x=-59,95, y=68,00, z=63,67], EntityGib['desconocido'/2278, l='MpServer', x=-25,83, y=21,28, z=53,39], EntityGib['desconocido'/2279, l='MpServer', x=-25,17, y=21,28, z=53,61], EntityCreeper['Creeper'/2024, l='MpServer', x=-48,50, y=30,00, z=49,50], EntityCow['Vaca'/748, l='MpServer', x=-30,63, y=73,00, z=-13,38], EntityZombie['Zombi'/4085, l='MpServer', x=-21,94, y=40,00, z=78,41], EntityCreeper['Creeper'/507, l='MpServer', x=-82,69, y=55,00, z=77,34], EntityCreeper['Creeper'/508, l='MpServer', x=-88,47, y=57,00, z=86,03]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:407) at net.minecraft.client.Minecraft.func_71396_d(Unknown Source) at net.minecraft.client.Minecraft.func_99999_d(Unknown Source) at net.minecraft.client.main.Main.main(SourceFile:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Linux (amd64) version 3.19.8-desktop-3.mga5 Java Version: 1.8.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 655746928 bytes (625 MB) / 1580654592 bytes (1507 MB) up to 2134114304 bytes (2035 MB) JVM Flags: 5 total; -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M IntCache: cache: 0, tcache: 0, allocated: 1, tallocated: 105 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1521 Optifine OptiFine_1.8_HD_U_D5 46 mods loaded, 46 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forge-1.8-11.14.3.1521.jar) UCHIJAAAA Forge{11.14.3.1521} [Minecraft Forge] (forge-1.8-11.14.3.1521.jar) UCHIJAAAA OldModelLoader{NX3 Build 111} [LMMNX OldModelLoader] (minecraft.jar) UCHIJAAAA PlayerAPI{1.4} [Player API] (minecraft.jar) UCHIJAAAA RenderPlayerAPI{1.5} [Render Player API] (minecraft.jar) UCHIJAAAA SmartCore{1.2.1} [smart Core] (minecraft.jar) UCHIJAAAA battlegear2{1.8} [Mine & Blade Battlegear 2 - Bullseye] (1.8-MB_Battlegear2-Bullseye-1.0.9.0.jar) UCHIJAAAA MoreFurnaces{1.3.11} [More Furnaces] (Better Furnaces Mod 1.8.jar) UCHIJAAAA BiomesOPlenty{3.0.0} [biomes O' Plenty] (BiomesOPlenty-1.8-3.0.0.1461-universal.jar) UCHIJAAAA Bloodmoon{1.2} [bloodmoon] (Bloodmoon-1.3.jar) UCHIJAAAA dldungeonsjdg{1.8.2} [Doomlike Dungeons] (DoomlikeDungeons-1.8.3-MC1.8.jar) UCHIJAAAA DungeonPack{1.8} [DungeonPack] (dungeonpack-1.8.jar) UCHIJAAAA DynamicLights{1.3.9} [Dynamic Lights] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_onFire{1.0.5} [Dynamic Lights Burning Entity Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_creepers{1.0.4} [Dynamic Lights Creeper Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_dropItems{1.0.8} [Dynamic Lights EntityItem Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_entityClasses{1.0.1} [Dynamic Lights Entity Light Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_mobEquipment{1.0.8} [Dynamic Lights Mob Equipment Light Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_flameArrows{1.0.0} [Dynamic Lights Fiery Arrows Light Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_floodLights{1.0.2} [Dynamic Lights Flood Light] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_otherPlayers{1.0.7} [Dynamic Lights OtherPlayers Light Module] (DynamicLights-1.8.jar) UCHIJAAAA DynamicLights_thePlayer{1.1.3} [Dynamic Lights Player Light Module] (DynamicLights-1.8.jar) UCHIJAAAA net.blacklab.lib{EL1 Build 5} [EBLib] (EBLib-EL1B5-1.8-F1450.jar) UCHIJAAAA EnderZoo{1.8-1.1.24_beta} [Ender Zoo] (Ender-Zoo-Mod-1.8.jar) UCHIJAAAA grim3212core{V0.1 - 1.8} [Grim3212 Core] (Grim3212-Core-V0.1 - 1.8.jar) UCHIJAAAA iChunUtil{5.4.0} [iChunUtil] (iChunUtil-5.4.0.jar) UCHIJAAAA lmmx{NX3 Build 111} [LittleMaidMobNX] (LittleMaidMobNX-NX3B111-1.8-F1450.jar) UCHIJAAAA MMMLibX{NX3 Build 111} [MMMLibX] (LittleMaidMobNX-NX3B111-1.8-F1450.jar) UCHIJAAAA lmmnxapi{8} [LMMNX API] (LittleMaidMobNX-NX3B111-1.8-F1450.jar) UCHIJAAAA minions{1.9.8} [Minions] (Minions-1.8.jar) UCHIJAAAA MobAmputation{5.0.0} [MobAmputation] (MobAmputation-5.0.0.jar) UCHIJAAAA modmercenario{1.8} [modmercenario] (modmercenario-0022_1.8.jar) UCHIJAAAA pokeball{V0.1 - 1.8} [Pokeball] (Pokeball-V0.1 - 1.8.jar) UCHIJAAAA realisticpain{1.0} [Realistic Pain] (Realistic Pain-1.0-1.8.jar) UCHIJAAAA Rediscovered{1.1} [Minecraft Rediscovered Mod] (Rediscovered-1.8-1.1.jar) UCHIJAAAA Roguelike{1.3.6} [Roguelike Dungeons] (RoguelikeDungeons-1.8-1.3.6.jar) UCHIJAAAA AS_Ruins{15.2} [Ruins Spawning System] (Ruins-1.8.jar) UCHIJAAAA SmartCursor{1.5.0} [smartCursor] (SmartCursor-Mod-1.8.jar) UCHIJAAAA SmartMoving{16.2} [smart Moving] (SmartMoving-1.8-16.2.jar) UCHIJAAAA SmartRender{2.1} [smart Render] (SmartRender-1.8-2.1.jar) UCHIJAAAA thirstmod{1.8.15} [Thirst Mod] (thirstmod-1.8.15.jar) UCHIJAAAA worldtools{1.1.1} [World Tools] (World-Tools-Mod-1.8.jar) UCHIJAAAA wormsmod{1.1.2} [Worms Mod] (wormsmod-1.8.x-1.1.2.jar) UCHIJAAAA XaeroMinimap{1.6.2} [Xaero's Minimap] (xaeros_minimap_v1.6.2_Forge_1.8.jar) UCHIJAAAA zeldaswordskills{1.8.1-3.0.1} [Zelda Sword Skills] (Zelda-Sword-Skills-Mod-1.8.jar) Loaded coremods (and transformers): Mine and Blade: Battlegear2 (1.8-MB_Battlegear2-Bullseye-1.0.9.0.jar) mods.battlegear2.coremod.transformers.EntityPlayerTransformer mods.battlegear2.coremod.transformers.ModelBipedTransformer mods.battlegear2.coremod.transformers.NetClientHandlerTransformer mods.battlegear2.coremod.transformers.NetServerHandlerTransformer mods.battlegear2.coremod.transformers.PlayerControllerMPTransformer mods.battlegear2.coremod.transformers.ItemRendererTransformer mods.battlegear2.coremod.transformers.RenderItemTransformer mods.battlegear2.coremod.transformers.MinecraftTransformer mods.battlegear2.coremod.transformers.ItemStackTransformer mods.battlegear2.coremod.transformers.ItemInWorldTransformer mods.battlegear2.coremod.transformers.EntityAIControlledByPlayerTransformer mods.battlegear2.coremod.transformers.EntityOtherPlayerMPTransformer MMMCoremod (LittleMaidMobNX-NX3B111-1.8-F1450.jar) mmmlibx.lib.multiModel.MMMLoader.MMMTransformer RenderPlayerAPIPlugin (RenderPlayerAPI-1.8-1.5.jar) api.player.forge.RenderPlayerAPITransformer PlayerAPIPlugin (PlayerAPI-1.8-1.4.jar) api.player.forge.PlayerAPITransformer LoadingPlugin (Bloodmoon-1.3.jar) lumien.bloodmoon.asm.ClassTransformer DLFMLCorePlugin (DynamicLights-1.8.jar) atomicstryker.dynamiclights.common.DLTransformer SmartCorePlugin (SmartMoving-1.8-16.2.jar) net.smart.core.SmartCoreTransformer BOPLoadingPlugin (BiomesOPlenty-1.8-3.0.0.1461-universal.jar) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 346.72' Renderer: 'GeForce GT 520/PCIe/SSE2' Launched Version: 1.8-forge1.8-11.14.3.1521 LWJGL: 2.9.1 OpenGL: GeForce GT 520/PCIe/SSE2 GL version 4.5.0 NVIDIA 346.72, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [Minecraft HD(x64) v18.1.5.zip, resources.zip] Current Language: Español (México) Profiler Position: N/A (disabled) akCreeper.class package mercenarymod.entidades.hostiles; import com.google.common.base.Predicate; import mercenarymod.entidades.armasDisparables; import mercenarymod.entidades.mobMercenario; import mercenarymod.entidades.ai.EntityAIakCreeperSwell; import mercenarymod.items.MercenaryModItems; import mercenarymod.utilidades.util; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIAvoidEntity; import net.minecraft.entity.ai.EntityAICreeperSwell; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityOcelot; import net.minecraft.entity.passive.EntityRabbit; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.Item; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathNavigateGround; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class akCreeper extends EntityMob implements IRangedAttackMob { /** * Time when this creeper was last in an active state (Messed up code here, * probably causes creeper animation to go weird) */ private int lastActiveTime; /** * The amount of time since the creeper was close enough to the player to * ignite */ private int timeSinceIgnited; private int fuseTime = 30; /** Explosion radius for this creeper. */ private int explosionRadius = 3; private int field_175494_bm = 0; private static final String __OBFID = "CL_00001684"; private int heldItemLeft = 1; /** * Records whether the model should be rendered holding an item in the right * hand, and if that item is a block. */ private int heldItemRight = 0; public boolean isSneak = false; /** Records whether the model should be rendered aiming a bow. */ private boolean aimedBow = false; private int aimedBowTick = 0; private int onUpdateTick = 0; private InventoryBasic mercenaryInventory; private EntityLivingBase shootingEntity; private int shootingEntityId = 0; private Entity targetEntity; private int targetEntityId = 0; private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 10, 30.0F); private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false); public akCreeper(World worldIn) { super(worldIn); this.setSize(0.6F, 1.8F); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.field_175455_a); // this.tasks.addTask(6, new EntityAIakCreeperSwell(this)); this.tasks.addTask(3, new EntityAIAvoidEntity(this, new Predicate() { private static final String __OBFID = "CL_00002224"; public boolean func_179958_a(Entity p_179958_1_) { return p_179958_1_ instanceof EntityOcelot; } public boolean apply(Object p_apply_1_) { return this.func_179958_a((Entity) p_apply_1_); } }, 6.0F, 1.0D, 1.2D)); ((PathNavigateGround) this.getNavigator()).func_179690_a(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[0])); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, mobMercenario.class, true)); this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityVillager.class, true)); this.tasks.addTask(3, new EntityAIAvoidEntity(this, new Predicate() { private static final String __OBFID = "CL_00002203"; public boolean func_179945_a(Entity p_179945_1_) { return p_179945_1_ instanceof EntityCreeper; } public boolean apply(Object p_apply_1_) { return this.func_179945_a((Entity) p_apply_1_); } }, 6.0F, 1.0D, 1.2D)); /* ItemStack ak200 = new ItemStack(MercenaryModItems.fusil200AKG, 1, 4); mercenarymod.items.armasdefuego.fusil200akg.fusil200AKG.intialize(ak200); util.setInttag(ak200, "municion", 999); */ ItemStack ak47 = new ItemStack(MercenaryModItems.fusil47AKG, 1, 4); mercenarymod.items.armasdefuego.fusil47akg.fusil47AKG.intialize(ak47); util.setInttag(ak47, "municion", 999); this.setCurrentItemOrArmor(0, ak47); if (worldIn != null && !worldIn.isRemote) { this.setCombatTask(); } } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20D); // 0.25D } /** * The maximum height from where the entity is alowed to jump (used in * pathfinder) */ public int getMaxFallHeight() { return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F); } public void fall(float distance, float damageMultiplier) { super.fall(distance, damageMultiplier); this.timeSinceIgnited = (int) ((float) this.timeSinceIgnited + distance * 1.5F); if (this.timeSinceIgnited > this.fuseTime - 5) { this.timeSinceIgnited = this.fuseTime - 5; } } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, Byte.valueOf((byte) -1)); this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); this.dataWatcher.addObject(18, Byte.valueOf((byte) 0)); // variables del render // a aimedBow boolean // s isSneak boolean // r heldItemRight int 0~4 // l heldItemLeft int 0~1 int lrsa = 0; this.dataWatcher.addObject(22, lrsa); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); if (this.dataWatcher.getWatchableObjectByte(17) == 1) { tagCompound.setBoolean("powered", true); } tagCompound.setShort("Fuse", (short) this.fuseTime); tagCompound.setByte("ExplosionRadius", (byte) this.explosionRadius); tagCompound.setBoolean("ignited", this.func_146078_ca()); } // ################################################################################################################# /** * sets this entity's combat AI. */ public void setCombatTask() { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItem(); if (armasDisparables.esDisparable(itemstack)) { this.tasks.addTask(4, this.aiArrowAttack); } else { this.tasks.addTask(4, this.aiAttackOnCollide); } } // ################################################################################################################# /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.dataWatcher.updateObject(17, Byte.valueOf((byte) (tagCompund.getBoolean("powered") ? 1 : 0))); if (tagCompund.hasKey("Fuse", 99)) { this.fuseTime = tagCompund.getShort("Fuse"); } if (tagCompund.hasKey("ExplosionRadius", 99)) { this.explosionRadius = tagCompund.getByte("ExplosionRadius"); } if (tagCompund.getBoolean("ignited")) { this.func_146079_cb(); } this.setCombatTask(); this.setCanPickUpLoot(false); } // ################################################################################################################# /** * Attack the specified entity using a ranged attack. */ @Override public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) { ItemStack itemstack = this.getHeldItem(); targetEntityId = target.getEntityId(); if (itemstack != null) { Item cosa = itemstack.getItem(); if (cosa == Items.bow) { EntityArrow entityarrow = new EntityArrow(this.worldObj, this, target, 1.6F, (float) (14 - this.worldObj.getDifficulty().getDifficultyId() * 4)); int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); if (i > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); } if (j > 0) { entityarrow.setKnockbackStrength(j); } this.worldObj.spawnEntityInWorld(entityarrow); } } this.targetEntity = target; // noEstaMuyLejosNiEstaObstruido(this, target, 30.0F); this.swingItem(); } // ################################################################################################################# /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); /* * if (this.isEntityAlive()) { * * * this.lastActiveTime = this.timeSinceIgnited; * * if (this.func_146078_ca()) { this.setCreeperState(1); } * * * int i = this.getCreeperState(); * * if (i > 0 && this.timeSinceIgnited == 0) { * this.playSound("creeper.primed", 1.0F, 0.5F); } * * this.timeSinceIgnited += i; * * if (this.timeSinceIgnited < 0) { this.timeSinceIgnited = 0; } * * if (this.timeSinceIgnited >= this.fuseTime) { this.timeSinceIgnited = * this.fuseTime; this.explode(); } } */ // actualizar variables del render atravez del dataWacher // variables del render // a aimedBow boolean // s isSneak boolean // r heldItemRight int 0~4 // l heldItemLeft int 0~1 int lrsa = 0; if (!this.worldObj.isRemote) { if (aimedBow) { lrsa = lrsa + 1; } if (isSneak) { lrsa = lrsa + 10; } if (heldItemRight > 0) { lrsa = lrsa + (heldItemRight * 100); } if (heldItemLeft > 0) { lrsa = lrsa + (heldItemLeft * 100); } this.dataWatcher.updateObject(22, (int)lrsa); } else { lrsa = this.dataWatcher.getWatchableObjectInt(22); aimedBow = false; if ((lrsa % 10) > 0) { aimedBow = true; } isSneak = false; if (((lrsa % 100) / 10) > 0) { isSneak = true; } heldItemRight = ((lrsa % 1000) / 100); heldItemLeft = ((lrsa % 10000) / 1000); } // ################################## // corregir altura del disparo if (targetEntity != null) { shootingEntity = this; aimedBowTick = 10; /* * System.out.println("\n\n\n"); * * System.out.println("#sh="+shootingEntity.getName() ); * System.out.println("#tg="+targetEntity.getName() ); * * System.out.println("tg height="+targetEntity.height); * System.out.println("tg eye="+targetEntity.getEyeHeight()); */ double x = shootingEntity.posX; double y = shootingEntity.posY; double z = shootingEntity.posZ; float yaw = shootingEntity.getRotationYawHead(); // shootingEntity.rotationYaw; float pitch = shootingEntity.rotationPitch; // vallestaMercenaria // System.out.println("pitch1 = "+pitch); // shootingEntity.height; this.posY = shootingEntity.posY + (double) shootingEntity.getEyeHeight() - 0.10000000149011612D; double d0 = targetEntity.posX - shootingEntity.posX; double d1 = (targetEntity.posY + targetEntity.getEyeHeight()) - (shootingEntity.posY); /// 3.0F /// targetEntity.getEntityBoundingBox().minY /// + /// (double) /// //+ /// shootingEntity.getEyeHeight() double d2 = targetEntity.posZ - shootingEntity.posZ; double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; // float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D / // Math.PI)); //- float f3 = (float) ((Math.tan(d1 / d3)) * 180.0D / Math.PI); // - float f4 = (float) ((Math.atan(d1 / d3) * -1) * 180.0D / Math.PI); // - // * // 180.0D // / // Math.PI1 /* * System.out.println("altura = "+d1); System.out.println( * "distancia = "+d3); * * System.out.println("f3 = "+f3); System.out.println("f4 = " * +f4); */ pitch = f4; // pitch - // System.out.println("pitch2 = "+pitch); } shootingEntity.setPositionAndRotation(x, y, z, yaw, pitch); // terminar una vez este muerto el objetivo if (!targetEntity.isEntityAlive()) { targetEntity = null; } } // ################################## // ### AimedBow ticks if (!this.worldObj.isRemote) { if (aimedBowTick > 0 | aimedBow) { aimedBow = true; if (aimedBowTick < 2) { aimedBow = false; } aimedBowTick--; } } onUpdateTick++; } // ################################################################################################################# /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.creeper.say"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.creeper.death"; } /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (cause.getEntity() instanceof EntitySkeleton) { int i = Item.getIdFromItem(Items.record_13); int j = Item.getIdFromItem(Items.record_wait); int k = i + this.rand.nextInt(j - i + 1); this.dropItem(Item.getItemById(k), 1); } else if (cause.getEntity() instanceof akCreeper && cause.getEntity() != this && ((akCreeper) cause.getEntity()).getPowered() && ((akCreeper) cause.getEntity()).isAIEnabled()) { ((akCreeper) cause.getEntity()).func_175493_co(); this.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F); } this.entityDropItem(new ItemStack(MercenaryModItems.bala76239mm_Standar, 0, 4), 0.0F); } public boolean attackEntityAsMob(Entity p_70652_1_) { return true; } /** * Returns true if the creeper is powered by a lightning bolt. */ public boolean getPowered() { return this.dataWatcher.getWatchableObjectByte(17) == 1; } /** * Params: (Float)Render tick. Returns the intensity of the creeper's flash * when it is ignited. */ @SideOnly(Side.CLIENT) public float getCreeperFlashIntensity(float p_70831_1_) { return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (float) (this.fuseTime - 2); } protected Item getDropItem() { return MercenaryModItems.bala76239mm_Standar;// gunpowder; } /** * Returns the current state of creeper, -1 is idle, 1 is 'in fuse' */ public int getCreeperState() { return this.dataWatcher.getWatchableObjectByte(16); } /** * Sets the state of creeper, -1 to idle and 1 to be 'in fuse' */ public void setCreeperState(int p_70829_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte) p_70829_1_)); } /** * Called when a lightning bolt hits the entity. */ public void onStruckByLightning(EntityLightningBolt lightningBolt) { super.onStruckByLightning(lightningBolt); this.dataWatcher.updateObject(17, Byte.valueOf((byte) 1)); } /** * Called when a player interacts with a mob. e.g. gets milk from a cow, * gets into the saddle on a pig. */ protected boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() == Items.flint_and_steel) { this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.ignite", 1.0F, this.rand.nextFloat() * 0.4F + 0.8F); player.swingItem(); if (!this.worldObj.isRemote) { this.func_146079_cb(); itemstack.damageItem(1, player); return true; } } return super.interact(player); } /** * Creates an explosion as determined by this creeper's power and explosion * radius. */ private void explode() { if (!this.worldObj.isRemote) { boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); float f = this.getPowered() ? 2.0F : 1.0F; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag); this.setDead(); } } public boolean func_146078_ca() { return this.dataWatcher.getWatchableObjectByte(18) != 0; } public void func_146079_cb() { this.dataWatcher.updateObject(18, Byte.valueOf((byte) 1)); } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return this.field_175494_bm < 1 && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"); } public void func_175493_co() { ++this.field_175494_bm; } // ################################################################################################################# @Override public boolean allowLeashing() { return super.allowLeashing(); } // ################################################################################################################# public boolean getAimedBow() { return aimedBow; } // ################################################################################################################# public void setAimedBow(boolean a) { aimedBow = a; } // ################################################################################################################# public boolean getisSneak() { return isSneak; } // ################################################################################################################# public void setisSneak(boolean s) { isSneak = s; } // ################################################################################################################# public int getHeldItemRight() { return heldItemRight; } // ################################################################################################################# public void setHeldItemRight(int r) { heldItemRight = r; } // ################################################################################################################# public int getHeldItemLeft() { return heldItemLeft; } // ################################################################################################################# public void setHeldItemLeft(int r) { heldItemLeft = r; } }
-
hey thanks the bioma[] fix it, and then the 100, 4, 4 (weight, min, max). means the entity shall spanw 100% for sure whit at least four entityes per chunk and now i remenber and old doub the entity ID //preinit registroSimple( mercenarymod.entidades.hostiles.akCreeper.class , "akCreeper"); //#### //registrar entidad Simple public static void registroSimple(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 4, true); } //Init BiomeGenBase[] allBiomes = FluentIterable.from(Arrays.asList(BiomeGenBase.getBiomeGenArray())).filter(Predicates.notNull()).toArray(BiomeGenBase.class); EntityRegistry.addSpawn(mercenarymod.entidades.hostiles.akCreeper.class, 100, 1, 5, EnumCreatureType.MONSTER, allBiomes); i read some where than the EntityRegistry.findGlobalUniqueEntityId(); has a limit of 256 and becoze of this is bether to set ids manually and spawning eggs dont work unless you use and id from EntityRegistry.findGlobalUniqueEntityId(); spawn eggs are not of concern for mi mod and i dont see a reason i coul'dn make a common item egg shaped to spawn mi entityes if ist true the limit of 256 what is the rules to asign id numbers coz i remenber the times of 1.6 whith their mobs id conflict focking up at the startup of minecraft, and wanna avoid that if posible thanks for reading
-
good nigths this nigth im working on make mi custom entity spawn in the world, but two things i dont grasp im using this to register and spawn registrarEntidad( mercenarymod.entidades.hostiles.akCreeper.class , "akCreeper"); EntityRegistry.addSpawn(mercenarymod.entidades.hostiles.akCreeper.class, 8, 1, 5, EnumCreatureType.MONSTER, BiomeGenBase.plains); //registrar entidad public static void registrarEntidad(Class entityClass, String name) { int entityID = EntityRegistry.findGlobalUniqueEntityId(); long seed = name.hashCode(); Random rand = new Random(seed); int primaryColor = rand.nextInt() * 16777215; int secondaryColor = rand.nextInt() * 16777215; EntityRegistry.registerGlobalEntityID(entityClass, name, entityID); System.out.println("$$$ entityID="+entityID+" "+name); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 4, true); EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); } ##### in one side i want to now how works spawn rate, if i leave this in 8, 1, 5, EnumCreatureType.MONSTER, the mob have very low spawns rate, but spawn if i set it to 99, 1, 5, or 1, 1, 5, or 20, 1, 5, the entity don't spawn or a least i have not seeit spawing this is a custom creeper it must spawn almost the same as vainilla creeper i need to now creepers spawn rate to set it all, and all the test has been done on a plane whole world all in the plains bioma ##### the other thing i need to know, is how i set this spawn to multiples biomas why this line its only spawn in the plains biomas, is there somewhere a BiomeGenBase.all or i must write a line per bioma wanted for spawn , if then how do you do whith the custom biomas aded for other mods EntityRegistry.addSpawn(mercenarymod.entidades.hostiles.akCreeper.class, 8, 1, 5, EnumCreatureType.MONSTER, BiomeGenBase.all); //? multi biomas thanks for reading
-
[1.8] make zombie drops custom seeds<SOLVED>
perromercenary00 replied to perromercenary00's topic in Modder Support
eee upss Fixed // Zombie drops @SubscribeEvent public void onEntityDrop(LivingDropsEvent event) { if (event.entity instanceof EntityZombie) { int R = ((int) (Math.random() * 100)); //5% if (R > 94) { event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaVerdeSemilla, 1))); } //2% R = ((int) (Math.random() * 100)); if (R > 98) { event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaRojaSemilla, 1))); } //2% R = ((int) (Math.random() * 100)); if (R > 98) { event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaAzulSemilla, 1))); } //not for now R = ((int) (Math.random() * 100)); if (R > 100) { event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaAmarillaSemilla, 1))); } } } -
good nigths i wanna make the zoombies drop mi custom seeds when dieded but it seems its dont wants to work reading some guides i reach to this two methods but eithers works @EventHandler public void onEntityDrop(LivingDropsEvent event){ System.out.println("\nLivingDropsEvent"); if(event.entity instanceof EntityZombie){ EntityZombie zom = (EntityZombie) event.entity; int R = ((int) (Math.random() * 3)) ; Item tudrop = null; switch (R) { case 0: tudrop = MercenaryModItems.hierbaVerdeSemilla; case 1: tudrop = MercenaryModItems.hierbaRojaSemilla; case 2: tudrop = MercenaryModItems.hierbaAmarillaSemilla; case 3: tudrop = MercenaryModItems.hierbaAzulSemilla; } BlockPos bzom = zom.getPosition().add(0,1,0); World bworld = zom.getEntityWorld(); bworld.spawnEntityInWorld(new EntityItem(bworld, bzom.getX(), bzom.getY(), bzom.getZ(), new ItemStack(tudrop ,1,0))); } } @EventHandler public void onEDeath(LivingDeathEvent event) { System.out.println("\nLivingDeathEvent"); //drops the item if (event.entity instanceof EntityZombie) { EntityZombie zom = (EntityZombie) event.entity; System.out.println("\nZOMMMBIE"); int R = ((int) (Math.random() * 3)) ; Item tudrop = null; switch (R) { case 0: tudrop = MercenaryModItems.hierbaVerdeSemilla; case 1: tudrop = MercenaryModItems.hierbaRojaSemilla; case 2: tudrop = MercenaryModItems.hierbaAmarillaSemilla; case 3: tudrop = MercenaryModItems.hierbaAzulSemilla; } BlockPos bzom = zom.getPosition().add(0,1,0); World bworld = zom.getEntityWorld(); bworld.spawnEntityInWorld(new EntityItem(bworld, bzom.getX(), bzom.getY(), bzom.getZ(), new ItemStack(tudrop ,1,0))); } } some one can point wath i been doing wrong thanks for reading
-
ñaaa i frustate whith UUID i found't not any method to get back the entity using the uuid only this worldIn.getPlayerEntityByUUID(UUID.fromString(fantasmaUUID)) but this is only for EntityPlayer, and i need to recall most of the time EntityLivingBase so anyway i tried this whith the uuid from an entityLivingBase Entity temp00 = worldIn.getPlayerEntityByUUID(UUID.fromString(fantasmaUUID)); an it returns Null, and no errors the other thing i notice is that the entityID change when i close/save the world and then reload the saved world, but not the uuid thats has no changes soo recall a deadEntity by ID won't gonna works coze its changes and can't recall an entity by storing their ID number in an item, after close minecraft not gonna works coze its change the ID #### At the point ¿¿ is way to recall an EntityLivingBase(notDead) using their UUID in both remote and local world ??
-
[1.8] [SOLVED] Push floating drops
perromercenary00 replied to jeffryfisher's topic in Modder Support
yea rare i been using thath metod in my grenade entity List lista=null; int f=10; BlockPos posMin = nucleo.add( -f, -f, -f); BlockPos posMax = nucleo.add( f, f, f); AxisAlignedBB boundingBox=new AxisAlignedBB(posMin, posMax); lista = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox); yaa probably is the boundingBox wrong defined -
i du not know wath are fiting for been doing some test and can't not return an entity from dead, i been using entity id coz there is no method in the world class to call an entity for the uuid aparently thats only for EntityPlayer // ###################################################################################3 fantasmaMercenarioMarkLancer getFantasma(World worldIn,EntityLivingBase entidad, ItemStack pistola) { int fantasmaID = util.getInttag(pistola, "fantasmaID"); String fantasmaUUID = util.getStringtag(pistola, "fantasmaUUID"); boolean createFantasma = true; if ( fantasmaID > 0 ) //if (fantasmaUUID.length() > 0) { createFantasma = false; System.out.println( "\n\nFantasma Conjurado id =("+fantasmaID+")\n" ); System.out.println( "\n\nFantasma Conjurado uuid=("+fantasmaUUID+")\n" ); Entity entidad2 = worldIn.getEntityByID(fantasmaID); //Entity entidad2 = worldIn.getPlayerEntityByUUID(UUID.fromString(fantasmaUUID)); if (entidad2 == null) { //here it return a pretty java.lang.NullPointerException for the entidad2.isDead //so it is absolutly null System.out.println( "\nEl Fantasma es Nulo="+entidad2.isDead ); //createFantasma = true; } else { System.out.println( "\nEntidad="+entidad2.getName()+"\n"); } /* if ( !entidad2.isDead ) { System.out.println( "\n00 el Fantasma("+fantasmaID+") esta Vivo" ); } else { System.out.println( "\n00 el Fantasma("+fantasmaID+") esta Muerto" ); entidad2.isDead = false; } if ( !entidad2.isDead ) { System.out.println( "\n01 el Fantasma("+fantasmaID+") esta Vivo" ); } */ if (entidad2 != null) { if (entidad2 instanceof fantasmaMercenarioMarkLancer) { System.out.println( "\ninstanceof fantasmaMercenarioMarkLancer\n" ); if (entidad2.isEntityAlive()) { System.out.println( "\n is Alive fantasmaMercenarioMarkLancer\n" ); crearFantasma = false; return (fantasmaMercenarioMarkLancer)entidad2; } } else { crearFantasma = true; System.out.println( "\nla entidad "+fantasmaID+" No Es un fantasma mercenario\n" ); } } else { crearFantasma = true; System.out.println( "\nla entidad "+fantasmaID+" No existe\n" ); } } if (crearFantasma){ return conjurar(worldIn, entidad, pistola); } return null; } // ###################################################################################3 fantasmaMercenarioMarkLancer conjurar(World worldIn, EntityLivingBase shootingEntity, ItemStack pistola) { fantasmaMercenarioMarkLancer entidad = null; if (!worldIn.isRemote) { mercenarymod.entidades.fantasmaMercenarioMarkLancer fantasma = new mercenarymod.entidades.fantasmaMercenarioMarkLancer(worldIn); fantasma.setPistola(pistola); fantasma.setShootingEntity(shootingEntity); // fantasma.setTargetEntity(entidad.getAITarget()); double x = shootingEntity.posX; double y = shootingEntity.posY + shootingEntity.getEyeHeight(); double z = shootingEntity.posZ; float yaw = shootingEntity.rotationYaw; // getRotationYawHead(); rotationYaw; float pitch = shootingEntity.rotationPitch; fantasma.setPositionAndRotation(x, y, z, yaw, pitch); int fantasmaID = fantasma.getEntityId(); String fantasmaUUID = fantasma.getUniqueID().toString(); util.setInttag(pistola, "fantasmaID", fantasmaID); util.setStringtag(pistola, "fantasmaUUID", fantasmaUUID); System.out.println( "\n\nFantasma Conjurado id =("+fantasmaID+")\n" ); System.out.println( "\n\nFantasma Conjurado uuid=("+fantasmaUUID+")\n" ); worldIn.spawnEntityInWorld(fantasma); fantasma.setShootingEntity(shootingEntity); fantasma.setPistola(pistola); entidad = fantasma; } return entidad; } // ########################################################################3 this test was done first i use the gun once to create the entity fantasma and load the values in the nbttag for the gun i close all minecraft i reopen minecraft the entity dies coz has not all the values neede to work then i use again the gun to recall the dead fantasma using its ID, but fails the entity returned is absolutly null
-
i have this little issue whith this of writing custom nbttag to entityes i been working if a wololo staff there is a later post, but i store the ownweUUID as string in an nbt whith the same name is done in entityTameable for that i du UUID uuid = playerIn.getUniqueID(); String Suuid = playerIn.getUniqueID().toString(); NBTTagCompound targetNBT = target.getEntityData(); targetNBT.setString("OwnerUUID", Suuid); // this write the uuid to targetEntity i can later reade it. if i close completely minecraft restart the pc fireup again the minecraft the nbt is still there but is only accessible in the server side coz in the client side it allways return empty, and i notice there is not an target.setEntityData(NBTTagCompound targetNBT); ############################ i think is becoze i been mising something to writte the nbttag whith the change again to entity soo nbttags gets magicaly update or what is the code to write an nbttag to an entity ?? i ask this coz today im working in a complex entitie that gona manage a complex firegun, well i gone try to fix the mark2lacer from mi mod this entity has to have access to the player Inventory but like i wana do this gun compatible whith mi custom mobs the methods to check if the entity has magazines or bullets must be compatibles whith EntityLivingBase plus must be able to read from the inventories i be done in custome armour, that means i have to extract the inventory rigth from the nbtags rater than the playerIn.inventory.methods and later writing back when comsume bullets or magazines something like // #########################################################################3 // @Override public void readFromNBT() { this.clear(); //delete the contens from the inventory arrays //here is to inventoryes array [] // shootinginventario[] for the player or mob inventory and // inventario[] for the items store in the armour pockets //later i gona join this two in only one to make easy // Shoting Entity Inventory if (shootingEntity != null) { NBTTagCompound compound3 = shootingEntity.getEntityData(); if (compound3 != null) { NBTTagList nbttaglist3 = compound3.getTagList("Items", 10); if (nbttaglist3.tagCount() > 0) { for (int i = 0; i < nbttaglist3.tagCount(); ++i) { NBTTagCompound nbttagcompound3 = nbttaglist3.getCompoundTagAt(i); int j = nbttagcompound3.getByte("Slot") & 255; if (j >= 0 && j < shootinginventario.length) { shootinginventario[j] = ItemStack.loadItemStackFromNBT(nbttagcompound3); if (shootinginventario[j] != null) { } } } } } } inventario[0] = this.shootingEntity.getEquipmentInSlot(0);// .getHeldItem(); inventario[3] = this.shootingEntity.getEquipmentInSlot(3);// getCurrentArmor(2);chest chestItem = inventario[3]; // this.entidad.getEquipmentInSlot(3); //inventario en la armadura if (chestItem != null) { NBTTagCompound compound2 = chestItem.getTagCompound(); if (compound2 != null) { NBTTagList nbttaglist2 = compound2.getTagList("Items", 10); if (nbttaglist2.tagCount() > 0) { for (int i = 0; i < nbttaglist2.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist2.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < inventario.length) { inventario[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); if (inventario[j] != null) { } } } } } } } // #########################################################################3 // Sorry i been doing more turn arounds than nesesary coze english is not native languague what i need is now how to write an NBTTAG compound Back to an Entity Thanks for reading
-
soo they are delete lets say i wanna create an entity for the sole proposite of storing data from an item and for some reason i don't wanna use directly the nbt in the item, but the datawacher in the entity, and ad the same i only want this storingEntity to be alive when the item is held if is not this must remain dead or i gona have a trouble of excess of ghost entityes over the head of the player but in the other hand ? is way to store a whole entitie in an item ?
-
thats the question in mi mod i spawn entities like crazy, every bullet you shoot is an entity, every ghost to launch an action in a gun is an entity. soo is posible for the game to lag or freeze if it is to many dead() Entities store in the database of whatever is called or beter said can I fuckUp a world if not carefull whith the amounts of custome entities Dead() mi mod generates ?
-
Now is done for solved i discover it don't cares if i do an NBTTagCompound targetNBT = target.getEntityData(); String own = targetNBT.getString("OwnerUUID"); UUID uuid = UUID.fromString(own); ownerEntity = worldIn.getPlayerEntityByUUID(uuid); it return the playerEntity when the uuid is "00000000-0000-0000-0000-000000000000" but i have to give up to the idea of make the little maids change to tamed whith this staff the maids has hers own way to set the Master entity for that i must make mi mod ask for the littlemaidMod as a dependency i dont want that it only gonna works whith vainilla wolves Horses and mi custom entityes may later i do some changes to make the staff replace vainilla mobs for custom mob version that atack other mobs well as is works anyway thanks
-
ñaaa mising topic this is the normal minecraft you download from mojan, plus the forge for the mods no any other hack or crack has been added to this instalation. isay it becoze whith this set up i can't enter to servers and my player Name is always "Player" and think this could be relevant info now going back to the topic i use the command. UUID uuid = playerIn.getUniqueID(); to get the uuid from the player and write it on the entities, this piece of code when runing on eclipse works perfect it return the uuid from the player whith that i could make me own entityes like horses an wolves and mi custom entities but when compile the mod and run in the normal minecraft vainilla game the code return only Zeroes bether explain showing video in this video the key is the green leters in the screen, this are the uuid from the player using the staff the first part in eclipse, the second is in the runing vainilla game and the code geting the uuid run only in the server side so i think maiby is like minecraft mc only runing in the client side or something ?if its the case, is some way i could get the player uuid in the server side ? thanks
-
good days Im triying to make some kind of wololo Staff and its works well in eclipse i can get control from wolfs and horses, as well as ocelotes but when compile and put the mod in normal forged Minecraft it does Not work so i set some System.outs and find than UUID uuid = playerIn.getUniqueID(); String Suuid = uuid.toString(); //playerIn.getUniqueID().toString(); is returning zero's per example in eclipse it returns Suuid=a73b0b5d-2d3b-3ddb-ba64-20632ca9f512 but after compile in the game this is Suuid=00000000-0000-0000-0000-00000000000 ### is there way to fix this, or at least another way to get the uuid from player ??
-
and thats solve it all fix the slot.class and whith that i fix the other things now i can display the entity inventorys, whitout hiden slots disabling the player from steal from the entityes. fix the thing whith the armour slots now only allow the rigth armour type package mercenarymod.gui.containers; import mercenarymod.entidades.armasDisparables; //package net.minecraft.inventory; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class mercenarySlot extends Slot { /** The index of the slot in the inventory. */ private final int slotIndex; /** The inventory we want to extract a slot from. */ public final IInventory inventory; /** the id of the slot(also the index in the inventory arraylist) */ public int slotNumber; /** display position of the inventory slot on the screen x axis */ public int xDisplayPosition; /** display position of the inventory slot on the screen y axis */ public int yDisplayPosition; private static final String __OBFID = "CL_00001762"; private boolean habilitado = true; // ##########################################################################################3 public mercenarySlot(IInventory inventoryIn, int index, int xPosition, int yPosition, boolean habilitado) { super(inventoryIn, index, xPosition, yPosition); this.inventory = inventoryIn; this.slotIndex = index; this.xDisplayPosition = xPosition; this.yDisplayPosition = yPosition; this.habilitado = habilitado; } // ##########################################################################################3 @Override /** * Check if the stack is a valid item for this slot. Always true beside for * the armor slots. */ public boolean isItemValid(ItemStack stack) { int index = this.slotIndex; if (index > 0 & index < 5 ) { /** Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots */ int armadura = armasDisparables.esArmadura(stack); if (armadura < 0) { return false; } //botas if (index == 1 & armadura != 3) { return false; } //pantalones if (index == 2 & armadura != 2) { return false; } //chest if (index == 3 & armadura != 1) { return false; } //casco if (index == 4 & armadura != 0) { return false; } } return habilitado; } // ##########################################################################################3 @Override /** * Return whether this slot's stack can be taken from this slot. */ public boolean canTakeStack(EntityPlayer playerIn) { return habilitado; } // ##########################################################################################3 @Override /** * Actualy only call when we want to render the white square effect over the * slots. Return always True, except for the armor slot of the Donkey/Mule * (we can't interact with the Undead and Skeleton horses) */ @SideOnly(Side.CLIENT) public boolean canBeHovered() { return habilitado; } // ##########################################################################################3 public void setHabilitado(boolean b) { habilitado = b; } // ##########################################################################################3 public boolean getHabilitado() { return habilitado; } } package mercenarymod.gui.containers; import net.minecraft.entity.Entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import mercenarymod.entidades.armasDisparables; import mercenarymod.items.armasdefuego.inventario.inventarioArmas; import mercenarymod.items.armasdefuego.inventario.inventarioArmasyEntidades; import mercenarymod.tileentity.ModTileEntity; import mercenarymod.utilidades.util; public class ContainerMenuMercenario02 extends Container { private inventarioArmasyEntidades inventarioenlaArmadura; private IInventory playerInv = null; private EntityLivingBase entidad = null; // ############################################################################################################################################## // ############################################################################################################################################## public ContainerMenuMercenario02(IInventory playerInv, inventarioArmasyEntidades te, boolean canbeTaken ) { // super(); this.inventarioenlaArmadura = te; this.entidad = te.getEntity(); this.playerInv = playerInv; // te.readFromNBT(null); ItemStack chestIS = this.entidad.getEquipmentInSlot(3); int sn = 0; if (chestIS != null) { //get the slots number from armour and change to that sn = armasDisparables.tieneBolsillos(chestIS); } switch (sn) { case 0: this.cambiarA0(canbeTaken); break; case 7: this.cambiarA7(canbeTaken); break; case 23: this.cambiarA23(canbeTaken); break; } } // ############################################################################################################################################## public void cambiarA0( boolean canbeTaken ) { //reset all inventory arrays to Zero inventoryItemStacks = Lists.newArrayList(); inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // 0 - 27 chest slots // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, 8, canbeTaken)); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62, canbeTaken)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, 26, 26, false)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, 53, 8, false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, 71, 8, false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, 53, 26, false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, 71, 26, false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, 53, 44, false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, 71, 44, false)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), 98, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), 116, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), 134, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), 152, 8 + (18 * x), false)); } // 28 - 54 // Player Inventory, Slot 28 - 54, Slot IDs 28 - 54 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 63 // Player Inventory, Slot 55-63, Slot IDs 55-63 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x, 8 + x * 18, 142)); } } // ############################################################################################################################################## public void cambiarA7(boolean canbeTaken) { //reset all inventory arrays to Zero inventoryItemStacks = Lists.newArrayList(); inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // 0 - 27 chest slots // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, 8, canbeTaken)); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62, canbeTaken)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, 26, 26, canbeTaken)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, 53, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, 71, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, 53, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, 71, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, 53, 44, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, 71, 44, canbeTaken)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), 98, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), 116, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), 134, 8 + (18 * x), false)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), 152, 8 + (18 * x), false)); } // 28 - 54 // Player Inventory, Slot 28 - 54, Slot IDs 28 - 54 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 63 // Player Inventory, Slot 55-63, Slot IDs 55-63 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x, 8 + x * 18, 142)); } } // ############################################################################################################################################## public void cambiarA23(boolean canbeTaken) { //reset all inventory arrays to Zero inventoryItemStacks = Lists.newArrayList(); inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // 0 - 27 chest slots // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, 8, canbeTaken)); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62, canbeTaken)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, 26, 26, canbeTaken)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, 53, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, 71, 8, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, 53, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, 71, 26, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, 53, 44, canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, 71, 44, canbeTaken)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), 98, 8 + (18 * x), canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), 116, 8 + (18 * x), canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), 134, 8 + (18 * x), canbeTaken)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), 152, 8 + (18 * x), canbeTaken)); } // 28 - 54 // Player Inventory, Slot 28 - 54, Slot IDs 28 - 54 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 63 // Player Inventory, Slot 55-63, Slot IDs 55-63 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(this.playerInv, x, 8 + x * 18, 142)); } } // ############################################################################################################################################## @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.inventarioenlaArmadura.isUseableByPlayer(playerIn); } // ############################################################################################################################################## @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = null; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < 28) { // From TE Inventory to Player Inventory if (!this.mergeItemStack(current, 28, 63, true)) return null; } else { // From Player Inventory to TE Inventory if (!this.mergeItemStack(current, 0, 28, false)) return null; } if (current.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); if (current.stackSize == previous.stackSize) return null; slot.onPickupFromSlot(playerIn, current); } return previous; } // ############################################################################################################################################## // 0 -4 armadura y arma // 5 arma secundaria // 6-11 pockets // 12 -27 backpack // 28 -54 inventory // 55 -63 hotbar // ################################################################################################################################################################################# }
-
well is becoze i been alredy tryng that and don't works this is in the IInventory class, but this is just for when player pickup somethig or drop something in the inventory i think must do same but in the slot class and thats trouble if i extend the Slot.class whit mi mercenarySlot.class for some reason the forge Container.class don't accep mi slot's and i end whith a bunch of empty slots in the gui, is like all slots that reach to Container.class is null or becomes null and it sends its like that // ################################################################################################### /** * Returns true if automation is allowed to insert the given stack (ignoring * stack size) into the given slot. */ @Override public boolean isItemValidForSlot(int index, ItemStack stack) { if (index > 0 & index < 5 ) { /** Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots */ int armadura = armasDisparables.esArmadura(stack); if (armadura < 0) { return false; } //botas if (index == 1 & armadura != 3) { return false; } //pantalones if (index == 2 & armadura != 2) { return false; } //chest if (index == 3 & armadura != 1) { return false; } //casco if (index == 4 & armadura != 0) { return false; } } return true; } // ################################################################################################### package mercenarymod.gui.containers; //package net.minecraft.inventory; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class mercenarySlot extends Slot { /** The index of the slot in the inventory. */ private final int slotIndex; /** The inventory we want to extract a slot from. */ public final IInventory inventory; /** the id of the slot(also the index in the inventory arraylist) */ public int slotNumber; /** display position of the inventory slot on the screen x axis */ public int xDisplayPosition; /** display position of the inventory slot on the screen y axis */ public int yDisplayPosition; private static final String __OBFID = "CL_00001762"; private boolean habilitado = true; // ##########################################################################################3 public mercenarySlot(IInventory inventoryIn, int index, int xPosition, int yPosition) { super(inventoryIn, index, xPosition, yPosition); this.inventory = inventoryIn; this.slotIndex = index; this.xDisplayPosition = xPosition; this.yDisplayPosition = yPosition; } // ##########################################################################################3 @Override /** * if par2 has more items than par1, onCrafting(item,countIncrease) is * called */ public void onSlotChange(ItemStack p_75220_1_, ItemStack p_75220_2_) { if (p_75220_1_ != null && p_75220_2_ != null) { if (p_75220_1_.getItem() == p_75220_2_.getItem()) { int i = p_75220_2_.stackSize - p_75220_1_.stackSize; if (i > 0) { this.onCrafting(p_75220_1_, i); } } } } // ##########################################################################################3 @Override /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, * not ore and wood. Typically increases an internal count then calls * onCrafting(item). */ protected void onCrafting(ItemStack stack, int amount) { } // ##########################################################################################3 @Override /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, * not ore and wood. */ protected void onCrafting(ItemStack stack) { } // ##########################################################################################3 @Override public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { this.onSlotChanged(); } // ##########################################################################################3 @Override /** * Check if the stack is a valid item for this slot. Always true beside for * the armor slots. */ public boolean isItemValid(ItemStack stack) { return true; } // ##########################################################################################3 @Override /** * Helper fnct to get the stack in the slot. */ public ItemStack getStack() { return this.inventory.getStackInSlot(this.slotIndex); } // ##########################################################################################3 @Override /** * Returns if this slot contains a stack. */ public boolean getHasStack() { return this.getStack() != null; } // ##########################################################################################3 @Override /** * Helper method to put a stack in the slot. */ public void putStack(ItemStack stack) { this.inventory.setInventorySlotContents(this.slotIndex, stack); this.onSlotChanged(); } // ##########################################################################################3 @Override /** * Called when the stack in a Slot changes */ public void onSlotChanged() { this.inventory.markDirty(); } // ##########################################################################################3 @Override /** * Returns the maximum stack size for a given slot (usually the same as * getInventoryStackLimit(), but 1 in the case of armor slots) */ public int getSlotStackLimit() { return this.inventory.getInventoryStackLimit(); } // ##########################################################################################3 @Override public int getItemStackLimit(ItemStack stack) { return this.getSlotStackLimit(); } // ##########################################################################################3 @Override @SideOnly(Side.CLIENT) public String getSlotTexture() { return backgroundName; } // ##########################################################################################3 @Override /** * Decrease the size of the stack in slot (first int arg) by the amount of * the second int arg. Returns the new stack. */ public ItemStack decrStackSize(int amount) { return this.inventory.decrStackSize(this.slotIndex, amount); } // ##########################################################################################3 @Override /** * returns true if the slot exists in the given inventory and location */ public boolean isSlotInInventory(IInventory inv, int slotIn) { return inv == this.inventory && slotIn == this.slotIndex; } // ##########################################################################################3 @Override /** * Return whether this slot's stack can be taken from this slot. */ public boolean canTakeStack(EntityPlayer playerIn) { return habilitado; } // ##########################################################################################3 @Override /** * Actualy only call when we want to render the white square effect over the * slots. Return always True, except for the armor slot of the Donkey/Mule * (we can't interact with the Undead and Skeleton horses) */ @SideOnly(Side.CLIENT) public boolean canBeHovered() { return habilitado; } // ##########################################################################################3 public void setHabilitado(boolean b) { habilitado = b; } // ##########################################################################################3 public boolean getHabilitado() { return habilitado; } } package mercenarymod.gui.containers; import net.minecraft.entity.Entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import mercenarymod.entidades.armasDisparables; import mercenarymod.items.armasdefuego.inventario.inventarioArmas; import mercenarymod.items.armasdefuego.inventario.inventarioArmasyEntidades; import mercenarymod.tileentity.ModTileEntity; import mercenarymod.utilidades.util; public class ContainerMenuMercenario02 extends Container { private int bolsillos = 0; private inventarioArmasyEntidades inventarioenlaArmadura; private IInventory playerInv = null; private EntityLivingBase entidad = null; /** * The current drag mode (0 : evenly split, 1 : one item by slot, 2 : not * used ?) */ //private int dragMode = -1; /** The current drag event (0 : start, 1 : add slot : 2 : end) */ //private int dragEvent; /** The list of slots where the itemstack holds will be distributed */ //private final Set dragSlots = Sets.newHashSet(); // ############################################################################################################################################## private void cantidaddeBolsillos() { } // ############################################################################################################################################## /* * SLOTS: * * Tile Entity 0-8 ........ 0 - 8 Player Inventory 9-35 .. 9 - 35 Player * Inventory 0-8 ... 36 - 44 */ public ContainerMenuMercenario02(IInventory playerInv, inventarioArmasyEntidades te) { // super(); this.inventarioenlaArmadura = te; this.bolsillos = te.getBolsillos(); this.entidad = te.getEntity(); this.playerInv = playerInv; // System.out.println("################# ContainerMenuMercenario02"); // weapon slot this.addSlotToContainer(new mercenarySlot(te, 0, 26, ); // entity armor slots this.addSlotToContainer(new mercenarySlot(te, 4, 8, ); this.addSlotToContainer(new mercenarySlot(te, 3, 8, 26)); this.addSlotToContainer(new mercenarySlot(te, 2, 8, 44)); this.addSlotToContainer(new mercenarySlot(te, 1, 8, 62)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(te, 5, -999, 26)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(te, 6, -999, ); this.addSlotToContainer(new mercenarySlot(te, 7, -999, ); this.addSlotToContainer(new mercenarySlot(te, 8, -999, 26)); this.addSlotToContainer(new mercenarySlot(te, 9, -999, 26)); this.addSlotToContainer(new mercenarySlot(te, 10, -999, 44)); this.addSlotToContainer(new mercenarySlot(te, 11, -999, 44)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(te, 12 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(te, 13 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(te, 14 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(te, 15 + (x * 4), -999, 8 + (18 * x))); } // 0 - 27 chest slots // 28 - 54 // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 64 // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(playerInv, x, 8 + x * 18, 142)); } // te.readFromNBT(null); ItemStack chestIS = this.entidad.getEquipmentInSlot(3); if (chestIS != null) { int sn = armasDisparables.tieneBolsillos(chestIS); this.bolsillos = sn; switch (sn) { case 0: this.cambiarA0(); break; case 7: this.cambiarA7(); break; case 23: this.cambiarA23(); break; } } } // ############################################################################################################################################## public void cambiarA0() { inventoryItemStacks = Lists.newArrayList(); /** the list of all slots in the inventory */ inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // System.out.println("################# ContainerMenu cambiarA0"); // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, ); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, -999, 26)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, -999, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, -999, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, -999, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, -999, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, -999, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, -999, 44)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), -999, 8 + (18 * x))); } /* * Tile Entity 0-8 ........ 0-27 Player Inventory 9-35 .. 28 - 55 Player * Inventory 0-8 ... 56 - 64 */ // 0 - 27 chest slots // 28 - 54 // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 64 // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x, 8 + x * 18, 142)); } // System.out.println("inventorySlots"+inventorySlots); // System.out.println("inventorySlots="+inventorySlots.size()); } // ############################################################################################################################################## public void cambiarA7() { inventoryItemStacks = Lists.newArrayList(); /** the list of all slots in the inventory */ inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // System.out.println("################# ContainerMenu cambiarA7"); // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, ); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, 26, 26)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, 53, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, 71, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, 53, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, 71, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, 53, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, 71, 44)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), -999, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), -999, 8 + (18 * x))); } /* * Tile Entity 0-8 ........ 0-27 Player Inventory 9-35 .. 28 - 55 Player * Inventory 0-8 ... 56 - 64 */ // 0 - 27 chest slots // 28 - 54 // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 64 // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x, 8 + x * 18, 142)); } // System.out.println("inventorySlots"+inventorySlots); // System.out.println("inventorySlots="+inventorySlots.size()); } // ############################################################################################################################################## public void cambiarA23() { inventoryItemStacks = Lists.newArrayList(); /** the list of all slots in the inventory */ inventorySlots = Lists.newArrayList(); crafters = Lists.newArrayList(); // System.out.println("################# ContainerMenu cambiarA7"); // weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 0, 26, ); // entity armor slots this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 4, 8, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 3, 8, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 2, 8, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 1, 8, 62)); // Sub weapon slot this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 5, 26, 26)); // six pockets tactical vest this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 6, 53, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 7, 71, ); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 8, 53, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 9, 71, 26)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 10, 53, 44)); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 11, 71, 44)); // BackPack for (int x = 0; x < 4; ++x) { this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 12 + (x * 4), 98, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 13 + (x * 4), 116, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 14 + (x * 4), 134, 8 + (18 * x))); this.addSlotToContainer(new mercenarySlot(inventarioenlaArmadura, 15 + (x * 4), 152, 8 + (18 * x))); } /* * Tile Entity 0-8 ........ 0-27 Player Inventory 9-35 .. 28 - 55 Player * Inventory 0-8 ... 56 - 64 */ // 0 - 27 chest slots // 28 - 54 // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // 55 - 64 // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new mercenarySlot(this.playerInv, x, 8 + x * 18, 142)); } // System.out.println("inventorySlots"+inventorySlots); // System.out.println("inventorySlots="+inventorySlots.size()); } // ############################################################################################################################################## @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.inventarioenlaArmadura.isUseableByPlayer(playerIn); } // ############################################################################################################################################## @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = null; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < 28) { // From TE Inventory to Player Inventory if (!this.mergeItemStack(current, 28, 63, true)) return null; } else { // From Player Inventory to TE Inventory if (!this.mergeItemStack(current, 0, 28, false)) return null; } if (current.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); if (current.stackSize == previous.stackSize) return null; slot.onPickupFromSlot(playerIn, current); } return previous; } // ############################################################################################################################################## package mercenarymod.items.armasdefuego.inventario; import java.util.ArrayList; import java.util.Random; import mercenarymod.Mercenary; import mercenarymod.entidades.armasDisparables; import mercenarymod.gui.guiHandlers; import mercenarymod.gui.containers.ContainerMenuMercenario00; import mercenarymod.gui.containers.ContainerMenuMercenario01; import mercenarymod.gui.containers.ContainerMenuMercenario02; import mercenarymod.gui.guis.guiMenuMercenario02; import mercenarymod.items.MercenaryModItems; import mercenarymod.tileentity.ModTileEntity; import mercenarymod.utilidades.util; import net.minecraft.block.BlockChest; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerDispenser; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import net.minecraft.world.IWorldNameable; import net.minecraft.world.World; //################################################################################################### public class inventarioArmasyEntidades implements IInventory // extends TileEntityDispenser implements IInventory { { // private ItemStack pistola = null; private int SizeInventory = 28; private ItemStack[] Items = new ItemStack[sizeInventory]; private boolean[] slotHabilitado = new boolean[sizeInventory]; private World worldIn = null; private static final Random RNG = new Random(); private String customName = "algo"; private EntityLivingBase entidad = null; private EntityLivingBase playerIn = null; private double posEX = 0; private double posEY = 0; private double posEZ = 0; private ItemStack chestItem = null; private int numerodeserie = 0; private int bolsillos = 0; private ContainerMenuMercenario02 containerMercenario = null; private guiMenuMercenario02 gui02 = null; // ################################################################################################### public inventarioArmasyEntidades(World worldIn, EntityLivingBase entidad, EntityLivingBase playerIn) { super(); // this.pistola = entidad.getHeldItem() ; this.worldIn = worldIn; this.entidad = entidad; this.playerIn = playerIn; // System.out.println("\n###\n###\n###\ninventarioArmasyEntidades=" + // worldIn.isRemote + "\n###"); NBTTagCompound tagCompund = null; if (this.entidad != null) { this.readFromNBT(null); } } // ################################################################################################### /** * Returns the number of slots in the inventory. */ @Override public int getSizeInventory() // ItemStack pistola { return SizeInventory;// SizeInventory; } // ################################################################################################### /** * inicializa cuales slots son validos y cuales estaran deshabilitados */ // a try to disable the armour slots whiout hide them // @Override public void habilitarSlots() // ItemStack pistola { for (int n = 0; n < SizeInventory; n++) { slotHabilitado[n] = true; if (n <= this.bolsillos + 4) { // slotHabilitado[n] = true; } else { // Items[n] = new ItemStack(MercenaryModItems.vacio, 1, 1); slotHabilitado[n] = false; } // System.out.println("mundo="+worldIn.isRemote+" // slotHabilitado["+n+"]="+slotHabilitado[n]); } } // ################################################################################################### /** * Add the given ItemStack to this Dispenser. Return the Slot the Item was * placed in or -1 if no free slot is available. */ public int addItemStack(ItemStack stack) { for (int i = 0; i < Items.length; ++i) { if ((Items[i] == null || Items[i].getItem() == null)) { this.setInventorySlotContents(i, stack); return i; } } return -1; } // ################################################################################################### /** * Returns the maximum stack size for a inventory slot. Seems to always be * 64, possibly will be extended. *Isn't this more of a set than a get?* */ @Override public int getInventoryStackLimit() { return 64; } // ################################################################################################### /** * For tile entities, ensures the chunk containing the tile entity is saved * to disk later - the game won't think it hasn't changed and skip it. */ public void markDirty() { if (worldIn != null) { // System.out.println("\n\n Marcado como sucio en el mundo=" + // worldIn.isRemote); writeToNBT(new NBTTagCompound()); } } // ################################################################################################### /** * Do not make give this method the name canInteractWith because it clashes * with Container */ @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public void openInventory(EntityPlayer player) { // System.out.println("###### openInventory() "); } @Override public void closeInventory(EntityPlayer player) { // System.out.println("###### closeInventory() "); } // ################################################################################################### /** * Returns true if automation is allowed to insert the given stack (ignoring * stack size) into the given slot. */ @Override public boolean isItemValidForSlot(int index, ItemStack stack) { if (index > 0 & index < 5 ) { /** Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots */ int armadura = armasDisparables.esArmadura(stack); if (armadura < 0) { return false; } //botas if (index == 1 & armadura != 3) { return false; } //pantalones if (index == 2 & armadura != 2) { return false; } //chest if (index == 3 & armadura != 1) { return false; } //casco if (index == 4 & armadura != 0) { return false; } } return true; } // ################################################################################################### @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { for (int i = 0; i < Items.length; ++i) { Items[i] = null; } // System.out.println("$$$ clear()"); } @Override public String getName() { return this.customName; } /** * Returns true if this thing is named */ @Override public boolean hasCustomName() { return true; } // @Override public void setCustomName(String name) { this.customName = name; } @Override public IChatComponent getDisplayName() { IChatComponent displayname = new ChatComponentText(EnumChatFormatting.RED + "" + entidad.getName() + " id:/" + entidad.getEntityId()); return displayname; } // #########################################################################3 // @Override public void readFromNBT(NBTTagCompound compound) { // super.readFromNBT(compound); // System.out.println("\n### read from nbt mundo=" + worldIn.isRemote); // Items = new ItemStack[this.getSizeInventory()]; this.clear(); Items[0] = this.entidad.getEquipmentInSlot(0);// .getHeldItem(); Items[1] = this.entidad.getEquipmentInSlot(1);// getCurrentArmor(0); // boots Items[2] = this.entidad.getEquipmentInSlot(2);// getCurrentArmor(1); // pants Items[3] = this.entidad.getEquipmentInSlot(3);// getCurrentArmor(2); // chest Items[4] = this.entidad.getEquipmentInSlot(4);// getCurrentArmor(3); // helmet ItemStack chestIS = this.entidad.getEquipmentInSlot(3); //Items[3]; // this.bolsillos = 0; this.numerodeserie = 0; if (chestIS != null) { //get the amount of slots in this chest Armour Item int sn = armasDisparables.tieneBolsillos(chestIS); this.bolsillos = sn; //set slots pattern in Container if (containerMercenario != null) { // System.out.println("####################### // containerMercenario="+sn); switch (sn) { case 0: containerMercenario.cambiarA0(); break; case 7: containerMercenario.cambiarA7(); break; case 23: containerMercenario.cambiarA23(); break; } } //set gui background in gui if (gui02 != null) { // System.out.println("####################### gui02="+sn); gui02.guiN = sn; } this.chestItem = chestIS; //serial number from armour to know diferences betwint instance of the same kind of item numerodeserie = getInttag(chestIS, "numerodeserie"); if (numerodeserie < 1) { numerodeserie = util.getSerialAlHazar(); setInttag(chestIS, "numerodeserie", numerodeserie); } if (sn > 0) { NBTTagCompound compound2 = chestIS.getTagCompound(); if (compound2 != null) { NBTTagList nbttaglist2 = compound2.getTagList("Items", 10); for (int i = 0; i < nbttaglist2.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist2.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; // System.out.println("\n### read from nbt"); if (j >= 0 && j < Items.length) { Items[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); if (Items[j] != null) { // System.out.println("mundo="+worldIn.isRemote+" // slot read" + j + " =" + // Items[j].getUnlocalizedName()); } } } if (compound2.hasKey("CustomName", ) { this.customName = compound2.getString("CustomName"); } } } } else { //change slots order in Container to just basic five if (containerMercenario != null) { containerMercenario.cambiarA0(); } //change Gui BackGroundto basic five background if (gui02 != null) { gui02.guiN = 0; } } // System.out.println("mundo="+worldIn.isRemote+" // bolsillos="+this.bolsillos); // System.out.println("mundo="+worldIn.isRemote+" // numerodeserie="+this.numerodeserie); habilitarSlots(); } // #########################################################################3 // @Override public void writeToNBT(NBTTagCompound compound) { // super.writeToNBT(compound); // System.out.println("\n### write to nbt mundo=" + worldIn.isRemote); ItemStack chestIS = Items[3];// this.entidad.getEquipmentInSlot(3); int numerodeserieIS = 0; if (chestIS != null) { numerodeserieIS = getInttag(chestIS, "numerodeserie"); if (numerodeserieIS < 1) { numerodeserieIS = util.getSerialAlHazar(); setInttag(chestIS, "numerodeserie", numerodeserieIS); } } // System.out.println(worldIn.isRemote + " sn0=" + this.numerodeserie); // System.out.println(worldIn.isRemote + " sn1=" + numerodeserieIS); if (numerodeserieIS != numerodeserie) { this.entidad.setCurrentItemOrArmor(3, Items[3]); readFromNBT(null); // System.out.println("###" + "\n\n\n" + "Chest Item hass change"); if (playerIn instanceof EntityPlayer & worldIn.isRemote) { // ((EntityPlayer) playerIn).openGui(Mercenary.instance, // guiHandlers.GUIMERCENARIA00, worldIn, 0, 0, 0); } } else { if (chestIS != null) { int sn = armasDisparables.tieneBolsillos(chestIS); if (sn > 0) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 5; i < Items.length; ++i) { if (Items[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); Items[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } NBTTagCompound chestcompound = chestIS.getTagCompound(); if (chestcompound == null) { chestcompound = new NBTTagCompound(); } if (this.hasCustomName()) { chestcompound.setString("CustomName", this.customName); } chestcompound.setTag("Items", nbttaglist); chestIS.setTagCompound(chestcompound); this.Items[3] = chestIS; } } this.entidad.setCurrentItemOrArmor(0, Items[0]); this.entidad.setCurrentItemOrArmor(1, Items[1]); this.entidad.setCurrentItemOrArmor(2, Items[2]); this.entidad.setCurrentItemOrArmor(3, Items[3]); this.entidad.setCurrentItemOrArmor(4, Items[4]); } } // #########################################################################3 public int getDispenseSlot() { int i = -1; int j = 1; for (int k = 0; k < Items.length; ++k) { if (Items[k] != null && RNG.nextInt(j++) == 0) { i = k; } } return i; } // #########################################################################3 public String getGuiID() { return "minecraft:chest"; } // #########################################################################3 public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerMenuMercenario02(playerInventory, this); } // #########################################################################3 @Override public ItemStack getStackInSlot(int index) { /* * if (index == 3){ //System.out.println("\n\n"+worldIn.isRemote); * * if (Items[3] == null){ //System.out.println(" SlotContents"+index+ * " st="+"null" ); } else { //System.out.println(" SlotContents"+index+ * " st="+Items[3].getUnlocalizedName() ); } * * } * */ if (index < 0 || index >= this.getSizeInventory()) return null; // System.out.println("getStackInSlot"+index); return this.Items[index]; } // #########################################################################3 @Override public ItemStack decrStackSize(int index, int count) { if (this.getStackInSlot(index) != null) { ItemStack itemstack; if (this.getStackInSlot(index).stackSize <= count) { itemstack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); this.markDirty(); return itemstack; } else { itemstack = this.getStackInSlot(index).splitStack(count); if (this.getStackInSlot(index).stackSize <= 0) { this.setInventorySlotContents(index, null); } else { // Just to show that changes happened this.setInventorySlotContents(index, this.getStackInSlot(index)); } this.markDirty(); return itemstack; } } else { return null; } } // #########################################################################3 @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); return stack; } // #########################################################################3 @Override public void setInventorySlotContents(int index, ItemStack stack) { if (index == 3) { // System.out.println("\n\n" + worldIn.isRemote); if (Items[3] == null) { // System.out.println(" SlotContents" + index + " st=" + // "null"); } else { // System.out.println(" SlotContents" + index + " st=" + // Items[3].getUnlocalizedName()); } if (stack == null) { // System.out.println(" setInventorySlotContents" + index + " // st=" + "null"); } else { // System.out.println(" setInventorySlotContents" + index + " // st=" + stack.getUnlocalizedName()); } if (playerIn instanceof EntityPlayer) { // ((EntityPlayer) playerIn).openGui(Mercenary.instance, // guiHandlers.GUIMERCENARIA00, worldIn, 0, 0, 0); } } if (index < 0 || index >= this.getSizeInventory()) return; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) stack.stackSize = this.getInventoryStackLimit(); if (stack != null && stack.stackSize == 0) stack = null; this.Items[index] = stack; this.markDirty(); } public String getCustomName() { return this.customName; } // #########################################################################3 public static float getFloattag(ItemStack item, String tag) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 0.0F; } float ex = etiquetas.getFloat(tag); return ex; } // #########################################################################3 public static void setFloattag(ItemStack item, String tag, float value) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); } etiquetas.setFloat(tag, value); item.setTagCompound(etiquetas); } // #########################################################################3 public static int getInttag(ItemStack item, String tag) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 0; } int ex = etiquetas.getInteger(tag); return ex; } // #########################################################################3 public static void setInttag(ItemStack item, String tag, int value) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); } etiquetas.setInteger(tag, value); item.setTagCompound(etiquetas); } // #########################################################################3 public static int[] getIntArraytag(ItemStack item, String tag) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); int[] empty = { 0 }; return empty; } int[] ex = etiquetas.getIntArray(tag); return ex; } // #########################################################################3 public static void setIntArraytag(ItemStack item, String tag, int[] value) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); } etiquetas.setIntArray(tag, value); item.setTagCompound(etiquetas); } // #########################################################################3 public static Boolean getBooleantag(ItemStack item, String tag) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return false; } boolean ex = etiquetas.getBoolean(tag); return ex; } // #########################################################################3 public static void setBooleantag(ItemStack item, String tag, boolean value) { NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null) { etiquetas = item.getTagCompound(); } etiquetas.setBoolean(tag, value); item.setTagCompound(etiquetas); } // #########################################################################3 public int getBolsillos() { return this.bolsillos; } // #########################################################################3 public EntityLivingBase getEntity() { return this.entidad; } public void setContainer(ContainerMenuMercenario02 containerMercenario) { this.containerMercenario = containerMercenario; } public void setGui(guiMenuMercenario02 gui02) { this.gui02 = gui02; } } i been thinking maiby i fucked up whith basic java i dont see becoze tireness or something this thing whith the inventory is for unification only one inventory that could work in a vainilla cown, in my custom creepers as well in an elf from the lord of rings mod (asuming its gone a be 1.8 or 1.9 version) and the inventory must be simple but awesome in today test the thing goes very well whith littlemaid mod mobs mod and mi mob when the main gun gets empty it automatically switch to watever is in sub weapon slot and have a creeper that can chase the player whith an ak 47, but first fix this gui then fix the exploting thing bugs and the other thing whit the spawn in the world not working
-
(hiding them, by setting e.g. xCoord to -999) thats good thats solve most of the troubles but was not so easy i have to make seters a getters to properly control gui and container from iinventory and add some methods to delete the arrayList in the container and recreate it as i whish at demand, for some reason i could not override the other method in the original container class whitout end whit weird behaveours if i override slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn) whiout changes it works until player try to drag someting then crash. or left all the slots unaccesibles close/open to fix , whith this method i could avoid the player to make click and get the contens for individual slots ñaa i gonna end written some rules to avoid open the gui over some mobs and creatures ### the nest question is how do you prevent to put items that are not armour in the armmour slots, so you can only put helmet items in the helmet slots and boot in boots slot im pretty sure i read something about it in a guide from jabellar but now idont find it anywhere
-
good nigths sorry i been working on this and forget all about the post I found its posible to, on the fly change the Container and the the gui background using a trick calling again the gui handler, in mi case player.openGui(Mercenary.instance, guiHandlers.GUIMERCENARIA00, worldIn, 0, 0, 0); but must be done in the rigth moment and has its downsides, its throws to the ground, whatever the itemStack you have in your hand this code has some issues, sometimes the armor gets stuck and the gui/container don't change, i think is becoze it take some tics to the server to recive the packages or whatever and apply changes to inventory, so its end whith something null Video here i can open the inventory of any entityLiving mob set armours change weapons, thats what i wanna control, i create 3 sets of custome container/gui the first for entities whitout armour or armour whitout pockets just five slots for armour and main weapon the second for the armours whith sevent pockets six for munition and one for SubWeapon the third for armours whith 23 pockets , one subWeapon plus 6 slots plus backpack 16 slots the gui now change in base to what its inside the entity chest slot ### Questions - ¿is posible to send a package whith an NBTTag compound whith all the items ffrom local to server ?? i need to fix sync - ¿how do you do the canTakeStack ting i found the code public boolean canTakeStack(EntityPlayer playerIn) { return true; } @SideOnly(Side.CLIENT) public boolean canBeHovered() { return true; } but no idea of how actually use them well thanks