mirror of
https://github.com/chylex/Hardcore-Ender-Expansion.git
synced 2025-04-10 20:15:42 +02:00
Make Enderman block stealing conditioned, add chance to drop carried block on tp, tweak despawning
This commit is contained in:
parent
0e2c358a78
commit
cc6b502d1c
src/main/java/chylex/hee/entity/mob
@ -1,7 +1,9 @@
|
||||
package chylex.hee.entity.mob;
|
||||
import java.util.IdentityHashMap;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
|
||||
import net.minecraft.entity.ai.EntityAILookIdle;
|
||||
@ -93,11 +95,15 @@ public class EntityMobEnderman extends EntityAbstractEndermanCustom implements I
|
||||
ITeleportY.findSolidBottom(ITeleportY.around(16),8)
|
||||
);
|
||||
|
||||
for(MobTeleporter teleporter:new MobTeleporter[]{ teleportAroundClose, teleportAroundFull }){
|
||||
for(MobTeleporter<EntityMobEnderman> teleporter:new MobTeleporter[]{ teleportAroundClose, teleportAroundFull }){
|
||||
teleporter.setAttempts(128);
|
||||
teleporter.addLocationPredicate(ITeleportPredicate.noCollision);
|
||||
teleporter.addLocationPredicate(ITeleportPredicate.noLiquid);
|
||||
teleporter.onTeleport(ITeleportListener.playSound);
|
||||
|
||||
teleporter.onTeleport((entity, startPos, rand) -> {
|
||||
if (rand.nextInt(5) <= 2)entity.dropCarrying();
|
||||
});
|
||||
}
|
||||
|
||||
ReflectionPublicizer.f__carriable__EntityEnderman(new IdentityHashMap<Block,Boolean>(){
|
||||
@ -250,7 +256,7 @@ public class EntityMobEnderman extends EntityAbstractEndermanCustom implements I
|
||||
if (teleportAround(false))return true;
|
||||
}
|
||||
|
||||
if (getAttackTarget() == null)extraDespawnOffset += MathUtil.ceil(amount*4F);
|
||||
if (getAttackTarget() == null)extraDespawnOffset += MathUtil.ceil(amount*9F);
|
||||
}
|
||||
|
||||
return onEndermanAttackedFrom(source,amount);
|
||||
@ -267,6 +273,16 @@ public class EntityMobEnderman extends EntityAbstractEndermanCustom implements I
|
||||
return distance <= (Causatum.hasReached(target,Progress.ENDERMAN_KILLED) ? lookDistance : lookDistance*0.5D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Pos findBlockStealPosition(EntityCreature entity){
|
||||
return worldObj.getClosestPlayerToEntity(this,16D) != null ? null : super.findBlockStealPosition(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Pos findBlockPlacePosition(EntityCreature entity){
|
||||
return worldObj.getClosestPlayerToEntity(this,16D) != null ? null : super.findBlockPlacePosition(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttackTarget(EntityLivingBase target){
|
||||
if (target instanceof EntityPlayer && !Causatum.hasReached((EntityPlayer)target,Progress.ENDERMAN_KILLED))return;
|
||||
|
@ -42,6 +42,7 @@ public class EntityAIMoveBlocksRandomly extends EntityAIAbstractContinuous{
|
||||
if (holding.block == Blocks.air && rand.nextFloat() < stealChance){
|
||||
for(int attempt = 0; attempt < 5; attempt++){
|
||||
Pos pos = moveHandler.findBlockStealPosition(entity);
|
||||
if (pos == null)return;
|
||||
|
||||
if (ArrayUtils.contains(validBlocks,pos.getBlock(entity.worldObj))){
|
||||
moveHandler.setCarryingBlock(pos.getInfo(entity.worldObj));
|
||||
@ -53,6 +54,8 @@ public class EntityAIMoveBlocksRandomly extends EntityAIAbstractContinuous{
|
||||
else if (holding.block != Blocks.air && rand.nextFloat() < placeChance){
|
||||
for(int attempt = 0; attempt < 5; attempt++){
|
||||
Pos pos = moveHandler.findBlockPlacePosition(entity);
|
||||
if (pos == null)return;
|
||||
|
||||
Pos below = pos.getDown();
|
||||
|
||||
if (pos.isAir(entity.worldObj) && !below.isAir(entity.worldObj) && below.getBlock(entity.worldObj).renderAsNormalBlock()){
|
||||
@ -68,13 +71,13 @@ public class EntityAIMoveBlocksRandomly extends EntityAIAbstractContinuous{
|
||||
void setCarryingBlock(@Nullable BlockInfo info);
|
||||
@Nonnull BlockInfo getCarryingBlock();
|
||||
|
||||
default Pos findBlockStealPosition(EntityCreature entity){
|
||||
default @Nullable Pos findBlockStealPosition(EntityCreature entity){
|
||||
return Pos.at(entity.posX+(entity.getRNG().nextDouble()-0.5D)*4D,
|
||||
entity.posY+entity.getRNG().nextDouble()*3D,
|
||||
entity.posZ+(entity.getRNG().nextDouble()-0.5D)*4D);
|
||||
}
|
||||
|
||||
default Pos findBlockPlacePosition(EntityCreature entity){
|
||||
default @Nullable Pos findBlockPlacePosition(EntityCreature entity){
|
||||
return Pos.at(entity.posX+(entity.getRNG().nextDouble()-0.5D)*3D,
|
||||
entity.posY+entity.getRNG().nextDouble()*2D,
|
||||
entity.posZ+(entity.getRNG().nextDouble()-0.5D)*3D);
|
||||
|
Loading…
Reference in New Issue
Block a user