Search in sources :

Example 1 with Village

use of net.minecraft.village.Village in project CumServerPro by MCUmbrella.

the class EntityAIRestrictOpenDoor method shouldExecute.

public boolean shouldExecute() {
    if (this.entity.world.isDaytime()) {
        return false;
    } else {
        BlockPos blockpos = new BlockPos(this.entity);
        Village village = this.entity.world.getVillageCollection().getNearestVillage(blockpos, 16);
        if (village == null) {
            return false;
        } else {
            this.frontDoor = village.getNearestDoor(blockpos);
            if (this.frontDoor == null) {
                return false;
            } else {
                return (double) this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
            }
        }
    }
}
Also used : Village(net.minecraft.village.Village) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with Village

use of net.minecraft.village.Village in project CumServerPro by MCUmbrella.

the class EntityAIMoveThroughVillage method shouldExecute.

public boolean shouldExecute() {
    this.resizeDoorList();
    if (this.isNocturnal && this.entity.world.isDaytime()) {
        return false;
    } else {
        Village village = this.entity.world.getVillageCollection().getNearestVillage(new BlockPos(this.entity), 0);
        if (village == null) {
            return false;
        } else {
            this.doorInfo = this.findNearestDoor(village);
            if (this.doorInfo == null) {
                return false;
            } else {
                PathNavigateGround pathnavigateground = (PathNavigateGround) this.entity.getNavigator();
                boolean flag = pathnavigateground.getEnterDoors();
                pathnavigateground.setBreakDoors(false);
                this.path = pathnavigateground.getPathToPos(this.doorInfo.getDoorBlockPos());
                pathnavigateground.setBreakDoors(flag);
                if (this.path != null) {
                    return true;
                } else {
                    Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.entity, 10, 7, new Vec3d((double) this.doorInfo.getDoorBlockPos().getX(), (double) this.doorInfo.getDoorBlockPos().getY(), (double) this.doorInfo.getDoorBlockPos().getZ()));
                    if (vec3d == null) {
                        return false;
                    } else {
                        pathnavigateground.setBreakDoors(false);
                        this.path = this.entity.getNavigator().getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
                        pathnavigateground.setBreakDoors(flag);
                        return this.path != null;
                    }
                }
            }
        }
    }
}
Also used : Village(net.minecraft.village.Village) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Example 3 with Village

use of net.minecraft.village.Village in project Minecraft-SlientClient-Hack by YouNeverKnow00.

the class EntityAIRestrictOpenDoor method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
    if (this.entityObj.world.isDaytime()) {
        return false;
    } else {
        BlockPos blockpos = new BlockPos(this.entityObj);
        Village village = this.entityObj.world.getVillageCollection().getNearestVillage(blockpos, 16);
        if (village == null) {
            return false;
        } else {
            this.frontDoor = village.getNearestDoor(blockpos);
            if (this.frontDoor == null) {
                return false;
            } else {
                return (double) this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
            }
        }
    }
}
Also used : Village(net.minecraft.village.Village) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with Village

use of net.minecraft.village.Village in project DynamicSurroundings by OreCruncher.

the class EnvironmentService method tickEvent.

@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.PlayerTickEvent event) {
    if (event.phase == Phase.END && event.side == Side.SERVER) {
        final EntityPlayer player = event.player;
        final VillageCollection villageCollection = player.getEntityWorld().getVillageCollection();
        boolean inVillage = false;
        if (villageCollection != null) {
            final List<Village> villages = villageCollection.getVillageList();
            if (villages != null && villages.size() > 0) {
                final BlockPos pos = player.getPosition();
                for (final Village v : villages) if (v.isBlockPosWithinSqVillageRadius(pos)) {
                    inVillage = true;
                    break;
                }
            }
        }
        final PacketEnvironment packet = new PacketEnvironment(inVillage);
        Network.sendToPlayer((EntityPlayerMP) player, packet);
    }
}
Also used : Village(net.minecraft.village.Village) PacketEnvironment(org.blockartistry.DynSurround.network.PacketEnvironment) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) VillageCollection(net.minecraft.village.VillageCollection) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with Village

use of net.minecraft.village.Village in project Random-Things by lumien231.

the class FestivalHandler method addFestival.

public int addFestival(EntityVillager villager) {
    Village v = ReflectionUtil.getVillage(villager);
    if (v != null) {
        List<VillageDoorInfo> doorInfos = v.getVillageDoorInfoList();
        if (doorInfos != null && !doorInfos.isEmpty()) {
            Festival f = new Festival();
            for (VillageDoorInfo doorInfo : doorInfos) {
                f.addDoorPos(doorInfo.getInsideBlockPos());
            }
            HashSet<BlockPos> hashTest = new HashSet<>(f.getDoorPositions());
            for (Festival currentFestival : currentFestivals) {
                for (BlockPos p : currentFestival.doorPositions) {
                    if (hashTest.contains(p)) {
                        return 1;
                    }
                }
            }
            addFestival(f);
            return 2;
        }
    }
    return 0;
}
Also used : Village(net.minecraft.village.Village) VillageDoorInfo(net.minecraft.village.VillageDoorInfo) BlockPos(net.minecraft.util.math.BlockPos) HashSet(java.util.HashSet)

Aggregations

Village (net.minecraft.village.Village)14 BlockPos (net.minecraft.util.math.BlockPos)7 BlockPos (net.minecraft.util.BlockPos)6 PathNavigateGround (net.minecraft.pathfinding.PathNavigateGround)5 Vec3 (net.minecraft.util.Vec3)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Vec3d (net.minecraft.util.math.Vec3d)2 VillageCollection (net.minecraft.village.VillageCollection)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)1 VillageDoorInfo (net.minecraft.village.VillageDoorInfo)1 PacketEnvironment (org.blockartistry.DynSurround.network.PacketEnvironment)1 PacketEnvironment (org.orecruncher.dsurround.network.PacketEnvironment)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1