Base work for ticket based syphoning
To be used for providing a history. This commit breaks any usage of the network events. Heads up @TeamDMan @Arcaratus
This commit is contained in:
parent
c8e42e3288
commit
47b88b95b0
5 changed files with 203 additions and 104 deletions
24
src/main/java/WayofTime/bloodmagic/util/BooleanResult.java
Normal file
24
src/main/java/WayofTime/bloodmagic/util/BooleanResult.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.bloodmagic.util;
|
||||
|
||||
public class BooleanResult<T> {
|
||||
|
||||
private final boolean result;
|
||||
private final T value;
|
||||
|
||||
private BooleanResult(boolean result, T value) {
|
||||
this.result = result;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static <T> BooleanResult<T> newResult(boolean success, T value) {
|
||||
return new BooleanResult<>(success, value);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package WayofTime.bloodmagic.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.core.data.Binding;
|
||||
import WayofTime.bloodmagic.iface.IBindable;
|
||||
import WayofTime.bloodmagic.core.data.SoulTicket;
|
||||
import WayofTime.bloodmagic.event.SoulNetworkEvent;
|
||||
import WayofTime.bloodmagic.iface.IBindable;
|
||||
import WayofTime.bloodmagic.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.core.registry.OrbRegistry;
|
||||
|
@ -97,7 +98,7 @@ public class NetworkHelper {
|
|||
* @param user - User of the item.
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
* @return - Whether the action should be performed.
|
||||
* @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, int)}
|
||||
* @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, SoulTicket)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) {
|
||||
|
@ -128,9 +129,9 @@ public class NetworkHelper {
|
|||
return false;
|
||||
|
||||
SoulNetwork network = getSoulNetwork(binding);
|
||||
SoulNetworkEvent.ItemDrainInContainerEvent event = new SoulNetworkEvent.ItemDrainInContainerEvent(stack, binding.getOwnerId(), toSyphon);
|
||||
SoulNetworkEvent.Syphon.Item event = new SoulNetworkEvent.Syphon.Item(network, new SoulTicket(toSyphon), stack);
|
||||
|
||||
return !MinecraftForge.EVENT_BUS.post(event) && network.syphon(event.syphon) >= toSyphon;
|
||||
return !MinecraftForge.EVENT_BUS.post(event) && network.syphon(event.getTicket(), true) >= toSyphon;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue