Compare commits

..
6 Commits
Author SHA1 Message Date
Pilzinsel64 8ca820f71c prevent ghostloading (#115)
* prevent ghostloading by MEConduit

* prevent more ghostloading by MEConduit

* spottlessApply

* prevent ghostloading by ConduitUtil
2023-04-01 15:10:20 +02:00
D-Cysteine 4e40230bf3 Try to fix energy overflow (#114) 2023-03-29 17:25:43 +02:00
Pilzinsel64 76708883c0 needUpdateConnections only while updating cons (#113) 2023-03-23 21:12:11 +01:00
Pilzinsel64 0a1ee81780 Add comments for needUpdateConnections (#112)
* imrpove canConnectToExternal()

* needUpdateConnections

* add comments for needUpdateconnections
2023-03-23 06:46:13 +01:00
Pilzinsel64 1fd7ae7567 Improve canConnectToExternal() (#111)
* imrpove canConnectToExternal()

* needUpdateConnections
2023-03-22 23:43:32 +01:00
Pilzinsel64 251fcc26b0 Ultra Dense ME Conduits (#105)
* 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()
2023-03-19 10:35:42 +01:00
8 changed files with 116 additions and 27 deletions

No files matched your search

+4 -4
View File
@@ -1,4 +1,4 @@
//version: 1678003329
//version: 1677938302
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -73,7 +73,7 @@ plugins {
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.2.3'
id 'com.gtnewhorizons.retrofuturagradle' version '1.2.2'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
@@ -153,7 +153,7 @@ java {
} else {
languageVersion.set(projectJavaVersion)
}
vendor.set(JvmVendorSpec.AZUL)
vendor.set(JvmVendorSpec.ADOPTIUM)
}
if (!noPublishedSources) {
withSourcesJar()
@@ -222,7 +222,7 @@ if (enableModernJavaSyntax.toBoolean()) {
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.AZUL)
vendor.set(JvmVendorSpec.ADOPTIUM)
})
}
}
+8 -8
View File
@@ -3,17 +3,17 @@
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.2.13:dev')
implementation('com.github.GTNewHorizons:ForestryMC:4.5.8:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.39-GTNH:dev')
api('com.github.GTNewHorizons:BuildCraft:7.1.31:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.3.35-GTNH:dev')
api('com.github.GTNewHorizons:BuildCraft:7.1.27:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
compileOnly('com.github.GTNewHorizons:waila:1.5.24:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-175-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.13.19:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.11.20-GTNH:api') {transitive = false}
implementation('com.github.GTNewHorizons:Chisel:2.10.17-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.5.23:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-168-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.13.6:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.11.13-GTNH:api') {transitive = false}
implementation('com.github.GTNewHorizons:Chisel:2.10.8-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.8.0.13-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
@@ -84,6 +84,18 @@ public abstract class AbstractConduit implements IConduit {
protected boolean connectionsDirty = true;
/**
* This shows if the currently running connection update should not finish with settings connectionsDirty to false.
* If this is true, it will trigger a reconnection on the next Tick.
* <p>
* Use the method needUpdateConnections() instead of setting this to true.
*
* @see needUpdateConnections()
*/
private boolean needUpdateConnections = false;
private boolean isUpdatingConnections = false;
protected AbstractConduit() {}
@Override
@@ -434,10 +446,13 @@ public abstract class AbstractConduit implements IConduit {
}
private void updateConnections() {
if (!connectionsDirty) {
if (!connectionsDirty && !needUpdateConnections) {
return;
}
isUpdatingConnections = true;
needUpdateConnections = false;
boolean externalConnectionsChanged = false;
List<ForgeDirection> copy = new ArrayList<ForgeDirection>(externalConnections);
// remove any no longer valid connections
@@ -462,6 +477,21 @@ public abstract class AbstractConduit implements IConduit {
}
connectionsDirty = false;
isUpdatingConnections = false;
}
/**
* This method prevents connection update from getting completed successfully by not settings connectionsDirty to
* false. This will trigger an connection update at the next Tick.
* <p>
* Only use this while executing updateConnections().
* <p>
* See this PR for more info: https://github.com/GTNewHorizons/EnderIO/pull/111
*/
protected void needUpdateConnections() {
if (isUpdatingConnections) {
needUpdateConnections = true;
}
}
@Override
@@ -248,7 +248,7 @@ public class ConduitUtil {
public static <T extends IConduit> Collection<T> getConnectedConduits(World world, int x, int y, int z,
Class<T> type) {
TileEntity te = world.getTileEntity(x, y, z);
TileEntity te = world.blockExists(x, y, z) ? world.getTileEntity(x, y, z) : null;
if (!(te instanceof IConduitBundle)) {
return Collections.emptyList();
}
@@ -13,6 +13,7 @@ import net.minecraft.world.World;
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;
@@ -154,7 +155,16 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
public boolean canConnectToExternal(ForgeDirection dir, boolean ignoreDisabled) {
World world = getBundle().getWorld();
BlockCoord pos = getLocation();
TileEntity te = world.getTileEntity(pos.x + dir.offsetX, pos.y + dir.offsetY, pos.z + dir.offsetZ);
final int exactPosX = pos.x + dir.offsetX;
final int exactPosY = pos.y + dir.offsetY;
final int exactPosZ = pos.z + dir.offsetZ;
if (!world.blockExists(exactPosX, exactPosY, exactPosZ)) {
return false;
}
TileEntity te = world.getTileEntity(exactPosX, exactPosY, exactPosZ);
if (te instanceof TileConduitBundle) {
return false;
@@ -162,26 +172,44 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
// 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();
}
if (node == null) {
// The GridNode has not been initialized yet, let's try on the next Tick.
needUpdateConnections();
}
}
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;
@@ -286,7 +314,11 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
private void onNodeChanged(BlockCoord location) {
World world = getBundle().getWorld();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = location.getLocation(dir).getTileEntity(world);
BlockCoord dirLocation = location.getLocation(dir);
TileEntity te = null;
if (world.blockExists(dirLocation.x, dirLocation.y, dirLocation.z)) {
te = location.getLocation(dir).getTileEntity(world);
}
if (te != null && te instanceof IGridHost && !(te instanceof IConduitBundle)) {
IGridNode node = ((IGridHost) te).getGridNode(ForgeDirection.UNKNOWN);
if (node == null) {
@@ -302,7 +334,12 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
@Override
public void onAddedToBundle() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getLocation().getLocation(dir).getTileEntity(getBundle().getWorld());
World world = getBundle().getWorld();
BlockCoord dirLocation = getLocation().getLocation(dir);
TileEntity te = null;
if (world.blockExists(dirLocation.x, dirLocation.y, dirLocation.z)) {
te = dirLocation.getTileEntity(world);
}
if (te instanceof TileConduitBundle) {
IMEConduit cond = ((TileConduitBundle) te).getConduit(IMEConduit.class);
if (cond != null) {
@@ -131,6 +131,10 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (maxReceive < 0) {
return 0;
}
int res = super.receiveEnergy(container, maxReceive, simulate);
if (res != 0 && !simulate) {
updateDamage(container);
@@ -148,6 +152,10 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
}
public int extractEnergyInternal(ItemStack container, int maxExtract, boolean simulate) {
if (maxExtract < 0) {
return 0;
}
int res = super.extractEnergy(container, maxExtract, simulate);
if (res != 0 && !simulate) {
updateDamage(container);
@@ -67,6 +67,12 @@ public class ItemTeleportStaff extends ItemTravelStaff {
return equipped;
}
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
// Don't allow receiving energy, since we have infinite energy.
return 0;
}
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
// Don't allow extracting energy.
@@ -103,6 +103,10 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (maxReceive < 0) {
return 0;
}
int res = super.receiveEnergy(container, maxReceive, simulate);
if (res != 0 && !simulate) {
updateDamage(container);
@@ -112,6 +116,10 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (maxExtract < 0) {
return 0;
}
int res = super.extractEnergy(container, maxExtract, simulate);
if (res != 0 && !simulate) {
updateDamage(container);