本文整理汇总了Java中net.minecraftforge.event.AnvilUpdateEvent.setMaterialCost方法的典型用法代码示例。如果您正苦于以下问题:Java AnvilUpdateEvent.setMaterialCost方法的具体用法?Java AnvilUpdateEvent.setMaterialCost怎么用?Java AnvilUpdateEvent.setMaterialCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.AnvilUpdateEvent
的用法示例。
在下文中一共展示了AnvilUpdateEvent.setMaterialCost方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: anvilChange
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void anvilChange(AnvilUpdateEvent ev)
{
ItemStack left = ev.getLeft();
ItemStack right = ev.getRight();
if (left.getCount() <= 0 || left.getItem() != belt)
return;
if (right.getCount() <= 0 || right.getItem() != pouch)
return;
int cost = ItemToolBelt.getUpgradeXP(left);
if (cost < 0)
{
ev.setCanceled(true);
return;
}
ev.setCost(cost);
ev.setMaterialCost(1);
ev.setOutput(ItemToolBelt.upgrade(left));
}
示例2: fullyRepairItem
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private void fullyRepairItem(AnvilUpdateEvent event, IAnvilRepairable repairable, int materialCost, int xpCost)
{
ItemStack repaired = event.getLeft().copy();
if (repairable.repairItem(repaired, -1))
{
event.setMaterialCost(materialCost);
event.setCost(xpCost);
event.setOutput(repaired);
this.updateItemName(event, repaired);
}
else
{
event.setCanceled(true);
}
}
示例3: eventAnvil
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void eventAnvil(AnvilUpdateEvent event) {
// Check what items are in slot left & right
if (event.getLeft() == null || event.getRight() == null) { return; }
if (event.getLeft().getItem() instanceof ItemProgram && event.getLeft().getMetadata() == 0 && event.getRight().getItem() instanceof ItemNeedle && event.getRight().getMetadata() == 1) {
//
ItemStack output = new ItemStack(ModItems.sc_program, 1 ,1);
NBTTagCompound nbt = output.getTagCompound();
if (event.getRight().getTagCompound() == null || !event.getRight().getTagCompound().hasKey("entity")) { return; }
if (nbt == null) { output.setTagCompound(nbt = new NBTTagCompound()); }
String outputString = I18n.format("statclock.translate.program") + ": " + event.getRight().getTagCompound().getString("entity") + " " + I18n.format("statclock.translate.kills");
nbt.setInteger(event.getRight().getTagCompound().getString("entity") + "Kills", 0);
output.setTagCompound(nbt);
output.setStackDisplayName("§6" + outputString);
event.setOutput(output);
event.setCost(1);
event.setMaterialCost(1);
}
}
示例4: onAnvilUpdate
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilUpdate (AnvilUpdateEvent event) {
for (final IAnvilRecipe recipe : MMDLibRegistry.getAnvilRecipes())
if (recipe.isValidRecipe(event.getLeft(), event.getRight(), event.getName())) {
event.setCost(recipe.getExperienceCost(event.getLeft(), event.getRight(), event.getName()));
event.setMaterialCost(recipe.getMaterialCost(event.getLeft(), event.getRight(), event.getName()));
event.setOutput(recipe.getOutput(event.getLeft(), event.getRight(), event.getName()));
return;
}
}
示例5: onAnvilUpdate
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilUpdate (AnvilUpdateEvent event) {
for (final IAnvilRecipe recipe : BookshelfRegistry.getAnvilRecipes()) {
if (recipe.isValidRecipe(event.getLeft(), event.getRight(), event.getName())) {
event.setCost(recipe.getExperienceCost(event.getLeft(), event.getRight(), event.getName()));
event.setMaterialCost(recipe.getMaterialCost(event.getLeft(), event.getRight(), event.getName()));
event.setOutput(recipe.getOutput(event.getLeft(), event.getRight(), event.getName()));
return;
}
}
}
示例6: handleUpgrade
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
public void handleUpgrade(ItemStack leftInput, ItemStack rightInput, AnvilUpdateEvent event)
{
if (leftInput.getItem() == HZ_Items.ItemHammer && rightInput.func_190916_E() == 1 && HammerInfoHandler.isStackDarkSteelHammer(leftInput))
{
ItemStack Output = leftInput.copy();
List<IUpgrade> upgrades = UpgradeManager.getInstance().getUpgradeList();
Iterator<IUpgrade> iterator = upgrades.iterator();
while (iterator.hasNext())
{
IUpgrade upgrade = iterator.next();
if (rightInput.getItem() == upgrade.getItem().getItem() && rightInput.getItemDamage() == upgrade.getItem().getItemDamage())
{
NBTTagCompound tagCompound = RandomUtils.getNBT(Output);
if (tagCompound.getInteger(ItemHammer.Key_Empower) == upgrade.getLevel() - 1)
{
tagCompound.setInteger(ItemHammer.Key_Empower, upgrade.getLevel());
Output.setTagCompound(tagCompound);
if(rightInput.getItem() instanceof IEnergyContainerItem)
{
IEnergyContainerItem item = (IEnergyContainerItem) rightInput.getItem();
int energy = item.getEnergyStored(rightInput);
if(Output.getItem() instanceof ItemHammer)
{
NBTTagCompound finalCompound = RandomUtils.getNBT(Output);
int hammerEnergy = finalCompound.getInteger(ItemHammer.Tag_DarkSteelEnergy);
if(hammerEnergy + energy > EnergyHandler.getMaxEnergyStored(Output))
{
finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, EnergyHandler.getMaxEnergyStored(Output));
}
else
{
finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, hammerEnergy + energy);
}
}
}
event.setCost(upgrade.getCost());
event.setMaterialCost(1);
event.setOutput(Output);
return;
}
}
}
}
}
示例7: upgradeKits
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void upgradeKits(AnvilUpdateEvent event){
if(!(event.getRight().getItem() instanceof ItemUpgradeKit)) return;
int cost = 0;
float f = (float)(event.getLeft().getMaxDamage() - event.getLeft().getItemDamage()) / (float)event.getLeft().getMaxDamage();
if(f >= 0)
cost = 10;
if(f >= 0.1f)
cost = 9;
if(f >= 0.2f)
cost = 8;
if(f >= 0.3f)
cost = 7;
if(f >= 0.4f)
cost = 6;
if(f >= 0.5f)
cost = 5;
if(f >= 0.6f)
cost = 4;
if(f >= 0.7f)
cost = 3;
if(f >= 0.8f)
cost = 2;
if(f >= 0.9f)
cost = 1;
ItemStack stack = UpgradeKitRecipes.instance().getUpgrade((ItemUpgradeKit)event.getRight().getItem(), event.getLeft());
if(!stack.isEmpty()){
if(StringUtils.isNullOrEmpty(event.getName())){
if(event.getLeft().hasDisplayName()){
cost += 1;
stack.clearCustomName();
}
} else if(!event.getName().equals(event.getLeft().getDisplayName())){
cost += 1;
stack.setStackDisplayName(event.getName());
}
for(int i : EnchantmentHelper.getEnchantments(event.getLeft()).values())
cost += i;
EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(event.getLeft()), stack);
stack.setCount(event.getLeft().getCount());
event.setOutput(stack);
}
event.setMaterialCost(1);
event.setCost(cost == 0 ? 1 : cost);
}
示例8: onAnvilEvent
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilEvent(AnvilUpdateEvent event)
{
Iterator iterator;
String rightSlotItemName;
int rightSlotItemDamage;
String staffFragmentItemName;
MobSettings mobConfig;
if (event.getLeft() == null || event.getLeft().stackSize != 1 ||
event.getLeft().getItem() != (Item)ModItems.mobSpawningStaff ||
event.getRight() == null ||
!ItemNBTHelper.getString(event.getLeft(), Names.NBTTags.STAFF_MOB_TO_SPAWN).isEmpty())
{
return;
}
rightSlotItemName = Item.REGISTRY.getNameForObject(event.getRight().getItem()).toString();
rightSlotItemDamage = event.getRight().getItemDamage();
staffFragmentItemName = Item.REGISTRY.getNameForObject(ModItems.staffFragment).toString();
iterator = MobList.mobList.values().iterator();
while (iterator.hasNext())
{
mobConfig = (MobSettings)iterator.next();
if (mobConfig.enableStaffCreationPrimaryItem && (mobConfig.staffCreationPrimaryItem.equals(rightSlotItemName)
&& mobConfig.staffCreationPrimaryItemDamage == rightSlotItemDamage)
&& event.getRight().stackSize >= mobConfig.staffCreationPrimaryItemAmount)
{
LogHelper.info("Primary item enabled for entity " + MobList.getKey(mobConfig));
event.setOutput(event.getLeft().copy());
ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, MobList.getKey(mobConfig));
event.getOutput().getItem().setMaxDamage(mobConfig.staffCreationPrimaryItemUses);
event.setCost(mobConfig.staffCreationPrimaryItemLevels);
event.setMaterialCost(mobConfig.staffCreationPrimaryItemAmount);
return;
}
else if (mobConfig.enableStaffCreationSecondaryItem && (mobConfig.staffCreationSecondaryItem.equals(rightSlotItemName)
&& mobConfig.staffCreationSecondaryItemDamage == rightSlotItemDamage)
&& event.getRight().stackSize >= mobConfig.staffCreationSecondaryItemAmount)
{
LogHelper.info("Secondary item enabled for entity " + MobList.getKey(mobConfig));
event.setOutput(event.getLeft().copy());
ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, MobList.getKey(mobConfig));
event.getOutput().getItem().setMaxDamage(mobConfig.staffCreationSecondaryItemUses);
event.setCost(mobConfig.staffCreationSecondaryItemLevels);
event.setMaterialCost(mobConfig.staffCreationSecondaryItemAmount);
return;
}
else if (Settings.General.enableStaffFragmentItem && (rightSlotItemName.equals(staffFragmentItemName)) && ItemNBTHelper.hasTag(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB)
&& (event.getRight().stackSize >= mobConfig.staffFragmentAnvilAmount) && (ItemNBTHelper.getString(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB).equals(MobList.getKey(mobConfig))))
{
event.setOutput(event.getLeft().copy());
ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, ItemNBTHelper.getString(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB));
event.getOutput().getItem().setMaxDamage(mobConfig.staffFragmentAnvilUses);
event.setCost(mobConfig.staffFragmentAnvilLevels);
event.setMaterialCost(mobConfig.staffFragmentAnvilAmount);
return;
}
}
}