Skip to content

Commit

Permalink
Ultra Dense ME Conduits (#105)
Browse files Browse the repository at this point in the history
* basic MEConduit DenseUltra implementation

* add assets for ME Conduit Dense Ultra

* fix icon array count

* fix previous commit

* finalize ultra dense me conduits

* add configu for Ultra Dense ME Conduits

* edit texture a little bit more

* adjust meConduitCoreDenseUltra.png

* fix enableMEUltraDenseConduits

* spottlessApply

* fix texture

* improve canConnectToExternal()
  • Loading branch information
Pilzinsel64 authored Mar 19, 2023
1 parent b22915c commit 251fcc2
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 20 deletions.
7 changes: 6 additions & 1 deletion src/main/java/crazypants/enderio/conduit/ConduitRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ private static void addAeRecipes() {
addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber);

res.stackSize = 1;
addShaped(new ItemStack(EnderIO.itemMEConduit, 1, 1), "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res);
ItemStack resDense = new ItemStack(EnderIO.itemMEConduit, 1, 1);
ItemStack resUltra = new ItemStack(EnderIO.itemMEConduit, 1, 2);
addShaped(resDense, "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res);
if (Config.enableMEUltraDenseConduits) {
addShaped(resUltra, "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', resDense);
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/crazypants/enderio/conduit/me/IMEConduit.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public interface IMEConduit extends IConduit {

boolean isDense();

boolean isDenseUltra();

int getChannelsInUse();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class ItemMEConduit extends AbstractItemConduit {

private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
new ItemConduitSubtype(ModObject.itemMEConduit.name(), "enderio:itemMeConduit"),
new ItemConduitSubtype(ModObject.itemMEConduit.name() + "Dense", "enderio:itemMeConduitDense") };
new ItemConduitSubtype(ModObject.itemMEConduit.name() + "Dense", "enderio:itemMeConduitDense"),
new ItemConduitSubtype(ModObject.itemMEConduit.name() + "DenseUltra", "enderio:itemMeConduitDenseUltra") };

public static ItemMEConduit create() {
ItemMEConduit result = new ItemMEConduit();
Expand Down
66 changes: 50 additions & 16 deletions src/main/java/crazypants/enderio/conduit/me/MEConduit.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraftforge.common.util.ForgeDirection;

import appeng.api.AEApi;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
Expand Down Expand Up @@ -44,13 +45,15 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
public static IIcon[] longTextures;

private boolean isDense;
private boolean isDenseUltra;
private int playerID = -1;

public MEConduit() {
this(0);
}

public MEConduit(int itemDamage) {
isDenseUltra = itemDamage == 2;
isDense = itemDamage == 1;
}

Expand All @@ -59,14 +62,16 @@ public static void initIcons() {

@Override
public void registerIcons(IIconRegister register) {
coreTextures = new IIcon[2];
longTextures = new IIcon[2];
coreTextures = new IIcon[3];
longTextures = new IIcon[3];

coreTextures[0] = register.registerIcon(EnderIO.DOMAIN + ":meConduitCore");
coreTextures[1] = register.registerIcon(EnderIO.DOMAIN + ":meConduitCoreDense");
coreTextures[2] = register.registerIcon(EnderIO.DOMAIN + ":meConduitCoreDenseUltra");

longTextures[0] = register.registerIcon(EnderIO.DOMAIN + ":meConduit");
longTextures[1] = register.registerIcon(EnderIO.DOMAIN + ":meConduitDense");
longTextures[2] = register.registerIcon(EnderIO.DOMAIN + ":meConduitDenseUltra");
}

@Override
Expand All @@ -76,8 +81,14 @@ public int getTextureType() {
});
}

public static int getDamageForState(boolean isDense) {
return isDense ? 1 : 0;
public static int getDamageForState(boolean isDense, boolean isDenseUltra) {
if (isDenseUltra) {
return 2;
}
if (isDense) {
return 1;
}
return 0;
}

@Override
Expand All @@ -87,7 +98,7 @@ public Class<? extends IConduit> getBaseConduitType() {

@Override
public ItemStack createItem() {
return new ItemStack(EnderIO.itemMEConduit, 1, getDamageForState(isDense));
return new ItemStack(EnderIO.itemMEConduit, 1, getDamageForState(isDense, isDenseUltra));
}

@Override
Expand All @@ -105,6 +116,7 @@ public boolean setNetwork(AbstractConduitNetwork<?, ?> network) {
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
nbtRoot.setBoolean("isDense", isDense);
nbtRoot.setBoolean("isDenseUltra", isDenseUltra);
nbtRoot.setInteger("playerID", playerID);
}

Expand All @@ -117,6 +129,9 @@ public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
} else {
playerID = -1;
}
if (nbtRoot.hasKey("isDenseUltra")) {
isDenseUltra = nbtRoot.getBoolean("isDenseUltra");
}
}

public void setPlayerID(int playerID) {
Expand Down Expand Up @@ -148,34 +163,48 @@ public boolean canConnectToExternal(ForgeDirection dir, boolean ignoreDisabled)

// because the AE2 API doesn't allow an easy query like "which side can connect to an ME cable" it needs this
// mess
IGridNode node = null;
if (te instanceof IPartHost) {
IPart part = ((IPartHost) te).getPart(dir.getOpposite());
if (part == null) {
part = ((IPartHost) te).getPart(ForgeDirection.UNKNOWN);
return part != null;
}
if (part.getExternalFacingNode() != null) {
return true;
if (part != null) {
node = part.getExternalFacingNode();
if (node == null) {
node = part.getGridNode();
}
}
String name = part.getClass().getSimpleName();
return "PartP2PTunnelME".equals(name) || "PartQuartzFiber".endsWith(name)
|| "PartToggleBus".equals(name)
|| "PartInvertedToggleBus".equals(name);
} else if (te instanceof IGridHost) {
IGridNode node = ((IGridHost) te).getGridNode(dir.getOpposite());
node = ((IGridHost) te).getGridNode(dir.getOpposite());
if (node == null) {
node = ((IGridHost) te).getGridNode(ForgeDirection.UNKNOWN);
}
if (node != null) {
return node.getGridBlock().getConnectableSides().contains(dir.getOpposite());
}
if (node != null) {
return canConnectToGridNode(node, dir);
}
return false;
}

@Method(modid = "appliedenergistics2")
private Boolean canConnectToGridNode(IGridNode node, ForgeDirection dir) {
if (node.getGridBlock().getConnectableSides().contains(dir.getOpposite())) {
if (isDenseUltra()) {
return node.hasFlag(GridFlags.ULTRA_DENSE_CAPACITY)
|| ((node.hasFlag(GridFlags.DENSE_CAPACITY)) && !node.hasFlag(GridFlags.CANNOT_CARRY));
} else if (isDense()) {
return true;
} else {
return !node.hasFlag(GridFlags.ULTRA_DENSE_CAPACITY);
}
}
return false;
}

@Override
public IIcon getTextureForState(CollidableComponent component) {
int state = getDamageForState(isDense);
int state = getDamageForState(isDense, isDenseUltra);
if (component.dir == ForgeDirection.UNKNOWN) {
return coreTextures[state];
} else {
Expand Down Expand Up @@ -343,4 +372,9 @@ public EnumSet<ForgeDirection> getConnections() {
public boolean isDense() {
return isDense;
}

@Override
public boolean isDenseUltra() {
return isDenseUltra;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public ItemStack getMachineRepresentation() {

@Override
public EnumSet<GridFlags> getFlags() {
return conduit.isDense() ? EnumSet.of(GridFlags.DENSE_CAPACITY) : EnumSet.noneOf(GridFlags.class);
if (conduit.isDenseUltra()) {
return EnumSet.of(GridFlags.ULTRA_DENSE_CAPACITY);
}
if (conduit.isDense()) {
return EnumSet.of(GridFlags.DENSE_CAPACITY);
}
return EnumSet.noneOf(GridFlags.class);
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/crazypants/enderio/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ public String lc() {

public static boolean isGasConduitEnabled = true;
public static boolean enableMEConduits = true;
public static boolean enableMEUltraDenseConduits = false;
public static boolean enableOCConduits = true;
public static boolean enableOCConduitsAnimatedTexture = true;

Expand Down Expand Up @@ -2298,6 +2299,11 @@ public static void processConfig(Configuration config) {
sectionItems.name,
enableMEConduits,
"Allows ME conduits. Only has an effect with AE2 installed.");
enableMEUltraDenseConduits = config.getBoolean(
"enableMEUltraDenseConduits",
sectionItems.name,
enableMEUltraDenseConduits,
"Allows ME Ultra Dense conduits. Only has an effect with AE2 installed.");
enableOCConduits = config.getBoolean(
"enableOCConduits",
sectionItems.name,
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/crazypants/enderio/waila/WailaCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,14 @@ private void getWailaBodyConduitBundle(ItemStack itemStack, List<String> current
} else if (itemStack.getItem() == EnderIO.itemMEConduit) {
NBTTagCompound nbtRoot = _accessor.getNBTData();
if (nbtRoot.hasKey("isDense")) {
boolean isDenseUltra = nbtRoot.getBoolean("isDenseUltra");
boolean isDense = nbtRoot.getBoolean("isDense");
int channelsInUse = nbtRoot.getInteger("channelsInUse");
currenttip.add(
MessageFormat.format(
EnderIO.lang.localize("itemMEConduit.channelsUsed"),
channelsInUse,
isDense ? 32 : 8));
isDenseUltra ? 128 : (isDense ? 32 : 8)));
}
}
}
Expand Down Expand Up @@ -395,6 +396,7 @@ public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCom
if (mec != null) {
tag.setInteger("channelsInUse", mec.getChannelsInUse());
tag.setBoolean("isDense", mec.isDense());
tag.setBoolean("isDenseUltra", mec.isDenseUltra());
}
} else if (te instanceof IInternalPoweredTile) {
IInternalPoweredTile ipte = (IInternalPoweredTile) te;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/enderio/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ enderio.itemGasConduit.tooltip.detailed.line1=Transportiert Mekanism-kompatible

enderio.itemMEConduit.name=ME-Leitung
enderio.itemMEConduitDense.name=Dichte ME-Leitung
enderio.itemMEConduitDenseUltra.name=Extrem Dichte ME-Leitungen
enderio.itemMEConduit.channelsUsed={0,number} von {1,number} Kanälen

enderio.itemOCConduit.name=Netzwerkleitung (OC)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/enderio/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ enderio.itemGasConduit.tooltip.detailed.line1=Transfers Mekanism-compatible gase

enderio.itemMEConduit.name=ME Conduit
enderio.itemMEConduitDense.name=Dense ME Conduit
enderio.itemMEConduitDenseUltra.name=Ultra Dense ME Conduit
enderio.itemMEConduit.channelsUsed={0,number} of {1,number} Channels

enderio.itemOCConduit.name=Network Conduit (OC)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 251fcc2

Please sign in to comment.