mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Added behaviours for filverfish, endermen, and spellcasting illagers
This commit is contained in:
parent
2a5e6e6e72
commit
7ebfa16770
5 changed files with 102 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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<EndermanEntity> {
|
||||
@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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -139,6 +139,9 @@ public class EntityBehaviour<T extends Entity> {
|
|||
}
|
||||
|
||||
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<T extends Entity> {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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<SilverfishEntity> {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<SpellcastingIllagerEntity> {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue