mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 23:13:21 +00:00
Add IRedstoneConnectable to API to allow forced rs conduit connections
This commit is contained in:
1 parent
370f783373
commit
a8d734ddbb
7 files changed
+69
-33
No files matched your search
@@ -4,6 +4,6 @@ public final class EnderIOAPIProps {
|
||||
|
||||
private EnderIOAPIProps() {}
|
||||
|
||||
public static final String VERSION = "0.0.1";
|
||||
public static final String VERSION = "0.0.2";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package crazypants.enderio.api.redstone;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this on your Block or TileEntity to control whether insulated
|
||||
* restone conduits will automatically connect to your block.
|
||||
* <p>
|
||||
* Implementing on both is not recommended and will likely not work as expected.
|
||||
*/
|
||||
public interface IRedstoneConnectable {
|
||||
|
||||
boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@API(apiVersion = EnderIOAPIProps.VERSION, owner = "EnderIO", provides = "EnderIOAPI|Redstone")
|
||||
package crazypants.enderio.api.redstone;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
import crazypants.enderio.api.EnderIOAPIProps;
|
||||
|
||||
@@ -24,6 +24,7 @@ import cofh.api.tileentity.IRedstoneControl;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.api.redstone.IRedstoneConnectable;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
@@ -281,31 +282,26 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
}
|
||||
//Not set so figure it out
|
||||
BlockCoord loc = getLocation().getLocation(direction);
|
||||
Block block = getBundle().getEntity().getWorldObj().getBlock(loc.x, loc.y, loc.z);
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
Block block = world.getBlock(loc.x, loc.y, loc.z);
|
||||
TileEntity te = world.getTileEntity(loc.x, loc.y, loc.z);
|
||||
|
||||
if(block == null || block == EnderIO.blockConduitBundle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(VANILLA_CONECTABLES.contains(block)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(block == EnderIO.blockConduitBundle) {
|
||||
return false;
|
||||
|
||||
if (block instanceof IRedstoneConnectable) {
|
||||
return ((IRedstoneConnectable) block).shouldRedstoneConduitConnect(world, loc.x, loc.y, loc.z, direction);
|
||||
}
|
||||
|
||||
if(block == EnderIO.blockCapacitorBank) {
|
||||
return true;
|
||||
|
||||
if (te instanceof IRedstoneConnectable) {
|
||||
return ((IRedstoneConnectable) te).shouldRedstoneConduitConnect(world, loc.x, loc.y, loc.z, direction);
|
||||
}
|
||||
|
||||
if(block == EnderIO.blockElectricLight) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = getBundle().getEntity().getWorldObj();
|
||||
TileEntity te = world.getTileEntity(loc.x, loc.y, loc.z);
|
||||
|
||||
Map<Class<?>, Boolean> connectableInterfaces = getConnectableInterfaces();
|
||||
for(Class<?> connectable : connectableInterfaces.keySet()) {
|
||||
if((te != null && connectable.isAssignableFrom(te.getClass())) || (connectable.isAssignableFrom(block.getClass()))) {
|
||||
@@ -320,7 +316,6 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
if(CONNECTABLE_CLASSES == null) {
|
||||
CONNECTABLE_CLASSES = new HashMap<Class<?>, Boolean>();
|
||||
CONNECTABLE_CLASSES.put(IRedstoneControl.class, false);
|
||||
CONNECTABLE_CLASSES.put(AbstractMachineEntity.class, false);
|
||||
try{
|
||||
Class<?> conInterface = Class.forName("powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection");
|
||||
CONNECTABLE_CLASSES.put(conInterface, false);
|
||||
|
||||
@@ -14,20 +14,22 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.TileEntityEio;
|
||||
import crazypants.enderio.api.redstone.IRedstoneConnectable;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.InventoryWrapper;
|
||||
import crazypants.util.ItemUtil;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public abstract class AbstractMachineEntity extends TileEntityEio implements ISidedInventory, IMachine, IRedstoneModeControlable,
|
||||
IIoConfigurable {
|
||||
public abstract class AbstractMachineEntity extends TileEntityEio implements ISidedInventory, IMachine, IRedstoneModeControlable,
|
||||
IRedstoneConnectable, IIoConfigurable {
|
||||
|
||||
public short facing;
|
||||
|
||||
@@ -64,7 +66,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
public AbstractMachineEntity(SlotDefinition slotDefinition) {
|
||||
this.slotDefinition = slotDefinition;
|
||||
facing = 3;
|
||||
|
||||
|
||||
inventory = new ItemStack[slotDefinition.getNumSlots()];
|
||||
redstoneControlMode = RedstoneControlMode.IGNORE;
|
||||
soundRes = getSoundFor(getSoundName());
|
||||
@@ -102,7 +104,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
faceModes.put(faceHit, mode);
|
||||
forceClientUpdate = true;
|
||||
notifyNeighbours = true;
|
||||
|
||||
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
@@ -224,8 +226,6 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Process Loop
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -275,8 +275,6 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
|
||||
requiresClientSync |= processTasks(redstoneCheckPassed);
|
||||
|
||||
|
||||
|
||||
if(requiresClientSync) {
|
||||
|
||||
// this will cause 'getPacketDescription()' to be called and its result
|
||||
@@ -324,6 +322,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
|
||||
BlockCoord loc = getLocation().getLocation(dir);
|
||||
TileEntity te = worldObj.getTileEntity(loc.x, loc.y, loc.z);
|
||||
|
||||
if(te == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -602,8 +601,6 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
@@ -669,5 +666,11 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
public void onNeighborBlockChange(Block blockId) {
|
||||
redstoneStateDirty = true;
|
||||
}
|
||||
|
||||
|
||||
/* IRedstoneConnectable */
|
||||
|
||||
@Override
|
||||
public boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.api.redstone.IRedstoneConnectable;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
@@ -52,7 +53,7 @@ import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTooltipProvider, IWailaInfoProvider {
|
||||
public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTooltipProvider, IWailaInfoProvider, IRedstoneConnectable {
|
||||
|
||||
public static int renderId = -1;
|
||||
|
||||
@@ -574,4 +575,11 @@ public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTool
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.BIT_DETAILED;
|
||||
}
|
||||
|
||||
/* IRedstoneConnectable */
|
||||
|
||||
@Override
|
||||
public boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,12 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.api.redstone.IRedstoneConnectable;
|
||||
import crazypants.enderio.api.tool.ITool;
|
||||
import crazypants.enderio.tool.ToolUtil;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
public class BlockElectricLight extends BlockEio {
|
||||
public class BlockElectricLight extends BlockEio implements IRedstoneConnectable {
|
||||
|
||||
static final float BLOCK_HEIGHT = 0.05f;
|
||||
static final float BLOCK_WIDTH = 0.3f;
|
||||
@@ -268,4 +269,11 @@ public class BlockElectricLight extends BlockEio {
|
||||
}
|
||||
return new ItemStack(this);
|
||||
}
|
||||
|
||||
/* IRedstoneConnectable */
|
||||
|
||||
@Override
|
||||
public boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user