Jump to content

_Cruelar_

Members
  • Posts

    292
  • Joined

  • Last visited

Everything posted by _Cruelar_

  1. That with the UUID didn't helped. Now the Item is also useless after one use.
  2. As Animefan8888's signature says Vanilla code is the best resource. ? But I know what you mean. Is this also false? Or is this Networking 'cause I'm a bit confused about networking. WIll look into the docs. @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeBoolean(entityPlayer==null); if (entityPlayer!=null) { buffer.writeInt(entityPlayer.getEntityId()); } } @Override public void readSpawnData(ByteBuf additionalData) { boolean nullPlayer = additionalData.readBoolean(); if (!nullPlayer){ EntityPlayer entityByID=(EntityPlayer) world.getEntityByID(additionalData.readInt()); if (entityByID!=null){ entityPlayer=entityByID; } this.shoot(entityPlayer); } }
  3. I can't post at GitHub at the moment but I'll give all code Referring to this Item and the Entity: CommonProxy(will change that Code Style #1) ClientProxy: ModItems: ModEntities: Clawshot_TP: Clawshot_Head: And this Post is the perfect example why you should use GitHub, but as I said currently having Problems with it.
  4. Yeah okay missed that. But what's about the still respawning Entities. I can't kill them without commands while they seem to disappear after reloading the world.
  5. What the Heck is causing this? The Entity spawns 36 Blocks in negative Z direction from me. Updated Entity code: Item code:
  6. For beginner's it's easier to see the ModelLoader thing in the Item that goes with it as code with ItemVariants can be easily forgotten while using an general method for it. How should it do that if it's made like the guide says you to do that, I always like it to learn new things about how things can go wrong so I can avoid using these things.
  7. In the guide of which I posted the link to uses item.initModels so I wanted to keep it like that for the explanation. Yes there's no reason to do that in the Item class and a central method would be better but both ways work perfectly fine as long you don't make mistakes.
  8. No you put it in initModel() in your Item call that in initModels in your ModItems which you call in your registerModels() in your ClientProxy
  9. Where you got that with public static final Item itemLightBridge = null;
  10. The Proxies are fine
  11. Use this instead of using itemLightBridge
  12. What's about CommonProxy and ClientProxy
  13. Post all relevant code, please. Then we might find the error faster.
  14. I think the fizzlers wil never come. As I know the mod is dead/in a zombie-like state getting only ported to new versions. I would really like to see the things out of 1.7.10 Portalgun mod into 1.12.2 or 1.13. Wait why broken? I use it quite the same way and he registers it as stuff of my mod.
  15. Simply insert the json at the right place, it should work then. BTW: Is this a Portalgun expansion of a kind. Like adding lightbridges, fizzlers etc.
  16. Do you register it some where with this: event.getRegistry().register(new Triforce()); (Triforce is a normal Item in my mod)
  17. As I said logs would help to find the problem
  18. Simply use the String you typed in in setRegistryName() after your modid in your case hardlightbridge So complete it would be modid:registryName
  19. Please post the log for more help but have you registered it in your common code.(In the guide it's a CommonProxy which would be false. refer to Code Style #1)
  20. Try this guide McJty:Render your Item
  21. Still spawns at Random places behind me and they still die and respawn. New code: package com.cruelar.cruelars_triforcemod.entities.projectiles; import io.netty.buffer.ByteBuf; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.MoverType; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.*; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Iterator; import java.util.List; public class Clawshot_Head extends Entity implements IEntityAdditionalSpawnData{ private EntityPlayer entityPlayer; public Entity caughtEntity; public Clawshot_Head.State currentState; private static final DataParameter<Integer> DATA_HOOKED_ENTITY; private boolean inGround; private int ticksInAir; private int ticksInGround; private boolean shouldRetarct=false; public static ResourceLocation RESOURCE_LOCATION=new ResourceLocation("cruelars_triforcemod:textures/entity/projectiles/clawshot_head.png"); public Clawshot_Head(World world){ super(world); } public Clawshot_Head(World world, EntityPlayer entityPlayer){ super(world); this.init(entityPlayer); this.currentState = Clawshot_Head.State.FLYING; this.setPosition((double)entityPlayer.posX,(double)entityPlayer.posY+entityPlayer.getEyeHeight(),(double)entityPlayer.posX); this.shoot(entityPlayer); } @SideOnly(Side.CLIENT) public Clawshot_Head(World world, EntityPlayer entityPlayer, double posX, double posY, double posZ) { super(world); this.init(entityPlayer); this.setPosition(posX,posY,posZ); this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; } public void notifyDataManagerChange(DataParameter<?> p_notifyDataManagerChange_1_) { if (DATA_HOOKED_ENTITY.equals(p_notifyDataManagerChange_1_)) { int i = (Integer)this.getDataManager().get(DATA_HOOKED_ENTITY); this.caughtEntity = i > 0 ? this.world.getEntityByID(i - 1) : null; } super.notifyDataManagerChange(p_notifyDataManagerChange_1_); } public void onUpdate() { super.onUpdate(); if (this.entityPlayer == null) { this.setDead(); } else if (this.world.isRemote ) { if (this.inGround) { ++this.ticksInGround; if (this.ticksInGround >= 1200) { this.setDead(); return; } } BlockPos blockpos = new BlockPos(this); IBlockState iblockstate = this.world.getBlockState(blockpos); if (this.currentState == Clawshot_Head.State.FLYING) { if (this.caughtEntity != null) { this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; this.currentState = Clawshot_Head.State.HOOKED_IN_ENTITY; return; } if (!this.world.isRemote) { this.checkCollision(); } if (!this.inGround && !this.onGround && !this.collidedHorizontally) { ++this.ticksInAir; } else { this.ticksInAir = 0; this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; } if (ticksInAir>=100){ this.shouldRetarct=true; } } else { if (this.currentState == Clawshot_Head.State.HOOKED_IN_ENTITY) { if (this.caughtEntity != null) { if (this.caughtEntity.isDead) { this.caughtEntity = null; this.currentState = Clawshot_Head.State.FLYING; } else { this.posX = this.caughtEntity.posX; double d2 = (double)this.caughtEntity.height; this.posY = this.caughtEntity.getEntityBoundingBox().minY + d2 * 0.8D; this.posZ = this.caughtEntity.posZ; this.setPosition(this.posX, this.posY, this.posZ); } } return; } } if (iblockstate.getMaterial() != Material.WATER) { this.motionY -= 0.03D; } this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ); this.updateRotation(); this.setPosition(this.posX, this.posY, this.posZ); } } private void updateRotation() { float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI)); for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; } public void shoot(Entity entity) { System.out.println(entity); this.motionX=0.6D*entity.getLookVec().x; this.motionY=0.6D*entity.getLookVec().y; this.motionZ=0.6D*entity.getLookVec().z; } public void shoot(double p_shoot_1_, double p_shoot_3_, double p_shoot_5_, float p_shoot_7_, float p_shoot_8_){} public int handleHookRetraction() { if (!this.world.isRemote && this.entityPlayer != null) { int i = 0; if (this.caughtEntity != null) { this.bringInHookedEntity(); this.world.setEntityState(this, (byte)31); i = this.caughtEntity instanceof EntityItem ? 3 : 5; } else if (this.inGround) { i = 2; } this.setDead(); return i; } else { return 0; } } protected void bringInHookedEntity() { if (this.entityPlayer != null) { double d0 = this.entityPlayer.posX - this.posX; double d1 = this.entityPlayer.posY - this.posY; double d2 = this.entityPlayer.posZ - this.posZ; double d3 = 0.1D; this.caughtEntity.motionX += d0 * 0.1D; this.caughtEntity.motionY += d1 * 0.1D; this.caughtEntity.motionZ += d2 * 0.1D; } } public void setDead() { super.setDead(); } public EntityPlayer getAngler() { return this.entityPlayer; } private void init(EntityPlayer p_init_1_) { this.setSize(0.25F, 0.25F); this.ignoreFrustumCheck = true; this.entityPlayer = p_init_1_; } private void checkCollision() { Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ); Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1, false, true, false); vec3d = new Vec3d(this.posX, this.posY, this.posZ); vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (raytraceresult != null) { vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z); this.motionX=0; this.motionY=0; this.motionZ=0; entityPlayer.posX=this.posX; entityPlayer.posY=this.posY; entityPlayer.posZ=this.posZ; } Entity entity = null; List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D)); double d0 = 0.0D; Iterator var8 = list.iterator(); while(true) { Entity entity1; double d1; do { RayTraceResult raytraceresult1; do { do { do { if (!var8.hasNext()) { if (entity != null) { raytraceresult = new RayTraceResult(entity); } if (raytraceresult != null && raytraceresult.typeOfHit != RayTraceResult.Type.MISS) { if (raytraceresult.typeOfHit == RayTraceResult.Type.ENTITY) { this.caughtEntity = raytraceresult.entityHit; this.setHookedEntity(); } else { this.inGround = true; } } return; } entity1 = (Entity)var8.next(); } while(!this.canBeHooked(entity1)); } while(entity1 == this.entityPlayer && this.ticksInAir < 5); AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D); raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); } while(raytraceresult1 == null); d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec); } while(d1 >= d0 && d0 != 0.0D); entity = entity1; d0 = d1; } } private void setHookedEntity() { this.getDataManager().set(DATA_HOOKED_ENTITY, this.caughtEntity.getEntityId() + 1); } protected boolean canBeHooked(Entity p_canBeHooked_1_) { return p_canBeHooked_1_.canBeCollidedWith() || p_canBeHooked_1_ instanceof EntityItem; } protected void entityInit() { this.getDataManager().register(DATA_HOOKED_ENTITY, 0); } @Override protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) { } @Override protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) { } static { DATA_HOOKED_ENTITY = EntityDataManager.createKey(Clawshot_Head.class, DataSerializers.VARINT); } @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeBoolean(entityPlayer==null); if (entityPlayer!=null) { buffer.writeInt(entityPlayer.getEntityId()); } } @Override public void readSpawnData(ByteBuf additionalData) { boolean nullPlayer = additionalData.readBoolean(); if (!nullPlayer){ EntityPlayer entityByID=(EntityPlayer) world.getEntityByID(additionalData.readInt()); if (entityByID!=null){ entityPlayer=entityByID; } this.shoot(entityPlayer); } } static enum State { FLYING, HOOKED_IN_ENTITY; private State() { } } }
  22. Should I save its UUID as NBT or use the Capability system? Or something else.
  23. There's no delay but the FishHook is saved to the player Code in ItemFishingRod.class: public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (playerIn.fishEntity != null) { int i = playerIn.fishEntity.handleHookRetraction(); itemstack.damageItem(i, playerIn); playerIn.swingArm(handIn); worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); } else { worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntityFishHook entityfishhook = new EntityFishHook(worldIn, playerIn); int j = EnchantmentHelper.getFishingSpeedBonus(itemstack); if (j > 0) { entityfishhook.setLureSpeed(j); } int k = EnchantmentHelper.getFishingLuckBonus(itemstack); if (k > 0) { entityfishhook.setLuck(k); } worldIn.spawnEntity(entityfishhook); } playerIn.swingArm(handIn); playerIn.addStat(StatList.getObjectUseStats(this)); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); }
  24. Sorry was in a Hurry yesterday, so I took the easiest way to get a ItemStack not the ItemStack. Replaced it with ItemStack itemStack = entityPlayer.getHeldItem(enumHand);
×
×
  • Create New...

Important Information

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