net.minecraft.entity.passive.EntityPig Java Examples

The following examples show how to use net.minecraft.entity.passive.EntityPig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BiomeCanyon.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public BiomeCanyon() {
	super(properties);
	if (!TraverseConfig.vanillaCanyonBlocks) {
		redRock = getBlock("red_rock").getDefaultState();
	}
	topBlock = redRock;
	fillerBlock = redRock;
	decorator.treesPerChunk = -999;
	decorator.extraTreeChance = -999;
	decorator.flowersPerChunk = -999;
	decorator.grassPerChunk = 1;
	decorator.generateFalls = false;

	spawnableCreatureList.clear();
	spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 3, 3, 5));
}
 
Example #2
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public final int despawnVanillaAnimals(WorldServer worldObj)
{
    int count = 0;
    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if (!(entity instanceof EntityLiving))
        {
            continue;
        }
        if ((entity instanceof EntityCow || entity instanceof EntitySheep || entity instanceof EntityPig || entity instanceof EntityOcelot || entity instanceof EntityChicken || entity instanceof EntitySquid || entity instanceof EntityWolf))
        {
            count += entityDespawnCheck(worldObj, (EntityLiving) entity);

        }
    }
    return count;
}
 
Example #3
Source File: MoCreatures.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void ClearVanillaSpawnLists()
{
    for (int i = 0; i < BiomeGenBase.biomeList.length; i++)
    {
        if (BiomeGenBase.biomeList[i] != null)
        {
            EntityRegistry.removeSpawn(EntityCow.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityPig.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntitySheep.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityChicken.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityWolf.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntitySquid.class, EnumCreatureType.waterCreature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityOcelot.class, EnumCreatureType.creature, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityBat.class, EnumCreatureType.ambient, BiomeGenBase.biomeList[i]);
        }
    }
}
 
Example #4
Source File: ItemRidingCrop.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    stack.damageItem(1, player);
    if (victim instanceof EntityHorse || victim instanceof EntityPig)
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 5));
    else if (victim instanceof EntityPlayer || victim instanceof EntityGolem) {
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1));
    }
    if (!player.worldObj.isRemote && !Config.noLust && player.worldObj.provider.dimensionId == -1 && player.worldObj.rand.nextInt(15) == 1) {
        EntityItem ent = victim.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
        ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
        ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
        ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
    }
    return true;
}
 
Example #5
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
	if (stack == null)
		return;
	if (!(event.target instanceof EntityAnimal))
		return;

	EntityAnimal animal = (EntityAnimal) event.target;
	if (!animal.isChild()) {
		if (animal instanceof EntityPig) {
			if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
		} else if (animal instanceof EntityChicken)
			if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
	} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
		feedBaby(animal, event.entityPlayer, stack);
}
 
Example #6
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPig) {
		EntityPig pig = (EntityPig) event.entity;
		if (EtFuturum.enableBeetroot)
			pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
	} else if (event.entity instanceof EntityChicken) {
		EntityChicken chicken = (EntityChicken) event.entity;
		if (EtFuturum.enableBeetroot)
			chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
	} else if (event.entity instanceof EntityWolf) {
		EntityWolf wolf = (EntityWolf) event.entity;
		if (EtFuturum.enableRabbit)
			wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
	} else if (event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		for (Object obj : villager.tasks.taskEntries) {
			EntityAITaskEntry entry = (EntityAITaskEntry) obj;
			if (entry.action instanceof EntityAIOpenDoor) {
				villager.tasks.removeTask(entry.action);
				villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
				break;
			}
		}
	}
}
 
Example #7
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    World world = entity.world;
    BlockPos posAt = new BlockPos(entity);

    Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);
    if (!event.getWorld().isRemote && physicsObject.isPresent()
        && !(entity instanceof EntityFallingBlock)) {
        if (entity instanceof EntityArmorStand
            || entity instanceof EntityPig || entity instanceof EntityBoat) {
            EntityMountable entityMountable = new EntityMountable(world,
                entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES, posAt);
            world.spawnEntity(entityMountable);
            entity.startRiding(entityMountable);
        }
        physicsObject.get()
            .getShipTransformationManager()
            .getCurrentTickTransform().transform(entity,
            TransformType.SUBSPACE_TO_GLOBAL);
        // TODO: This should work but it doesn't because of sponge. Instead we have to rely on MixinChunk.preAddEntity() to fix this
        // event.setCanceled(true);
        // event.getWorld().spawnEntity(entity);
    }
}
 
