From d30b22c11ce28117d70ee88fe1baa1ebf6ce07b9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 24 Sep 2020 21:26:11 +0200 Subject: [PATCH] Add a bee behaviour --- .../entity/behaviour/BeeBehaviour.java | 30 +++++++++++++++++++ .../entity/behaviour/EntityBehaviour.java | 1 + 2 files changed, 31 insertions(+) create mode 100644 src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java new file mode 100644 index 00000000..24790512 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java @@ -0,0 +1,30 @@ +package com.minelittlepony.unicopia.entity.behaviour; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.ability.magic.Spell; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.sound.AggressiveBeeSoundInstance; +import net.minecraft.client.sound.PassiveBeeSoundInstance; +import net.minecraft.entity.passive.BeeEntity; + +public class BeeBehaviour extends EntityBehaviour { + @Override + public void onCreate(BeeEntity entity) { + super.onCreate(entity); + if (entity.world.isClient) { + MinecraftClient.getInstance().getSoundManager().playNextTick( + entity.hasAngerTime() ? new AggressiveBeeSoundInstance(entity) : new PassiveBeeSoundInstance(entity) + ); + } + } + + @Override + public void update(Caster source, BeeEntity entity, Spell spell) { + + if (source.getOwner().isSneaking()) { + entity.setAngerTime(10); + } else { + entity.setAngerTime(0); + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index 1c4bf91c..a691915f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -178,6 +178,7 @@ public class EntityBehaviour { static { register(VillagerBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER); register(SheepBehaviour::new, EntityType.SHEEP); + register(BeeBehaviour::new, EntityType.BEE); register(EndermanBehaviour::new, EntityType.ENDERMAN); register(SpellcastingIllagerBehaviour::new, EntityType.ILLUSIONER, EntityType.EVOKER); register(ShulkerBehaviour::new, EntityType.SHULKER);