本文整理匯總了Java中net.minecraft.entity.passive.EntityVillager類的典型用法代碼示例。如果您正苦於以下問題:Java EntityVillager類的具體用法?Java EntityVillager怎麽用?Java EntityVillager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityVillager類屬於net.minecraft.entity.passive包,在下文中一共展示了EntityVillager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEntityDeath
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
{
// iterate through the itemstacks in the villager's inventory
InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
// remove the stack from the inventory and spawn it in the world
ItemStack stack = inventory.getStackInSlot(i);
if (stack != ItemStack.EMPTY)
{
event.getEntityLiving().entityDropItem(stack, 0.0F);
}
}
}
}
示例2: convertToVillager
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Convert this zombie into a villager.
*/
protected void convertToVillager()
{
EntityVillager entityvillager = new EntityVillager(this.worldObj);
entityvillager.copyLocationAndAnglesFrom(this);
entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
entityvillager.setLookingForHome();
if (this.isChild())
{
entityvillager.setGrowingAge(-24000);
}
this.worldObj.removeEntity(this);
entityvillager.setNoAI(this.isAIDisabled());
if (this.hasCustomName())
{
entityvillager.setCustomNameTag(this.getCustomNameTag());
entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
}
this.worldObj.spawnEntityInWorld(entityvillager);
entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
示例3: convertToVillager
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@Override
protected void convertToVillager() {
EntityVillager villager = new EntityVillager(worldObj);
villager.copyLocationAndAnglesFrom(this);
villager.onSpawnWithEgg((IEntityLivingData) null);
villager.setLookingForHome();
villager.setProfession(getType());
if (isChild())
villager.setGrowingAge(-24000);
worldObj.removeEntity(this);
worldObj.spawnEntityInWorld(villager);
villager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
worldObj.playAuxSFXAtEntity(null, 1017, (int) posX, (int) posY, (int) posZ, 0);
}
示例4: shouldExecute
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theGolem.worldObj.isDaytime())
{
return false;
}
else if (this.theGolem.getRNG().nextInt(8000) != 0)
{
return false;
}
else
{
this.theVillager = (EntityVillager)this.theGolem.worldObj.findNearestEntityWithinAABB(EntityVillager.class, this.theGolem.getEntityBoundingBox().expand(6.0D, 2.0D, 6.0D), this.theGolem);
return this.theVillager != null;
}
}
示例5: getEntityTexture
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(EntityVillager entity)
{
switch (entity.getProfession())
{
case 0:
return farmerVillagerTextures;
case 1:
return librarianVillagerTextures;
case 2:
return priestVillagerTextures;
case 3:
return smithVillagerTextures;
case 4:
return butcherVillagerTextures;
default:
return villagerTextures;
}
}
示例6: preRenderCallback
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
* entityLiving, partialTickTime
*/
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime)
{
float f = 0.9375F;
if (entitylivingbaseIn.getGrowingAge() < 0)
{
f = (float)((double)f * 0.5D);
this.shadowSize = 0.25F;
}
else
{
this.shadowSize = 0.5F;
}
GlStateManager.scale(f, f, f);
}
示例7: spawnVillagers
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
protected void spawnVillagers(World worldIn, StructureBoundingBox p_74893_2_, int p_74893_3_, int p_74893_4_, int p_74893_5_, int p_74893_6_)
{
if (this.villagersSpawned < p_74893_6_)
{
for (int i = this.villagersSpawned; i < p_74893_6_; ++i)
{
int j = this.getXWithOffset(p_74893_3_ + i, p_74893_5_);
int k = this.getYWithOffset(p_74893_4_);
int l = this.getZWithOffset(p_74893_3_ + i, p_74893_5_);
if (!p_74893_2_.isVecInside(new BlockPos(j, k, l)))
{
break;
}
++this.villagersSpawned;
EntityVillager entityvillager = new EntityVillager(worldIn);
entityvillager.setLocationAndAngles((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F);
entityvillager.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
entityvillager.setProfession(this.func_180779_c(i, entityvillager.getProfession()));
worldIn.spawnEntityInWorld(entityvillager);
}
}
}
示例8: getEntityColor
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public Color getEntityColor() {
if ((entity instanceof EntityAnimal)) {
return Color.white;
}
if ((entity instanceof EntityMob)) {
return Color.red;
}
if ((entity instanceof EntitySlime)) {
return Color.green;
}
if ((entity instanceof EntityVillager)) {
return new Color(245, 245, 220);
}
if ((entity instanceof EntityBat)) {
return Color.BLACK;
}
if ((entity instanceof EntitySquid)) {
return Color.PINK;
}
return Color.white;
}
示例9: getEntityTexture
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(EntityVillager entity)
{
switch (entity.getProfession())
{
case 0:
return FARMER_VILLAGER_TEXTURES;
case 1:
return LIBRARIAN_VILLAGER_TEXTURES;
case 2:
return PRIEST_VILLAGER_TEXTURES;
case 3:
return SMITH_VILLAGER_TEXTURES;
case 4:
return BUTCHER_VILLAGER_TEXTURES;
case 5:
default:
return VILLAGER_TEXTURES;
}
}
示例10: preRenderCallback
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Allows the render to do state modifications necessary before the model is rendered.
*/
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime)
{
float f = 0.9375F;
if (entitylivingbaseIn.getGrowingAge() < 0)
{
f = (float)((double)f * 0.5D);
this.shadowSize = 0.25F;
}
else
{
this.shadowSize = 0.5F;
}
GlStateManager.scale(f, f, f);
}
示例11: handleVillagers
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
private void handleVillagers(int x, int y, List<IWidget> locatedTextures) {
locatedTextures.add(new LocatedEntity(EntityVillager.class, x + 70, y + 95, 2F));
LocatedEntity locatedEntity = new LocatedEntity(EntityVillager.class, x + 215, y + 125, 2F);
EntityVillager villager = (EntityVillager) locatedEntity.entity;
// villager.setProfession(ConfigHandler.general.villagerMechanicID);
locatedTextures.add(locatedEntity);
}
示例12: entitySpawned
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@SubscribeEvent
public static void entitySpawned(EntityJoinWorldEvent event){
// This only runs server side
if(event.getWorld().isRemote)return;
if(EntityVillager.class.isInstance(event.getEntity())
&& !event.getEntity().getEntityData().getBoolean(tagName)){
if(ConfigHandler.LOGGING){
LogManager.getLogger().log(Level.INFO, "A villager spawned at x" + event.getEntity().posX + "z" + event.getEntity().posZ + " and has been added to the data list.");
}
// set this to true to inform future calls of this code that this villager has been handled.
event.getEntity().getEntityData().setBoolean(tagName, true);
// have to use the MathHelper workaround because chunkX and chunkZ are 0 on spawn
NBTDataHandler.incrementVillagersSpawnedForChunk(event.getWorld().provider.getDimension(), MathHelper.floor(event.getEntity().posX / 16.0D), MathHelper.floor(event.getEntity().posZ / 16.0D));
}
}
示例13: isPassive
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
* Checks if the specified entity is a passive
*
* @param e The entity
* @return Whether or not the entity is a passive
*/
public static boolean isPassive(Entity e) {
if (e instanceof EntityPigZombie)
return !isAngry((EntityPigZombie) e);
if (e instanceof EntityIronGolem)
return !isAngry((EntityIronGolem) e);
if (e instanceof EntityPolarBear)
return !isAngry((EntityPolarBear) e);
if (e instanceof EntityAnimal)
return true;
if (e instanceof EntitySquid)
return true;
if (e instanceof EntityBat)
return true;
if (e instanceof EntityVillager)
return true;
if (e instanceof EntitySnowman)
return true;
return false;
}
示例14: replaceList
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public void replaceList(IMerchant merchant, MerchantRecipeList list)
{
if(merchant instanceof EntityVillager)
{
replaceTradeList((EntityVillager) merchant,list);
}
else
{
merchant.setRecipes(list);
}
}
示例15: replaceTradeList
import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public static void replaceTradeList(EntityVillager villager, MerchantRecipeList newlist) {
if (buyingList == null)
buyingList = ReflectionHelper.findField(EntityVillager.class, "buyingList", "field_70963_i");
if (villager != null) {
try {
buyingList.set(villager, newlist);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}