From 82007f627fe2ef94b703c05642add404cd376c88 Mon Sep 17 00:00:00 2001 From: QuImUfu Date: Tue, 27 Jun 2023 23:47:05 +0200 Subject: [PATCH] test and fix multiplayer --- .../ColourfulPortalsMod.java | 13 +------- .../ColourfulPortalsModClient.java | 16 ++++++++++ .../portal/PortalListComponent.java | 2 +- .../portal/PortalManager.java | 2 +- .../quimufu/colourful_portals/util/Pair.java | 32 +++++++++++++++++++ src/main/resources/fabric.mod.json | 2 +- 6 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 src/main/java/quimufu/colourful_portals/ColourfulPortalsModClient.java create mode 100644 src/main/java/quimufu/colourful_portals/util/Pair.java diff --git a/src/main/java/quimufu/colourful_portals/ColourfulPortalsMod.java b/src/main/java/quimufu/colourful_portals/ColourfulPortalsMod.java index a4d435e..45890c1 100644 --- a/src/main/java/quimufu/colourful_portals/ColourfulPortalsMod.java +++ b/src/main/java/quimufu/colourful_portals/ColourfulPortalsMod.java @@ -1,16 +1,12 @@ package quimufu.colourful_portals; -import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; -import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.BlockState; import net.minecraft.block.enums.Instrument; -import net.minecraft.client.render.RenderLayer; import net.minecraft.entity.EntityType; import net.minecraft.item.*; import net.minecraft.registry.Registries; @@ -22,7 +18,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import quimufu.colourful_portals.client.PortalFluidRenderHandler; import quimufu.colourful_portals.config.ColourfulPortalConfig; import quimufu.colourful_portals.portal_fluid.PortalFluid; import quimufu.colourful_portals.portal_fluid.PortalFluidBlock; @@ -30,7 +25,7 @@ import quimufu.colourful_portals.portal_fluid.PortalFluidBucketItem; import java.util.HashSet; -public class ColourfulPortalsMod implements ModInitializer, ClientModInitializer { +public class ColourfulPortalsMod implements ModInitializer { public static final String MOD_ID = "colourful_portals"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); @@ -91,10 +86,4 @@ public class ColourfulPortalsMod implements ModInitializer, ClientModInitializer content.add(BLOB_DARK); } - public void onInitializeClient() { - BlockRenderLayerMap.INSTANCE.putBlock(PORTAL_BLOCK, RenderLayer.getTranslucent()); - BlockRenderLayerMap.INSTANCE.putFluid(PORTAL_FLUID, RenderLayer.getTranslucent()); - FluidRenderHandlerRegistry.INSTANCE.register(PORTAL_FLUID, new PortalFluidRenderHandler()); - } - } \ No newline at end of file diff --git a/src/main/java/quimufu/colourful_portals/ColourfulPortalsModClient.java b/src/main/java/quimufu/colourful_portals/ColourfulPortalsModClient.java new file mode 100644 index 0000000..aba2fed --- /dev/null +++ b/src/main/java/quimufu/colourful_portals/ColourfulPortalsModClient.java @@ -0,0 +1,16 @@ +package quimufu.colourful_portals; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; +import net.minecraft.client.render.RenderLayer; +import quimufu.colourful_portals.client.PortalFluidRenderHandler; + +public class ColourfulPortalsModClient implements ClientModInitializer { + public void onInitializeClient() { + BlockRenderLayerMap.INSTANCE.putBlock(ColourfulPortalsMod.PORTAL_BLOCK, RenderLayer.getTranslucent()); + BlockRenderLayerMap.INSTANCE.putFluid(ColourfulPortalsMod.PORTAL_FLUID, RenderLayer.getTranslucent()); + FluidRenderHandlerRegistry.INSTANCE.register(ColourfulPortalsMod.PORTAL_FLUID, new PortalFluidRenderHandler()); + } + +} \ No newline at end of file diff --git a/src/main/java/quimufu/colourful_portals/portal/PortalListComponent.java b/src/main/java/quimufu/colourful_portals/portal/PortalListComponent.java index 0c2dc95..66828f3 100644 --- a/src/main/java/quimufu/colourful_portals/portal/PortalListComponent.java +++ b/src/main/java/quimufu/colourful_portals/portal/PortalListComponent.java @@ -1,6 +1,5 @@ package quimufu.colourful_portals.portal; -import com.ibm.icu.impl.Pair; import dev.onyxstudios.cca.api.v3.component.Component; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; @@ -10,6 +9,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldProperties; +import quimufu.colourful_portals.util.Pair; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/quimufu/colourful_portals/portal/PortalManager.java b/src/main/java/quimufu/colourful_portals/portal/PortalManager.java index 3f24b94..ec5d95e 100644 --- a/src/main/java/quimufu/colourful_portals/portal/PortalManager.java +++ b/src/main/java/quimufu/colourful_portals/portal/PortalManager.java @@ -1,6 +1,5 @@ package quimufu.colourful_portals.portal; -import com.ibm.icu.impl.Pair; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -18,6 +17,7 @@ import qouteall.imm_ptl.core.api.PortalAPI; import qouteall.imm_ptl.core.portal.Portal; import qouteall.q_misc_util.my_util.DQuaternion; import quimufu.colourful_portals.config.ColourfulPortalConfig; +import quimufu.colourful_portals.util.Pair; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/quimufu/colourful_portals/util/Pair.java b/src/main/java/quimufu/colourful_portals/util/Pair.java new file mode 100644 index 0000000..90a63d2 --- /dev/null +++ b/src/main/java/quimufu/colourful_portals/util/Pair.java @@ -0,0 +1,32 @@ +package quimufu.colourful_portals.util; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import java.util.Objects; + +public class Pair { + + public final A first; + public final B second; + public Pair(A first, B second) { + this.first = first; + this.second = second; + } + public static Pair of(A first, B second) { + return new Pair<>(first,second); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pair pair = (Pair) o; + return Objects.equals(first, pair.first) && Objects.equals(second, pair.second); + } + + @Override + public int hashCode() { + return Objects.hash(first, second); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4dcf57c..909e935 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,7 +19,7 @@ "quimufu.colourful_portals.ColourfulPortalsMod" ], "client": [ - "quimufu.colourful_portals.ColourfulPortalsMod" + "quimufu.colourful_portals.ColourfulPortalsModClient" ], "cardinal-components": [ "quimufu.colourful_portals.Components"