tutorial:projectiles
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:projectiles [2021/06/18 14:08] – Update to 1.17 part 2 redgrapefruit | tutorial:projectiles [2022/04/29 03:38] – updated a method call ayutac | ||
---|---|---|---|
Line 108: | Line 108: | ||
entity.damage(DamageSource.thrownProjectile(this, | entity.damage(DamageSource.thrownProjectile(this, | ||
- | if (entity instanceof LivingEntity) { // checks if entity is an instance of LivingEntity (meaning it is not a boat or minecart) | + | if (entity instanceof LivingEntity |
- | ((LivingEntity) entity).addStatusEffect((new StatusEffectInstance(StatusEffects.BLINDNESS, | + | livingEntity.addStatusEffect((new StatusEffectInstance(StatusEffects.BLINDNESS, |
- | ((LivingEntity) entity).addStatusEffect((new StatusEffectInstance(StatusEffects.SLOWNESS, | + | livingEntity.addStatusEffect((new StatusEffectInstance(StatusEffects.SLOWNESS, |
- | ((LivingEntity) entity).addStatusEffect((new StatusEffectInstance(StatusEffects.POISON, | + | livingEntity.addStatusEffect((new StatusEffectInstance(StatusEffects.POISON, |
- | entity.playSound(SoundEvents.AMBIENT_CAVE, | + | livingEntity.playSound(SoundEvents.AMBIENT_CAVE, |
} | } | ||
} | } | ||
Line 120: | Line 120: | ||
if (!this.world.isClient) { // checks if the world is client | if (!this.world.isClient) { // checks if the world is client | ||
this.world.sendEntityStatus(this, | this.world.sendEntityStatus(this, | ||
- | this.remove(); // kills the projectile | + | this.kill(); // kills the projectile |
} | } | ||
Line 204: | Line 204: | ||
PackedSnowballEntity snowballEntity = new PackedSnowballEntity(world, | PackedSnowballEntity snowballEntity = new PackedSnowballEntity(world, | ||
snowballEntity.setItem(itemStack); | snowballEntity.setItem(itemStack); | ||
- | snowballEntity.setProperties(user, user.pitch, user.yaw, 0.0F, 1.5F, 0F); | + | snowballEntity.setVelocity(user, user.pitch, user.yaw, 0.0F, 1.5F, 0F); |
+ | /* | ||
+ | snowballEntity.setProperties(user, | ||
+ | In 1.17,we will use setProperties instead of setVelocity. | ||
+ | */ | ||
world.spawnEntity(snowballEntity); | world.spawnEntity(snowballEntity); | ||
} | } | ||
Line 256: | Line 260: | ||
@Override | @Override | ||
public void onInitializeClient() { | public void onInitializeClient() { | ||
- | EntityRendererRegistry.INSTANCE.register(ProjectileTutorialMod.PackedSnowballEntityType, | + | EntityRendererRegistry.register(ProjectileTutorialMod.PackedSnowballEntityType, |
new FlyingItemEntityRenderer(context)); | new FlyingItemEntityRenderer(context)); | ||
+ | // older versions may have to use | ||
+ | /* EntityRendererRegistry.INSTANCE.register(ProjectileTutorialMod.PackedSnowballEntityType, | ||
+ | new FlyingItemEntityRenderer(context)); | ||
[. . .] | [. . .] | ||
} | } | ||
Line 272: | Line 279: | ||
byteBuf.writeUuid(e.getUuid()); | byteBuf.writeUuid(e.getUuid()); | ||
byteBuf.writeVarInt(e.getEntityId()); | byteBuf.writeVarInt(e.getEntityId()); | ||
+ | | ||
PacketBufUtil.writeVec3d(byteBuf, | PacketBufUtil.writeVec3d(byteBuf, | ||
PacketBufUtil.writeAngle(byteBuf, | PacketBufUtil.writeAngle(byteBuf, | ||
PacketBufUtil.writeAngle(byteBuf, | PacketBufUtil.writeAngle(byteBuf, | ||
- | return ServerSidePacketRegistry.INSTANCE.toPacket(packetID, byteBuf); | + | /* |
+ | In 1.17,we use these. | ||
+ | byteBuf.writeVarInt(e.getId()); | ||
+ | |||
+ | PacketBufUtil.writeVec3d(byteBuf, | ||
+ | PacketBufUtil.writeAngle(byteBuf, | ||
+ | PacketBufUtil.writeAngle(byteBuf, | ||
+ | */ | ||
+ | |||
+ | return ServerPlayNetworking.createS2CPacket(packetID, byteBuf); | ||
} | } | ||
public static final class PacketBufUtil { | public static final class PacketBufUtil { |
tutorial/projectiles.txt · Last modified: 2024/03/08 01:56 by netuserget