use of net.minecraft.entity.passive.EntitySheep in project BluePower by Qmunity.
the class ItemIndigoDye method itemInteractionForEntity.
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) {
if (entity instanceof EntitySheep) {
EntitySheep sheep = (EntitySheep) entity;
if (!sheep.getSheared() && sheep.getFleeceColor() != 10) {
sheep.setFleeceColor(10);
--stack.stackSize;
}
return true;
}
return false;
}
use of net.minecraft.entity.passive.EntitySheep in project Engine by VoltzEngine-Project.
the class TestAbstractLocation method testInit.
/**
* Tests constructors
*/
public void testInit() {
List<TLocation> locations = new ArrayList();
//Test main method
locations.add(new TLocation(world, 10, 11, 12));
//Test entity method
Entity entity = new EntitySheep(world);
entity.setPosition(10, 11, 12);
locations.add(new TLocation(entity));
//Test tile
TileEntity tile = new TileEntity();
tile.setWorldObj(world);
tile.xCoord = 10;
tile.yCoord = 11;
tile.zCoord = 12;
locations.add(new TLocation(tile));
//Test NBT method
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("dimension", world.provider.dimensionId);
tag.setDouble("x", 10);
tag.setDouble("y", 11);
tag.setDouble("z", 12);
locations.add(new TLocation(tag));
//Test byte buf method
ByteBuf buf = Unpooled.buffer();
buf.writeInt(world.provider.dimensionId);
buf.writeDouble(10);
buf.writeDouble(11);
buf.writeDouble(12);
locations.add(new TLocation(buf));
//Test IWorldPosition
locations.add(new TLocation(new IWorldPosition() {
@Override
public World world() {
return world;
}
@Override
public double x() {
return 10;
}
@Override
public double y() {
return 11;
}
@Override
public double z() {
return 12;
}
}));
//Test world, IPos3D
locations.add(new TLocation(world, new IPos3D() {
@Override
public double x() {
return 10;
}
@Override
public double y() {
return 11;
}
@Override
public double z() {
return 12;
}
}));
//Test world, vec3
locations.add(new TLocation(world, Vec3.createVectorHelper(10, 11, 12)));
//Test world, moving object
locations.add(new TLocation(world, new MovingObjectPosition(10, 11, 12, 0, Vec3.createVectorHelper(10, 11, 12))));
for (int i = 0; i < locations.size(); i++) {
TLocation location = locations.get(i);
assertTrue("" + i, location.world == world);
assertTrue("" + i, location.xi() == 10);
assertTrue("" + i, location.yi() == 11);
assertTrue("" + i, location.zi() == 12);
}
}
use of net.minecraft.entity.passive.EntitySheep in project MineFactoryReloaded by powercrystals.
the class RanchableSheep method ranch.
@Override
public List<ItemStack> ranch(World world, EntityLiving entity, IInventory rancher) {
EntitySheep s = (EntitySheep) entity;
if (s.getSheared() || s.getGrowingAge() < 0) {
return null;
}
List<ItemStack> stacks = new LinkedList<ItemStack>();
stacks.add(new ItemStack(Block.cloth, 1, s.getFleeceColor()));
s.setSheared(true);
return stacks;
}
use of net.minecraft.entity.passive.EntitySheep in project Pearcel-Mod by MiningMark48.
the class BlockSummoner method onBlockActivated.
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
Random rand = new Random();
int spawnRand = rand.nextInt(5) + 1;
int negRand = rand.nextInt(2) + 1;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
if (negRand == 1) {
spawnRand = -spawnRand;
}
EntitySheep sheep = new EntitySheep(world);
sheep.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityEnderman enderman = new EntityEnderman(world);
enderman.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityBlaze blaze = new EntityBlaze(world);
blaze.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityGhast ghast = new EntityGhast(world);
ghast.setPosition(x + spawnRand, y + 5, z + spawnRand);
EntitySkeleton skeleton = new EntitySkeleton(world);
skeleton.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityCreeper creeper = new EntityCreeper(world);
creeper.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityEnderCrystal endcrystal = new EntityEnderCrystal(world);
endcrystal.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityHorse horse = new EntityHorse(world);
horse.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityIronGolem iron_golem = new EntityIronGolem(world);
iron_golem.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityVillager villager = new EntityVillager(world);
villager.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityDragon dragon = new EntityDragon(world);
dragon.setPosition(x + spawnRand, y + 2, z + spawnRand);
EntityWither wither = new EntityWither(world);
wither.setPosition(x + spawnRand, y + 2, z + spawnRand);
if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
if (!player.isSneaking() && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.sap) {
if (!world.isRemote) {
//Missing Block
if (world.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.missingBlock")));
if (world.isRemote) {
world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
}
} else //Dragon
if (isCorrectSetup(pos, world, Blocks.DRAGON_EGG, Blocks.DIAMOND_BLOCK)) {
if (player.dimension == 1) {
setTainted(pos, world);
world.spawnEntity(dragon);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.dragon") + " " + Translate.toLocal("summoner.summoned")));
} else {
player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.wrongDimension")));
}
} else //Wither
if (isCorrectSetup(pos, world, Blocks.SKULL, Blocks.DIAMOND_BLOCK)) {
setTainted(pos, world);
world.spawnEntity(wither);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.wither") + " " + Translate.toLocal("summoner.summoned")));
} else //Sheep
if (isCorrectSetup(pos, world, Blocks.WOOL, Blocks.WOOL)) {
setTainted(pos, world);
world.spawnEntity(sheep);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.sheep") + " " + Translate.toLocal("summoner.summoned")));
} else //Enderman
if (isCorrectSetup(pos, world, Blocks.END_STONE, Blocks.END_STONE)) {
setTainted(pos, world);
world.spawnEntity(enderman);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.enderman") + " " + Translate.toLocal("summoner.summoned")));
} else //Blaze
if (isCorrectSetup(pos, world, Blocks.GRAVEL, Blocks.NETHERRACK)) {
setTainted(pos, world);
world.spawnEntity(blaze);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.blaze") + " " + Translate.toLocal("summoner.summoned")));
} else //Ghast
if (isCorrectSetup(pos, world, Blocks.COBBLESTONE, Blocks.SOUL_SAND)) {
setTainted(pos, world);
world.spawnEntity(ghast);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.ghast") + " " + Translate.toLocal("summoner.summoned")));
} else //Skeleton
if (isCorrectSetup(pos, world, Blocks.PLANKS, Blocks.SAND)) {
setTainted(pos, world);
world.spawnEntity(skeleton);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.skeleton") + " " + Translate.toLocal("summoner.summoned")));
} else //Creeper
if (isCorrectSetup(pos, world, Blocks.TNT, Blocks.TNT)) {
setTainted(pos, world);
world.spawnEntity(creeper);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.creeper") + " " + Translate.toLocal("summoner.summoned")));
} else //Horse
if (isCorrectSetup(pos, world, Blocks.HAY_BLOCK, Blocks.HAY_BLOCK)) {
setTainted(pos, world);
world.spawnEntity(horse);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.horse") + " " + Translate.toLocal("summoner.summoned")));
} else //Iron Golem
if (isCorrectSetup(pos, world, Blocks.IRON_BLOCK, Blocks.IRON_BLOCK)) {
setTainted(pos, world);
world.spawnEntity(iron_golem);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.iron_golem") + " " + Translate.toLocal("summoner.summoned")));
} else //Villager
if (isCorrectSetup(pos, world, Blocks.EMERALD_BLOCK, Blocks.SKULL)) {
setTainted(pos, world);
world.spawnEntity(villager);
player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.villager") + " " + Translate.toLocal("summoner.summoned")));
} else {
if (!world.isRemote) {
setTainted(pos, world);
player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectBlock")));
}
if (world.isRemote) {
world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
}
}
}
player.playSound(ModSoundEvents.BLOCK_SUMMONER_LAUGH, 5.0F, 1.0F);
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x, y, z, 1.0D, 0.0D, 0.0D);
if (!player.isCreative()) {
player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);
player.attackEntityFrom(DamageSource.outOfWorld, 10.0F);
}
} else {
if (!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectItem")));
}
}
}
return true;
}
Aggregations