Java源码示例:net.minecraft.entity.passive.EntitySheep
示例1
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
final Minecraft mc = Minecraft.getMinecraft();
if(mc.player.inventory.getCurrentItem().getItem() instanceof ItemShears) {
for(Entity e : mc.world.loadedEntityList) {
if(e != null && e instanceof EntitySheep) {
final EntitySheep sheep = (EntitySheep) e;
if(sheep.getHealth() > 0) {
if (!sheep.isChild() && !sheep.getSheared() && mc.player.getDistance(sheep) <= 4.5f) {
mc.playerController.interactWithEntity(mc.player, sheep, EnumHand.MAIN_HAND);
}
}
}
}
}
}
}
示例2
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
final Minecraft mc = Minecraft.getMinecraft();
if(mc.player.inventory.getCurrentItem().getItem() instanceof ItemDye) {
final EnumDyeColor color = EnumDyeColor.byDyeDamage(mc.player.inventory.getCurrentItem().getMetadata());
for(Entity e : mc.world.loadedEntityList) {
if(e != null && e instanceof EntitySheep) {
final EntitySheep sheep = (EntitySheep) e;
if(sheep.getHealth() > 0) {
if (sheep.getFleeceColor() != color && !sheep.getSheared() && mc.player.getDistance(sheep) <= 4.5f) {
mc.playerController.interactWithEntity(mc.player, sheep, EnumHand.MAIN_HAND);
}
}
}
}
}
}
}
示例3
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void dropEvent(LivingDropsEvent event) {
if (event.entityLiving.worldObj.isRemote)
return;
if (EtFuturum.enableSkullDrop)
dropHead(event.entityLiving, event.source, event.lootingLevel, event.drops);
Random rand = event.entityLiving.worldObj.rand;
if (EtFuturum.enableMutton && event.entityLiving instanceof EntitySheep) {
int amount = rand.nextInt(3) + 1 + rand.nextInt(1 + event.lootingLevel);
for (int i = 0; i < amount; i++)
if (event.entityLiving.isBurning())
addDrop(new ItemStack(ModItems.cooked_mutton), event.entityLiving, event.drops);
else
addDrop(new ItemStack(ModItems.raw_mutton), event.entityLiving, event.drops);
}
}
示例4
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]);
}
}
}
示例5
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;
}
示例6
@Override
public void drawBackground(TextureManager renderEngine, int mouseX, int mouseY) {
int barTop = absoluteY + height/2 - (barHeight/2-1);
int borderColor = 0xff000000;
if(this.selected) {
borderColor = 0xff22dd22; // bright green?
}
this.drawRect(absoluteX, absoluteY, absoluteX+height, absoluteY+height, borderColor);
this.drawRect(absoluteX+width-height, absoluteY, absoluteX+width, absoluteY+height, borderColor);
this.drawRect(absoluteX+height, barTop, absoluteX+width-height, barTop+barHeight, borderColor);
float[] color = EntitySheep.fleeceColorTable[this.channelIdx];
this.drawRect(absoluteX+1, absoluteY+1, absoluteX+height-1, absoluteY+height-1, color[0], color[1], color[2], 1.0f);
this.drawRect(absoluteX+width-height+1, absoluteY+1, absoluteX+width-1, absoluteY+height-1, 0xff777777);
}
示例7
public void doRenderLayer(EntityOvergrownSheep sheep, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
if (!sheep.getSheared() && !sheep.isInvisible())
{
this.sheepRenderer.bindTexture(TEXTURE);
if (sheep.hasCustomName() && "jeb_".equals(sheep.getCustomNameTag()))
{
float time = 25F;
int i = sheep.ticksExisted / 25 + sheep.getEntityId();
int j = EnumDyeColor.values().length;
int k = i % j;
int l = (i + 1) % j;
float f = ((sheep.ticksExisted % time) + partialTicks) / time;
float[] afloat1 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(k));
float[] afloat2 = EntitySheep.getDyeRgb(EnumDyeColor.byMetadata(l));
GlStateManager.color(afloat1[0] * (1.0F - f) + afloat2[0] * f, afloat1[1] * (1.0F - f) + afloat2[1] * f, afloat1[2] * (1.0F - f) + afloat2[2] * f);
}
else
{
float[] afloat = EntitySheep.getDyeRgb(sheep.getFleeceColor());
GlStateManager.color(afloat[0], afloat[1], afloat[2]);
}
this.sheepModel.setModelAttributes(this.sheepRenderer.getMainModel());
this.sheepModel.setLivingAnimations(sheep, limbSwing, limbSwingAmount, partialTicks);
//(float)sheep.getDataManager().get(EntityOvergrownSheep.GROWTH) / 10000000F
this.sheepModel.render(sheep, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
}
}
示例8
/**
* If an entity is not in range, do some more checks to see if we should
* give it a shot.
*
* @param entity
* @return
*/
public static boolean checkEntityImmunities(Entity entity) {
// quick checks.
if (entity.inWater || entity.fire > 0) {
return true;
}
if (!(entity instanceof EntityArrow)) {
if (!entity.onGround || !entity.riddenByEntities.isEmpty() || entity.isRiding()) {
return true;
}
} else if (!((EntityArrow) entity).inGround) {
return true;
}
// special cases.
if (entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTime > 0 || living.activePotionsMap.size() > 0) {
return true;
}
if (entity instanceof EntityCreature && ((EntityCreature) entity).getAttackTarget() != null) {
return true;
}
if (entity instanceof EntityVillager && ((EntityVillager) entity).isMating()) {
return true;
}
if (entity instanceof EntityAnimal) {
EntityAnimal animal = (EntityAnimal) entity;
if (animal.isChild() || animal.isInLove()) {
return true;
}
if (entity instanceof EntitySheep && ((EntitySheep) entity).getSheared()) {
return true;
}
}
if (entity instanceof EntityCreeper && ((EntityCreeper) entity).hasIgnited()) { // isExplosive
return true;
}
}
return false;
}
示例9
private boolean isAnimal(EntityLivingBase victim) {
return victim instanceof EntityCow ||
victim instanceof EntityHorse ||
victim instanceof EntityPig ||
victim instanceof EntityDonkey ||
victim instanceof EntityChicken ||
victim instanceof EntitySheep;
}
示例10
@Override
public Object getMeta(EntitySheep target, Vec3 relativePos) {
Map<String, Object> map = Maps.newHashMap();
map.put("sheepColor", target.getFleeceColor());
map.put("isSheared", target.getSheared());
return map;
}
示例11
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase yEntityLivingBase) {
if (yEntityLivingBase instanceof EntitySheep && stack.getItemDamage() == 1) {
EntitySheep entitysheep = (EntitySheep) yEntityLivingBase;
if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != 15) {
entitysheep.setFleeceColor(15);
--stack.stackSize;
}
return true;
} else {
return false;
}
}
示例12
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;
}
示例13
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);
}
}
示例14
public CraftSheep(CraftServer server, EntitySheep entity) {
super(server, entity);
}
示例15
@Override
public EntitySheep getHandle() {
return (EntitySheep) entity;
}
示例16
/**
* If an entity is not in range, do some more checks to see if we should
* give it a shot.
*
* @param entity
* @return
*/
public static boolean checkEntityImmunities(Entity entity)
{
// quick checks.
if ( entity.inWater /* isInWater */ || entity.fire > 0 )
{
return true;
}
if ( !( entity instanceof EntityArrow ) )
{
if ( !entity.onGround || entity.riddenByEntity != null
|| entity.ridingEntity != null )
{
return true;
}
} else if ( !( (EntityArrow) entity ).inGround )
{
return true;
}
// special cases.
if ( entity instanceof EntityLiving )
{
EntityLiving living = (EntityLiving) entity;
if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
{
return true;
}
if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
{
return true;
}
if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
{
return true;
}
if ( entity instanceof EntityAnimal )
{
EntityAnimal animal = (EntityAnimal) entity;
if ( animal.isChild() || animal.isInLove() /*love*/ )
{
return true;
}
if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
{
return true;
}
}
}
return false;
}
示例17
@Override
public boolean isEntityApplicable(Entity e) {
return e instanceof EntitySheep && ((EntitySheep) e).getSheared();
}
示例18
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
EntitySheep sheep = (EntitySheep) e;
if(sheep.worldObj.rand.nextInt(10) == 0) sheep.setSheared(false);
}
示例19
private void updateSegments() {
int x = xCoord;
int y = yCoord;
int z = zCoord;
segments.clear();
TileEntityNewBeacon.BeamSegment beamsegment = new TileEntityNewBeacon.BeamSegment(EntitySheep.fleeceColorTable[0]);
segments.add(beamsegment);
boolean flag = true;
for (int i = y + 1; i < worldObj.getActualHeight(); i++) {
Block iblockstate = worldObj.getBlock(x, i, z);
float[] colours;
if (iblockstate == Blocks.stained_glass)
colours = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(x, i, z)];
else {
if (iblockstate != Blocks.stained_glass_pane) {
if (iblockstate.getLightOpacity() >= 15) {
segments.clear();
break;
}
beamsegment.func_177262_a();
continue;
}
colours = EntitySheep.fleeceColorTable[worldObj.getBlockMetadata(x, i, z)];
}
if (!flag)
colours = new float[] { (beamsegment.func_177263_b()[0] + colours[0]) / 2.0F, (beamsegment.func_177263_b()[1] + colours[1]) / 2.0F, (beamsegment.func_177263_b()[2] + colours[2]) / 2.0F };
if (Arrays.equals(colours, beamsegment.func_177263_b()))
beamsegment.func_177262_a();
else {
beamsegment = new TileEntityNewBeacon.BeamSegment(colours);
segments.add(beamsegment);
}
flag = false;
}
}