From 0d9e6cf32e9fef32e4b5af1eb317da432dd60c7b Mon Sep 17 00:00:00 2001 From: Tschipp <11649893+Tschipp@users.noreply.github.com> Date: Sun, 19 Nov 2023 23:00:43 +0100 Subject: [PATCH] Fixed memory leak, crash with Rats, now compatible with newer forge versions. --- .../client/render/CarriedObjectRender.java | 16 +++++++++------- .../carryon/common/config/CarryConfig.java | 4 ++-- .../tschipp/carryon/events/CommonEvents.java | 2 +- Forge/src/main/resources/META-INF/mods.toml | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Common/src/main/java/tschipp/carryon/client/render/CarriedObjectRender.java b/Common/src/main/java/tschipp/carryon/client/render/CarriedObjectRender.java index f482633..58cea06 100644 --- a/Common/src/main/java/tschipp/carryon/client/render/CarriedObjectRender.java +++ b/Common/src/main/java/tschipp/carryon/client/render/CarriedObjectRender.java @@ -35,6 +35,14 @@ import java.util.Optional; public class CarriedObjectRender { + private static Map builders = Map.of( + RenderType.glint(), new BufferBuilder(RenderType.glint().bufferSize()), + RenderType.glintDirect(), new BufferBuilder(RenderType.glintDirect().bufferSize()), + RenderType.glintTranslucent(), new BufferBuilder(RenderType.glintTranslucent().bufferSize()), + RenderType.entityGlint(), new BufferBuilder(RenderType.entityGlint().bufferSize()), + RenderType.entityGlintDirect(), new BufferBuilder(RenderType.entityGlintDirect().bufferSize()) + ); + public static boolean drawFirstPerson(Player player, MultiBufferSource buffer, PoseStack matrix, int light, float partialTicks) { if(Services.PLATFORM.isModLoaded("firstperson") || Services.PLATFORM.isModLoaded("firstpersonmod")) @@ -159,13 +167,7 @@ public class CarriedObjectRender RenderSystem.enableBlend(); RenderSystem.disableCull(); RenderSystem.disableDepthTest(); - Map builders = Map.of( - RenderType.glint(), new BufferBuilder(RenderType.glint().bufferSize()), - RenderType.glintDirect(), new BufferBuilder(RenderType.glintDirect().bufferSize()), - RenderType.glintTranslucent(), new BufferBuilder(RenderType.glintTranslucent().bufferSize()), - RenderType.entityGlint(), new BufferBuilder(RenderType.entityGlint().bufferSize()), - RenderType.entityGlintDirect(), new BufferBuilder(RenderType.entityGlintDirect().bufferSize()) - ); + BufferSource buffer = MultiBufferSource.immediateWithBuffers(builders, Tesselator.getInstance().getBuilder()); for (Player player : level.players()) diff --git a/Common/src/main/java/tschipp/carryon/common/config/CarryConfig.java b/Common/src/main/java/tschipp/carryon/common/config/CarryConfig.java index 2b85360..8cd5ce0 100644 --- a/Common/src/main/java/tschipp/carryon/common/config/CarryConfig.java +++ b/Common/src/main/java/tschipp/carryon/common/config/CarryConfig.java @@ -248,7 +248,7 @@ public class CarryConfig "mekanismgenerators:wind_generator", "cookingforblockheads:cabinet", "cookingforblockheads:corner", "cookingforblockheads:counter", "cookingforblockheads:oven", "cookingforblockheads:toaster", "cookingforblockheads:milk_jar", "cookingforblockheads:cow_jar", "cookingforblockheads:fruit_basket", "cookingforblockheads:cooking_table", "cookingforblockheads:fridge", "cookingforblockheads:sink", - "powah:*" + "powah:*", "advancementtrophies:trophy", "mekanismgenerators:heat_generator", "mna:filler_block" }; @Property( @@ -261,7 +261,7 @@ public class CarryConfig "minecraft:item_frame", "minecraft:painting", "minecraft:shulker_bullet", "animania:hamster", "animania:ferret*", "animania:hedgehog*", "animania:cart", "animania:wagon", "mynko:*", "pixelmon:*", "mocreatures:*", "quark:totem", "vehicle:*", - "securitycraft:*", "taterzens:npc", "easy_npc:*" + "securitycraft:*", "taterzens:npc", "easy_npc:*", "bodiesbodies:dead_body" }; @Property( diff --git a/Forge/src/main/java/tschipp/carryon/events/CommonEvents.java b/Forge/src/main/java/tschipp/carryon/events/CommonEvents.java index 32f8138..0b9295a 100644 --- a/Forge/src/main/java/tschipp/carryon/events/CommonEvents.java +++ b/Forge/src/main/java/tschipp/carryon/events/CommonEvents.java @@ -77,7 +77,7 @@ public class CommonEvents } else { PlacementHandler.tryPlaceEntity((ServerPlayer) player, pos, event.getFace(), (pPos, toPlace) -> { if (toPlace instanceof Mob mob) { - FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, null, MobSpawnType.EVENT, null, null, null); + FinalizeSpawn checkSpawn = new FinalizeSpawn(mob, (ServerLevelAccessor) level, pPos.x, pPos.y, pPos.z, level.getCurrentDifficultyAt(new BlockPos((int) pPos.x, (int) pPos.y, (int) pPos.z)), MobSpawnType.EVENT, null, null, null); MinecraftForge.EVENT_BUS.post(checkSpawn); return event.getResult() != Result.DENY; } diff --git a/Forge/src/main/resources/META-INF/mods.toml b/Forge/src/main/resources/META-INF/mods.toml index 32012ad..a1b6e24 100644 --- a/Forge/src/main/resources/META-INF/mods.toml +++ b/Forge/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ issueTrackerURL="https://github.com/Tschipp/CarryOn/issues" # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[46,47.1.47]" #mandatory + versionRange="[46,47.1.3],[47.1.43,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER