From c284748b6c9e68b2d17d28bc0f93fc81220af217 Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Thu, 2 Sep 2021 19:28:04 -0300 Subject: [PATCH] fix p2p not updating properly on memory card loading --- gradle.properties | 2 +- .../java/appeng/parts/p2p/PartP2PTunnel.java | 31 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 51f9c154e..3beb812cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ aechannel=stable aebuild=7 aegroup=appeng aebasename=appliedenergistics2 -trousers=omni-fixes-v46n +trousers=omni-fixes-v46o ######################################################### # Versions # diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index 6271684ed..d591506ee 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -350,9 +350,25 @@ public abstract class PartP2PTunnel extends PartBasicSt if( needsNewFrequency ) { newFreq = this.getProxy().getP2P().newFrequency(); - } - this.getProxy().getP2P().updateFreq( this, newFreq ); + final ItemStack newType = new ItemStack( data ); + + this.getHost().removePart( this.getSide(), false ); + final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player, hand ); + final IPart newBus = this.getHost().getPart( dir ); + + if( newBus instanceof PartP2PTunnel ) + { + final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; + newTunnel.setOutput( false ); + newTunnel.onTunnelNetworkChange(); + newTunnel.getProxy().getP2P().updateFreq( newTunnel, newFreq ); + } + } + else + { + this.getProxy().getP2P().updateFreq( this, newFreq ); + } } catch( final GridAccessException e ) { @@ -365,10 +381,17 @@ public abstract class PartP2PTunnel extends PartBasicSt final String type = p2pItem.getUnlocalizedName(); p2pItem.writeToNBT( data ); - data.setShort( "freq", this.getFrequency() ); + if( needsNewFrequency ) + { + data.setShort( "freq", newFreq ); + } + else + { + data.setShort( "freq", this.getFrequency() ); + } final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() ); - final int[] colorCode = new int[] { + final int[] colorCode = new int[]{ colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(), colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(), };