本文整理汇总了Java中net.minecraftforge.event.AnvilUpdateEvent.setCost方法的典型用法代码示例。如果您正苦于以下问题:Java AnvilUpdateEvent.setCost方法的具体用法?Java AnvilUpdateEvent.setCost怎么用?Java AnvilUpdateEvent.setCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.AnvilUpdateEvent
的用法示例。
在下文中一共展示了AnvilUpdateEvent.setCost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handleAnvilEvent
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent event)
{
if (SocketRecipe.isValidInput(event.getLeft(), event.getRight()))
{
ItemStack output = event.getLeft().copy();
NBTTagCompound socketTag = (NBTTagCompound) output.getTagCompound().getTag("sockets");
SocketUtil.setSocket(socketTag, "diamond", SocketUtil.getFirstAvailableSlotNumber(socketTag));
output.getTagCompound().setTag("sockets", socketTag);
event.setOutput(output);
event.setCost(0);
}
}
示例3: onAnvilUpdate
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilUpdate(AnvilUpdateEvent event) {
if (event.getLeft().isEmpty() || event.getRight().isEmpty())
return;
ItemStack shard = event.getLeft();
ItemStack mat = event.getRight();
ItemStack artifact = ModItems.brokenArtifact.getInnerStack(shard);
if (!artifact.isEmpty() && mat.getItem() == artifact.getItem() && !mat.isItemDamaged()) {
ItemStack innercopy = artifact.copy();
innercopy.setItemDamage(0);
innercopy.setRepairCost(innercopy.getRepairCost() / 2); //TODO: make this configurable??
event.setOutput(innercopy);
event.setCost(35);
}
}
示例4: AnvilUpdate
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void AnvilUpdate(AnvilUpdateEvent event)
{
ItemStack rightItem = event.getRight();
ItemStack leftItem = event.getLeft();
if ((rightItem.getItem() == Item.getItemFromBlock(ModRegistry.CompressedStoneBlock())
&& rightItem.getMetadata() == BlockCompressedStone.EnumType.TRIPLE_COMPRESSED_STONE.getMetadata())
|| (leftItem.getItem() == Item.getItemFromBlock(ModRegistry.CompressedStoneBlock())
&& leftItem.getMetadata() == BlockCompressedStone.EnumType.TRIPLE_COMPRESSED_STONE.getMetadata()))
{
if (rightItem.getItem() == ModRegistry.Bulldozer() || leftItem.getItem() == ModRegistry.Bulldozer())
{
event.setCost(4);
ItemStack bulldozer = rightItem.getItem() == ModRegistry.Bulldozer() ? rightItem : leftItem;
ItemStack outputStack = new ItemStack(ModRegistry.Bulldozer());
ModRegistry.Bulldozer().setPoweredValue(outputStack, true);
outputStack.setItemDamage(0);
event.setOutput(outputStack);
}
}
}
示例5: 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);
}
}
示例6: updateItemName
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private void updateItemName(AnvilUpdateEvent event, ItemStack outputStack)
{
String name = event.getName();
if (StringUtils.isBlank(name) == false)
{
outputStack.setStackDisplayName(name);
event.setCost(event.getCost() + 1);
}
else if (outputStack.hasDisplayName())
{
// Remove the custom name
outputStack.clearCustomName();
event.setCost(event.getCost() + 1);
}
}
示例7: handleAnvilEvent
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
if (Prep.isInvalid(evt.getLeft()) || evt.getLeft().getCount() != 1 || evt.getLeft().getItem() != block_powered_spawner.getItem()) {
return;
}
if (Prep.isInvalid(evt.getRight()) || evt.getRight().getCount() != 1 || evt.getRight().getItem() != ModObject.itemBrokenSpawner.getItem()) {
return;
}
CapturedMob spawnerType = CapturedMob.create(evt.getRight());
if (spawnerType == null || isBlackListed(spawnerType.getEntityName())) {
return;
}
evt.setCost(SpawnerConfig.powerSpawnerAddSpawnerCost.get());
evt.setOutput(evt.getLeft().copy());
evt.getOutput().setTagCompound(spawnerType.toNbt(evt.getOutput().getTagCompound()));
}
示例8: handleRepair
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private static void handleRepair(AnvilUpdateEvent evt) {
ItemStack targetStack = evt.getLeft();
ItemStack ingots = evt.getRight();
// repair event
IDarkSteelItem targetItem = (IDarkSteelItem) targetStack.getItem();
int maxIngots = targetItem.getIngotsRequiredForFullRepair();
double damPerc = (double) targetStack.getItemDamage() / targetStack.getMaxDamage();
int requiredIngots = (int) Math.ceil(damPerc * maxIngots);
if (ingots.getCount() > requiredIngots) {
return;
}
int damageAddedPerIngot = (int) Math.ceil((double) targetStack.getMaxDamage() / maxIngots);
int totalDamageRemoved = damageAddedPerIngot * ingots.getCount();
ItemStack resultStack = targetStack.copy();
resultStack.setItemDamage(Math.max(0, resultStack.getItemDamage() - totalDamageRemoved));
evt.setOutput(resultStack);
evt.setCost(ingots.getCount() + (int) Math.ceil(getEnchantmentRepairCost(resultStack) / 2));
}
示例9: 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);
}
}
示例10: onArtifactBreak
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onArtifactBreak(AnvilUpdateEvent event)
{
if(event.getLeft().isEmpty() || event.getRight().isEmpty())
return;
ItemStack tool = event.getLeft();
ItemStack mat = event.getRight();
if(ItemUtil.isTool(tool.getItem()) && mat.getItem() == Items.FLINT)
{
event.setOutput(ModItems.brokenArtifact.makeFrom(tool));
event.setCost(1);
}
}
示例11: 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;
}
}
示例12: 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;
}
}
}
示例13: handleUpgrade
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private static void handleUpgrade(AnvilUpdateEvent evt) {
for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
if (upgrade.isUpgradeItem(evt.getRight()) && upgrade.canAddToItem(evt.getLeft())) {
ItemStack res = new ItemStack(evt.getLeft().getItem(), 1, evt.getLeft().getItemDamage());
final NBTTagCompound tagCompound = evt.getLeft().getTagCompound();
if (tagCompound != null) {
res.setTagCompound(tagCompound.copy());
}
upgrade.addToItem(res);
evt.setOutput(res);
evt.setCost(upgrade.getLevelCost());
return;
}
}
}
示例14: onAnvil
import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvil(AnvilUpdateEvent event){
AnvilRecipe eventIn = new AnvilRecipe(event.getLeft(), event.getRight(), event.getOutput(), event.getCost(), false);
for(AnvilRecipe recipe : AnvilRecipes.getRecipes()){
if(eventIn.equals(recipe)){
event.setCost(recipe.getCost());
event.setOutput(recipe.getOutput().copy());
return;
}
}
}
示例15: 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;
}
}
}
}
}