Example #8
Source File: BiomeMiniJungle.java    From Traverse-Legacy-1-12-2 with MIT License 6 votes vote down vote up
public void decorate(World worldIn, Random rand, BlockPos pos) {
    super.decorate(worldIn, rand, pos);
    int i = rand.nextInt(16) + 8;
    int j = rand.nextInt(16) + 8;
    int height = worldIn.getHeight(pos.add(i, 0, j)).getY() * 2; // could == 0, which crashes nextInt
    if (height < 1) height = 1;
    int k = rand.nextInt(height);
    if (net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN))
        (new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j));
    WorldGenVines worldgenvines = new WorldGenVines();

    if (net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS))
        for (j = 0; j < 50; ++j) {
            k = rand.nextInt(16) + 8;
            int l = 128;
            int i1 = rand.nextInt(16) + 8;
            worldgenvines.generate(worldIn, rand, pos.add(k, 128, i1));
            EntityPig pig = new EntityPig(worldIn);
        }
}
 
Example #9
Source File: BiomeCanyon.java    From Traverse-Legacy-1-12-2 with MIT License 6 votes vote down vote up
public BiomeCanyon() {
	super(properties);
	if (!TraverseConfig.vanillaCanyonBlocks) {
		redRock = getBlock("red_rock").getDefaultState();
	}
	topBlock = redRock;
	fillerBlock = redRock;
	decorator.treesPerChunk = -999;
	decorator.extraTreeChance = -999;
	decorator.flowersPerChunk = -999;
	decorator.grassPerChunk = 1;
	decorator.generateFalls = false;

	spawnableCreatureList.clear();
	spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 3, 3, 5));
}
 
Example #10
Source File: BiomeMiniJungle.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void decorate(World worldIn, Random rand, BlockPos pos) {
    super.decorate(worldIn, rand, pos);
    int i = rand.nextInt(16) + 8;
    int j = rand.nextInt(16) + 8;
    int height = worldIn.getHeight(pos.add(i, 0, j)).getY() * 2; // could == 0, which crashes nextInt
    if (height < 1) height = 1;
    int k = rand.nextInt(height);
    if (net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN))
        (new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j));
    WorldGenVines worldgenvines = new WorldGenVines();

    if (net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS))
        for (j = 0; j < 50; ++j) {
            k = rand.nextInt(16) + 8;
            int l = 128;
            int i1 = rand.nextInt(16) + 8;
            worldgenvines.generate(worldIn, rand, pos.add(k, 128, i1));
            EntityPig pig = new EntityPig(worldIn);
        }
}
 
Example #11
Source File: CivilizationHandlers.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private boolean isAnimal(EntityLivingBase victim) {
	return victim instanceof EntityCow ||
			victim instanceof EntityHorse ||
			victim instanceof EntityPig ||
			victim instanceof EntityDonkey ||
			victim instanceof EntityChicken ||
			victim instanceof EntitySheep;
}
 
Example #12
Source File: VSWorldEventListener.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntityAdded(Entity entity) {
    if (entity instanceof PhysicsWrapperEntity) {
        ValkyrienSkiesMod.VS_PHYSICS_MANAGER.onShipLoad((PhysicsWrapperEntity) entity);
    } else {
        // This is really only here because Sponge doesn't call the entity join event for some reason :/
        // So I basically just copied the event code here as well.
        World world = worldObj;
        BlockPos posAt = new BlockPos(entity);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);

        if (!worldObj.isRemote && physicsObject.isPresent()
            && !(entity instanceof EntityFallingBlock)) {
            if (entity instanceof EntityArmorStand
                || entity instanceof EntityPig || entity instanceof EntityBoat) {
                EntityMountable entityMountable = new EntityMountable(world,
                    entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES,
                    posAt);
                world.spawnEntity(entityMountable);
                entity.startRiding(entityMountable);
            }
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .removeEntity(entity);
            physicsObject.get()
                .getShipTransformationManager()
                .getCurrentTickTransform().transform(entity,
                TransformType.SUBSPACE_TO_GLOBAL);
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .addEntity(entity);
        }
    }
}
 
