Jump to content

Thornack

Members
  • Posts

    629
  • Joined

  • Last visited

Everything posted by Thornack

  1. I still need to figure out how to get the aiming code working (that would require the invnetory to be on client side also so that the onItemRightClick method can be called on client and server just like the player one does
  2. Ok I got my damage working but now I still need the targeting to work. It was a simple fix ish where I passed in the the target as an entity player so that the player into the target.attackEntityFrom(getDamageSource((EntityPlayer) target), appliedDmg); can take damage from the wild entities. Im not sure if the damage is the correct damage but the player can now be hurt by the entity so that seems to work good.
  3. I think I need it to happen on both sides for my code to work properly
  4. My customized onItemRightClick method from my attack item class that I changed to work for my custom entity (it works for the player). Currently just trying to get the else if(ball ==false){} attacks done and working as they represent the majority of my attacks (the last else statement in this method). The ball type attacks are kind of like a snowball projectile but they do damage and have a trailing particle behind them and use a custom model. For now the non ball attacks is what I am looking at. My onUsingTickMethod inside my attack item class (atm I only care about the non stationary attacks (again since they represent the majority) (last else statement in this method The handleUpdateTick method inside my attack item class that I use for my main attacks. The non ball non stationary attacks (these are the majority of my particle attacks and they behave like a flamethrower essentially but all have different particles that are set elsewhere. All particles spawn normally but damage isnt done ever
  5. Ok Thanks for clarifying that up, coolAlias I think I understand packets a bit better now, but I still need to send my packet and still have the same problem. I dont know how to sync my attack items client and server side.. I dont have a gui for my entity, I need to make my items exist on client side also so that my mob entity can use them. Currently what I have is the following. Entity is spawned -> Entities level is generated -> Entities attacks are calculated based on level -> This is done server side -> Entity can be added to players party -> Entity can then be spawned by player as an ownable entity -> Player can become this entity by morphing into it -> Player gets all entity stats, inventory and items in inventory -> Items are attacks that the player can then use. All of that works great. Im trying ot now write an AI to use my entities attack items so that the untamed entity can attack other entities using the attack items (just like the player can). my partial entity class (sorry alot of the code is pretty complicated so I omitted the crazy stuff cause this entity can do a lot atm) Hopefully this is sufficient to help grasp the issue. I need this entity to be able to use my attack items with onItem Right Click and on Item Use -> and onUsingTick-> to spawn custom particles and deal custom damage from a custom DamageSource. I left in every line related to my attack items. The attacks only exist on server side however for my entity. Currently My entity spawns the attack item particles but the attack does no damage (for some reason) When I get the entities that the attack is supposed to target (they return correctly Sorry I also removed a lot of logic here cause its kinda huge atm) BUT for some reason List<EntityLivingBase> targets = TargetingHelper.acquireAllLookTargets(customEntity, Math.round(damageRadius), 1.0F); for (EntityLivingBase target : targets) { System.out.println("Damage Done: " + appliedDmg + " target " + target); target.attackEntityFrom(getDamageSource(customEntity), appliedDmg); } The damage isnt done since when I call target.attackEntityFrom(getDamageSource(customEntity), appliedDmg); the appliedDmg variable is there and calculated correctly, the entity is there, the damage source is there, but the attackEntityFrom bit is never called (I checked with a break point)!! But for the player (when player is morphed into the entity and gets the entities attack) everything is there and damage does get dealt...So I checked whether or not my item exists client side for my entity and it does not, I suspect this is the problem. The onLivingUpdate method crashes the game when I allow it to call the following on client side because the item is null when I call. if(this.worldObj.isRemote){ System.out.println(attacks[0]); <- this is null on client side but not null on server side Attack att = (Attack) attacks[0].getItem(); att.onItemRightClick( attacks[0], this.worldObj, this); } So my item is only there on server side and this is probably why I am having issues. Its basically driving me crazy how hard this "get mobs to use my items" is to implement ugh. The good thing though if I get this one class implemented then all of my attacks will work because they are all set up the same. Any ideas anybody? I am basically trying to take all of the onItemRightClick stuff and onItemUse, and onUsingTick etc etc and implement it for my entity so that it can use my item. I believe the important classes/methods have already been posted
  6. Hi everyone, I have a method that gives my mob attacks which are basically customized items (it works). But I need to sync the mobs inventory so that the attack items also exist on the client. Im not sure how to do this. (And Dont just say "Packets" I know that it requires packets or use of a datawatcher but I am stumped how to do this) Currently I have tried the following see below). This method is called server side only when my entity gets constructed and then again whenever my entity levels up (this works) public void attacks(EntityCustom customEntity){ if(customEntity instanceof EntityMyMob){ int lvl = customEntity.getStats().level; if(lvl <= 5){ customEntity.attacks[0] = new ItemStack(CommonProxy.itemAttack_Primary); PacketOverlord.sendToAll(new PacketSyncAttacks(customEntity)); <- need to update the attacks when they are given } if(lvl > 5){ customEntity.attacks[1] = new ItemStack(CommonProxy.itemAttack_Secondary); PacketOverlord.sendToAll(new PacketSyncAttacks(customEntity)); <- need to update the attacks when they are given } if (lvl >= 12){ customEntity.attacks[2] = new ItemStack(CommonProxy.itemAttack_Tertiary); PacketOverlord.sendToAll(new PacketSyncAttacks(customEntity)); <- need to update the attacks when they are given } if(lvl >= 18){ customEntity.attacks[3] = new ItemStack(CommonProxy.itemAttack_Quaternary); PacketOverlord.sendToAll(new PacketSyncAttacks(customEntity)); <- need to update the attacks when they are given } } } My packet class - The issue is my entity is null when I send the packet for some reason, So I am unsure how to update the entity on its client side so that it has the attacks on both sides. Currently the attacks are only present on server side public class PacketSyncAttacks extends AbstractMessageToClient<PacketSyncAttacks> { private NBTTagCompound data; EntityCustom custom; public PacketSyncAttacks() {} public PacketSyncAttacks(EntityCustom custom) { this.custom= custom; <- Entity is not null here data = new NBTTagCompound(); custom.writeEntityToNBT(data); } @Override protected void read(PacketBuffer buffer) throws IOException { data = buffer.readNBTTagCompoundFromBuffer(); } @Override protected void write(PacketBuffer buffer) throws IOException { System.out.println("FUCK3"); buffer.writeNBTTagCompoundToBuffer(data); } @Override public void process(EntityPlayer player, Side side) { //But my entity is null here. So I am unsure what to do to update my entities inventory if(data != null && custom!= null){ <- this is never called since entity is null here on client side this.custom.readFromNBT(data); } } } My Packet Handler class Anyone know of a good way to do this I am stumped atm
  7. Nvm Im stupid if(attackInUse.getItem() instanceof CustomItem){ CustomItem attack = (CustomItem ) attackInUse.getItem(); attack.onUsingTick(attackInUse, this, attackInUseCount); }
  8. Ok I am having some trouble here. I need to implement my own version of onUsingTick so that it can be called only when my entity is using the item. (But when the player uses theitem I need it to continue to use the vanilla onUsing tick) but I am unsure how to do this. in my onLivingUpdate method inside my entity class I am trying to implement all of the player logic that causes a player to use an item so that my custom entity can use the item instead. Basically the following @Override public void onLivingUpdate(){ super.onLivingUpdate(); if (this.attackInUse != null) { ItemStack itemstack = this.getCurrentAttack(); if (itemstack == this.attackInUse) { if (attackInUseCount <= 0) { this.onAttackUseFinish(); } else { attackInUse.getItem().onUsingTick(attackInUse, this, attackInUseCount); if (--this.attackInUseCount == 0 && !this.worldObj.isRemote) { this.onAttackUseFinish(); } } } else { this.clearAttackInUse(); } } } I think I did everything correctly so far with a few minor modifications it should work ok but im stuck on the onUsingTick method. I need to be able to have the new onUsingTick available so that I can do attackInUse.getItem().onUsingTick(attackInUse,(EntityCustom) this, attackInUseCount); where currently vanilla doesnt allow this since the second parameter needs to be a EntityPlayer. I have a CustomItem class which extends the vanilla Item class. My CustomItem class is then extended by my attack item class. The attack items are the items that I want my entity to be able to use. But in order for this to work I need to be able to have the entity call the onItemRightClick and onItemUse methods. Inside this class is where I put my custom onUsingTick that I need to be able to call to set my item in use, but I am unsure how to do that. Im not sure how to implement the onUsingTick method that is in my generic CustomItem class rather than the one that is inside the vanilla Item class. I cant use the vanilla one since it requires the player as a parameter and obviously I cannot make my custom mob a player entity. Basically to make my item useable by both the player and the entity I am trying to implement a second onItemRightClick method that replaces the player parameter with the custom entity parameter so that it can be called by my entity from its AI Any ideas how to implement the onUsingTick method from inside my customItem class rather than the regular vanilla onUsingTick method?? Or any ideas on how to implement what I am trying to achieve in a simpler way??
  9. I render my custom gui hud elements as so in the event you see above GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); ...//Custom Stuff... ///Then the stuff you care about/// /////////ExpBar//////////////////////////////////////////// this.mc.getTextureManager().bindTexture(expBarTexture); int expBarWidth = (int)(((float) (((int)expGained) -this.getExpFromLevel(id, level))/ (this.getExpFromLevel(id, level + 1)-this.getExpFromLevel(id, level))) * pixelWidthOfTexture); drawTexturedModalRect(width/2 -106, height- 32, 0, 0, 77, 9); drawTexturedModalRect(width/2 -106 + 2, height- 32 + 1, 0, 9, expBarWidth, 5); ////////////////HealthBar//////////////////////////////////////////// this.mc.getTextureManager().bindTexture(healthBarTexture); int healthBarWidth = (int)(((float) (int)this.mc.thePlayer.getHealth() / hpMax) * pixelWidthOfTexture); drawTexturedModalRect(width/2 -106, height- 40, 0, 0, 77, 9); drawTexturedModalRect(width/2 -106 + 2, height- 40 + 1, 0, 19, healthBarWidth, 5); ...//.etc etc.... ///more custom stuff/// GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); Again The Thank you btn is ---> that a way ish
  10. Hey so what I have found is that the rendering needs to be cancelled in a specific order and reimplemented in a specific order. In order to cancel Hunger, Health, Exp, and the storage... @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderPre(RenderGameOverlayEvent.Pre event) { if (event.type == ElementType.HOTBAR) { event.setCanceled(true); return; } if (event.type == ElementType.FOOD) { event.setCanceled(true); return; } if (event.type == ElementType.EXPERIENCE) { event.setCanceled(true); return; } if (event.type == ElementType.HEALTH) { event.setCanceled(true); return; } ///Im not positive if you need this statement but I kept it in otherwise I noticed weird glitches with my custom stuff if (event.type != ElementType.FOOD) { return; } } then in the RenderGameOverlay Post event render your new custom elements in the same order as above. Note, I am unsure where the air bar fits in I havent messed with it yet, lemme know if you figure that out. If you mess up the order you get weird glitches I found where some of your custom stuff will look weird. Im not sure why this happens but this seems to work perfectly for me. @SubscribeEvent(priority=EventPriority.NORMAL) public void RenderBattleGUI(RenderGameOverlayEvent.Post event) { if (event.type != ElementType.CROSSHAIRS) { return; } ////////////////Render Custom Hot Bar//////////////////////////////////////////// ////////////////Render Custom Food Bar//////////////////////////////////////////// ///////////////////Render Custom ExpBar//////////////////////////////////////////// ////////////////Render Custom HealthBar//////////////////////////////////////////// } Also ---------------> Hit Thanks if you dont mind
  11. Hmm ok, I will look into youre first suggestion. Id like to accomplish this somehow as it would make things very very awesome for my mod
  12. Hi everyone, This question may be simple or may be difficult but how would you get a mob to use an item just like the player does? My mob entities have their own inventory and their inventory is full of attack items that use onItemRightClick and onItemUse to attack other entities. My question is how would you get the mob to use these items (call onItemRightClick and call onItemUse etc etc) just like the player does. Any ideas?
  13. Thanks Ernio, I didnt think of using the player tick event to do the timer portion. I just put a while loop into the hurt event which would pause the game loop haha kind of a cool matrix type effect actually but not what I wanted. thanks
  14. Im not sure how to implement this in a way that wont critically damage performance.
  15. Hi everyone, I want to implement a timer that gets started when the onHurt event is called and ends when it reaches some value x. Im not really sure what would be the best way to do this, a for loop or while loop? or some vanilla timer that already exists. The event gives me access to world time through @SubscribeEvent public void hurt(LivingHurtEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; long time = player.worldObj.getWorldInfo().getWorldTime() % 2400; } } but this isnt what I would need since the timer should begin at 0 when the player is hurt, the hurt event should be cancelled, and a gui should open. (I have the gui open and the cancelled part down) But the timer should persist even if the gui I have is closed so that if you are hurt again the gui doesnt open until the timer hits its end point. At this point if youre hurt again repeat the cycle. I do have access to my IEEP class in this method so maybe putting the timer in there would be best. Im not sure though so Im putting it out there. What would be the simplest solution. Basically I want to create a gui that opens only if the player is hurt and if the timer isnt ticking. (otherwise the gui opening gets too annoying if a mob has you cornered and is attacking you once per second or whatever.) Basically, Player is Attacked -> Gui opens -> timer starts counting to 10seconds -> if player is attacked again nothing happens until the timer stops counting and resets to 0 (even if the player closes the gui nothing should happen (the hurt event should be cancelled still))-> If player is hit again -> repeat the cycle
  16. Post your movement code I think you might have an issue somewhere in there with the pitch. They should be handled the same so theres probably an issue in the movement class. Show the classes in order of movement is set here-> movement is passed here -> fish is rendered here-> etc etc. will help in figuring this out.
  17. I do the following to ensure that everytime a player joins the world they get an istance of my IEEP class. This event seems to cover allc ases (I havent found any cases where my IEEP isnt initialized. @SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer) { if (CustomExtendedPlayerProperties.get((EntityPlayer) event.entity) == null) { CustomExtendedPlayerProperties.register((EntityPlayer) event.entity); } } } Then inside my IEEP public static final CustomExtendedPlayerProperties get(EntityPlayer player) { return (CustomExtendedPlayerProperties) player.getExtendedProperties("CustomExtendedPlayerProperties"); } public static final void register(EntityPlayer player) { player.registerExtendedProperties("CustomExtendedPlayerProperties", new CustomExtendedPlayerProperties(player)); }
  18. Hi Everyone, I want to get the pitch and the yaw fromt he look vector. I think I have the yaw done correctly but the pitch is eluding me i think. How would you do it. Currently I am doing it liek this and I am not sure what my mistake is. Pitch Code - I think I buggered up something in this one public static float getPitchFromVector(Vec3 vec3) { double dx = vec3.xCoord; double dz = vec3.zCoord; double pitch = 0; // Set pitch if (dx != 0) { // Set pitch i think start value based on dx if (dx < 0) { pitch = 1.5 * Math.PI; } else { pitch = 0.5 * Math.PI; } pitch -= Math.sin(vec3.yCoord/Math.sqrt((vec3.xCoord*vec3.xCoord + vec3.zCoord*vec3.zCoord))); } else if (dz < 0) { pitch = Math.PI; } return (float) (-pitch * 180 / Math.PI - 90); } Yaw Code - I think this one is correct public static float getYawFromVector(Vec3 vec3) { double dx = vec3.xCoord; double dz = vec3.zCoord; double yaw = 0; // Set yaw if (dx != 0) { // Set yaw start value based on dx if (dx < 0) { yaw = 1.5 * Math.PI; } else { yaw = 0.5 * Math.PI; } yaw -= Math.atan(dz / dx); } else if (dz < 0) { yaw = Math.PI; } return (float) (-yaw * 180 / Math.PI - 90); }
  19. After some major digging around I have found the function that seems to do the "registering of particles" but I dont think there is an easy way to register new ones... Located in public class RenderGlobal public EntityFX doSpawnParticle(String p_72726_1_, double p_72726_2_, double p_72726_4_, double p_72726_6_, double p_72726_8_, double p_72726_10_, double p_72726_12_){ } it seems to be called by the following method located in public class RenderGlobal public void spawnParticle(String p_72708_1_, final double p_72708_2_, final double p_72708_4_, final double p_72708_6_, double p_72708_8_, double p_72708_10_, double p_72708_12_){} which is called by the following method located in public abstract class World public void spawnParticle(String p_72869_1_, double p_72869_2_, double p_72869_4_, double p_72869_6_, double p_72869_8_, double p_72869_10_, double p_72869_12_){} which is called by everything that spawns particles in vanilla... Does anyone have any idea how to access this in a smart way to allow registration of new particles in the same way vanilla does it?
  20. Hi Everyone, I was wondering if anyone could explain how the vanilla particles are registered to a string. I want to try and set up a system where I can use my custom particle sheet in tandem with the vanilla particle sheet that contains their textures, to add more particles to the game. I like their spawning of particles using the string but I have been looking at this and I dont really understand how it works. (the string part - how exactly does vanilla associate the "snowshovel" string with the particle class that is the EntityFX for snowshovel particle) public void spawnParticle(String particleName, double xCoord, double yCoord, double zCoord, double velX, double velY, double velZ) if the particle name is snowshovel I know how to spawn it but lets say I wanted to add a particle with name dustydesert how would I map this name to that particle EntityFX so that I can spawn it the same way vanilla does it. This is currently how I spawn vanilla particles - nothing fancy but I want to be able to create my own custom particle with custom parameters such as (particleMaxAge, Scale,...etc etc) so that I can give it custom motion and all of that good stuff. Then register it in such a way so that I can spawn it the same way vanilla does it. Is this even possible @Override public void spawnParticles(World world, double xCoord, double yCoord, double zCoord, float radius, Vec3 lookVector) { yCoord += 1.62D; for (float f = 0; f < radius; f += 0.5F) { xCoord += lookVector.xCoord; yCoord += lookVector.yCoord; zCoord += lookVector.zCoord; for (int numberOfParticles = 0; numberOfParticles < maxNumberOfPrticles; ++numberOfParticles) { world.spawnParticle("snowshovel", xCoord + 0.5F - world.rand.nextFloat(), yCoord + 0.5F - world.rand.nextFloat(), zCoord + 0.5F - world.rand.nextFloat(), lookVector.xCoord * (0.5F * world.rand.nextFloat()), lookVector.yCoord * (0.5F * world.rand.nextFloat()), lookVector.zCoord * (0.5F * world.rand.nextFloat())); } } }
  21. 1) The block has a tile entity, i want it to render sphericalish models on top of it when it is interacted with by the player using the table. -Only 1 player should be able to use table at a time. The sphericalish models will be different but Ill be able to control that once i set this up. 2) There can be anywhere from 0 to 6 party members. (party is the word I use to describe the group of characters your player travels with/can become in my mod 3) The rendering already is pretty advanced, the block is a custom rendered block, it has a model that has approx 45 cuboidal pieces (mostly cubes and cuboidal rectangles and such its a techne/tabula model) - The sphericalish models I want to render on top of my block have over 100 pieces (theyre also techne models just like my block model is) - I want to render between 0 and 6 of these models on various locations on my block, Basically If this is the block //IF I HAVE 6 Party Members Render like so ___________ | | | O O | | O O | | O O | |__________| I want to render my models on the circles on the top face of the block. //IF I HAVE 5 Party Members Render like so ___________ | | | O O | | O | | O O | |__________| //IF I HAVE 4 Party Members Render like so ___________ | | | O O | | | | O O | |__________| //IF I HAVE 3 Party Members Render like so ___________ | | | O | | O | | O | |__________| //IF I HAVE 2 Party Members Render like so ___________ | | | | | O O | | | |__________| //IF I HAVE 5 Party Members Render like so ___________ | | | | | O | | | |__________| My block currently appears in game and has a tile entity already associated with it, it has its own renderer, and it also has a custom model as mentioned above.
  22. Im not sure how to save it, im just trying to figure this out conceptually so that I can begin to design how it will work. I want the block model to render extra things depending on how many party members the player has in his IEEP. (This value is stored as an int in the players IEEP)
  23. Hi Everyone, I have a block model that appears in game properly. I want to add additional parts to this block model when a player interacts with it. How would you go about doing this. I know I would have to use the onBlockActivated method and most likely and alter stuff inside my model file but im not exactly sure how to structure this. Anyone know of a rough idea/outline how to accomplish this.
  24. Yes there are my mod is at almost a million lines of code now i think. Also Thanks a bunch Ernio
  25. Ok So I kind of have a fix but it kinda sucks haha. To overcome the problem with PEACEFUL Mode I simply decriment the players health everytime the onUpdate method incriments it. Kinda hacky n shitty but it works. My custom FoodStats Class public class CustomFoodStats extends FoodStats { /** The player's food amountl. */ private int foodAmount = 15; /** The player's food saturation. */ private float foodSaturation = 2.50F; /** The player's food exhaustion. */ private float foodExhaustionAmount; /** The player's food bar timer value. */ private int foodBarTimer; private int prevFoodAmount = 15; @Override public void onUpdate(EntityPlayer player) { if (player.worldObj.difficultySetting == EnumDifficulty.PEACEFUL && player.getHealth() < player.getMaxHealth() && player.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && player.ticksExisted % 20 * 12 == 0) { player.heal(-1.0F);//Need to do this because the onLivingUpdate in EntityPlayer heals the player in peaceful mode. } EnumDifficulty enumdifficulty = player.worldObj.difficultySetting; this.prevFoodAmount = this.foodAmount; if (this.foodExhaustionAmount > 4.0F) { this.foodExhaustionAmount -= 4.0F; if (this.foodSaturation > 0.0F) { this.foodSaturation = Math.max(this.foodSaturation - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { this.foodAmount = Math.max(this.foodAmount - 1, 0); } } if (player.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodAmount >= 18 && player.shouldHeal()) { ++this.foodBarTimer; if (this.foodBarTimer >= 80) { if(condition = true){ //Do Custom Healing }else{ player.heal(1.0F);//You can cancel healing by commenting this out } this.addExhaustion(3.0F); this.foodBarTimer = 0; } } else if (this.foodAmount <= 0) { ++this.foodBarTimer; if (this.foodBarTimer >= 80) { if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) { player.attackEntityFrom(DamageSource.starve, 1.0F); } this.foodBarTimer = 0; } } else { this.foodBarTimer = 0; } } } And my event which makes it all possible @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote) { ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class,(EntityPlayer) event.entity, new CustomFoodStats(),"foodStats", "field_71100_bB"); } } If you know of a better way to stop healing from happening I would love to hear about it. I can now just use my condition to trigger this and keep default behavior if my condition isnt true.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.