Skip to content

Commit

Permalink
Fix connection for Forge clients
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Nov 4, 2023
1 parent 9320a50 commit db42ff2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@
import org.spongepowered.common.bridge.core.RegistryBridge;
import org.spongepowered.common.registry.SpongeRegistryEntry;
import org.spongepowered.common.registry.SpongeRegistryType;
import org.spongepowered.forge.bridge.minecraftforge.registries.ForgeRegistryBridge;

import java.util.Map;
import java.util.StringJoiner;

@Mixin(ForgeRegistry.class)
public abstract class ForgeRegistryMixin_Forge<V> implements ForgeRegistryBridge<V> {
public abstract class ForgeRegistryMixin_Forge<V> {

// @formatter:off
@Shadow @Final private net.minecraft.resources.ResourceKey<Registry<V>> key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,30 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.forge.bridge.minecraftforge.registries;
package org.spongepowered.forge.mixin.core.minecraftforge.registries;

import org.spongepowered.common.bridge.core.RegistryBridge;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.RegistryManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

public interface ForgeRegistryBridge<T> {
import java.util.Map;

RegistryBridge<T> bridge$parent();
@Mixin(RegistryManager.class)
public class RegistryManagerMixin_Forge {

@SuppressWarnings("UnstableApiUsage")
@Inject(method = "takeSnapshot", at = @At("RETURN"))
public void forge$dontSendSpongeDataToClient(boolean savingToDisc, CallbackInfoReturnable<Map<ResourceLocation, ForgeRegistry.Snapshot>> cir) {
if (savingToDisc) {
return;
}

for (ForgeRegistry.Snapshot snapshot : cir.getReturnValue().values()) {
snapshot.ids.keySet().removeIf(loc -> loc.getNamespace().equals("sponge"));
}
}
}
3 changes: 2 additions & 1 deletion forge/src/mixins/resources/mixins.spongeforge.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"api.event.entity.ChangeEventWorldEvent_PostMixin_Forge",
"commands.CommandsMixin_Forge",
"minecraftforge.MinecraftForgeMixin_Forge",
"minecraftforge.registries.ForgeRegistryMixin_Forge",
"minecraftforge.event.entity.EntityTravelToDimensionEventMixin_Forge",
"minecraftforge.event.entity.player.PlayerEvent_PlayerChangedDimensionEventMixin_Forge",
"minecraftforge.event.world.BlockEvent_BreakEventMixin_Forge",
"minecraftforge.event.world.BlockEventMixin_Forge",
"minecraftforge.internal.BrandingControlMixin_Forge",
"minecraftforge.network.NetworkHooksMixin_Forge",
"minecraftforge.registries.ForgeRegistryMixin_Forge",
"minecraftforge.registries.RegistryManagerMixin_Forge",
"minecraftforge.util.ITeleporterMixin_Forge",
"network.ConnectionMixin_Forge",
"network.FriendlyByteBufMixin_Forge",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.service.ban.Ban;
import org.spongepowered.api.service.ban.BanService;
import org.spongepowered.common.SpongeCommon;
import org.spongepowered.common.util.BanUtil;
import org.spongepowered.common.util.NetworkUtil;

Expand Down Expand Up @@ -63,7 +64,10 @@ protected boolean contains(final String entry) {
try {
return Sponge.server().serviceProvider().banService().find(InetAddress.getByName(entry)).join().isPresent();
} catch (final UnknownHostException e) {
throw new IllegalArgumentException("Error parsing Ban IP address!", e);
// TODO SF 1.19.4
SpongeCommon.logger().info("Error parsing Ban IP address!", e);
return false;
// throw new IllegalArgumentException("Error parsing Ban IP address!", e);
}
}

Expand Down

0 comments on commit db42ff2

Please sign in to comment.