mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-18 03:15:15 +00:00
bit of code cleanup
This commit is contained in:
1 parent
fe5999606d
commit
c920b72862
25 files changed
+1860
-2932
No files matched your search
+4
-9
@@ -1,27 +1,22 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.api.networking.security;
|
||||
|
||||
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
|
||||
public class WCTPlayerSource extends PlayerSource
|
||||
{
|
||||
public class WCTPlayerSource extends PlayerSource {
|
||||
|
||||
public final EntityPlayer player;
|
||||
public final WCTIActionHost via;
|
||||
|
||||
public WCTPlayerSource( final EntityPlayer p, final WCTIActionHost v )
|
||||
{
|
||||
super(p,(IActionHost) v);
|
||||
public WCTPlayerSource(final EntityPlayer p, final WCTIActionHost v) {
|
||||
super(p, (IActionHost) v);
|
||||
this.player = p;
|
||||
this.via = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer()
|
||||
{
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+530
-753
File diff suppressed because it is too large.
Load diff
@@ -25,12 +25,12 @@ import net.p455w0rd.wirelesscraftingterminal.proxy.CommonProxy;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
|
||||
@Mod(modid = Reference.MODID, acceptedMinecraftVersions = "[1.7.10]", name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY, dependencies = "required-after:Forge@[" // require
|
||||
// forge.
|
||||
@Mod(modid = Reference.MODID, acceptedMinecraftVersions = "[1.7.10]", name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY, dependencies = "required-after:Forge@["
|
||||
+ net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",);required-after:appliedenergistics2@[rv3-beta-1,);")
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",);"
|
||||
+ "required-after:appliedenergistics2@[rv3-beta-1,);")
|
||||
|
||||
public class WirelessCraftingTerminal {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class WirelessCraftingTerminal {
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.PREINITIALIZATION;
|
||||
WirelessCraftingTerminal.INSTANCE = this;
|
||||
creativeTab = new CreativeTabWCT(CreativeTabs.getNextID(), Reference.MODID).setNoScrollbar();
|
||||
WirelessCraftingTerminal.proxy.registerItems();
|
||||
proxy.registerItems();
|
||||
ConfigHandler.init(new File(event.getModConfigurationDirectory(), Reference.CONFIG_FILE));
|
||||
FMLCommonHandler.instance().bus().register(proxy);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler((IWirelessTermHandler) ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
@@ -76,7 +76,7 @@ public class WirelessCraftingTerminal {
|
||||
FMLCommonHandler.instance().registerCrashCallable(new IntegrationCrashEnhancement());
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this.INSTANCE, new WCTGuiHandler());
|
||||
NetworkHandler.instance = new NetworkHandler("WCT");
|
||||
WirelessCraftingTerminal.proxy.removeItemsFromNEI();
|
||||
proxy.removeItemsFromNEI();
|
||||
WCTLog.endSection("PostInit", stopwatch);
|
||||
}
|
||||
|
||||
|
||||
+4
-17
@@ -51,7 +51,7 @@ public class ContainerMagnet extends Container {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isInHotbar(int slotNum) {
|
||||
return (slotNum >= HOTBAR_START) && (slotNum <= HOTBAR_END);
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public class ContainerMagnet extends Container {
|
||||
public boolean canInteractWith(EntityPlayer p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean alreadyFiltered(ItemStack item) {
|
||||
for (int i = 0; i < magnetInventory.getSizeInventory(); i++) {
|
||||
if (isIdenticalItem(item, magnetInventory.getStackInSlot(i))) {
|
||||
@@ -92,7 +93,7 @@ public class ContainerMagnet extends Container {
|
||||
// return null;
|
||||
//}
|
||||
if (getSlot(slotNum) instanceof SlotMagnetFilter) {
|
||||
|
||||
|
||||
SlotMagnetFilter slot = (SlotMagnetFilter) getSlot(slotNum);
|
||||
ItemStack stack = null;
|
||||
|
||||
@@ -158,7 +159,7 @@ public class ContainerMagnet extends Container {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fillPhantomSlot(SlotMagnetFilter slot, ItemStack stackHeld, int mouseButton) {
|
||||
if (!slot.canAdjustPhantom()) {
|
||||
return;
|
||||
@@ -237,20 +238,6 @@ public class ContainerMagnet extends Container {
|
||||
}
|
||||
slot.onPickupFromSlot(p, stack);
|
||||
return stack;
|
||||
/*
|
||||
*
|
||||
* int numSlots = inventorySlots.size(); ItemStack stackInSlot =
|
||||
* slot.getStack(); ItemStack originalStack = stackInSlot.copy();
|
||||
*
|
||||
* slot.onSlotChange(stackInSlot, originalStack); if
|
||||
* (stackInSlot.stackSize <= 0) { slot.putStack(null); } else {
|
||||
* slot.onSlotChanged(); }
|
||||
*
|
||||
* if (stackInSlot.stackSize == originalStack.stackSize) { return null;
|
||||
* }
|
||||
*
|
||||
* slot.onPickupFromSlot(player, stackInSlot); return originalStack;
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
|
||||
|
||||
+476
-628
File diff suppressed because it is too large.
Load diff
+487
-711
File diff suppressed because it is too large.
Load diff
+54
-97
@@ -9,9 +9,7 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.WCTBaseContainer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
|
||||
public class AppEngSlot extends Slot
|
||||
{
|
||||
public class AppEngSlot extends Slot {
|
||||
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
@@ -22,209 +20,170 @@ public class AppEngSlot extends Slot
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
|
||||
public AppEngSlot( final IInventory inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
public AppEngSlot(final IInventory inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
public Slot setNotDraggable()
|
||||
{
|
||||
this.setDraggable( false );
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setPlayerSide()
|
||||
{
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTooltip()
|
||||
{
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearStack()
|
||||
{
|
||||
super.putStack( null );
|
||||
public void clearStack() {
|
||||
super.putStack(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
{
|
||||
return super.isItemValid( par1ItemStack );
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
return super.isItemValid(par1ItemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isEnabled() )
|
||||
{
|
||||
public ItemStack getStack() {
|
||||
if (!this.isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( this.inventory.getSizeInventory() <= this.getSlotIndex() )
|
||||
{
|
||||
if (this.inventory.getSizeInventory() <= this.getSlotIndex()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( this.isDisplay() )
|
||||
{
|
||||
this.setDisplay( false );
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
if (this.isEnabled()) {
|
||||
super.putStack(par1ItemStack);
|
||||
|
||||
if( this.getContainer() != null )
|
||||
{
|
||||
if (this.getContainer() != null) {
|
||||
if (this.getContainer() instanceof ContainerWirelessCraftingTerminal) {
|
||||
((ContainerWirelessCraftingTerminal) this.getContainer()).onSlotChange( this );
|
||||
((ContainerWirelessCraftingTerminal) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
if (this.getContainer() instanceof WCTBaseContainer) {
|
||||
((WCTBaseContainer) this.getContainer()).onSlotChange( this );
|
||||
((WCTBaseContainer) this.getContainer()).onSlotChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if( this.inventory instanceof AppEngInternalInventory )
|
||||
{
|
||||
( (AppEngInternalInventory) this.inventory ).markDirty( this.getSlotIndex() );
|
||||
public void onSlotChanged() {
|
||||
if (this.inventory instanceof AppEngInternalInventory) {
|
||||
((AppEngInternalInventory) this.inventory).markDirty(this.getSlotIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
super.onSlotChanged();
|
||||
}
|
||||
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
{
|
||||
return super.canTakeStack( par1EntityPlayer );
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
if (this.isEnabled()) {
|
||||
return super.canTakeStack(par1EntityPlayer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_111238_b()
|
||||
{
|
||||
public boolean func_111238_b() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
public ItemStack getDisplayStack() {
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getIcon()
|
||||
{
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
|
||||
public boolean shouldDisplay()
|
||||
{
|
||||
public boolean shouldDisplay() {
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
|
||||
private int getIIcon()
|
||||
{
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
|
||||
public void setIIcon( final int iIcon )
|
||||
{
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
|
||||
private boolean isDisplay()
|
||||
{
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
|
||||
public void setDisplay( final boolean isDisplay )
|
||||
{
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
|
||||
public boolean isDraggable()
|
||||
{
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
|
||||
private void setDraggable( final boolean isDraggable )
|
||||
{
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
|
||||
void setPlayerSide( final boolean isPlayerSide )
|
||||
{
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
|
||||
public hasCalculatedValidness getIsValid()
|
||||
{
|
||||
public hasCalculatedValidness getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public void setIsValid( final hasCalculatedValidness isValid )
|
||||
{
|
||||
public void setIsValid(final hasCalculatedValidness isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
Container getContainer()
|
||||
{
|
||||
Container getContainer() {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
return (ContainerWirelessCraftingTerminal) this.myContainer;
|
||||
}
|
||||
@@ -234,8 +193,7 @@ public class AppEngSlot extends Slot
|
||||
return this.myContainer;
|
||||
}
|
||||
|
||||
public void setContainer( final Container myContainer )
|
||||
{
|
||||
public void setContainer(final Container myContainer) {
|
||||
if (this.myContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
this.myContainer = (ContainerWirelessCraftingTerminal) myContainer;
|
||||
}
|
||||
@@ -247,8 +205,7 @@ public class AppEngSlot extends Slot
|
||||
}
|
||||
}
|
||||
|
||||
public enum hasCalculatedValidness
|
||||
{
|
||||
public enum hasCalculatedValidness {
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
+4
-26
@@ -1,39 +1,17 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container.slot;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet;
|
||||
|
||||
public class SlotMagnet extends AppEngSlot
|
||||
{
|
||||
public class SlotMagnet extends AppEngSlot {
|
||||
|
||||
/**
|
||||
* Custom slot for magnet card
|
||||
*
|
||||
* @param inv
|
||||
* @param index
|
||||
* @param xPos
|
||||
* @param yPos
|
||||
*/
|
||||
public SlotMagnet(IInventory inv, int xPos, int yPos)
|
||||
{
|
||||
public SlotMagnet(IInventory inv, int xPos, int yPos) {
|
||||
super(inv, 0, xPos, yPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures only the infinity booster card can be placed in the custom slot
|
||||
*
|
||||
* @param is
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack is)
|
||||
{
|
||||
// Everything returns false except an instance of our Item
|
||||
public boolean isItemValid(ItemStack is) {
|
||||
return ((is != null) && (is.getItem() instanceof ItemMagnet));
|
||||
}
|
||||
|
||||
|
||||
+28
-47
@@ -14,9 +14,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEve
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
|
||||
public class NetworkHandler
|
||||
{
|
||||
public class NetworkHandler {
|
||||
|
||||
public static NetworkHandler instance;
|
||||
|
||||
@@ -26,86 +24,69 @@ public class NetworkHandler
|
||||
private final IPacketHandler clientHandler;
|
||||
private final IPacketHandler serveHandler;
|
||||
|
||||
public NetworkHandler( final String channelName )
|
||||
{
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
this.ec = NetworkRegistry.INSTANCE.newEventDrivenChannel( this.myChannelName = channelName );
|
||||
this.ec.register( this );
|
||||
public NetworkHandler(final String channelName) {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
this.ec = NetworkRegistry.INSTANCE.newEventDrivenChannel(this.myChannelName = channelName);
|
||||
this.ec.register(this);
|
||||
|
||||
this.clientHandler = this.createClientSide();
|
||||
this.serveHandler = this.createServerSide();
|
||||
}
|
||||
|
||||
private IPacketHandler createClientSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
private IPacketHandler createClientSide() {
|
||||
try {
|
||||
return new WCTClientPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
catch (final Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createServerSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
private IPacketHandler createServerSide() {
|
||||
try {
|
||||
return new WCTServerPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
catch (final Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket( final ServerCustomPacketEvent ev )
|
||||
{
|
||||
public void serverPacket(final ServerCustomPacketEvent ev) {
|
||||
final NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler();
|
||||
if( this.serveHandler != null )
|
||||
{
|
||||
this.serveHandler.onPacketData( null, ev.packet, srv.playerEntity );
|
||||
if (this.serveHandler != null) {
|
||||
this.serveHandler.onPacketData(null, ev.packet, srv.playerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientPacket( final ClientCustomPacketEvent ev )
|
||||
{
|
||||
if( this.clientHandler != null )
|
||||
{
|
||||
this.clientHandler.onPacketData( null, ev.packet, null );
|
||||
public void clientPacket(final ClientCustomPacketEvent ev) {
|
||||
if (this.clientHandler != null) {
|
||||
this.clientHandler.onPacketData(null, ev.packet, null);
|
||||
}
|
||||
}
|
||||
|
||||
public String getChannel()
|
||||
{
|
||||
public String getChannel() {
|
||||
return this.myChannelName;
|
||||
}
|
||||
|
||||
public void sendToAll( final WCTPacket message )
|
||||
{
|
||||
this.ec.sendToAll( message.getProxy() );
|
||||
public void sendToAll(final WCTPacket message) {
|
||||
this.ec.sendToAll(message.getProxy());
|
||||
}
|
||||
|
||||
public void sendTo( final WCTPacket message, final EntityPlayerMP player )
|
||||
{
|
||||
this.ec.sendTo( message.getProxy(), player );
|
||||
public void sendTo(final WCTPacket message, final EntityPlayerMP player) {
|
||||
this.ec.sendTo(message.getProxy(), player);
|
||||
}
|
||||
|
||||
public void sendToAllAround( final WCTPacket message, final NetworkRegistry.TargetPoint point )
|
||||
{
|
||||
this.ec.sendToAllAround( message.getProxy(), point );
|
||||
public void sendToAllAround(final WCTPacket message, final NetworkRegistry.TargetPoint point) {
|
||||
this.ec.sendToAllAround(message.getProxy(), point);
|
||||
}
|
||||
|
||||
public void sendToDimension( final WCTPacket message, final int dimensionId )
|
||||
{
|
||||
this.ec.sendToDimension( message.getProxy(), dimensionId );
|
||||
public void sendToDimension(final WCTPacket message, final int dimensionId) {
|
||||
this.ec.sendToDimension(message.getProxy(), dimensionId);
|
||||
}
|
||||
|
||||
public void sendToServer( final WCTPacket message )
|
||||
{
|
||||
this.ec.sendToServer( message.getProxy() );
|
||||
public void sendToServer(final WCTPacket message) {
|
||||
this.ec.sendToServer(message.getProxy());
|
||||
}
|
||||
}
|
||||
-1
@@ -28,7 +28,6 @@ public class PacketCraftRequest extends WCTPacket {
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest(final ByteBuf stream) {
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
|
||||
+8
-11
@@ -18,12 +18,11 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
public class PacketMagnetFilterMode extends WCTPacket {
|
||||
|
||||
boolean isWhitelisting;
|
||||
|
||||
public PacketMagnetFilterMode( final ByteBuf stream )
|
||||
{
|
||||
|
||||
public PacketMagnetFilterMode(final ByteBuf stream) {
|
||||
this.isWhitelisting = stream.readBoolean();
|
||||
}
|
||||
|
||||
|
||||
public PacketMagnetFilterMode(final boolean isWhitelisting) {
|
||||
this.isWhitelisting = isWhitelisting;
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
@@ -32,12 +31,11 @@ public class PacketMagnetFilterMode extends WCTPacket {
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeBoolean(this.isWhitelisting);
|
||||
this.configureWrite( data );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player )
|
||||
{
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
ItemStack magnetItem = RandomUtils.getMagnet(player.inventory);
|
||||
if (!(magnetItem.getItem() instanceof ItemMagnet)) {
|
||||
return;
|
||||
@@ -49,10 +47,9 @@ public class PacketMagnetFilterMode extends WCTPacket {
|
||||
magnetItem.getTagCompound().setBoolean("Whitelisting", this.isWhitelisting);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player )
|
||||
{
|
||||
public void clientPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
GuiMagnet.mode = this.isWhitelisting;
|
||||
}
|
||||
}
|
||||
+4
-20
@@ -20,38 +20,22 @@ public class PacketOpenWirelessTerm extends WCTPacket {
|
||||
public PacketOpenWirelessTerm(final ByteBuf stream) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public PacketOpenWirelessTerm() {
|
||||
if( Platform.isClient() ) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
}
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
data.writeInt( this.getPacketID() );
|
||||
this.configureWrite( data );
|
||||
data.writeInt(this.getPacketID());
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
//WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_WCT, player, world, x, y, z);
|
||||
if (player.openContainer instanceof ContainerPlayer) {
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, Reference.GUI_WCT, world, x, y, z);
|
||||
WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
//WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_WCT, player, world, x, y, z);
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, Reference.GUI_WCT, world, x, y, z);
|
||||
}
|
||||
}
|
||||
+45
-75
@@ -28,89 +28,70 @@ import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketValueConfig extends WCTPacket
|
||||
{
|
||||
public class PacketValueConfig extends WCTPacket {
|
||||
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig( final ByteBuf stream ) throws IOException
|
||||
{
|
||||
final DataInputStream dis = new DataInputStream( new ByteArrayInputStream( stream.array(), stream.readerIndex(), stream.readableBytes() ) );
|
||||
public PacketValueConfig(final ByteBuf stream) throws IOException {
|
||||
final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(stream.array(), stream.readerIndex(), stream.readableBytes()));
|
||||
this.Name = dis.readUTF();
|
||||
this.Value = dis.readUTF();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketValueConfig( final String name, final String value ) throws IOException
|
||||
{
|
||||
public PacketValueConfig(final String name, final String value) throws IOException {
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final DataOutputStream dos = new DataOutputStream( bos );
|
||||
dos.writeUTF( name );
|
||||
dos.writeUTF( value );
|
||||
// dos.close();
|
||||
|
||||
data.writeBytes( bos.toByteArray() );
|
||||
|
||||
this.configureWrite( data );
|
||||
final DataOutputStream dos = new DataOutputStream(bos);
|
||||
dos.writeUTF(name);
|
||||
dos.writeUTF(value);
|
||||
data.writeBytes(bos.toByteArray());
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player )
|
||||
{
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "Item" ) && RandomUtils.getWirelessTerm(player.inventory) != null && RandomUtils.getWirelessTerm(player.inventory).getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
if (this.Name.equals("Item") && RandomUtils.getWirelessTerm(player.inventory) != null && RandomUtils.getWirelessTerm(player.inventory).getItem() instanceof IMouseWheelItem) {
|
||||
final ItemStack is = RandomUtils.getWirelessTerm(player.inventory);
|
||||
final IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel( is, this.Value.equals( "WheelUp" ) );
|
||||
si.onWheel(is, this.Value.equals("WheelUp"));
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus )
|
||||
{
|
||||
else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftingStatus) {
|
||||
final ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
qk.cycleCpu(this.Value.equals("Next"));
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
qk.cycleCpu(this.Value.equals("Next"));
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
else if (this.Name.equals("Terminal.Start") && c instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
}
|
||||
else if( this.Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU )
|
||||
{
|
||||
else if (this.Name.equals("TileCrafting.Cancel") && c instanceof ContainerCraftingCPU) {
|
||||
final ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for( final Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
final Enum<?> def = cm.getSetting( e );
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
}
|
||||
catch( final IllegalArgumentException err )
|
||||
{
|
||||
catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
@@ -121,55 +102,44 @@ public class PacketValueConfig extends WCTPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final WCTPacket packet, final EntityPlayer player )
|
||||
{
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "CustomName" ))
|
||||
{
|
||||
if (this.Name.equals("CustomName")) {
|
||||
if (c instanceof ContainerWirelessCraftingTerminal) {
|
||||
( (ContainerWirelessCraftingTerminal) c ).setCustomName( this.Value );
|
||||
((ContainerWirelessCraftingTerminal) c).setCustomName(this.Value);
|
||||
}
|
||||
if (c instanceof WCTBaseContainer) {
|
||||
( (WCTBaseContainer) c ).setCustomName( this.Value );
|
||||
((WCTBaseContainer) c).setCustomName(this.Value);
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "SyncDat." ) )
|
||||
{
|
||||
else if (this.Name.startsWith("SyncDat.")) {
|
||||
if (c instanceof ContainerWirelessCraftingTerminal) {
|
||||
( (ContainerWirelessCraftingTerminal) c ).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value );
|
||||
((ContainerWirelessCraftingTerminal) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value);
|
||||
}
|
||||
if (c instanceof WCTBaseContainer) {
|
||||
( (WCTBaseContainer) c ).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value );
|
||||
((WCTBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value);
|
||||
}
|
||||
}
|
||||
else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) )
|
||||
{
|
||||
else if (this.Name.equals("CraftingStatus") && this.Value.equals("Clear")) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if( gs instanceof GuiCraftingCPU )
|
||||
{
|
||||
( (GuiCraftingCPU) gs ).clearItems();
|
||||
if (gs instanceof GuiCraftingCPU) {
|
||||
((GuiCraftingCPU) gs).clearItems();
|
||||
}
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for( final Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
final Enum<?> def = cm.getSetting( e );
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
}
|
||||
catch( final IllegalArgumentException err )
|
||||
{
|
||||
catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ public class AchievementHandler {
|
||||
public static void init() {
|
||||
registerAchievements();
|
||||
registerPage();
|
||||
//addAchievementToPage(wctAch);
|
||||
}
|
||||
|
||||
public static void registerAchievements() {
|
||||
|
||||
@@ -14,6 +14,11 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class ConfigHandler {
|
||||
/*
|
||||
* A big part of what goes on here is reloading the cfg on-the-fly
|
||||
* since Ender-Core adds the abilitty to modify config stuff while in game,
|
||||
* I figured I'd add support for such possibilities
|
||||
*/
|
||||
public static Configuration config;
|
||||
public static boolean enableInfinityBooster;
|
||||
public static boolean enableEasyMode;
|
||||
@@ -106,6 +111,8 @@ public class ConfigHandler {
|
||||
}
|
||||
ItemEnum.BOOSTER_CARD.getItem().setCreativeTab(null);
|
||||
}
|
||||
//Added here because the only item being added to creative was the Booster Card
|
||||
//even when I set the Creative Tabs in the individual item classes
|
||||
ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem().setCreativeTab(WirelessCraftingTerminal.creativeTab);
|
||||
ItemEnum.MAGNET_CARD.getItem().setCreativeTab(WirelessCraftingTerminal.creativeTab);
|
||||
}
|
||||
|
||||
@@ -38,17 +38,14 @@ public class KeybindHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(KeyInputEvent event) {
|
||||
//if (event.phase == Phase.END) {
|
||||
EntityClientPlayerMP p = (EntityClientPlayerMP) Minecraft.getMinecraft().thePlayer;
|
||||
if (openTerminal.isPressed()) {
|
||||
//if (p.openContainer != null && p.openContainer instanceof ContainerPlayer) {
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(p);
|
||||
EntityClientPlayerMP p = (EntityClientPlayerMP) Minecraft.getMinecraft().thePlayer;
|
||||
if (openTerminal.isPressed()) {
|
||||
if (p.openContainer != null && p.openContainer instanceof ContainerPlayer) {
|
||||
if (!FMLClientHandler.instance().isGUIOpen(GuiWirelessCraftingTerminal.class)) {
|
||||
NetworkHandler.instance.sendToServer( new PacketOpenWirelessTerm() );
|
||||
NetworkHandler.instance.sendToServer(new PacketOpenWirelessTerm());
|
||||
}
|
||||
//}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -100,17 +100,5 @@ public class RecipeHandler {
|
||||
}
|
||||
recipeList.clear();
|
||||
init();
|
||||
/*
|
||||
* ItemStack recipeRegistryItem = null; ArrayList recipeRegistry =
|
||||
* (ArrayList) CraftingManager.getInstance().getRecipeList(); for (int i
|
||||
* = 0; i < recipeRegistry.size(); i++) { IRecipe tmpRecipe = (IRecipe)
|
||||
* recipeRegistry.get(i); if (tmpRecipe instanceof ShapedOreRecipe) {
|
||||
* ShapedOreRecipe recipeRegistryRecipe = (ShapedOreRecipe)tmpRecipe;
|
||||
* recipeRegistryItem = recipeRegistryRecipe.getRecipeOutput(); } else {
|
||||
* continue; } for (IRecipe recipe : recipeList) { ItemStack
|
||||
* recipeOutput = recipe.getRecipeOutput(); if
|
||||
* (ItemStack.areItemStacksEqual(recipeOutput, recipeRegistryItem)) {
|
||||
* recipeRegistry.remove(i); } } }
|
||||
*/
|
||||
}
|
||||
}
|
||||
+83
-147
@@ -32,9 +32,7 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware, WCTIActionHost
|
||||
{
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware, WCTIActionHost {
|
||||
|
||||
private final ItemStack effectiveItem;
|
||||
private final IWirelessTermHandler wth;
|
||||
@@ -48,37 +46,28 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
private double myRange = Double.MAX_VALUE;
|
||||
private final int inventorySlot;
|
||||
|
||||
public WirelessTerminalGuiObject( final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z )
|
||||
{
|
||||
this.encryptionKey = wh.getEncryptionKey( is );
|
||||
public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z) {
|
||||
this.encryptionKey = wh.getEncryptionKey(is);
|
||||
this.effectiveItem = is;
|
||||
this.myPlayer = ep;
|
||||
this.wth = wh;
|
||||
this.inventorySlot = x;
|
||||
|
||||
ILocatable obj = null;
|
||||
|
||||
try
|
||||
{
|
||||
final long encKey = Long.parseLong( this.encryptionKey );
|
||||
obj = AEApi.instance().registries().locatable().getLocatableBy( encKey );
|
||||
try {
|
||||
final long encKey = Long.parseLong(this.encryptionKey);
|
||||
obj = AEApi.instance().registries().locatable().getLocatableBy(encKey);
|
||||
}
|
||||
catch( final NumberFormatException err )
|
||||
{
|
||||
catch (final NumberFormatException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
if( obj instanceof IGridHost )
|
||||
{
|
||||
final IGridNode n = ((IGridHost) obj).getGridNode( ForgeDirection.UNKNOWN );
|
||||
if( n != null )
|
||||
{
|
||||
if (obj instanceof IGridHost) {
|
||||
final IGridNode n = ((IGridHost) obj).getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (n != null) {
|
||||
this.targetGrid = n.getGrid();
|
||||
if( this.targetGrid != null )
|
||||
{
|
||||
this.sg = this.targetGrid.getCache( IStorageGrid.class );
|
||||
if( this.sg != null )
|
||||
{
|
||||
if (this.targetGrid != null) {
|
||||
this.sg = this.targetGrid.getCache(IStorageGrid.class);
|
||||
if (this.sg != null) {
|
||||
this.itemStorage = this.sg.getItemInventory();
|
||||
}
|
||||
}
|
||||
@@ -86,196 +75,158 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
}
|
||||
|
||||
public double getRange()
|
||||
{
|
||||
public double getRange() {
|
||||
return this.myRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||
{
|
||||
if( this.sg == null )
|
||||
{
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
if (this.sg == null) {
|
||||
return null;
|
||||
}
|
||||
return this.sg.getItemInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||
{
|
||||
if( this.sg == null )
|
||||
{
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
if (this.sg == null) {
|
||||
return null;
|
||||
}
|
||||
return this.sg.getFluidInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( final IMEMonitorHandlerReceiver<IAEItemStack> l, final Object verificationToken )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
this.itemStorage.addListener( l, verificationToken );
|
||||
public void addListener(final IMEMonitorHandlerReceiver<IAEItemStack> l, final Object verificationToken) {
|
||||
if (this.itemStorage != null) {
|
||||
this.itemStorage.addListener(l, verificationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( final IMEMonitorHandlerReceiver<IAEItemStack> l )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
this.itemStorage.removeListener( l );
|
||||
public void removeListener(final IMEMonitorHandlerReceiver<IAEItemStack> l) {
|
||||
if (this.itemStorage != null) {
|
||||
this.itemStorage.removeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems( final IItemList out )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
return this.itemStorage.getAvailableItems( out );
|
||||
public IItemList<IAEItemStack> getAvailableItems(final IItemList out) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getAvailableItems(out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList()
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
public IItemList<IAEItemStack> getStorageList() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getStorageList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
public AccessRestriction getAccess() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getAccess();
|
||||
}
|
||||
return AccessRestriction.NO_ACCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized( final IAEItemStack input )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
return this.itemStorage.isPrioritized( input );
|
||||
public boolean isPrioritized(final IAEItemStack input) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.isPrioritized(input);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept( final IAEItemStack input )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
return this.itemStorage.canAccept( input );
|
||||
public boolean canAccept(final IAEItemStack input) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.canAccept(input);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
public int getPriority() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getPriority();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
public int getSlot() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getSlot();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validForPass( final int i )
|
||||
{
|
||||
return this.itemStorage.validForPass( i );
|
||||
public boolean validForPass(final int i) {
|
||||
return this.itemStorage.validForPass(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
return this.itemStorage.injectItems( input, type, src );
|
||||
public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final BaseActionSource src) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.injectItems(input, type, src);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
return this.itemStorage.extractItems( request, mode, src );
|
||||
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final BaseActionSource src) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.extractItems(request, mode, src);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
public StorageChannel getChannel() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getChannel();
|
||||
}
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier )
|
||||
{
|
||||
if( this.wth != null && this.effectiveItem != null )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return this.wth.hasPower( this.myPlayer, amt, this.effectiveItem ) ? amt : 0;
|
||||
public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) {
|
||||
if (this.wth != null && this.effectiveItem != null) {
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return this.wth.hasPower(this.myPlayer, amt, this.effectiveItem) ? amt : 0;
|
||||
}
|
||||
return this.wth.usePower( this.myPlayer, amt, this.effectiveItem ) ? amt : 0;
|
||||
return this.wth.usePower(this.myPlayer, amt, this.effectiveItem) ? amt : 0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
public ItemStack getItemStack() {
|
||||
return this.effectiveItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.wth.getConfigManager( this.effectiveItem );
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.wth.getConfigManager(this.effectiveItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode( final ForgeDirection dir )
|
||||
{
|
||||
public IGridNode getGridNode(final ForgeDirection dir) {
|
||||
return this.getActionableNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final ForgeDirection dir )
|
||||
{
|
||||
public AECableType getCableConnectionType(final ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
public void securityBreak() {
|
||||
|
||||
}
|
||||
|
||||
@@ -283,48 +234,39 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
public IGridNode getActionableNode() {
|
||||
return getActionableNode(false);
|
||||
}
|
||||
|
||||
public IGridNode getActionableNode(boolean ignoreRange)
|
||||
{
|
||||
|
||||
public IGridNode getActionableNode(boolean ignoreRange) {
|
||||
this.rangeCheck(ignoreRange);
|
||||
if( this.myWap != null )
|
||||
{
|
||||
if (this.myWap != null) {
|
||||
return this.myWap.getActionableNode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean rangeCheck() {
|
||||
return rangeCheck(false);
|
||||
}
|
||||
|
||||
public boolean rangeCheck(boolean ignoreRange)
|
||||
{
|
||||
public boolean rangeCheck(boolean ignoreRange) {
|
||||
this.sqRange = this.myRange = Double.MAX_VALUE;
|
||||
|
||||
if( this.targetGrid != null && this.itemStorage != null )
|
||||
{
|
||||
if( this.myWap != null )
|
||||
{
|
||||
if( this.myWap.getGrid() == this.targetGrid )
|
||||
{
|
||||
if( this.testWap( this.myWap ) )
|
||||
{
|
||||
if (this.targetGrid != null && this.itemStorage != null) {
|
||||
if (this.myWap != null) {
|
||||
if (this.myWap.getGrid() == this.targetGrid) {
|
||||
if (this.testWap(this.myWap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final IMachineSet tw = this.targetGrid.getMachines( TileWireless.class );
|
||||
final IMachineSet tw = this.targetGrid.getMachines(TileWireless.class);
|
||||
|
||||
this.myWap = null;
|
||||
|
||||
for( final IGridNode n : tw )
|
||||
{
|
||||
for (final IGridNode n : tw) {
|
||||
final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine();
|
||||
if( this.testWap( wap, ignoreRange ) )
|
||||
{
|
||||
if (this.testWap(wap, ignoreRange)) {
|
||||
this.myWap = wap;
|
||||
}
|
||||
}
|
||||
@@ -337,35 +279,30 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
private boolean testWap(final IWirelessAccessPoint wap) {
|
||||
return testWap(wap, false);
|
||||
}
|
||||
|
||||
private boolean testWap( final IWirelessAccessPoint wap, boolean ignoreRange )
|
||||
{
|
||||
|
||||
private boolean testWap(final IWirelessAccessPoint wap, boolean ignoreRange) {
|
||||
double rangeLimit = wap.getRange();
|
||||
rangeLimit *= rangeLimit;
|
||||
|
||||
final DimensionalCoord dc = wap.getLocation();
|
||||
|
||||
if( dc.getWorld() == this.myPlayer.worldObj )
|
||||
{
|
||||
if (dc.getWorld() == this.myPlayer.worldObj) {
|
||||
final double offX = dc.x - this.myPlayer.posX;
|
||||
final double offY = dc.y - this.myPlayer.posY;
|
||||
final double offZ = dc.z - this.myPlayer.posZ;
|
||||
|
||||
final double r = offX * offX + offY * offY + offZ * offZ;
|
||||
if( r < rangeLimit && this.sqRange > r && !ignoreRange)
|
||||
{
|
||||
if( wap.isActive() )
|
||||
{
|
||||
if (r < rangeLimit && this.sqRange > r && !ignoreRange) {
|
||||
if (wap.isActive()) {
|
||||
this.sqRange = r;
|
||||
this.myRange = Math.sqrt( r );
|
||||
this.myRange = Math.sqrt(r);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( wap.isActive() )
|
||||
{
|
||||
if (wap.isActive()) {
|
||||
this.sqRange = r;
|
||||
this.myRange = Math.sqrt( r );
|
||||
this.myRange = Math.sqrt(r);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -374,8 +311,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot()
|
||||
{
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
|
||||
+4
-33
@@ -18,12 +18,7 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
|
||||
|
||||
@Override
|
||||
public void openWirelessCraftingTerminalGui(final EntityPlayer player) {
|
||||
// Valid player?
|
||||
if ((player == null) || (player instanceof FakePlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.worldObj.isRemote) {
|
||||
if ((player == null) || (player instanceof FakePlayer) || player.worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +28,8 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the item the first wireless terminal
|
||||
// Get the first wireless terminal
|
||||
// If one is held, it takes precidence
|
||||
ItemStack wirelessTerminal = null;
|
||||
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
@@ -46,51 +42,26 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Ensure the stack is valid
|
||||
if ((wirelessTerminal == null)) {
|
||||
// Invalid terminal
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the interface
|
||||
IWirelessCraftingTermHandler terminalInterface = (IWirelessCraftingTermHandler) wirelessTerminal.getItem();
|
||||
|
||||
// Ensure the terminal has power
|
||||
if (terminalInterface.getAECurrentPower(wirelessTerminal) == 0) {
|
||||
// Terminal is dead
|
||||
if (terminalInterface.getAECurrentPower(wirelessTerminal) <= 0) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the terminal is linked
|
||||
if (!isTerminalLinked(terminalInterface, wirelessTerminal)) {
|
||||
// Unlinked terminal
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the encryption key
|
||||
String encKey = terminalInterface.getEncryptionKey(wirelessTerminal);
|
||||
|
||||
// Are any AP's in range?
|
||||
ArrayList<IWirelessAccessPoint> accessPoints = WirelessAELink.locateAPsInRangeOfPlayer(player, encKey);
|
||||
|
||||
// Error occured
|
||||
if (accessPoints == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
|
||||
}
|
||||
// None in range
|
||||
/*
|
||||
* else if( accessPoints.isEmpty() ) { player.addChatMessage(
|
||||
* PlayerMessages.OutOfRange.get() ); player.addChatMessage(new
|
||||
* ChatComponentText("XX")); }
|
||||
*/
|
||||
// Attempt to launch the gui
|
||||
// NOTE: Range check done in here
|
||||
else {
|
||||
WCTGuiHandler.launchGui(Reference.GUI_WCT, player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isTerminalLinked(final IWirelessCraftingTermHandler wirelessTerminal, final ItemStack wirelessTerminalItemstack) {
|
||||
|
||||
+70
-288
@@ -34,104 +34,42 @@ import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionH
|
||||
*
|
||||
*/
|
||||
public abstract class WirelessAELink implements IStorageMonitorable {
|
||||
/**
|
||||
* The player who owns this link.
|
||||
*/
|
||||
|
||||
protected final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Encryption key used to access the network.
|
||||
*/
|
||||
protected final String encryptionKey;
|
||||
|
||||
/**
|
||||
* Access point used to communicate with the AE network.
|
||||
*/
|
||||
protected IWirelessAccessPoint accessPoint;
|
||||
|
||||
/**
|
||||
* Where in the world is the access point.
|
||||
*/
|
||||
protected DimensionalCoord apLocation = null;
|
||||
|
||||
/**
|
||||
* Network source representing the player
|
||||
*/
|
||||
protected BaseActionSource actionSource;
|
||||
|
||||
public WirelessAELink( final @Nullable EntityPlayer player, @Nonnull final String encryptionKey )
|
||||
{
|
||||
// Set the player
|
||||
public WirelessAELink(final @Nullable EntityPlayer player, @Nonnull final String encryptionKey) {
|
||||
this.player = player;
|
||||
|
||||
// Set the enc key
|
||||
this.encryptionKey = encryptionKey;
|
||||
|
||||
// Link with the AP
|
||||
this.linkWithNewAP();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the AP at the specified location and has the specified range,
|
||||
* is close enough to communicate with.
|
||||
*
|
||||
* @param APLocation
|
||||
* @param APRange
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
private static boolean isAPInRange( final DimensionalCoord APLocation, final double APRange, final World world, final int x, final int y,
|
||||
final int z )
|
||||
{
|
||||
// Is the AP in the same world?
|
||||
if( !APLocation.isInWorld( world ) )
|
||||
{
|
||||
private static boolean isAPInRange(final DimensionalCoord APLocation, final double APRange, final World world, final int x, final int y, final int z) {
|
||||
if (!APLocation.isInWorld(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the square distance
|
||||
double squareDistance = getSquaredDistanceFromAP( APLocation, x, y, z );
|
||||
|
||||
// Return if close enough to use AP
|
||||
return squareDistance <= ( APRange * APRange );
|
||||
double squareDistance = getSquaredDistanceFromAP(APLocation, x, y, z);
|
||||
return squareDistance <= (APRange * APRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param grid
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<IWirelessAccessPoint> locateAPsInRange( final World world, final int x, final int y, final int z, final IGrid grid )
|
||||
{
|
||||
// Get all AP's on the grid
|
||||
IMachineSet accessPoints = grid.getMachines( TileWireless.class );
|
||||
if( accessPoints.isEmpty() )
|
||||
{
|
||||
private static ArrayList<IWirelessAccessPoint> locateAPsInRange(final World world, final int x, final int y, final int z, final IGrid grid) {
|
||||
IMachineSet accessPoints = grid.getMachines(TileWireless.class);
|
||||
if (accessPoints.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create the list
|
||||
ArrayList<IWirelessAccessPoint> aps = new ArrayList<IWirelessAccessPoint>();
|
||||
|
||||
// Loop over AP's and see if any are close enough to communicate with
|
||||
for( IGridNode APNode : accessPoints )
|
||||
{
|
||||
// Get the AP
|
||||
IWirelessAccessPoint AP = (IWirelessAccessPoint)APNode.getMachine();
|
||||
|
||||
// Is the AP active?
|
||||
if( AP.isActive() )
|
||||
{
|
||||
// Close enough to the AP?
|
||||
if( isAPInRange( AP.getLocation(), AP.getRange(), world, x, y, z ) )
|
||||
{
|
||||
aps.add( AP );
|
||||
for (IGridNode APNode : accessPoints) {
|
||||
IWirelessAccessPoint AP = (IWirelessAccessPoint) APNode.getMachine();
|
||||
if (AP.isActive()) {
|
||||
if (isAPInRange(AP.getLocation(), AP.getRange(), world, x, y, z)) {
|
||||
aps.add(AP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,253 +77,125 @@ public abstract class WirelessAELink implements IStorageMonitorable {
|
||||
return aps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the squared distance the specified coords are from the Access Point.
|
||||
*
|
||||
* @param locationAP
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
protected static double getSquaredDistanceFromAP( final DimensionalCoord locationAP, final int x, final int y, final int z )
|
||||
{
|
||||
if( locationAP == null )
|
||||
{
|
||||
protected static double getSquaredDistanceFromAP(final DimensionalCoord locationAP, final int x, final int y, final int z) {
|
||||
if (locationAP == null) {
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
// Calculate the distance from the AP
|
||||
int dX = locationAP.x - x, dY = locationAP.y - y, dZ = locationAP.z - z;
|
||||
|
||||
// Calculate the square distance
|
||||
return( ( dX * dX ) + ( dY * dY ) + ( dZ * dZ ) );
|
||||
return ((dX * dX) + (dY * dY) + (dZ * dZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unsorted list of AP's in range.
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param encryptionKey
|
||||
* @return Null on error, list of AP's in range otherwise.
|
||||
*/
|
||||
public static ArrayList<IWirelessAccessPoint> locateAPsInRange( final World world, final int x, final int y, final int z,
|
||||
final String encryptionKey )
|
||||
{
|
||||
// Get the encryption key
|
||||
public static ArrayList<IWirelessAccessPoint> locateAPsInRange(final World world, final int x, final int y, final int z, final String encryptionKey) {
|
||||
long encryptionValue;
|
||||
try
|
||||
{
|
||||
encryptionValue = Long.parseLong( encryptionKey );
|
||||
try {
|
||||
encryptionValue = Long.parseLong(encryptionKey);
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
// Invalid security key
|
||||
catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the linked source
|
||||
Object source = AEApi.instance().registries().locatable().getLocatableBy( encryptionValue );
|
||||
Object source = AEApi.instance().registries().locatable().getLocatableBy(encryptionValue);
|
||||
|
||||
// Ensure it is a security terminal
|
||||
if( !( source instanceof TileSecurity ) )
|
||||
{
|
||||
// Invalid security terminal
|
||||
if (!(source instanceof TileSecurity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the terminal
|
||||
TileSecurity securityHost = (TileSecurity)source;
|
||||
|
||||
// Get the grid
|
||||
TileSecurity securityHost = (TileSecurity) source;
|
||||
IGrid grid;
|
||||
try
|
||||
{
|
||||
grid = securityHost.getGridNode( ForgeDirection.UNKNOWN ).getGrid();
|
||||
try {
|
||||
grid = securityHost.getGridNode(ForgeDirection.UNKNOWN).getGrid();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Can not find the grid
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return locateAPsInRange( world, x, y, z, grid );
|
||||
return locateAPsInRange(world, x, y, z, grid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unsorted list of AP's in range.
|
||||
*
|
||||
* @param player
|
||||
* @param encryptionKey
|
||||
* @return Null on error, list of AP's in range otherwise.
|
||||
*/
|
||||
public static ArrayList<IWirelessAccessPoint> locateAPsInRangeOfPlayer( final EntityPlayer player, final String encryptionKey )
|
||||
{
|
||||
return locateAPsInRange( player.worldObj,
|
||||
(int)Math.floor( player.posX ),
|
||||
(int)Math.floor( player.posY ),
|
||||
(int)Math.floor( player.posZ ), encryptionKey );
|
||||
public static ArrayList<IWirelessAccessPoint> locateAPsInRangeOfPlayer(final EntityPlayer player, final String encryptionKey) {
|
||||
return locateAPsInRange(player.worldObj, (int) Math.floor(player.posX), (int) Math.floor(player.posY), (int) Math.floor(player.posZ), encryptionKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the AP is still active and in range.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isAPInRangeAndActive()
|
||||
{
|
||||
// Has AP?
|
||||
if( this.accessPoint != null )
|
||||
{
|
||||
// Is active?
|
||||
if( this.accessPoint.isActive() )
|
||||
{
|
||||
// In range?
|
||||
return isAPInRange( this.apLocation, this.accessPoint.getRange(), this.getUserWorld(),
|
||||
this.getUserPositionX(), this.getUserPositionY(), this.getUserPositionZ() );
|
||||
private boolean isAPInRangeAndActive() {
|
||||
if (this.accessPoint != null) {
|
||||
if (this.accessPoint.isActive()) {
|
||||
return isAPInRange(this.apLocation, this.accessPoint.getRange(), this.getUserWorld(), this.getUserPositionX(), this.getUserPositionY(), this.getUserPositionZ());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the closest AP in range and links with it.
|
||||
*
|
||||
* @return True if AP linked with.
|
||||
*/
|
||||
private boolean linkWithNewAP()
|
||||
{
|
||||
private boolean linkWithNewAP() {
|
||||
World w = this.getUserWorld();
|
||||
int x = this.getUserPositionX();
|
||||
int y = this.getUserPositionY();
|
||||
int z = this.getUserPositionZ();
|
||||
|
||||
IGrid grid = null;
|
||||
if( this.accessPoint != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.accessPoint != null) {
|
||||
try {
|
||||
grid = this.accessPoint.getGrid();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Get a list of AP's in range
|
||||
ArrayList<IWirelessAccessPoint> apList;
|
||||
if( grid != null )
|
||||
{
|
||||
apList = locateAPsInRange( w, x, y, z, grid );
|
||||
if (grid != null) {
|
||||
apList = locateAPsInRange(w, x, y, z, grid);
|
||||
}
|
||||
else
|
||||
{
|
||||
apList = locateAPsInRange( w, x, y, z, this.encryptionKey );
|
||||
else {
|
||||
apList = locateAPsInRange(w, x, y, z, this.encryptionKey);
|
||||
}
|
||||
|
||||
if( ( apList == null ) || ( apList.isEmpty() ) )
|
||||
{
|
||||
// No valid AP's found
|
||||
if ((apList == null) || (apList.isEmpty())) {
|
||||
this.accessPoint = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the closest
|
||||
IWirelessAccessPoint closest = null;
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
for( IWirelessAccessPoint ap : apList )
|
||||
{
|
||||
double dist = getSquaredDistanceFromAP( ap.getLocation(), x, y, z );
|
||||
if( dist < closestDistance )
|
||||
{
|
||||
for (IWirelessAccessPoint ap : apList) {
|
||||
double dist = getSquaredDistanceFromAP(ap.getLocation(), x, y, z);
|
||||
if (dist < closestDistance) {
|
||||
closestDistance = dist;
|
||||
closest = ap;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the closest as the AP to use
|
||||
this.setAP( closest );
|
||||
this.setAP(closest);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set's the access point used for communication.
|
||||
*
|
||||
* @param accessPoint
|
||||
*/
|
||||
private void setAP( final IWirelessAccessPoint accessPoint )
|
||||
{
|
||||
// Set the access point
|
||||
private void setAP(final IWirelessAccessPoint accessPoint) {
|
||||
this.accessPoint = accessPoint;
|
||||
|
||||
// Get the location of the access point
|
||||
this.apLocation = this.accessPoint.getLocation();
|
||||
|
||||
// Create the action source
|
||||
if( this.player != null )
|
||||
{
|
||||
this.actionSource = new WCTPlayerSource( this.player, (WCTIActionHost) this.accessPoint );
|
||||
if (this.player != null) {
|
||||
this.actionSource = new WCTPlayerSource(this.player, (WCTIActionHost) this.accessPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.actionSource = new MachineSource( (WCTIActionHost) this.accessPoint );
|
||||
else {
|
||||
this.actionSource = new MachineSource((WCTIActionHost) this.accessPoint);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x position of the user.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getUserPositionX();
|
||||
|
||||
/**
|
||||
* Return the y position of the user.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getUserPositionY();
|
||||
|
||||
/**
|
||||
* Return the z position of the user.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract int getUserPositionZ();
|
||||
|
||||
/**
|
||||
* Return the world the user is in.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract World getUserWorld();
|
||||
|
||||
/**
|
||||
* Is there enough local power to communicate with the AP?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean hasPowerToCommunicate();
|
||||
|
||||
public IEnergyGrid getEnergyGrid()
|
||||
{
|
||||
// Check AP
|
||||
if( this.accessPoint == null )
|
||||
{
|
||||
public IEnergyGrid getEnergyGrid() {
|
||||
if (this.accessPoint == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the energy grid
|
||||
return this.accessPoint.getActionableNode().getGrid().getCache( IEnergyGrid.class );
|
||||
try {
|
||||
return this.accessPoint.getActionableNode().getGrid().getCache(IEnergyGrid.class);
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
|
||||
@@ -393,24 +203,16 @@ public abstract class WirelessAELink implements IStorageMonitorable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||
{
|
||||
// Check connectivity
|
||||
if( ( this.accessPoint == null ) || !this.isConnected() )
|
||||
{
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
if ((this.accessPoint == null) || !this.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the storage grid
|
||||
IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache( IStorageGrid.class );
|
||||
|
||||
// Return the monitor
|
||||
try {
|
||||
IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache(IStorageGrid.class);
|
||||
return storageGrid.getFluidInventory();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
|
||||
@@ -418,51 +220,31 @@ public abstract class WirelessAELink implements IStorageMonitorable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||
{
|
||||
// Check connectivity
|
||||
if( ( this.accessPoint == null ) || !this.isConnected() )
|
||||
{
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
if ((this.accessPoint == null) || !this.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get the storage grid
|
||||
IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache( IStorageGrid.class );
|
||||
|
||||
// Return the monitor
|
||||
try {
|
||||
IStorageGrid storageGrid = this.accessPoint.getActionableNode().getGrid().getCache(IStorageGrid.class);
|
||||
return storageGrid.getItemInventory();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the AP is still connected.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isConnected()
|
||||
{
|
||||
// Is there power?
|
||||
if( !this.hasPowerToCommunicate() )
|
||||
{
|
||||
public boolean isConnected() {
|
||||
if (!this.hasPowerToCommunicate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is the current AP still good?
|
||||
if( this.isAPInRangeAndActive() )
|
||||
{
|
||||
// Current AP is still connected.
|
||||
if (this.isAPInRangeAndActive()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Attempt to link with a new AP
|
||||
return this.linkWithNewAP();
|
||||
}
|
||||
}
|
||||
@@ -4,51 +4,44 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum ItemEnum {
|
||||
BOOSTER_CARD ("infinityBoosterCard", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterCard")),
|
||||
BOOSTER_ICON ("infinityBoosterIcon", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterIcon")),
|
||||
WIRELESS_CRAFTING_TERMINAL ("wirelessCraftingTerminal", new ItemWirelessCraftingTerminal()),
|
||||
WCT_DUMMY_ICON ("ae2wctDummyIcon", new ItemAE2WCTDummyIcon()),
|
||||
MAGNET_CARD ("magnetCard", new ItemMagnet().setUnlocalizedName("magnetCard")),
|
||||
WCT_BOOSTER_BG_ICON ("boosterBG", new ItemBoosterBGIcon());
|
||||
|
||||
BOOSTER_CARD("infinityBoosterCard", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterCard")),
|
||||
BOOSTER_ICON("infinityBoosterIcon", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterIcon")),
|
||||
WIRELESS_CRAFTING_TERMINAL("wirelessCraftingTerminal", new ItemWirelessCraftingTerminal()),
|
||||
WCT_DUMMY_ICON("ae2wctDummyIcon", new ItemAE2WCTDummyIcon()),
|
||||
MAGNET_CARD("magnetCard", new ItemMagnet().setUnlocalizedName("magnetCard")),
|
||||
WCT_BOOSTER_BG_ICON("boosterBG", new ItemBoosterBGIcon());
|
||||
|
||||
private final String internalName;
|
||||
private Item item;
|
||||
public static final ItemEnum[] VALUES = ItemEnum.values();
|
||||
|
||||
private ItemEnum( final String internalName, final Item item )
|
||||
{
|
||||
|
||||
private ItemEnum(final String internalName, final Item item) {
|
||||
this.internalName = internalName;
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public ItemStack getDMGStack( final int damageValue )
|
||||
{
|
||||
return this.getDMGStack( damageValue, 1 );
|
||||
|
||||
public ItemStack getDMGStack(final int damageValue) {
|
||||
return this.getDMGStack(damageValue, 1);
|
||||
}
|
||||
|
||||
public ItemStack getDMGStack( final int damageValue, final int size )
|
||||
{
|
||||
return new ItemStack( this.item, size, damageValue );
|
||||
public ItemStack getDMGStack(final int damageValue, final int size) {
|
||||
return new ItemStack(this.item, size, damageValue);
|
||||
}
|
||||
|
||||
public String getInternalName()
|
||||
{
|
||||
public String getInternalName() {
|
||||
return this.internalName;
|
||||
}
|
||||
|
||||
public Item getItem()
|
||||
{
|
||||
public Item getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return this.getStack( 1 );
|
||||
public ItemStack getStack() {
|
||||
return this.getStack(1);
|
||||
}
|
||||
|
||||
public ItemStack getStack( final int size )
|
||||
{
|
||||
return new ItemStack( this.item, size );
|
||||
public ItemStack getStack(final int size) {
|
||||
return new ItemStack(this.item, size);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,6 @@ public class ItemMagnet extends Item {
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
// @Override
|
||||
public void doMagnet(ItemStack item, World world, EntityPlayer player, ItemStack wirelessTerm) {
|
||||
if (world.isRemote || getItemStack() == null)
|
||||
return;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.items;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -14,6 +15,7 @@ import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -51,7 +53,6 @@ public class ItemWirelessCraftingTerminal extends AEBasePoweredItem implements I
|
||||
|
||||
public ItemWirelessCraftingTerminal() {
|
||||
super(Reference.WCT_MAX_POWER, Optional.<String> absent());
|
||||
//this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
this.setUnlocalizedName("wirelessCraftingTerminal");
|
||||
this.setTextureName(Reference.MODID + ":wirelessCraftingTerminal");
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
@@ -27,6 +27,10 @@ public class ClientProxy extends CommonProxy {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerItems() {
|
||||
// =]
|
||||
}
|
||||
|
||||
public void registerRenderers() {
|
||||
// No renderers...yet =]
|
||||
|
||||
@@ -44,6 +44,7 @@ public class CommonProxy {
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
FMLCommonHandler.instance().bus().register(new ConfigHandler());
|
||||
}
|
||||
|
||||
public void registerItems() {
|
||||
for (ItemEnum item : ItemEnum.VALUES) {
|
||||
GameRegistry.registerItem(item.getItem(), item.getInternalName());
|
||||
@@ -51,10 +52,11 @@ public class CommonProxy {
|
||||
}
|
||||
|
||||
public void removeItemsFromNEI() {
|
||||
// XD
|
||||
}
|
||||
|
||||
public void registerRenderers() {
|
||||
// Ignored server side.
|
||||
// =P
|
||||
}
|
||||
|
||||
public void missingCoreMod() {
|
||||
@@ -125,7 +127,7 @@ public class CommonProxy {
|
||||
ConfigHandler.reloadRecipes();
|
||||
}
|
||||
// Was using this for hidden booster achievement
|
||||
// it was giving me too much of a headache..mayeb
|
||||
// it was giving me too much of a headache..maybe
|
||||
// i'll implement in the future
|
||||
/*
|
||||
AchievementPage achPg = AchievementPage.getAchievementPage("Wireless Crafting Term");
|
||||
@@ -154,6 +156,17 @@ public class CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void pickupEvent(PlayerEvent.ItemPickupEvent e) {
|
||||
if (Reference.WCT_BOOSTER_ENABLED && !Reference.WCT_EASYMODE_ENABLED) {
|
||||
if (e.pickedUp.getEntityItem().getItem() == ItemEnum.BOOSTER_CARD.getItem()) {
|
||||
if (AchievementHandler.isAchievementUnlocked(e.player, wctAch)) {
|
||||
AchievementHandler.triggerAch(boosterAch, e.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerCraftingEvent(final PlayerEvent.ItemCraftedEvent event) {
|
||||
boolean hasWCTAch = ((EntityPlayerMP) event.player).func_147099_x().hasAchievementUnlocked(AchievementHandler.wctAch);
|
||||
@@ -180,7 +193,7 @@ public class CommonProxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void achievementGetEvent(AchievementEvent event) {
|
||||
@@ -194,15 +207,4 @@ public class CommonProxy {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void pickupEvent(PlayerEvent.ItemPickupEvent e) {
|
||||
if (Reference.WCT_BOOSTER_ENABLED && !Reference.WCT_EASYMODE_ENABLED) {
|
||||
if (e.pickedUp.getEntityItem().getItem() == ItemEnum.BOOSTER_CARD.getItem()) {
|
||||
if (AchievementHandler.isAchievementUnlocked(e.player, wctAch)) {
|
||||
AchievementHandler.triggerAch(boosterAch, e.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user