mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Start API cleanup: Move ManaItemHandler to an interface implemented in the mod proper. Also move ColorHelper into mod proper.
This commit is contained in:
1 parent
54cdb17809
commit
272ef5bbab
56 files changed
+361
-264
No files matched your search
@@ -8,21 +8,28 @@
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraft.util.LazyValue;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class ManaItemHandler {
|
||||
public interface ManaItemHandler {
|
||||
LazyValue<ManaItemHandler> INSTANCE = new LazyValue<>(() -> {
|
||||
try {
|
||||
return (ManaItemHandler) Class.forName("vazkii.botania.common.impl.ManaItemHandlerImpl").newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
LogManager.getLogger().warn("Unable to find ManaItemHandlerImpl, using a dummy");
|
||||
return new ManaItemHandler() {};
|
||||
}
|
||||
});
|
||||
|
||||
static ManaItemHandler instance() {
|
||||
return INSTANCE.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list containing all mana-holding items in a player's inventory.
|
||||
@@ -31,27 +38,8 @@ public final class ManaItemHandler {
|
||||
*
|
||||
* @return The list of items
|
||||
*/
|
||||
public static List<ItemStack> getManaItems(PlayerEntity player) {
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ItemStack> toReturn = new ArrayList<>();
|
||||
player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(mainInv -> {
|
||||
int size = mainInv.getSlots();
|
||||
|
||||
for (int slot = 0; slot < size; slot++) {
|
||||
ItemStack stackInSlot = mainInv.getStackInSlot(slot);
|
||||
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ManaItemsEvent event = new ManaItemsEvent(player, toReturn);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getItems();
|
||||
default List<ItemStack> getManaItems(PlayerEntity player) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,27 +47,8 @@ public final class ManaItemHandler {
|
||||
*
|
||||
* @return The list of items
|
||||
*/
|
||||
public static List<ItemStack> getManaAccesories(PlayerEntity player) {
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
IItemHandler acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
if (acc == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ItemStack> toReturn = new ArrayList<>(acc.getSlots());
|
||||
|
||||
for (int slot = 0; slot < acc.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = acc.getStackInSlot(slot);
|
||||
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
default List<ItemStack> getManaAccesories(PlayerEntity player) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,37 +56,11 @@ public final class ManaItemHandler {
|
||||
*
|
||||
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
|
||||
* the amount of mana existent will be returned instead, if you want exact values use
|
||||
* requestManaExact.
|
||||
* {@link #requestManaExact}.
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
* @return The amount of mana received from the request.
|
||||
*/
|
||||
public static int requestMana(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItem = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot));
|
||||
|
||||
if (remove) {
|
||||
manaItem.addMana(stackInSlot, -mana);
|
||||
}
|
||||
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
||||
default int requestMana(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -129,31 +72,7 @@ public final class ManaItemHandler {
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
* @return If the request was succesful.
|
||||
*/
|
||||
public static boolean requestManaExact(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
manaItemSlot.addMana(stackInSlot, -manaToGet);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
default boolean requestManaExact(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -165,38 +84,7 @@ public final class ManaItemHandler {
|
||||
* @param add If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return The amount of mana actually sent.
|
||||
*/
|
||||
public static int dispatchMana(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int received;
|
||||
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) {
|
||||
received = manaToSend;
|
||||
} else {
|
||||
received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot));
|
||||
}
|
||||
|
||||
if (add) {
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
}
|
||||
|
||||
return received;
|
||||
}
|
||||
}
|
||||
|
||||
default int dispatchMana(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -208,31 +96,7 @@ public final class ManaItemHandler {
|
||||
* @param add If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return If an item received the mana sent.
|
||||
*/
|
||||
public static boolean dispatchManaExact(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (add) {
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
default boolean dispatchManaExact(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -246,10 +110,8 @@ public final class ManaItemHandler {
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
* @return The amount of mana received from the request.
|
||||
*/
|
||||
public static int requestManaForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
|
||||
int cost = (int) (manaToGet * multiplier);
|
||||
return (int) (requestMana(stack, player, cost, remove) / multiplier);
|
||||
default int requestManaForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,29 +123,15 @@ public final class ManaItemHandler {
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
* @return If the request was succesful.
|
||||
*/
|
||||
public static boolean requestManaExactForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
|
||||
int cost = (int) (manaToGet * multiplier);
|
||||
return requestManaExact(stack, player, cost, remove);
|
||||
default boolean requestManaExactForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sum of all the discounts on IManaDiscountArmor items equipped
|
||||
* on the player passed in. This discount can vary based on what the passed tool is.
|
||||
*/
|
||||
public static float getFullDiscountForTools(PlayerEntity player, ItemStack tool) {
|
||||
float discount = 0F;
|
||||
for (int i = 0; i < player.inventory.armorInventory.size(); i++) {
|
||||
ItemStack armor = player.inventory.armorInventory.get(i);
|
||||
if (!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor) {
|
||||
discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player, tool);
|
||||
}
|
||||
}
|
||||
|
||||
ManaDiscountEvent event = new ManaDiscountEvent(player, discount, tool);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
discount = event.getDiscount();
|
||||
|
||||
return discount;
|
||||
default float getFullDiscountForTools(PlayerEntity player, ItemStack tool) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Fired when the mod is gathering all items on a player that have mana.
|
||||
* For example, if you are an accessory mod, you would listen to this event and add stacks in your
|
||||
* accessory slots to the list using {@link #add}.
|
||||
*/
|
||||
public class ManaItemsEvent extends Event {
|
||||
|
||||
private final PlayerEntity entityPlayer;
|
||||
@@ -24,7 +29,7 @@ public class ManaItemsEvent extends Event {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public PlayerEntity getEntityPlayer() {
|
||||
public PlayerEntity getPlayer() {
|
||||
return entityPlayer;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public final class HUDHandler {
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> items = ManaItemHandler.getManaItems(player);
|
||||
List<ItemStack> items = ManaItemHandler.instance().getManaItems(player);
|
||||
for (ItemStack stack : items) {
|
||||
Item item = stack.getItem();
|
||||
if (!((IManaItem) item).isNoExport(stack)) {
|
||||
@@ -211,7 +211,7 @@ public final class HUDHandler {
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> acc = ManaItemHandler.getManaAccesories(player);
|
||||
List<ItemStack> acc = ManaItemHandler.instance().getManaAccesories(player);
|
||||
for (ItemStack stack : acc) {
|
||||
Item item = stack.getItem();
|
||||
if (!((IManaItem) item).isNoExport(stack)) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.common.block.mana.BlockSpreader;
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.api.capability.FloatingFlowerImpl;
|
||||
import vazkii.botania.api.item.IExoflameHeatable;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
|
||||
@@ -111,10 +111,10 @@ public class BlockAltar extends BlockMod {
|
||||
tile.trySetLastRecipe(player);
|
||||
return ActionResultType.SUCCESS;
|
||||
} else {
|
||||
if (!stack.isEmpty() && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, false))) {
|
||||
if (!stack.isEmpty() && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.instance().requestManaExact(stack, player, ItemWaterRod.COST, false))) {
|
||||
if (tile.getFluid() == Fluids.EMPTY) {
|
||||
if (stack.getItem() == ModItems.waterRod) {
|
||||
ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, player, ItemWaterRod.COST, true);
|
||||
} else if (!player.abilities.isCreativeMode) {
|
||||
player.setHeldItem(hand, drain(Fluids.WATER, stack));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.api.mana.ILens;
|
||||
import vazkii.botania.api.wand.IWandHUD;
|
||||
import vazkii.botania.api.wand.IWandable;
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.api.imc.IMC;
|
||||
import vazkii.botania.api.imc.OreWeightMessage;
|
||||
import vazkii.botania.api.imc.PaintableBlockMessage;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.api;
|
||||
package vazkii.botania.common.core.helper;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@@ -0,0 +1,220 @@
|
||||
package vazkii.botania.common.impl;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ManaItemHandlerImpl implements ManaItemHandler {
|
||||
@Override
|
||||
public List<ItemStack> getManaItems(PlayerEntity player) {
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ItemStack> toReturn = new ArrayList<>();
|
||||
player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(mainInv -> {
|
||||
int size = mainInv.getSlots();
|
||||
|
||||
for (int slot = 0; slot < size; slot++) {
|
||||
ItemStack stackInSlot = mainInv.getStackInSlot(slot);
|
||||
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ManaItemsEvent event = new ManaItemsEvent(player, toReturn);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getManaAccesories(PlayerEntity player) {
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
IItemHandler acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
if (acc == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ItemStack> toReturn = new ArrayList<>(acc.getSlots());
|
||||
|
||||
for (int slot = 0; slot < acc.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = acc.getStackInSlot(slot);
|
||||
|
||||
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
|
||||
toReturn.add(stackInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int requestMana(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItem = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot));
|
||||
|
||||
if (remove) {
|
||||
manaItem.addMana(stackInSlot, -mana);
|
||||
}
|
||||
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestManaExact(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
manaItemSlot.addMana(stackInSlot, -manaToGet);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int dispatchMana(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int received;
|
||||
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) {
|
||||
received = manaToSend;
|
||||
} else {
|
||||
received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot));
|
||||
}
|
||||
|
||||
if (add) {
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
}
|
||||
|
||||
return received;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchManaExact(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<ItemStack> items = getManaItems(player);
|
||||
List<ItemStack> acc = getManaAccesories(player);
|
||||
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
|
||||
if (stackInSlot == stack) {
|
||||
continue;
|
||||
}
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (add) {
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int requestManaForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
|
||||
int cost = (int) (manaToGet * multiplier);
|
||||
return (int) (requestMana(stack, player, cost, remove) / multiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestManaExactForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
|
||||
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
|
||||
int cost = (int) (manaToGet * multiplier);
|
||||
return requestManaExact(stack, player, cost, remove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFullDiscountForTools(PlayerEntity player, ItemStack tool) {
|
||||
float discount = 0F;
|
||||
for (int i = 0; i < player.inventory.armorInventory.size(); i++) {
|
||||
ItemStack armor = player.inventory.armorInventory.get(i);
|
||||
if (!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor) {
|
||||
discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player, tool);
|
||||
}
|
||||
}
|
||||
|
||||
ManaDiscountEvent event = new ManaDiscountEvent(player, discount, tool);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
discount = event.getDiscount();
|
||||
|
||||
return discount;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class ItemAstrolabe extends Item {
|
||||
|
||||
int size = getSize(stack);
|
||||
int cost = size * 320;
|
||||
if (!ManaItemHandler.requestManaExact(stack, player, cost, false)) {
|
||||
if (!ManaItemHandler.instance().requestManaExact(stack, player, cost, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ItemAstrolabe extends Item {
|
||||
for (BlockPos coords : blocksToPlace) {
|
||||
placeBlockAndConsume(player, stack, stackToPlace, coords);
|
||||
}
|
||||
ManaItemHandler.requestManaExact(stack, player, cost, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, player, cost, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) {
|
||||
if (ManaItemHandler.instance().requestManaExact(stack, player, COST_SELF, false)) {
|
||||
if (!player.world.isRemote) {
|
||||
player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> {
|
||||
return ChestContainer.createGeneric9X3(windowId, playerInv, p.getInventoryEnderChest());
|
||||
}, EnderChestBlock.field_220115_d));
|
||||
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, player, COST_SELF, true);
|
||||
}
|
||||
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
|
||||
return ActionResult.success(stack);
|
||||
@@ -59,14 +59,14 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand) {
|
||||
if (ConfigHandler.COMMON.enderPickpocketEnabled.get() && entity instanceof PlayerEntity && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) {
|
||||
if (ConfigHandler.COMMON.enderPickpocketEnabled.get() && entity instanceof PlayerEntity && ManaItemHandler.instance().requestManaExact(stack, player, COST_OTHER, false)) {
|
||||
if (!player.world.isRemote) {
|
||||
PlayerEntity other = (PlayerEntity) entity;
|
||||
player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> {
|
||||
return ChestContainer.createGeneric9X3(windowId, playerInv, other.getInventoryEnderChest());
|
||||
}, EnderChestBlock.field_220115_d));
|
||||
}
|
||||
ManaItemHandler.requestManaExact(stack, player, COST_OTHER, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, player, COST_OTHER, true);
|
||||
player.playSound(SoundEvents.BLOCK_ENDER_CHEST_OPEN, 1F, 1F);
|
||||
return true;
|
||||
}
|
||||
@@ -87,10 +87,10 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide
|
||||
|
||||
ItemStack istack = ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, false);
|
||||
if (!istack.isEmpty()) {
|
||||
boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false);
|
||||
boolean mana = ManaItemHandler.instance().requestManaExact(stack, player, COST_PROVIDE, false);
|
||||
if (mana) {
|
||||
if (doit) {
|
||||
ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, player, COST_PROVIDE, true);
|
||||
ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ItemManaGun extends Item implements IManaUsingItem {
|
||||
return ActionResult.success(stack);
|
||||
} else if (stack.getDamage() == 0) {
|
||||
EntityManaBurst burst = getBurst(player, stack, true, hand);
|
||||
if (burst != null && ManaItemHandler.requestManaExact(stack, player, burst.getMana(), true)) {
|
||||
if (burst != null && ManaItemHandler.instance().requestManaExact(stack, player, burst.getMana(), true)) {
|
||||
if (!world.isRemote) {
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.manaBlaster, SoundCategory.PLAYERS, 0.6F, 1);
|
||||
world.addEntity(burst);
|
||||
@@ -157,7 +157,7 @@ public class ItemManaGun extends Item implements IManaUsingItem {
|
||||
BurstProperties props = getBurstProps(player, stack, request, hand);
|
||||
|
||||
burst.setSourceLens(getLens(stack));
|
||||
if (!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) {
|
||||
if (!request || ManaItemHandler.instance().requestManaExact(stack, player, props.maxMana, false)) {
|
||||
burst.setColor(props.color);
|
||||
burst.setMana(props.maxMana);
|
||||
burst.setStartingMana(props.maxMana);
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
|
||||
|
||||
@Override
|
||||
public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
|
||||
if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) {
|
||||
if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou
|
||||
|
||||
@Override
|
||||
public void onArmorTick(ItemStack stack, World world, PlayerEntity player) {
|
||||
if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) {
|
||||
if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc
|
||||
if (food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) {
|
||||
player.heal(1F);
|
||||
}
|
||||
ManaItemHandler.dispatchManaExact(stack, player, 1, true);
|
||||
ManaItemHandler.instance().dispatchManaExact(stack, player, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (!player.world.isRemote && player instanceof PlayerEntity && player.ticksExisted % 10 == 0) {
|
||||
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
ManaItemHandler.instance().dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
EffectInstance effect = brew.getPotionEffects(stack).get(0);
|
||||
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
|
||||
boolean doRand = cost < 1;
|
||||
if (ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
|
||||
if (ManaItemHandler.instance().requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
|
||||
EffectInstance currentEffect = player.getActivePotionEffect(effect.getPotion());
|
||||
boolean nightVision = effect.getPotion() == Effects.NIGHT_VISION;
|
||||
if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 305 : 3)) {
|
||||
@@ -107,7 +107,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
}
|
||||
|
||||
if (!doRand || Math.random() < cost) {
|
||||
ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
|
||||
|
||||
if (!amulet.isEmpty()) {
|
||||
final int cost = 250;
|
||||
if (ManaItemHandler.requestManaExact(amulet, player, cost, false)) {
|
||||
if (ManaItemHandler.instance().requestManaExact(amulet, player, cost, false)) {
|
||||
final int range = 20;
|
||||
|
||||
List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(target.getX() - range, target.getY() - range, target.getZ() - range, target.getX() + range, target.getY() + range, target.getZ() + range), Predicates.instanceOf(IMob.class));
|
||||
@@ -78,7 +78,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
|
||||
((CreeperEntity) event.getEntityLiving()).timeSinceIgnited = 2;
|
||||
}
|
||||
|
||||
ManaItemHandler.requestManaExact(amulet, player, cost, true);
|
||||
ManaItemHandler.instance().requestManaExact(amulet, player, cost, true);
|
||||
player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.divaCharm, SoundCategory.PLAYERS, 1F, 1F);
|
||||
PacketHandler.sendToNearby(target.world, target, new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.DIVA_EFFECT, target.getX(), target.getY(), target.getZ(), target.getEntityId()));
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
player.abilities.allowFlying = true;
|
||||
if (player.abilities.isFlying) {
|
||||
if (!player.world.isRemote) {
|
||||
ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true);
|
||||
ManaItemHandler.instance().requestManaExact(tiara, player, getCost(tiara, left), true);
|
||||
} else if (Math.abs(player.getMotion().getX()) > 0.1 || Math.abs(player.getMotion().getZ()) > 0.1) {
|
||||
double x = event.getEntityLiving().getX() - 0.5;
|
||||
double y = event.getEntityLiving().getY() - 0.5;
|
||||
@@ -218,7 +218,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
if (!armor.isEmpty()) {
|
||||
int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME);
|
||||
boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false);
|
||||
return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItemStack(new ItemStack(ModItems.flugelEye))) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false);
|
||||
return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItemStack(new ItemStack(ModItems.flugelEye))) && ManaItemHandler.instance().requestManaExact(armor, player, getCost(armor, left), false);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem {
|
||||
|
||||
for (PlayerEntity player : players) {
|
||||
ItemStack charm = EquipmentHandler.findOrEmpty(ModItems.goddessCharm, player);
|
||||
if (!charm.isEmpty() && ManaItemHandler.requestManaExact(charm, player, COST, true)) {
|
||||
if (!charm.isEmpty() && ManaItemHandler.instance().requestManaExact(charm, player, COST, true)) {
|
||||
event.getAffectedBlocks().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem {
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (!player.world.isRemote && player instanceof PlayerEntity && player.ticksExisted % 2 == 0) {
|
||||
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
ManaItemHandler.instance().dispatchManaExact(stack, (PlayerEntity) player, 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (player instanceof PlayerEntity && !player.world.isRemote) {
|
||||
int manaCost = 2;
|
||||
boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false);
|
||||
boolean hasMana = ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) player, manaCost, false);
|
||||
if (!hasMana) {
|
||||
onUnequipped(stack, player);
|
||||
} else {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
if (player instanceof PlayerEntity && !player.world.isRemote) {
|
||||
int manaCost = 5;
|
||||
boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false);
|
||||
boolean hasMana = ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) player, manaCost, false);
|
||||
if (!hasMana) {
|
||||
onUnequipped(stack, player);
|
||||
} else {
|
||||
@@ -39,7 +39,7 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
|
||||
}
|
||||
|
||||
if (player.swingProgress == 0.25F) {
|
||||
ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, true);
|
||||
ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) player, manaCost, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem {
|
||||
|
||||
for (LivingEntity e : mobs) {
|
||||
EffectInstance potion = e.getActivePotionEffect(Effects.GLOWING);
|
||||
if ((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true)) {
|
||||
if ((potion == null || potion.getDuration() <= 2) && ManaItemHandler.instance().requestManaExact(stack, eplayer, COST, true)) {
|
||||
e.addPotionEffect(new EffectInstance(Effects.GLOWING, 12, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
|
||||
beltItem.onMovedTick(belt, player);
|
||||
|
||||
if (player.ticksExisted % COST_INTERVAL == 0) {
|
||||
ManaItemHandler.requestManaExact(belt, player, COST, true);
|
||||
ManaItemHandler.instance().requestManaExact(belt, player, COST, true);
|
||||
}
|
||||
} else {
|
||||
beltItem.onNotMovingTick(belt, player);
|
||||
@@ -118,7 +118,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
|
||||
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
|
||||
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
|
||||
if (!belt.isEmpty() && ManaItemHandler.requestManaExact(belt, player, COST, false)) {
|
||||
if (!belt.isEmpty() && ManaItemHandler.instance().requestManaExact(belt, player, COST, false)) {
|
||||
player.setMotion(player.getMotion().add(0, ((ItemTravelBelt) belt.getItem()).jump, 0));
|
||||
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
|
||||
|
||||
private boolean shouldPlayerHaveStepup(PlayerEntity player) {
|
||||
ItemStack result = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
return !result.isEmpty() && ManaItemHandler.requestManaExact(result, player, COST, false);
|
||||
return !result.isEmpty() && ManaItemHandler.instance().requestManaExact(result, player, COST, false);
|
||||
}
|
||||
|
||||
private void playerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
|
||||
}
|
||||
|
||||
if (!living.world.isRemote) {
|
||||
if (living instanceof PlayerEntity && !ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, COST, true)) {
|
||||
if (living instanceof PlayerEntity && !ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) living, COST, true)) {
|
||||
onUnequipped(stack, living);
|
||||
} else {
|
||||
addEffect(living, Effects.CONDUIT_POWER);
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class ToolCommons {
|
||||
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
while (amount > 0) {
|
||||
if (ManaItemHandler.requestManaExactForTool(stack, player, manaPerDamage, true)) {
|
||||
if (ManaItemHandler.instance().requestManaExactForTool(stack, player, manaPerDamage, true)) {
|
||||
amount--;
|
||||
} else {
|
||||
break;
|
||||
@@ -69,7 +69,7 @@ public final class ToolCommons {
|
||||
|
||||
public static void damageItem(ItemStack stack, int dmg, LivingEntity entity, int manaPerDamage) {
|
||||
int manaToRequest = dmg * manaPerDamage;
|
||||
boolean manaRequested = entity instanceof PlayerEntity && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) entity, manaToRequest, true);
|
||||
boolean manaRequested = entity instanceof PlayerEntity && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) entity, manaToRequest, true);
|
||||
|
||||
if (!manaRequested) {
|
||||
stack.damageItem(dmg, entity, e -> {});
|
||||
|
||||
@@ -33,14 +33,14 @@ public class ItemCrystalBow extends ItemLivingwoodBow {
|
||||
@Override
|
||||
boolean canFire(ItemStack stack, PlayerEntity player) {
|
||||
boolean infinity = EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
|
||||
return player.abilities.isCreativeMode || ManaItemHandler.requestManaExactForTool(stack, player, ARROW_COST / (infinity ? 2 : 1), false);
|
||||
return player.abilities.isCreativeMode || ManaItemHandler.instance().requestManaExactForTool(stack, player, ARROW_COST / (infinity ? 2 : 1), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
void onFire(ItemStack stack, LivingEntity living, boolean infinity, AbstractArrowEntity arrow) {
|
||||
arrow.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
|
||||
if (living instanceof PlayerEntity) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) living, ARROW_COST / (infinity ? 2 : 1), true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) living, ARROW_COST / (infinity ? 2 : 1), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem {
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class ItemManasteelShears extends ShearsItem implements IManaUsingItem {
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class ItemManasteelSword extends SwordItem implements IManaUsingItem {
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.instance().requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.common.item.Item16Colors;
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
|
||||
int cost = (int) (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, living.getX(), living.getY(), living.getZ()) * 10);
|
||||
|
||||
if (loc.getDimension() == world.getDimension().getType()
|
||||
&& (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, cost, true))) {
|
||||
&& (!(living instanceof PlayerEntity) || ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) living, cost, true))) {
|
||||
moveParticlesAndSound(living);
|
||||
living.setPositionAndUpdate(x + 0.5, y + 1.5, z + 0.5);
|
||||
moveParticlesAndSound(living);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
|
||||
return;
|
||||
}
|
||||
PlayerEntity player = (PlayerEntity) living;
|
||||
if (ManaItemHandler.requestManaExact(stack, player, 500, true)) {
|
||||
if (ManaItemHandler.instance().requestManaExact(stack, player, 500, true)) {
|
||||
if (count % 5 == 0) {
|
||||
player.getFoodStats().addStats(1, 1F);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
int spawned = getWeaponsSpawned(stack);
|
||||
|
||||
if (count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, 150, true))) {
|
||||
if (count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) living, 150, true))) {
|
||||
Vector3 look = new Vector3(living.getLookVec()).multiply(1, 0, 1);
|
||||
|
||||
double playerRot = Math.toRadians(living.rotationYaw + 90);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
|
||||
int successes = 0;
|
||||
for (BlockPos cursor : cursors) {
|
||||
BlockPos pos = hit.add(cursor);
|
||||
if (ManaItemHandler.requestManaExact(lokiRing, player, cost, false)) {
|
||||
if (ManaItemHandler.instance().requestManaExact(lokiRing, player, cost, false)) {
|
||||
Vec3d lookHit = lookPos.getHitVec();
|
||||
Vec3d newHitVec = new Vec3d(pos.getX() + MathHelper.frac(lookHit.getX()), pos.getY() + MathHelper.frac(lookHit.getY()), pos.getZ() + MathHelper.frac(lookHit.getZ()));
|
||||
BlockRayTraceResult newHit = new BlockRayTraceResult(newHitVec, lookPos.getFace(), pos, false);
|
||||
@@ -128,7 +128,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
|
||||
}
|
||||
|
||||
if (result == ActionResultType.SUCCESS) {
|
||||
ManaItemHandler.requestManaExact(lokiRing, player, cost, true);
|
||||
ManaItemHandler.instance().requestManaExact(lokiRing, player, cost, true);
|
||||
successes++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemCobbleRod extends Item implements IManaUsingItem, IBlockProvide
|
||||
@Override
|
||||
public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
|
||||
if (block == Blocks.COBBLESTONE) {
|
||||
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true);
|
||||
return !doit || ManaItemHandler.instance().requestManaExactForTool(requestor, player, COST, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider,
|
||||
Direction side = ctx.getFace();
|
||||
BlockPos pos = ctx.getPos();
|
||||
|
||||
if (player != null && ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) {
|
||||
if (player != null && ManaItemHandler.instance().requestManaExactForTool(stack, player, cost, false)) {
|
||||
int entities = world.getEntitiesWithinAABB(LivingEntity.class,
|
||||
new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider,
|
||||
PlayerHelper.substituteUse(ctx, stackToPlace);
|
||||
|
||||
if (stackToPlace.isEmpty()) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, cost, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, cost, true);
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(1F, r, g, b, 5);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
world.addParticle(data, pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0, 0, 0);
|
||||
@@ -90,7 +90,7 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider,
|
||||
@Override
|
||||
public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
|
||||
if (block == Blocks.DIRT) {
|
||||
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true);
|
||||
return !doit || ManaItemHandler.instance().requestManaExactForTool(requestor, player, COST, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity p, @Nonnull Hand hand) {
|
||||
ItemStack stack = p.getHeldItem(hand);
|
||||
if (ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) {
|
||||
if (ManaItemHandler.instance().requestManaExactForTool(stack, p, COST, true)) {
|
||||
if (world.isRemote) {
|
||||
int range = IManaProficiencyArmor.hasProficiency(p, stack) ? 20 : 15;
|
||||
long seedxor = world.rand.nextLong();
|
||||
|
||||
@@ -107,9 +107,9 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC
|
||||
|
||||
private void onLeftClick(PlayerInteractEvent.LeftClickBlock event) {
|
||||
ItemStack stack = event.getItemStack();
|
||||
if (!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getPlayer(), COST, false)) {
|
||||
if (!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.instance().requestManaExactForTool(stack, event.getPlayer(), COST, false)) {
|
||||
if (exchange(event.getWorld(), event.getPlayer(), event.getPos(), stack, getState(stack))) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, event.getPlayer(), COST, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, event.getPlayer(), COST, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC
|
||||
|
||||
BlockState state = getState(stack);
|
||||
if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
|
||||
if (!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
|
||||
if (!ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, false)) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
return;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC
|
||||
BlockPos coords = swap.get(world.rand.nextInt(swap.size()));
|
||||
boolean exchange = exchange(world, player, coords, stack, state);
|
||||
if (exchange) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true);
|
||||
} else {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ public class ItemFireRod extends Item implements IManaUsingItem, IAvatarWieldabl
|
||||
ItemStack stack = ctx.getItem();
|
||||
BlockPos pos = ctx.getPos();
|
||||
|
||||
if (!world.isRemote && player != null && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
|
||||
if (!world.isRemote && player != null && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, false)) {
|
||||
EntityFlameRing entity = new EntityFlameRing(world);
|
||||
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
|
||||
world.addEntity(entity);
|
||||
|
||||
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.hasProficiency(player, stack) ? COOLDOWN / 2 : COOLDOWN);
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true);
|
||||
|
||||
ctx.getWorld().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_BLAZE_AMBIENT, player != null ? SoundCategory.PLAYERS : SoundCategory.BLOCKS, 1F, 1F);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ItemGravityRod extends Item implements IManaUsingItem {
|
||||
return ActionResult.fail(stack);
|
||||
}
|
||||
|
||||
if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) {
|
||||
if (ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true)) {
|
||||
if (target instanceof ItemEntity) {
|
||||
((ItemEntity) target).setPickupDelay(5);
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ public class ItemMissileRod extends Item implements IManaUsingItem, IAvatarWield
|
||||
}
|
||||
PlayerEntity player = (PlayerEntity) living;
|
||||
|
||||
if (count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if (count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if (spawnMissile(player.world, player, player.getX() + (Math.random() - 0.5 * 0.1), player.getY() + 2.4 + (Math.random() - 0.5 * 0.1), player.getZ() + (Math.random() - 0.5 * 0.1))) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST_PER, true);
|
||||
}
|
||||
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false)) {
|
||||
if (!world.isRemote && ManaItemHandler.instance().requestManaExactForTool(stack, player, MANA_COST, false)) {
|
||||
Block place = ModBlocks.bifrost;
|
||||
Vector3 vector = new Vector3(player.getLookVec()).normalize();
|
||||
|
||||
@@ -113,7 +113,7 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield
|
||||
|
||||
if (count > 0) {
|
||||
world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F);
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, MANA_COST, false);
|
||||
player.getCooldownTracker().setCooldown(this, TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) {
|
||||
if (!world.isRemote && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST * 2, false)) {
|
||||
Vector3 playerVec = Vector3.fromEntityCenter(player);
|
||||
Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3);
|
||||
Vector3 placeVec = playerVec.add(lookVec);
|
||||
@@ -57,7 +57,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
|
||||
PlayerHelper.substituteUse(new ItemUseContext(player, hand, hit), stackToPlace);
|
||||
|
||||
if (stackToPlace.isEmpty()) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST * 2, true);
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.35F, 0.2F, 0.05F, 5);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
world.addParticle(data, x + Math.random(), y + Math.random(), z + Math.random(), 0, 0, 0);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
PlayerEntity p = (PlayerEntity) living;
|
||||
IInventory dummyInv = new Inventory(1);
|
||||
|
||||
if (!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) {
|
||||
if (!ManaItemHandler.instance().requestManaExactForTool(stack, p, COST_PER_TICK, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
p.world.playSound(null, p.getX(), p.getY(), p.getZ(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
|
||||
p.world.playSound(null, p.getX(), p.getY(), p.getZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true);
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, p, COST_PER_TICK, true);
|
||||
playerData.remove(p);
|
||||
decremented = false;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv
|
||||
|
||||
int cost = COST_PER * blocks.size();
|
||||
|
||||
if (world.isRemote || ManaItemHandler.requestManaExactForTool(stack, player, cost, true)) {
|
||||
if (world.isRemote || ManaItemHandler.instance().requestManaExactForTool(stack, player, cost, true)) {
|
||||
if (!world.isRemote) {
|
||||
for (CoordsWithBlock block : blocks) {
|
||||
world.setBlockState(block, block.block.getDefaultState());
|
||||
@@ -173,7 +173,7 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv
|
||||
@Override
|
||||
public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) {
|
||||
if (block == Blocks.DIRT) {
|
||||
return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true);
|
||||
return !doit || ManaItemHandler.instance().requestManaExactForTool(requestor, player, ItemDirtRod.COST, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ public class ItemTornadoRod extends Item implements IManaUsingItem, IAvatarWield
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
int fly = getFlyCounter(stack);
|
||||
if (fly == 0 && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
if (fly == 0 && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, false)) {
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true);
|
||||
setFlying(stack, true);
|
||||
return ActionResult.success(stack);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ItemWaterRod extends Item implements IManaUsingItem {
|
||||
if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) {
|
||||
BlockState blockstate = worldIn.getBlockState(blockpos);
|
||||
BlockPos blockpos1 = blockstate.getBlock() instanceof ILiquidContainer ? blockpos : blockraytraceresult.getPos().offset(blockraytraceresult.getFace());
|
||||
if (ManaItemHandler.requestManaExactForTool(itemstack, playerIn, COST, true)
|
||||
if (ManaItemHandler.instance().requestManaExactForTool(itemstack, playerIn, COST, true)
|
||||
&& ((BucketItem) Items.WATER_BUCKET).tryPlaceContainedLiquid(playerIn, worldIn, blockpos1, blockraytraceresult)) {
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) playerIn, blockpos1, itemstack);
|
||||
|
||||
Reference in new issue
Block a user