Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


Forge Modder
  • Posts

  • Joined

  • Last visited


  • Gender
  • Location
  • Personal Text
    NO copy-paste from me!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

FLUFFY2's Achievements

Diamond Finder

Diamond Finder (5/8)



  1. You guys dont understand... I have a gun that has EntityBullet extending EntityThrowable. Registered in the EntityRegistry!!! In survival i go close to any living entity, like cow or zombie i keep shooting MYSELF sometimes, and eventually i kill myself. Go ahead get snowballs, go close to a cow and start throwing it at him, sometimes it will do nothing to the cow, because it hits you. Thats because the onImpact() method resoult.entityHit returns the thrower sometimes. I made a new class called EntityShootable, that is a straight copy of EntityThrowable, and my EntityBullet calls extends that. In the EntityThrowable's onUpdate() where the actual resoult.entityHit is created(RayTraceResoult), i can see it does indeed not makes sure that the thrower cannot hit himself at the time the entity is spawned. Thats why i need the getThrower() on client site to make sure it never adds the player to the RayTraceResoult. But because its a server only field, the client still thinks im being shot at, only the damage is not dealt because its handled my the server. Mojang did f*cked it up, but if you dont believe just test my code: In main class preInit: EntityRegistry.registerModEntity(EntityBullet.class, ModID + ":Bullet", 1, instance, 250, 5, true); EntityBullet.calss public class EntityBullet extends EntityThrowable{ private int bulletdamage = 0; public EntityBullet(World worldIn){ super(worldIn); setSize(0.05F, 0.05F); } public EntityBullet(World worldIn, EntityLivingBase throwerIn){ super(worldIn, throwerIn); setSize(0.05F, 0.05F); } public EntityBullet(World worldIn, double x, double y, double z){ super(worldIn, x, y, z); setSize(0.05F, 0.05F); } public EntityBullet(World worldIn, EntityPlayer player, int damage){ super(worldIn, player); setSize(0.05F, 0.05F); this.bulletdamage = damage; } @Override protected void onImpact(RayTraceResult result){ if(result.entityHit != null){ if(result.entityHit instanceof EntityLivingBase){ result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), bulletdamage); result.entityHit.motionX = 0D; result.entityHit.motionY = 0D; result.entityHit.motionZ = 0D; //worldObj.playSound(this.posX, this.posY, this.posZ, SoundEventContainer.hit, SoundCategory.PLAYERS, 1F, 1F, false); } }else{ //worldObj.playSound(result.hitVec.xCoord, result.hitVec.yCoord, result.hitVec.zCoord, SoundEventContainer.bulletimpact, SoundCategory.BLOCKS, 1F, 1F, false); } if(!worldObj.isRemote){ this.setDead(); } } } Add this to an item to shoot the bullet: @Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand){ if(!worldIn.isRemote){ EntityBullet bullet = new EntityBullet(worldIn, playerIn, 10); bullet.func_184538_a(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0F, 3F, 0F); worldIn.spawnEntityInWorld(bullet); } //worldIn.playSound(playerIn, playerIn.getPosition(), SoundEventContainer.uspsshoot, SoundCategory.PLAYERS, 1F, 1F); return new ActionResult(EnumActionResult.PASS, itemStackIn); } Put this stuff in, spawn some cows, go close to them(like inside), and start shooting in survival. You will eventually kill yourself...
  2. I would suggest you to try snowballs in close range with zombies. You will sometimes hit yourself with the snowball. Even in creative you will see that the snowball explodes in fornt of you(sometimes). Now imagine a gun that is used in close combat and the bullet straight hits you. You die... and thats annoying. I will try to supply you with a code that you can test and see later.
  3. I found out that EntityThrowable has a bug where sometimes the thrown entity straight up hit its thrower. So i made a custom EntityThrowable named EntityShootable and i found that there is a problem in its onUpdate() method logic. Entity entity = null; List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D)); double d0 = 0.0D; boolean flag = false; for(int i = 0; i < list.size(); ++i){ Entity entity1 = list.get(i); if(entity1.canBeCollidedWith()){ if(entity1 == this.field_184539_c){ flag = true; }else if(this.ticksExisted < 2 && this.field_184539_c == null){ this.field_184539_c = entity1; flag = true; }else{ flag = false; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz(0.30000001192092896D); RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); if(raytraceresult1 != null){ double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec); if(d1 < d0 || d0 == 0.0D){ entity = entity1; d0 = d1; } } } } } Sometimes the "entity1" is the actual thrower so it sets the "entity" to the thrower, and "entity" should be the actual target(enemy). Now i tryed to make so if the "entity1" is the getThrower(), than do nothing and move on, in the entity list to the actual target. BUT, the cute little getThrower() is a server only thing, so i get nullPoinetrsExpections. Packets could slove the issue, but if the entity is spammed form like a fast firing gun, than thats a huge network overload. How i could fix this issue guys? This is sort of a vanilla bug i guess... Thanks!
  4. Well you guys were damn right... Lesson learned, client is not always "client", thanks!
  5. With a client side only registered PlayerTickEvent i would doubt that. But hey... try yourself: Register this in your ClientProxy: @SubscribeEvent public void PlayerTick(PlayerTickEvent event){ if(event.phase == Phase.START){ EntityPlayer player = event.player; System.out.println(player.getPosition()); } }
  6. I have made a custom throwable entity which causes damage if it hits a living entities. Now sometimes the custom entity dosen't even fly away, just straight causes damage to the thrower itself. Mostly happends when you are really close to another living entity. You can try this with snowballs too, if you walk pass or close to a zombie, than you go like 2-3 blocks away, the snowball will most likely explode in fornt of you, and never cause knockback on the zombie. This must be some bug with the EntityThrowable class's onUpdate method because only this part is revalent to the actual entity raytrace part: Entity entity = null; List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D)); double d0 = 0.0D; boolean flag = false; for (int i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); if (entity1.canBeCollidedWith()) { if (entity1 == this.field_184539_c) { flag = true; } else if (this.ticksExisted < 2 && this.field_184539_c == null) { this.field_184539_c = entity1; flag = true; } else { flag = false; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expandXyz(0.30000001192092896D); RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); if (raytraceresult1 != null) { double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } } if (this.field_184539_c != null) { if (flag) { this.field_184540_av = 2; } else if (this.field_184540_av-- <= 0) { this.field_184539_c = null; } } if (entity != null) { raytraceresult = new RayTraceResult(entity); } My guess is the "entity" is sometimes the actual thrower.
  7. My bad... forgot to tell: If you use the method in a ticking event, you will see each tick it will show a different value. It just swaps between two positions.
  8. Hi, It seems like when im at the edge of 2 block .getPosition() returns both blocks pos. This is very annoying... Hope it can be fixed. Right now the current fix would be: new BlockPos(Math.floor(player.posX), Math.floor(player.posY), Math.floor(player.posZ));
  9. If you mean that the client not recieving the server config, than its a problem at your side. You have to manually send the server config to the connecting player with a packet to update the client. Also you have to make sure that, when you disconnect form the server, reset the client config to its original state. Use: ServerConnectionFromClientEvent ClientDisconnectionFromServerEvent
  10. Hi, I know things like that got discussed before, but it looks like they never actually make it into Forge. Now i come up with something that might worth thinking about and its compatible with other mods, but somewhat "limited". Back in 1.7.10 we could achieve this with RenderPlayerEvent.Specials, but i think that caused incompability with other mods, and Specials was never supposed to be used for that. The idea of mine is to only be able to rotate the hand if we the item is held. The method would look like this in the Item class: public float rotateArm(ItemStack item, EntityPlayer player) return AMOUNT; ONLY call the method if the player is holding the item!!! In 1.9, the method would only apply to the hand thats holding the item. If item is in left hand only rotate the left arm, if right hand than the right arm. This would make compability with other mods. RenderPlayerAPI is a very instable API, and a lot of people only using it for the arm rotation. Making our own RenderPlayer class for this is just another bad idea. Thanks for reading!
  11. Thanks guys forge-1.8.9- finally fixes the issue. It took you guys long, but i really apprechiate it!
  12. You know that onEntityCollidedWithBlock() is called every tick right? You just can't kill the Minecraft fast enought to trigger the event only once. I suggest using a boolean.
  13. Hi, I don't know form what version of Forge but the display option "ground" stopped working in the json models. "ground": { "rotation": [ 0, -90, 90 ], "translation": [ 0, 1.8, -1 ], "scale": [ 0.8, 0.8, 0.8 ] } This will do nothing to the model when its dropped on the ground, but it worked before. Im currently on: Thanks!
  14. Never mind, this was a stupid thread by me. -.-
  15. First of all: for(int i=0; i < inv.getSizeInventory(); i++) { if(inv.getStackInSlot(i) != null) { ItemStack j = inv.getStackInSlot(i); if(j.getItem() != null && j.getItem() == ModItems.bullet) { inv.decrStackSize(i, 1); i = inv.getSizeInventory(); } } } That will decrease 1 form all the bullet stacks that is in your inventory. A boolean should fix it. Than, there is a thing player.posX, player.posY, player.posZ. Finally: (player.inventory.hasItem(ModItems.bullet) Returns true for some reason. How did you register your items?
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.