diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StateMaps.java b/src/main/java/com/minelittlepony/unicopia/block/state/StateMaps.java index c1e79395..519da259 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StateMaps.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StateMaps.java @@ -43,6 +43,15 @@ public class StateMaps { a.replaceBlock(Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS); }), "moss"); + public static final BlockStateConverter SILVERFISH_AFFECTED = register(Util.make(new BlockStateMap(), a -> { + a.replaceBlock(Blocks.CHISELED_STONE_BRICKS, Blocks.INFESTED_CHISELED_STONE_BRICKS); + a.replaceBlock(Blocks.COBBLESTONE, Blocks.INFESTED_COBBLESTONE); + a.replaceBlock(Blocks.CRACKED_STONE_BRICKS, Blocks.INFESTED_CRACKED_STONE_BRICKS); + a.replaceBlock(Blocks.MOSSY_STONE_BRICKS, Blocks.INFESTED_MOSSY_STONE_BRICKS); + a.replaceBlock(Blocks.STONE, Blocks.INFESTED_STONE); + a.replaceBlock(Blocks.STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS); + }), "infestation"); + public static final BlockStateConverter FIRE_AFFECTED = register(Util.make(new BlockStateMap(), a -> { a.removeBlock(s -> s.getBlock() == Blocks.SNOW || s.getBlock() == Blocks.SNOW_BLOCK); a.removeBlock(s -> s.getBlock() instanceof PlantBlock); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EndermanBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EndermanBehaviour.java new file mode 100644 index 00000000..6aeac619 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EndermanBehaviour.java @@ -0,0 +1,28 @@ +package com.minelittlepony.unicopia.entity.behaviour; + +import com.minelittlepony.unicopia.ability.magic.Caster; + +import net.minecraft.block.Blocks; +import net.minecraft.entity.mob.EndermanEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; + +public class EndermanBehaviour extends EntityBehaviour { + @Override + public void update(Caster source, EndermanEntity entity) { + if (source.getOwner().isSneaking() || source.getOwner().isSprinting()) { + entity.setTarget(entity); + } else { + entity.setTarget(null); + } + + ItemStack stack = source.getOwner().getStackInHand(Hand.MAIN_HAND); + if (stack.getItem() instanceof BlockItem) { + entity.setCarriedBlock(((BlockItem)stack.getItem()).getBlock().getDefaultState()); + } else { + entity.setCarriedBlock(Blocks.AIR.getDefaultState()); + } + + } +} 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 5628dbdd..c748904c 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -139,6 +139,9 @@ public class EntityBehaviour { } to.setSneaking(from.isSneaking()); + if (to instanceof PlayerEntity) { + to.setPose(from.getPose()); + } } protected void copyInventory(LivingEntity from, LivingEntity l) { @@ -172,8 +175,11 @@ public class EntityBehaviour { } static { + register(EndermanBehaviour::new, EntityType.ENDERMAN); + register(SpellcastingIllagerBehaviour::new, EntityType.ILLUSIONER, EntityType.EVOKER); register(ShulkerBehaviour::new, EntityType.SHULKER); register(CreeperBehaviour::new, EntityType.CREEPER); + register(SilverfishBehaviour::new, EntityType.SILVERFISH); register(ChickenBehaviour::new, EntityType.CHICKEN); register(MinecartBehaviour::new, EntityType.CHEST_MINECART, EntityType.COMMAND_BLOCK_MINECART, EntityType.FURNACE_MINECART, EntityType.HOPPER_MINECART, EntityType.MINECART, EntityType.SPAWNER_MINECART, EntityType.TNT_MINECART); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java new file mode 100644 index 00000000..a0a147f1 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java @@ -0,0 +1,30 @@ +package com.minelittlepony.unicopia.entity.behaviour; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.block.state.StateMaps; +import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.util.WorldEvent; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.mob.SilverfishEntity; +import net.minecraft.util.math.BlockPos; + +public class SilverfishBehaviour extends EntityBehaviour { + @Override + public void update(Caster source, SilverfishEntity entity) { + if (source instanceof Pony && !source.isClient()) { + Pony player = (Pony)source; + + if (player.sneakingChanged() && player.getOwner().isSneaking()) { + BlockPos pos = entity.getBlockPos().down(); + BlockState state = entity.world.getBlockState(pos); + + if (StateMaps.SILVERFISH_AFFECTED.canConvert(state)) { + + entity.world.setBlockState(pos, StateMaps.SILVERFISH_AFFECTED.getConverted(state)); + WorldEvent.play(WorldEvent.DESTROY_BLOCK, entity.world, pos, state); + } + } + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java new file mode 100644 index 00000000..41f36988 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java @@ -0,0 +1,29 @@ +package com.minelittlepony.unicopia.entity.behaviour; + +import com.minelittlepony.unicopia.ability.magic.Caster; +import com.minelittlepony.unicopia.entity.player.Pony; + +import net.minecraft.entity.mob.SpellcastingIllagerEntity; + +public class SpellcastingIllagerBehaviour extends EntityBehaviour { + @Override + public void update(Caster source, SpellcastingIllagerEntity entity) { + + if (source instanceof Pony) { + Pony player = (Pony)source; + + if (player.sneakingChanged()) { + if (player.getOwner().isSneaking()) { + SpellcastingIllagerEntity.Spell[] spells = SpellcastingIllagerEntity.Spell.values(); + SpellcastingIllagerEntity.Spell spell = spells[entity.world.random.nextInt(spells.length - 1) + 1]; + + entity.setSpell(spell); + entity.setTarget(entity); + } else { + entity.setSpell(SpellcastingIllagerEntity.Spell.NONE); + entity.setTarget(null); + } + } + } + } +}