本文整理汇总了Java中net.minecraft.entity.passive.EntityWolf.getCapability方法的典型用法代码示例。如果您正苦于以下问题:Java EntityWolf.getCapability方法的具体用法?Java EntityWolf.getCapability怎么用?Java EntityWolf.getCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.passive.EntityWolf
的用法示例。
在下文中一共展示了EntityWolf.getCapability方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeWolfItems
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
public static NBTTagCompound storeWolfItems(EntityWolf wolf, NBTTagCompound nbt) {
if (wolf.hasCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null)) {
IWolfArmorCapability wolfCapability = wolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (wolfCapability != null) {
nbt.setBoolean("HasChest", wolfCapability.getHasChest());
if (wolfCapability.getHasChest()) {
// wolfCapability.setInventory(wolfCapability.getInventory());//TODO setInventory!!!!
// NBTTagCompound itemsNBT = new NBTTagCompound();
// wolfCapability.getArmorItemStack().writeToNBT(itemsNBT);
// nbt.setTag("Items", itemsNBT);
wolfCapability.dropInventoryContents();
}
if (wolfCapability.getHasArmor()) {
NBTTagCompound armorNBT = new NBTTagCompound();
wolfCapability.getArmorItemStack().writeToNBT(armorNBT);
nbt.setTag("Armor", armorNBT);
}
}
}
return nbt;
}
示例2: dispenseWolfArmor
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
/**
* Helper method for dispensing item stacks
*
* @param source The block source
* @param stack The dispensing stack
* @return An item stack to dispense, or null if default dispense should occur.
*/
@Nonnull
private static ItemStack dispenseWolfArmor(@Nonnull IBlockSource source, @Nonnull ItemStack stack) {
BlockPos blockPos = source.getBlockPos().offset(source.getBlockState().getValue(BlockDispenser.FACING));
List<EntityWolf> wolves = source.getWorld().getEntitiesWithinAABB(EntityWolf.class, new AxisAlignedBB(blockPos));
if (!wolves.isEmpty()) {
EntityWolf wolf = null;
for (EntityWolf entity : wolves) {
if (entity.isTamed() && !entity.isChild()) {
wolf = entity;
break;
}
}
if (wolf != null) {
ItemStack copyStack = stack.copy();
copyStack.setCount(1);
IWolfArmorCapability wolfArmor = wolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (wolfArmor == null || !wolfArmor.canEquipItem(copyStack)) {
return stack;
}
wolfArmor.equipArmor(copyStack);
stack.shrink(1);
}
}
return stack;
}
示例3: GuiWolfInventory
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
/**
* Initializes a new wolf inventory GUI
*
* @param playerInventory The player's inventory. Used to display player's current items
* @param wolfInventory The wolf's inventory
* @param theWolf The wolf in question
*/
@SuppressWarnings("ConstantConditions")
public GuiWolfInventory(@Nonnull IInventory playerInventory,
@Nonnull IInventory wolfInventory,
@Nonnull EntityWolf theWolf,
@Nonnull EntityPlayer player) {
super(new ContainerWolfInventory(playerInventory, wolfInventory, theWolf, player));
this.wolfArmor = theWolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
this.wolfInventory = wolfInventory;
this.playerInventory = playerInventory;
this.theWolf = theWolf;
this.allowUserInput = false;
}
示例4: getWolfItems
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
public static void getWolfItems(EntityWolf wolf, NBTTagCompound nbt) {
if (wolf.hasCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null)) {
IWolfArmorCapability wolfCapability = wolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (nbt.getBoolean("HasChest")) {
wolfCapability.setHasChest(true);
// wolfCapability.setInventory(wolfCapability.getInventory());//TODO setInventory!!!!
}
if (nbt.hasKey("Armor")) {
wolfCapability.equipArmor(new ItemStack(nbt.getCompoundTag(("Armor"))));
}
}
}
示例5: copyWolfItems
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
public static void copyWolfItems(EntityWolf wolf, EntitySophisticatedWolf sWolf) {
//TODO CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY !!!!!!!!
if (wolf.hasCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null) && sWolf.hasCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null)) {
IWolfArmorCapability wolfCapability = wolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
IWolfArmorCapability sWolfCapability = sWolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (wolfCapability.getHasChest()) {
sWolfCapability.setHasChest(true);
// sWolfCapability.setInventory(wolfCapability.getInventory());//TODO setInventory!!!!
wolfCapability.dropInventoryContents();
}
if (wolfCapability.getHasArmor()) {
sWolfCapability.equipArmor(wolfCapability.getArmorItemStack());
}
}
}
示例6: doRenderLayer
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
/**
* Renders this layer.
*
* @param entityWolf The wolf to render. If it is not am EntityWolfArmored, the layer will not render.
* @param limbSwing The entity's limb swing progress.
* @param limbSwingAmount The entity's limb swing progress amount.
* @param partialTicks The current game tick.
* @param ageInTicks The entity's age.
* @param netHeadYaw The yaw of the entity's head.
* @param headPitch The pitch of the entity's head.
* @param scale The scale at which to render the layer.
*/
@Override
public void doRenderLayer(@Nonnull EntityWolf entityWolf,
float limbSwing,
float limbSwingAmount,
float partialTicks,
float ageInTicks,
float netHeadYaw,
float headPitch,
float scale) {
if (!WolfArmorMod.getConfiguration().getIsWolfArmorRenderEnabled()) {
return;
}
IWolfArmorCapability wolfArmor = entityWolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if(wolfArmor == null) {
return;
}
ItemStack itemStack = wolfArmor.getArmorItemStack();
if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemWolfArmor) {
ItemWolfArmor armorItem = (ItemWolfArmor) itemStack.getItem();
for (int layer = 0; layer < modelWolfArmors.length; layer++) {
ModelWolfArmor model = modelWolfArmors[layer];
model = getArmorModelForLayer(entityWolf, itemStack, layer, model);
model.setModelAttributes(this.renderer.getMainModel());
model.setLivingAnimations(entityWolf, limbSwing, limbSwingAmount, partialTicks);
this.renderer.bindTexture(this.getArmorResource(entityWolf, itemStack, layer, null));
int color = armorItem.getColor(itemStack);
if (color != 0xFFFFFFFF) {
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
GlStateManager.color(getColorRed() * r, getColorGreen() * g, getColorBlue() * b, getAlpha());
} else {
GlStateManager.color(getColorRed(), getColorGreen(), getColorBlue(), getAlpha());
}
model.render(entityWolf, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
GlStateManager.color(getColorRed(), getColorGreen(), getColorBlue(), getAlpha());
if (armorItem.getHasOverlay(itemStack)) {
this.renderer.bindTexture(this.getArmorResource(entityWolf, itemStack, layer, "overlay"));
model.render(entityWolf, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
}
if (!getShouldSkipArmorGlint() && itemStack.hasEffect()) {
LayerArmorBase.renderEnchantedGlint(renderer, entityWolf, model, limbSwing, limbSwingAmount, partialTicks,
ageInTicks, netHeadYaw, headPitch, scale);
}
}
}
}
示例7: doRenderLayer
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
/**
* Renders the layer.
*
* @param entityWolf The wolf to render. If it is not am EntityWolfArmored, the layer will not render.
* @param limbSwing The entity's limb swing progress.
* @param limbSwingAmount The entity's limb swing progress amount.
* @param partialTicks The current game tick.
* @param ageInTicks The entity's age.
* @param netHeadYaw The yaw of the entity's head.
* @param headPitch The pitch of the entity's head.
* @param scale The scale at which to render the layer.
*/
@SuppressWarnings("ConstantConditions")
@Override
public void doRenderLayer(@Nonnull EntityWolf entityWolf,
float limbSwing,
float limbSwingAmount,
float partialTicks,
float ageInTicks,
float netHeadYaw,
float headPitch,
float scale) {
if (!WolfArmorMod.getConfiguration().getIsWolfChestRenderEnabled()) {
return;
}
IWolfArmorCapability wolfArmor = entityWolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (wolfArmor != null && wolfArmor.getHasChest()) {
this.modelWolfBackpack.setModelAttributes(renderer.getMainModel());
this.modelWolfBackpack.setLivingAnimations(entityWolf, limbSwing, limbSwingAmount, partialTicks);
this.renderer.bindTexture(Textures.TEXTURE_WOLF_BACKPACK);
GlStateManager.color(1, 1, 1, 1);
if (!entityWolf.isInvisible()) {
this.modelWolfBackpack.render(entityWolf, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
} else {
GlStateManager.pushMatrix();
{
GlStateManager.color(1, 1, 1, 0.15F);
GlStateManager.depthMask(false);
{
GlStateManager.enableBlend();
{
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
this.modelWolfBackpack.render(entityWolf,
limbSwing,
limbSwingAmount,
ageInTicks,
netHeadYaw,
headPitch,
scale);
}
GlStateManager.disableBlend();
}
GlStateManager.depthMask(true);
}
GlStateManager.popMatrix();
}
}
}
示例8: onEntityWolfArmoredJoinedWorld
import net.minecraft.entity.passive.EntityWolf; //导入方法依赖的package包/类
/**
* Converts old EntityWolfArmored back to EntityWolf to leverage capabilities system
*
* @param event The event data
*/
@Deprecated
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityWolfArmoredJoinedWorld(@Nonnull EntityJoinWorldEvent event) {
World world = event.getWorld();
if (!world.isRemote) {
Entity entity = event.getEntity();
if (entity.getClass() == EntityWolfArmored.class) {
WolfArmorMod.getLogger().warning("Replacing EntityWolfArmored with new capable wolf");
EntityWolfArmored entityWolfArmored = (EntityWolfArmored) entity;
EntityWolf entityWolf = new EntityWolf(world);
IWolfArmorCapability wolfArmorCapability = entityWolf.getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if(wolfArmorCapability == null) {
throw new RuntimeException("Failed to replace entity: Capabilities were not properly registered!");
}
IInventory wolfInventory = entityWolfArmored.getInventory();
IInventory capabilityInventory = wolfArmorCapability.getInventory();
for (int i = 0; i < wolfInventory.getSizeInventory(); i++) {
ItemStack stack = wolfInventory.getStackInSlot(i);
capabilityInventory.setInventorySlotContents(i, stack);
}
if (entityWolfArmored.getHasArmor()) {
wolfArmorCapability.setArmorItemStack(entityWolfArmored.getArmorItemStack());
}
if (entityWolfArmored.getHasChest()) {
wolfArmorCapability.setHasChest(true);
}
NBTTagCompound compound = new NBTTagCompound();
entityWolfArmored.writeToNBT(compound);
entityWolf.copyLocationAndAnglesFrom(entityWolfArmored);
entityWolf.readEntityFromNBT(compound);
world.spawnEntity(entityWolf);
entityWolfArmored.setDead();
event.setCanceled(true);
}
}
}