Jump to content

Differentiation

Members
  • Posts

    606
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Differentiation

  1. You're good. Now its solved. Note: you don't have to make an instance of EntityPlayer, you can just use Entity.
  2. I'm trying to find that Forge thread for reaching across logical sides to insert here. Do you happen to know the link?
  3. I don't really understand what you're trying to do here... You have to understand that Minecraft::getMinecraft is a method only on the client thread. And the Minecraft class is only a class on the client thread. You cannot reference these on the running server thread. This will undoubtedly crash a dedicated server.
  4. This is definitely not solved
  5. Well, if you're gonna use that then at least include a check for World#isRemote. Otherwise you'd crash with - I believe - ClassDefNotFoundException on a dedicated server. Also, what do you mean move in the air?? The client thread does run on that event. Lastly, just use EntityPlayer#getHeldItemMainhand method to check for the item they are holding instead of what you're doing.
  6. You're reaching across logical sides. Use PlayerTickEvent#player. Don't use Minecraft::getMinecraft unless you have to (adding client effects, etc.).
  7. Then... can I just do this? public abstract class AbstractPacket<REQ extends IMessage> implements IMessage, IMessageHandler<REQ, REQ> { @Override public REQ onMessage(REQ message, MessageContext context) { if (context.side == Side.SERVER) { EntityPlayerMP player = context.getServerHandler().player; player.getServer().addScheduledTask(new Runnable() { @Override public void run() { handleServerSide(message, player); } }); } else { EntityPlayer player = Dinocraft.PROXY.getPlayer(); Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { handleClientSide(message, player); } }); } return null; } public abstract void handleClientSide(REQ message, EntityPlayer player); public abstract void handleServerSide(REQ message, EntityPlayer player); }
  8. So if I have something as simple as EntityPlayer::capabilities#allowFlight = true; in client handler I'd still need to schedule?
  9. I know it's good to schedule the messages received by the client and server in order to avoid crashes and bugs. However, should I make the messages scheduled or only a certain few? If so, how do I know which ones to add as a scheduled task? Any help is appreciated. Thanks
  10. So I'm just not gonna call the parent method in onUpdate and copy from EntityThrowable excluding the part with the tick delay and then I'll update the thread status.
  11. public class EntityRayBullet extends EntityThrowable { private static final DataParameter<Float> GRAVITY = EntityDataManager.createKey(EntityRayBullet.class, DataSerializers.FLOAT); public ResourceLocation getTexture() { return DinocraftEntities.RAY_BULLET_TEXTURE; } public EntityRayBullet(World world) { super(world); } public EntityRayBullet(World world, EntityLivingBase shooter) { super(world, shooter); } public EntityRayBullet(EntityLivingBase shooter, float gravity) { super(shooter.world, shooter); this.dataManager.set(GRAVITY, gravity); } @Override protected void entityInit() { super.entityInit(); this.dataManager.register(GRAVITY, 0.0F); } private void kill() { if (this.thrower != null && this.thrower instanceof EntityLiving) { DinocraftEntity.getEntity(this.thrower).setShootingTick(0); } this.setDead(); } @SideOnly(Side.CLIENT) @Override public void handleStatusUpdate(byte id) { if (id == 3) { this.world.playSound(this.posX, this.posY, this.posZ, DinocraftSoundEvents.CRACK, SoundCategory.NEUTRAL, 1.0F, rand.nextFloat() + 1.0F, false); for (int i = 0; i < 16; ++i) { this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1, Item.getIdFromItem(DinocraftItems.RAY_BULLET)); } } } @Override protected void onImpact(RayTraceResult result) { switch (result.typeOfHit) { case BLOCK: { Block block = this.world.getBlockState(result.getBlockPos()).getBlock(); if (block instanceof BlockBush || block instanceof BlockReed || block instanceof BlockVine) { return; } else { if (!this.world.isRemote) { this.kill(); } this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, result.getBlockPos().getX(), result.getBlockPos().getY(), result.getBlockPos().getZ(), Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1, Item.getIdFromItem(DinocraftItems.RAY_BULLET)); } break; } case ENTITY: { if (!this.world.isRemote && result.entityHit != null && result.entityHit instanceof EntityLivingBase && result.entityHit != this.getThrower()) { EntityLivingBase thrower = this.getThrower(); result.entityHit.attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, result.entityHit.isNonBoss() ? this.rand.nextFloat() + 4.5F : this.rand.nextFloat() + 0.5F); this.world.playSound(null, result.entityHit.getPosition(), DinocraftSoundEvents.HIT, SoundCategory.NEUTRAL, 1.0F, rand.nextFloat() + 1.0F); this.kill(); } else { return; } this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, result.entityHit.posX, result.entityHit.posY, result.entityHit.posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1, Item.getIdFromItem(DinocraftItems.RAY_BULLET)); break; } default: break; } if (!this.world.isRemote) { this.world.setEntityState(this, (byte) 3); this.kill(); } } @Override public void onUpdate() { if (this.ticksExisted > 200) { this.setDead(); } if (this.isInWater()) { this.motionY -= 0.005D; this.motionX *= 0.95D; this.motionZ *= 0.95D; } super.onUpdate(); } @Override protected float getGravityVelocity() { return this.dataManager.get(GRAVITY); } }
  12. No, the arrow doesn't do anything if the hit entity is the shooter. I didn't find anything with flown ticks affecting hit entities.
  13. So you're telling me I can just modify those to 0 and the thrower, respectively, in the constructor and problem solved?
  14. There's no code in my class that describes that. I didn't copy the code for EntityArrow, but I am extending EntityThrowable.
  15. Okay, that's solved. However, I don't understand why the bullets fired don't hit the entity I'm shooting at if I'm like 0 or 1 block away from it... This also happened before I got it to fire every tick. I tried setting the position of the bullet a little bit behind the player when it spawns in an attempt to avoid this, but then if the player has a block behind him, the bullet just ends up hitting the block. Is there any way to resolve this?
  16. Use this guy's tutorial. It's very good if you follow it in the exact order, step-by-step.
  17. I mean you could've just concatenated TextFormatting.RED and your String inside TextComponentString... but you do you.
  18. Alright, I gotta do my AP comp sci hw, then I'll change the thread status upon resolving everything.
  19. Aw damn, I forgot if I did it via an online converter or audacity...
  20. Err, I can't edit my previous post nor quote it??
  21. I already have Audacity installed. Does it serve the same benefits? Also, it'd be a pain for me to find the original sound files I used now. I'll just have to go to the file and delete one stereo for that
  22. I guess I couldn't think of a better way to do that
  23. The file was downloaded in mp3 format. I then used an online converter to convert to ogg
  24. I got it from some website ('cause it sounds good for what I needed) and converted to ogg format
×
×
  • Create New...

Important Information

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