Example #13
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private boolean isFoodItem(EntityAnimal animal, ItemStack food) {
	if (animal.isBreedingItem(food))
		return true;
	else if (animal instanceof EntityPig && food.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
		return true;
	else if (animal instanceof EntityChicken && food.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
		return true;
	else
		return false;
}
 
Example #14
Source File: ItemMobSpawner.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void loadSpawners(World world) {
    if (loaded) return;
    loaded = true;
    HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
    HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
    for (Class<Entity> eclass : classToStringMapping.keySet()) {
        if (!EntityLiving.class.isAssignableFrom(eclass))
            continue;
        try {
            EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[]{World.class}).newInstance(world);
            entityliving.isChild();

            int id = classToIDMapping.get(eclass);
            String name = classToStringMapping.get(eclass);

            if (name.equals("EnderDragon"))
                continue;

            IDtoNameMap.put(id, name);

            if (name.equals("Pig"))
                idPig = id;
        } catch (Throwable ignored) {
        }
    }

    for(Iterator<Entry<Integer, String>> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) {
        Entry<Integer, String> e = it.next();
        if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"))
            it.remove();
    }
}
 
Example #15
Source File: EntityPigMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityPig target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("isSaddled", target.getSaddled());

	return map;
}
 
Example #16
Source File: AdvancedModEventHandler.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Using the LivingDropsEvent. Note that this is from  net.minecraftforge.event, so to make this method be called, this class needs to be registered at MinecraftForge.EVENT_BUS.register(new AdvancedModEventHandler()).
 * @param event
 */
@SubscribeEvent
public void addPigDrops(LivingDropsEvent event){
    if(event.entityLiving instanceof EntityPig && event.entityLiving.getRNG().nextInt(3) == 0) {
        ItemStack stack = new ItemStack(ModBlocks.dutchFlag);
        event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, stack));
    }
}
 
Example #17
Source File: Chickenificator.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void onInit(FMLInitializationEvent event) {
	FMLLog.log.info("Chickenification is beginning...");
	//RenderingRegistry.registerEntityRenderingHandler(EntitySheep.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityCow.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityPig.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySquid.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityZombie.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySpider.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySkeleton.class, new RenderStupidChicken());
	FMLLog.log.info("Chickenificated all the bois!");
}
 
Example #18
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public static int despawnVanillaAnimals(World worldObj, List[] classList)
{
    int count = 0;
    for (int j = 0; j < worldObj.loadedEntityList.size(); j++)
    {
        Entity entity = (Entity) worldObj.loadedEntityList.get(j);
        if ((entity instanceof EntityLiving) && (entity instanceof EntityCow || entity instanceof EntitySheep || entity instanceof EntityPig || entity instanceof EntityChicken || entity instanceof EntitySquid || entity instanceof EntityWolf))
        {
            count += entityDespawnCheck(worldObj, (EntityLiving) entity);

        }
    }
    return count;
}
 
Example #19
Source File: CustomSpawner.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public CustomSpawner()
{
    biomeList = new ArrayList<BiomeGenBase>();
    log.setParent(FMLLog.getLogger());
    try
    {
        for (BiomeGenBase biomegenbase : BiomeGenBase.biomeList)
        {
            if (biomegenbase == null)
            {
                continue;
            }
            biomeList.add(biomegenbase);
        }

        customCreatureSpawnList = new List[biomeList.size()];
        customMobSpawnList = new List[biomeList.size()];
        customAmbientSpawnList = new List[biomeList.size()];
        customAquaticSpawnList = new List[biomeList.size()];
        entityClasses = new List[4];
        vanillaClassList = new ArrayList<Class>();
        vanillaClassList.add(EntityChicken.class);
        vanillaClassList.add(EntityCow.class);
        vanillaClassList.add(EntityPig.class);
        vanillaClassList.add(EntitySheep.class);
        vanillaClassList.add(EntityWolf.class);
        vanillaClassList.add(EntitySquid.class);
        vanillaClassList.add(EntityOcelot.class);
        vanillaClassList.add(EntityBat.class);
        clearLists();
    }
    catch (Exception ex)
    {
        throw new RuntimeException(ex);
    }
}
 
