Search in sources :

Example 1 with AbstractBlockGate

use of com.minecolonies.api.blocks.decorative.AbstractBlockGate in project minecolonies by Minecolonies.

the class EntityAIBreakDoor method tick.

@Override
public void tick() {
    if (mob.getCommandSenderWorld().getDifficulty().getId() < 2 || !MineColonies.getConfig().getServer().shouldRaidersBreakDoors.get()) {
        breakTime = 0;
    }
    // Only advances breaking time in relation to hardness
    if (this.mob.getRandom().nextInt(breakChance) != 0) {
        this.breakTime--;
    } else {
        int fasterBreakPerXNearby = 5;
        if (mob instanceof AbstractEntityMinecoloniesMob && !mob.level.isClientSide()) {
            final IColony colony = ((AbstractEntityMinecoloniesMob) mob).getColony();
            fasterBreakPerXNearby += colony.getResearchManager().getResearchEffects().getEffectStrength(MECHANIC_ENHANCED_GATES);
        }
        breakChance = Math.max(1, hardness / (1 + (mob.level.getLoadedEntitiesOfClass(AbstractEntityMinecoloniesMob.class, mob.getBoundingBox().inflate(5)).size() / fasterBreakPerXNearby)));
    }
    if (this.breakTime == this.getDoorBreakTime() - 1) {
        final BlockState toBreak = mob.level.getBlockState(doorPos);
        if (toBreak.getBlock() instanceof AbstractBlockGate) {
            ((AbstractBlockGate) toBreak.getBlock()).removeGate(mob.level, doorPos, toBreak.getValue(BlockStateProperties.HORIZONTAL_FACING).getClockWise());
        }
    }
    super.tick();
}
Also used : BlockState(net.minecraft.block.BlockState) AbstractBlockGate(com.minecolonies.api.blocks.decorative.AbstractBlockGate) IColony(com.minecolonies.api.colony.IColony) AbstractEntityMinecoloniesMob(com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob)

Example 2 with AbstractBlockGate

use of com.minecolonies.api.blocks.decorative.AbstractBlockGate in project minecolonies by ldtteam.

the class EntityAIBreakDoor method tick.

@Override
public void tick() {
    if (mob.getCommandSenderWorld().getDifficulty().getId() < 2 || !MineColonies.getConfig().getServer().shouldRaidersBreakDoors.get()) {
        breakTime = 0;
    }
    // Only advances breaking time in relation to hardness
    if (this.mob.getRandom().nextInt(breakChance) != 0) {
        this.breakTime--;
    } else {
        int fasterBreakPerXNearby = 5;
        if (mob instanceof AbstractEntityMinecoloniesMob && !mob.level.isClientSide()) {
            final IColony colony = ((AbstractEntityMinecoloniesMob) mob).getColony();
            fasterBreakPerXNearby += colony.getResearchManager().getResearchEffects().getEffectStrength(MECHANIC_ENHANCED_GATES);
        }
        breakChance = Math.max(1, hardness / (1 + (mob.level.getLoadedEntitiesOfClass(AbstractEntityMinecoloniesMob.class, mob.getBoundingBox().inflate(5)).size() / fasterBreakPerXNearby)));
    }
    if (this.breakTime == this.getDoorBreakTime() - 1) {
        final BlockState toBreak = mob.level.getBlockState(doorPos);
        if (toBreak.getBlock() instanceof AbstractBlockGate) {
            ((AbstractBlockGate) toBreak.getBlock()).removeGate(mob.level, doorPos, toBreak.getValue(BlockStateProperties.HORIZONTAL_FACING).getClockWise());
        }
    }
    super.tick();
}
Also used : BlockState(net.minecraft.block.BlockState) AbstractBlockGate(com.minecolonies.api.blocks.decorative.AbstractBlockGate) IColony(com.minecolonies.api.colony.IColony) AbstractEntityMinecoloniesMob(com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob)

Aggregations

AbstractBlockGate (com.minecolonies.api.blocks.decorative.AbstractBlockGate)2 IColony (com.minecolonies.api.colony.IColony)2 AbstractEntityMinecoloniesMob (com.minecolonies.api.entity.mobs.AbstractEntityMinecoloniesMob)2 BlockState (net.minecraft.block.BlockState)2