mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-24 05:54:27 +00:00
Merge pull request #2996 from spacebuilder2020/master
Updated createNetworkForType() based on comments from #2944
This commit is contained in:
commit
83134ded2e
3 files changed
+27
-24
No files matched your search
@@ -603,5 +603,28 @@ public abstract class AbstractConduit implements IConduit {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractConduitNetwork<?, ?> createNetworkForType()
|
||||
{
|
||||
Class<? extends IConduit> type = this.getClass();
|
||||
if(IRedstoneConduit.class.isAssignableFrom(type)) {
|
||||
return new RedstoneConduitNetwork();
|
||||
} else if(IPowerConduit.class.isAssignableFrom(type)) {
|
||||
return new PowerConduitNetwork();
|
||||
} else if(EnderLiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new EnderLiquidConduitNetwork();
|
||||
} else if(AdvancedLiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new AdvancedLiquidConduitNetwork();
|
||||
} else if(ILiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new LiquidConduitNetwork();
|
||||
} else if(IItemConduit.class.isAssignableFrom(type)) {
|
||||
return new ItemConduitNetwork();
|
||||
} else if(IGasConduit.class.isAssignableFrom(type)) {
|
||||
return new GasConduitNetwork();
|
||||
} else if(IMEConduit.class.isAssignableFrom(type)) {
|
||||
return new MEConduitNetwork();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,28 +59,6 @@ public class ConduitUtil {
|
||||
|
||||
public static final Random RANDOM = new Random();
|
||||
|
||||
public static AbstractConduitNetwork<?, ?> createNetworkForType(Class<? extends IConduit> type) {
|
||||
if(IRedstoneConduit.class.isAssignableFrom(type)) {
|
||||
return new RedstoneConduitNetwork();
|
||||
} else if(IPowerConduit.class.isAssignableFrom(type)) {
|
||||
return new PowerConduitNetwork();
|
||||
} else if(EnderLiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new EnderLiquidConduitNetwork();
|
||||
} else if(AdvancedLiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new AdvancedLiquidConduitNetwork();
|
||||
} else if(ILiquidConduit.class.isAssignableFrom(type)) {
|
||||
return new LiquidConduitNetwork();
|
||||
} else if(IItemConduit.class.isAssignableFrom(type)) {
|
||||
return new ItemConduitNetwork();
|
||||
} else if(IGasConduit.class.isAssignableFrom(type)) {
|
||||
return new GasConduitNetwork();
|
||||
} else if(IMEConduit.class.isAssignableFrom(type)) {
|
||||
return new MEConduitNetwork();
|
||||
}
|
||||
FMLCommonHandler.instance().raiseException(new Exception("Could not determine network type for class " + type), "ConduitUtil.createNetworkForType", false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void ensureValidNetwork(IConduit conduit) {
|
||||
TileEntity te = conduit.getBundle().getEntity();
|
||||
@@ -91,7 +69,7 @@ public class ConduitUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractConduitNetwork res = createNetworkForType(conduit.getClass());
|
||||
AbstractConduitNetwork res = conduitcreateNetworkForType();
|
||||
res.init(conduit.getBundle(), connections, world);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,5 +134,7 @@ public interface IConduit {
|
||||
boolean writeConnectionSettingsToNBT(ForgeDirection dir, NBTTagCompound nbt);
|
||||
|
||||
boolean readConduitSettingsFromNBT(ForgeDirection dir, NBTTagCompound nbt);
|
||||
|
||||
public AbstractConduitNetwork<?, ?> createNetworkForType();
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user