Example #20
Source File: EntityControlModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void pigTravel(EventPigTravel event) {
    final Minecraft mc = Minecraft.getMinecraft();
    final boolean moving = mc.player.movementInput.moveForward != 0 || mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.jump;

    final Entity riding = mc.player.getRidingEntity();

    if (riding != null && riding instanceof EntityPig) {
        if (!moving && riding.onGround) {
            event.setCanceled(true);
        }
    }
}
 
Example #21
Source File: CommonProxy.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public void registerEntities() {
	if (EtFuturum.enableBanners)
		GameRegistry.registerTileEntity(TileEntityBanner.class, Utils.getUnlocalisedName("banner"));
	if (EtFuturum.enableArmourStand)
		ModEntityList.registerEntity(EntityArmourStand.class, "wooden_armorstand", 0, EtFuturum.instance, 64, 1, true);
	if (EtFuturum.enableEndermite)
		ModEntityList.registerEntity(EntityEndermite.class, "endermite", 1, EtFuturum.instance, 64, 1, true, 1447446, 7237230);
	if (EtFuturum.enableChorusFruit)
		GameRegistry.registerTileEntity(TileEntityEndRod.class, Utils.getUnlocalisedName("end_rod"));
	if (EtFuturum.enableTippedArrows)
		ModEntityList.registerEntity(EntityTippedArrow.class, "tipped_arrow", 2, EtFuturum.instance, 64, 20, true);
	if (EtFuturum.enableBrewingStands)
		GameRegistry.registerTileEntity(TileEntityNewBrewingStand.class, Utils.getUnlocalisedName("brewing_stand"));
	if (EtFuturum.enableColourfulBeacons)
		GameRegistry.registerTileEntity(TileEntityNewBeacon.class, Utils.getUnlocalisedName("beacon"));

	if (EtFuturum.enableRabbit) {
		ModEntityList.registerEntity(EntityRabbit.class, "rabbit", 3, EtFuturum.instance, 80, 3, true, 10051392, 7555121);

		List<BiomeGenBase> biomes = new LinkedList<BiomeGenBase>();
		label: for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
			if (biome != null)
				// Check if pigs can spawn on this biome
				for (Object obj : biome.getSpawnableList(EnumCreatureType.creature))
					if (obj instanceof SpawnListEntry) {
						SpawnListEntry entry = (SpawnListEntry) obj;
						if (entry.entityClass == EntityPig.class) {
							biomes.add(biome);
							continue label;
						}
					}
		EntityRegistry.addSpawn(EntityRabbit.class, 10, 3, 3, EnumCreatureType.creature, biomes.toArray(new BiomeGenBase[biomes.size()]));
	}

	if (EtFuturum.enableLingeringPotions) {
		ModEntityList.registerEntity(EntityLingeringPotion.class, "lingering_potion", 4, EtFuturum.instance, 64, 10, true);
		ModEntityList.registerEntity(EntityLingeringEffect.class, "lingering_effect", 5, EtFuturum.instance, 64, 1, true);
	}

	if (EtFuturum.enableVillagerZombies)
		ModEntityList.registerEntity(EntityZombieVillager.class, "villager_zombie", 6, EtFuturum.instance, 80, 3, true, 44975, 7969893);

	if (EtFuturum.enableDragonRespawn) {
		ModEntityList.registerEntity(EntityPlacedEndCrystal.class, "end_crystal", 7, EtFuturum.instance, 256, Integer.MAX_VALUE, false);
		ModEntityList.registerEntity(EntityRespawnedDragon.class, "ender_dragon", 8, EtFuturum.instance, 160, 3, true);
	}

	if (EtFuturum.enableShearableGolems)
		ModEntityList.registerEntity(EntityNewSnowGolem.class, "snow_golem", 9, EtFuturum.instance, 80, 3, true);
}
 
Example #22
Source File: CraftPig.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public EntityPig getHandle() {
    return (EntityPig) entity;
}
 
Example #23
Source File: CraftPig.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftPig(CraftServer server, EntityPig entity) {
    super(server, entity);
}