Move non-interface out of API
This commit is contained in:
25
src/main/java/refinedstorage/api/network/IWirelessGridConsumer.java
Executable file
25
src/main/java/refinedstorage/api/network/IWirelessGridConsumer.java
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
package refinedstorage.api.network;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a player using a wireless grid.
|
||||||
|
*/
|
||||||
|
public interface IWirelessGridConsumer {
|
||||||
|
/**
|
||||||
|
* @return The hand this wireless grid is opened with
|
||||||
|
*/
|
||||||
|
EnumHand getHand();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The player using the wireless grid
|
||||||
|
*/
|
||||||
|
EntityPlayer getPlayer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The wireless grid stack
|
||||||
|
*/
|
||||||
|
ItemStack getStack();
|
||||||
|
}
|
||||||
@@ -39,11 +39,11 @@ public interface IWirelessGridHandler {
|
|||||||
void drainEnergy(EntityPlayer player, int energy);
|
void drainEnergy(EntityPlayer player, int energy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link WirelessGridConsumer} for a player.
|
* Returns a {@link IWirelessGridConsumer} for a player.
|
||||||
*
|
*
|
||||||
* @param player The player to get the wireless grid consumer for
|
* @param player The player to get the wireless grid consumer for
|
||||||
* @return The {@link IWirelessGridHandler} that corresponds to a player, or null if the player isn't using a wireless grid
|
* @return The {@link IWirelessGridConsumer} that corresponds to a player, or null if the player isn't using a wireless grid
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
WirelessGridConsumer getConsumer(EntityPlayer player);
|
IWirelessGridConsumer getConsumer(EntityPlayer player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package refinedstorage.api.network;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a player using a wireless grid.
|
|
||||||
*/
|
|
||||||
public class WirelessGridConsumer {
|
|
||||||
private EntityPlayer player;
|
|
||||||
private EnumHand hand;
|
|
||||||
private ItemStack wirelessGrid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player The player using this wireless grid
|
|
||||||
* @param hand The hand that this wireless grid is opened with
|
|
||||||
* @param wirelessGrid The wireless grid {@link ItemStack} in the player's inventory
|
|
||||||
*/
|
|
||||||
public WirelessGridConsumer(EntityPlayer player, EnumHand hand, ItemStack wirelessGrid) {
|
|
||||||
this.player = player;
|
|
||||||
this.hand = hand;
|
|
||||||
this.wirelessGrid = wirelessGrid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The wireless grid {@link ItemStack}
|
|
||||||
*/
|
|
||||||
public ItemStack getWirelessGrid() {
|
|
||||||
return wirelessGrid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The hand this wireless grid is opened with
|
|
||||||
*/
|
|
||||||
public EnumHand getHand() {
|
|
||||||
return hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The player using the wireless grid
|
|
||||||
*/
|
|
||||||
public EntityPlayer getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
33
src/main/java/refinedstorage/apiimpl/network/WirelessGridConsumer.java
Executable file
33
src/main/java/refinedstorage/apiimpl/network/WirelessGridConsumer.java
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
package refinedstorage.apiimpl.network;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import refinedstorage.api.network.IWirelessGridConsumer;
|
||||||
|
|
||||||
|
public class WirelessGridConsumer implements IWirelessGridConsumer {
|
||||||
|
private EntityPlayer player;
|
||||||
|
private EnumHand hand;
|
||||||
|
private ItemStack stack;
|
||||||
|
|
||||||
|
public WirelessGridConsumer(EntityPlayer player, EnumHand hand, ItemStack stack) {
|
||||||
|
this.player = player;
|
||||||
|
this.hand = hand;
|
||||||
|
this.stack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumHand getHand() {
|
||||||
|
return hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,8 @@ public class WirelessGridHandler implements IWirelessGridHandler {
|
|||||||
|
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
|
|
||||||
private List<WirelessGridConsumer> consumers = new ArrayList<WirelessGridConsumer>();
|
private List<IWirelessGridConsumer> consumers = new ArrayList<IWirelessGridConsumer>();
|
||||||
private List<WirelessGridConsumer> consumersToRemove = new ArrayList<WirelessGridConsumer>();
|
private List<IWirelessGridConsumer> consumersToRemove = new ArrayList<IWirelessGridConsumer>();
|
||||||
|
|
||||||
public WirelessGridHandler(INetworkMaster network) {
|
public WirelessGridHandler(INetworkMaster network) {
|
||||||
this.network = network;
|
this.network = network;
|
||||||
@@ -34,12 +34,12 @@ public class WirelessGridHandler implements IWirelessGridHandler {
|
|||||||
consumers.removeAll(consumersToRemove);
|
consumers.removeAll(consumersToRemove);
|
||||||
consumersToRemove.clear();
|
consumersToRemove.clear();
|
||||||
|
|
||||||
Iterator<WirelessGridConsumer> it = consumers.iterator();
|
Iterator<IWirelessGridConsumer> it = consumers.iterator();
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
WirelessGridConsumer consumer = it.next();
|
IWirelessGridConsumer consumer = it.next();
|
||||||
|
|
||||||
if (!RefinedStorageUtils.compareStack(consumer.getWirelessGrid(), consumer.getPlayer().getHeldItem(consumer.getHand()))) {
|
if (!RefinedStorageUtils.compareStack(consumer.getStack(), consumer.getPlayer().getHeldItem(consumer.getHand()))) {
|
||||||
/**
|
/**
|
||||||
* This will call {@link net.minecraft.inventory.Container#onContainerClosed(EntityPlayer)} so the consumer is removed from the list.
|
* This will call {@link net.minecraft.inventory.Container#onContainerClosed(EntityPlayer)} so the consumer is removed from the list.
|
||||||
*/
|
*/
|
||||||
@@ -83,7 +83,7 @@ public class WirelessGridHandler implements IWirelessGridHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(EntityPlayer player) {
|
public void onClose(EntityPlayer player) {
|
||||||
WirelessGridConsumer consumer = getConsumer(player);
|
IWirelessGridConsumer consumer = getConsumer(player);
|
||||||
|
|
||||||
if (consumer != null) {
|
if (consumer != null) {
|
||||||
consumersToRemove.add(consumer);
|
consumersToRemove.add(consumer);
|
||||||
@@ -92,7 +92,7 @@ public class WirelessGridHandler implements IWirelessGridHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drainEnergy(EntityPlayer player, int energy) {
|
public void drainEnergy(EntityPlayer player, int energy) {
|
||||||
WirelessGridConsumer consumer = getConsumer(player);
|
IWirelessGridConsumer consumer = getConsumer(player);
|
||||||
|
|
||||||
if (consumer != null) {
|
if (consumer != null) {
|
||||||
ItemWirelessGrid item = RefinedStorageItems.WIRELESS_GRID;
|
ItemWirelessGrid item = RefinedStorageItems.WIRELESS_GRID;
|
||||||
@@ -110,11 +110,11 @@ public class WirelessGridHandler implements IWirelessGridHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WirelessGridConsumer getConsumer(EntityPlayer player) {
|
public IWirelessGridConsumer getConsumer(EntityPlayer player) {
|
||||||
Iterator<WirelessGridConsumer> it = consumers.iterator();
|
Iterator<IWirelessGridConsumer> it = consumers.iterator();
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
WirelessGridConsumer consumer = it.next();
|
IWirelessGridConsumer consumer = it.next();
|
||||||
|
|
||||||
if (consumer.getPlayer() == player) {
|
if (consumer.getPlayer() == player) {
|
||||||
return consumer;
|
return consumer;
|
||||||
|
|||||||
Reference in New Issue
Block a user