Skip to content

Commit

Permalink
feat: Spawn llamas with random variants #281
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 30, 2024
1 parent ba45ee9 commit 06da951
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.animal.Turtle;
import net.minecraft.world.entity.animal.horse.Llama;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -69,6 +70,10 @@ public void serverTick() {
if (entity instanceof Turtle turtle) {
turtle.setHomePos(worldPosition);
}
if (entity instanceof Llama llama) {
final var candidates = Llama.Variant.values();
llama.setVariant(candidates[level.random.nextInt(candidates.length)]);
}
entity.setPos(worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5);
level.addFreshEntity(entity);
((ServerLevel) level).sendParticles(ParticleTypes.EXPLOSION,
Expand Down

0 comments on commit 06da951

Please sign in to comment.