From 29abbe4b25cdd1c0c1aa507643653ef8c822944f Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 24 Jul 2024 22:42:49 -0400 Subject: [PATCH 1/8] refactor: Rewrote mixins to not use @Redirect and LocalCapture --- .../client/EntityRenderDispatcherMixin.java | 26 ++-- .../mixin/client/GameRendererMixin.java | 11 +- .../mixin/client/PonderRegistryMixin.java | 22 +-- .../compat/create/AllSoundEventsMixin.java | 9 +- .../mixin/compat/create/ContraptionMixin.java | 140 +++++++++--------- .../create/MechanicalPistonBlockMixin.java | 9 +- .../compat/create/PistonContraptionMixin.java | 35 ++--- .../compat/create/PulleyBlockEntityMixin.java | 41 +++-- .../fabric/mixin/ArmTileEntityMixin.java | 10 +- 9 files changed, 146 insertions(+), 157 deletions(-) diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/EntityRenderDispatcherMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/EntityRenderDispatcherMixin.java index 8b822456c..106a8b32d 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/EntityRenderDispatcherMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/EntityRenderDispatcherMixin.java @@ -1,32 +1,28 @@ package rbasamoyai.createbigcannons.mixin.client; -import com.mojang.blaze3d.vertex.PoseStack; +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.CallbackInfo; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; import net.minecraft.client.renderer.MultiBufferSource; - -import net.minecraft.util.Mth; - -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.Redirect; - import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; - -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity; @Mixin(EntityRenderDispatcher.class) public class EntityRenderDispatcherMixin { - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isInvisible()Z", ordinal = 0)) - private boolean createbigcannons$render$isInvisible(Entity instance) { - return instance.isInvisible() || instance.getVehicle() instanceof PitchOrientedContraptionEntity poce && poce.getSeatPos(instance) != null; + @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isInvisible()Z", ordinal = 0)) + private boolean createbigcannons$render$isInvisible(Entity instance, Operation original) { + return original.call(instance) || instance.getVehicle() instanceof PitchOrientedContraptionEntity poce && poce.getSeatPos(instance) != null; } @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderDispatcher;renderHitbox(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/entity/Entity;F)V")) diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java index ef652a22f..b1e99c136 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java @@ -8,9 +8,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import com.mojang.blaze3d.shaders.Program; +import com.llamalad7.mixinextras.sugar.Local; import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.GameRenderer; @@ -21,11 +20,9 @@ @Mixin(GameRenderer.class) public class GameRendererMixin { - @Inject(method = "reloadShaders", - at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53), - locals = LocalCapture.CAPTURE_FAILHARD) - private void reloadShaders(ResourceManager resourceManager, CallbackInfo ci, List programs, - List>> shaderInstances) throws IOException { + @Inject(method = "reloadShaders", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53)) + private void reloadShaders(ResourceManager resourceManager, CallbackInfo ci, + @Local(ordinal = 1) List>> shaderInstances) throws IOException { for (CBCRenderTypes renderType : CBCRenderTypes.values()) shaderInstances.add(Pair.of(new ShaderInstance(resourceManager, renderType.id(), renderType.renderType().format()), renderType::setShaderInstance)); diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/PonderRegistryMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/PonderRegistryMixin.java index 4ddd08d10..99f24066d 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/PonderRegistryMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/PonderRegistryMixin.java @@ -1,28 +1,28 @@ package rbasamoyai.createbigcannons.mixin.client; -import com.simibubi.create.foundation.ponder.PonderRegistry; -import com.simibubi.create.foundation.ponder.PonderScene; -import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry; - -import net.minecraft.resources.ResourceLocation; +import java.util.ArrayList; +import java.util.List; 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; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import rbasamoyai.createbigcannons.CreateBigCannons; +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.foundation.ponder.PonderRegistry; +import com.simibubi.create.foundation.ponder.PonderScene; +import com.simibubi.create.foundation.ponder.PonderStoryBoardEntry; -import java.util.ArrayList; -import java.util.List; +import net.minecraft.resources.ResourceLocation; +import rbasamoyai.createbigcannons.CreateBigCannons; @Mixin(PonderRegistry.class) public class PonderRegistryMixin { @Inject(method = "compile(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;", - at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/ponder/PonderRegistry;compile(Ljava/util/List;)Ljava/util/List;"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void createbigcannons$compile(ResourceLocation id, CallbackInfoReturnable> cir, List list) { + at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/ponder/PonderRegistry;compile(Ljava/util/List;)Ljava/util/List;")) + private static void createbigcannons$compile(ResourceLocation id, CallbackInfoReturnable> cir, + @Local List list) { if (id.getNamespace().equals(CreateBigCannons.MOD_ID)) return; List modified = new ArrayList<>(); for (PonderStoryBoardEntry ponder : list) { diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/AllSoundEventsMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/AllSoundEventsMixin.java index 203108159..7a399f13b 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/AllSoundEventsMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/AllSoundEventsMixin.java @@ -1,11 +1,13 @@ package rbasamoyai.createbigcannons.mixin.compat.create; -import com.simibubi.create.AllSoundEvents; 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; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import com.llamalad7.mixinextras.sugar.Local; +import com.simibubi.create.AllSoundEvents; + import rbasamoyai.createbigcannons.index.CBCSoundEvents; @Mixin(AllSoundEvents.SoundEntryBuilder.class) @@ -13,10 +15,9 @@ public abstract class AllSoundEventsMixin { @Inject(method = "build", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), - locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, remap = false) - private void createbigcannons$build(CallbackInfoReturnable cir, AllSoundEvents.SoundEntry entry) { + private void createbigcannons$build(CallbackInfoReturnable cir, @Local AllSoundEvents.SoundEntry entry) { if (((Object) this) instanceof CBCSoundEvents.CBCSoundEntryBuilder) cir.setReturnValue(entry); } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/ContraptionMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/ContraptionMixin.java index 7117d9445..a86a42b1f 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/ContraptionMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/ContraptionMixin.java @@ -14,7 +14,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; @@ -44,7 +43,7 @@ @Mixin(Contraption.class) public abstract class ContraptionMixin { - @Unique private final Contraption self = (Contraption) (Object) this; + @Unique private final Contraption createbigcannons$self = (Contraption) (Object) this; @Shadow private Set glueToRemove; @@ -57,126 +56,123 @@ public abstract class ContraptionMixin { @Inject(method = "searchMovedStructure", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/BlockMovementChecks;isBrittle(Lnet/minecraft/world/level/block/state/BlockState;)Z", shift = At.Shift.BEFORE)) private void createbigcannons$searchMovedStructure$setForcedDirection(Level level, BlockPos pos, Direction forcedDirection, - CallbackInfoReturnable cir, @Local LocalRef forcedDirectionRef) { - if (!(this.self instanceof CanLoadBigCannon loader)) return; + CallbackInfoReturnable cir, + @Local(argsOnly = true) LocalRef forcedDirectionRef) { + if (!(this.createbigcannons$self instanceof CanLoadBigCannon loader)) return; if (forcedDirectionRef.get() == null) forcedDirectionRef.set(loader.createbigcannons$getAssemblyMovementDirection(level)); } @Inject(method = "searchMovedStructure", at = @At(value = "INVOKE", target = "Ljava/util/Queue;add(Ljava/lang/Object;)Z", shift = At.Shift.AFTER), - locals = LocalCapture.CAPTURE_FAILHARD, remap = false) private void createbigcannons$searchMovedStructure$removePulley(Level level, BlockPos pos, Direction forcedDirection, - CallbackInfoReturnable cir, Queue frontier) { - if (this.self instanceof PulleyContraption pulley) + CallbackInfoReturnable cir, @Local Queue frontier) { + if (this.createbigcannons$self instanceof PulleyContraption pulley) ContraptionRemix.pulleyChecks(pulley, level, pos, forcedDirection, frontier); } @Inject(method = "addBlocksToWorld", at = @At("HEAD")) private void createbigcannons$addBlocksToWorld(Level world, StructureTransform transform, CallbackInfo ci) { - if (this.disassembled || !(this.self instanceof HasFragileContraption fragile)) + if (this.disassembled || !(this.createbigcannons$self instanceof HasFragileContraption fragile)) return; if (!fragile.createbigcannons$isBrokenDisassembly()) - fragile.createbigcannons$setBrokenDisassembly(HasFragileContraption.checkForIntersectingBlocks(this.self.entity.level, this.self.entity, fragile)); + fragile.createbigcannons$setBrokenDisassembly(HasFragileContraption.checkForIntersectingBlocks(this.createbigcannons$self.entity.level, this.createbigcannons$self.entity, fragile)); } @ModifyExpressionValue(method = "addBlocksToWorld", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/Contraption;customBlockPlacement(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")) private boolean createbigcannons$addBlocksToWorld$customBlockPlacement(boolean original, Level level, StructureTransform transform, @Local(ordinal = 0) BlockPos targetPos, @Local(ordinal = 0) BlockState state) { - return original || ContraptionRemix.customBlockPlacement(this.self, level, targetPos, state); + return original || ContraptionRemix.customBlockPlacement(this.createbigcannons$self, level, targetPos, state); } @ModifyExpressionValue(method = "removeBlocksFromWorld", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/Contraption;customBlockRemoval(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")) private boolean createbigcannons$removeBlocksFromWorld$customBlockRemoval(boolean original, Level level, BlockPos offset, @Local(ordinal = 1) BlockPos add, @Local(ordinal = 0) StructureBlockInfo block) { - return original || ContraptionRemix.customBlockRemoval(this.self, level, add, block.state); + return original || ContraptionRemix.customBlockRemoval(this.createbigcannons$self, level, add, block.state); } @Inject(method = "moveBlock", - at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/BlockEntry;has(Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 0, shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD) + at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/BlockEntry;has(Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 0, shift = At.Shift.BEFORE)) private void createbigcannons$moveBlock$customChecks(Level level, Direction forcedDirection, Queue frontier, Set visited, CallbackInfoReturnable cir, - BlockPos pos, BlockState state) { - ContraptionRemix.customChecks(this.self, level, pos, state, forcedDirection, frontier, visited, cir); + @Local BlockPos pos, @Local BlockState state) { + ContraptionRemix.customChecks(this.createbigcannons$self, level, pos, state, forcedDirection, frontier, visited, cir); } @Inject(method = "moveBlock", at = @At(value = "INVOKE", target = "Ljava/util/Set;contains(Ljava/lang/Object;)Z", ordinal = 0, shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD, - remap = false) + remap = false) private void createbigcannons$moveBlock$stickerMarking(Level level, Direction forcedDirection, Queue frontier, - Set visited, CallbackInfoReturnable cir, BlockPos pos, - BlockState state, Direction offset, BlockPos attached) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.stickerMarking((Contraption & CanLoadBigCannon) this.self, level, attached, offset, forcedDirection); + Set visited, CallbackInfoReturnable cir, + @Local(ordinal = 1) Direction offset, @Local(ordinal = 1) BlockPos attached) { + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.stickerMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, attached, offset, forcedDirection); } - @Inject(method = "moveChassis", at = @At(value = "TAIL", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD, remap = false) + @Inject(method = "moveChassis", at = @At(value = "TAIL", shift = At.Shift.BEFORE), remap = false) private void createbigcannons$moveChassis(Level level, BlockPos pos, Direction movementDirection, Queue frontier, - Set visited, CallbackInfoReturnable cir, BlockEntity be, - ChassisBlockEntity chassis, List includedBlockPositions) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.chassisMarking((Contraption & CanLoadBigCannon) this.self, level, includedBlockPositions, frontier, visited, movementDirection, chassis); + Set visited, CallbackInfoReturnable cir, + @Local ChassisBlockEntity chassis, @Local List includedBlockPositions) { + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.chassisMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, includedBlockPositions, frontier, visited, movementDirection, chassis); } @Inject(method = "moveMechanicalPiston", at = @At("TAIL"), remap = false) private void createbigcannons$moveMechanicalPiston(Level level, BlockPos pos, Queue frontier, Set visited, BlockState state, CallbackInfoReturnable cir) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.pistonMarking((Contraption & CanLoadBigCannon) this.self, level, pos, state); + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.pistonMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, state); } @Inject(method = "movePistonHead", at = @At("TAIL"), remap = false) private void createbigcannons$movePistonHead(Level level, BlockPos pos, Queue frontier, Set visited, BlockState state, CallbackInfo ci) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.pistonHeadMarking((Contraption & CanLoadBigCannon) this.self, level, pos, state); + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.pistonHeadMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, state); } @Inject(method = "moveGantryPinion", at = @At("HEAD"), remap = false) private void createbigcannons$moveGantryPinion(Level level, BlockPos pos, Queue frontier, Set visited, BlockState state, CallbackInfo ci) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.gantryCarriageMarking((Contraption & CanLoadBigCannon) this.self, level, pos, state); + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.gantryCarriageMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, state); } @Inject(method = "moveBlock", - at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;below()Lnet/minecraft/core/BlockPos;", shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD) + at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;below()Lnet/minecraft/core/BlockPos;", shift = At.Shift.BEFORE)) private void createbigcannons$moveBlock$loaderBlocks(Level level, Direction forcedDirection, Queue frontier, Set visited, CallbackInfoReturnable cir, - BlockPos pos, BlockState state) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.moveLoaderBlocks((Contraption & CanLoadBigCannon) this.self, level, forcedDirection, frontier, visited, pos, state); + @Local BlockPos pos, @Local BlockState state) { + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.moveLoaderBlocks((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, forcedDirection, frontier, visited, pos, state); } @Inject(method = "moveBlock", - at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/BlockMovementChecks;isBrittle(Lnet/minecraft/world/level/block/state/BlockState;)Z"), - locals = LocalCapture.CAPTURE_FAILHARD) + at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/BlockMovementChecks;isBrittle(Lnet/minecraft/world/level/block/state/BlockState;)Z")) private void createbigcannons$moveBlock$addFrontier$0(Level level, Direction forcedDirection, Queue frontier, Set visited, CallbackInfoReturnable cir, - BlockPos pos, BlockState state, BlockPos posDown, - BlockState stateBelow, Direction[] var9, int var10, int var11, - Direction offset, BlockPos offsetPos, BlockState blockState, - boolean wasVisited, boolean faceHasGlue, boolean blockAttachedTowardsFace, + @Local(ordinal = 0) BlockPos pos, + @Local(ordinal = 0) BlockState state, + @Local(ordinal = 1) Direction offset, + @Local(ordinal = 2) BlockPos offsetPos, + @Local(ordinal = 2) BlockState blockState, + @Local(ordinal = 1) boolean faceHasGlue, + @Local(ordinal = 2) boolean blockAttachedTowardsFace, @Share("removeFlag") LocalBooleanRef removeFlag) { removeFlag.set(false); - if (!(this.self instanceof CanLoadBigCannon) || frontier.contains(offsetPos)) return; - boolean stickFlag = ContraptionRemix.getStickFlag((Contraption & CanLoadBigCannon) this.self, level, pos, offsetPos, + if (!(this.createbigcannons$self instanceof CanLoadBigCannon) || frontier.contains(offsetPos)) return; + boolean stickFlag = ContraptionRemix.getStickFlag((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, offsetPos, state, blockState, offset, forcedDirection, faceHasGlue | blockAttachedTowardsFace); - removeFlag.set(ContraptionRemix.handleCannonFrontier((Contraption & CanLoadBigCannon) this.self, level, pos, offsetPos, + removeFlag.set(ContraptionRemix.handleCannonFrontier((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, offsetPos, visited, offset, forcedDirection, stickFlag)); } @Inject(method = "moveBlock", at = @At(value = "INVOKE", target = "Ljava/util/Queue;add(Ljava/lang/Object;)Z", ordinal = 4, shift = At.Shift.AFTER), - locals = LocalCapture.CAPTURE_FAILHARD, remap = false) private void createbigcannons$moveBlock$addFrontier$1(Level level, Direction forcedDirection, Queue frontier, Set visited, CallbackInfoReturnable cir, - BlockPos pos, BlockState state, BlockPos posDown, - BlockState stateBelow, Direction[] var9, int var10, int var11, - Direction offset, BlockPos offsetPos, @Share("removeFlag") LocalBooleanRef removeFlag) { - if (this.self instanceof CanLoadBigCannon && removeFlag.get()) + @Local(ordinal = 2) BlockPos offsetPos, + @Share("removeFlag") LocalBooleanRef removeFlag) { + if (this.createbigcannons$self instanceof CanLoadBigCannon && removeFlag.get()) frontier.remove(offsetPos); } @@ -185,8 +181,8 @@ public abstract class ContraptionMixin { private Pair createbigcannons$moveBlock$preCannonBlockCapture(Pair original, Level level, @Nullable Direction forcedDirection, Queue frontier, Set visited, @Local(ordinal = 0) BlockPos pos) { - if (this.self instanceof CanLoadBigCannon) { - Pair pair = ContraptionRemix.handleCapture((Contraption & CanLoadBigCannon) this.self, + if (this.createbigcannons$self instanceof CanLoadBigCannon) { + Pair pair = ContraptionRemix.handleCapture((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, pos, frontier, visited, forcedDirection, this.glueToRemove); return pair == null ? original : pair; } @@ -196,7 +192,7 @@ public abstract class ContraptionMixin { @Inject(method = "movePulley", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getBlock()Lnet/minecraft/world/level/block/Block;", shift = At.Shift.BEFORE)) private void createbigcannons$movePulley$0(Level level, BlockPos pos, Queue frontier, Set visited, CallbackInfo ci, @Local(ordinal = 1) BlockPos ropePos, @Local LocalRef ropeState) { - if (this.self instanceof CanLoadBigCannon) + if (this.createbigcannons$self instanceof CanLoadBigCannon) ropeState.set(ContraptionRemix.getInnerCannonState(level, ropeState.get(), ropePos, Direction.DOWN)); } @@ -209,8 +205,8 @@ public abstract class ContraptionMixin { && level.getBlockEntity(ropePos) instanceof IBigCannonBlockEntity cbe && cbe.cannonBehavior().block().state.isAir()) { BlockPos local = this.toLocalPos(ropePos.above()); - if (this.self.getBlocks().containsKey(local) - && this.self.getBlocks().get(local).state.getBlock() instanceof BigCannonBlock + if (this.createbigcannons$self.getBlocks().containsKey(local) + && this.createbigcannons$self.getBlocks().get(local).state.getBlock() instanceof BigCannonBlock && level.getBlockEntity(ropePos.above()) instanceof IBigCannonBlockEntity cbe1 && cbe1.cannonBehavior().isConnectedTo(Direction.DOWN)) { return; @@ -225,14 +221,14 @@ public abstract class ContraptionMixin { Level level, BlockPos pos, @Local(ordinal = 1) BlockPos ropePos) { Direction forcedDirection = null; - if (this.self instanceof CanLoadBigCannon loader) + if (this.createbigcannons$self instanceof CanLoadBigCannon loader) forcedDirection = loader.createbigcannons$getAssemblyMovementDirection(level); BlockState state = level.getBlockState(ropePos); BlockPos local = this.toLocalPos(ropePos); if ((forcedDirection == null || forcedDirection.getAxis().isHorizontal()) - && this.self.getBlocks().containsKey(local) - && this.self.getBlocks().get(local).state.getBlock() instanceof BigCannonBlock) { + && this.createbigcannons$self.getBlocks().containsKey(local) + && this.createbigcannons$self.getBlocks().get(local).state.getBlock() instanceof BigCannonBlock) { return original; } if (state.getBlock() instanceof BigCannonBlock cBlock @@ -245,25 +241,25 @@ public abstract class ContraptionMixin { @Inject(method = "searchMovedStructure", at = @At(value = "RETURN", ordinal = 1), remap = false) private void createbigcannons$searchMovedStructure(Level level, BlockPos pos, Direction forcedDirection, CallbackInfoReturnable cir) throws AssemblyException { - ContraptionRemix.validateCannonRope(this.self, level, forcedDirection, this::toLocalPos); - if (this.self instanceof HasFragileContraption) - ContraptionRemix.markFragileBlocks((Contraption & HasFragileContraption) this.self); + ContraptionRemix.validateCannonRope(this.createbigcannons$self, level, forcedDirection, this::toLocalPos); + if (this.createbigcannons$self instanceof HasFragileContraption) + ContraptionRemix.markFragileBlocks((Contraption & HasFragileContraption) this.createbigcannons$self); } @Inject(method = "readNBT", at = @At("TAIL"), remap = false) private void createbigcannons$readNBT(Level level, CompoundTag nbt, boolean spawnData, CallbackInfo ci) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.readCannonLoaderData((Contraption & CanLoadBigCannon) this.self, nbt); - if (this.self instanceof HasFragileContraption) - ContraptionRemix.readFragileBlocks((Contraption & HasFragileContraption) this.self, nbt); + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.readCannonLoaderData((Contraption & CanLoadBigCannon) this.createbigcannons$self, nbt); + if (this.createbigcannons$self instanceof HasFragileContraption) + ContraptionRemix.readFragileBlocks((Contraption & HasFragileContraption) this.createbigcannons$self, nbt); } - @Inject(method = "writeNBT", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD, remap = false) - private void createbigcannons$writeNBT(boolean spawnPacket, CallbackInfoReturnable cir, CompoundTag nbt) { - if (this.self instanceof CanLoadBigCannon) - ContraptionRemix.writeCannonLoaderData((Contraption & CanLoadBigCannon) this.self, nbt); - if (this.self instanceof HasFragileContraption) - ContraptionRemix.writeFragileBlocks((Contraption & HasFragileContraption) this.self, nbt); + @Inject(method = "writeNBT", at = @At("TAIL"), remap = false) + private void createbigcannons$writeNBT(boolean spawnPacket, CallbackInfoReturnable cir, @Local(ordinal = 0) CompoundTag nbt) { + if (this.createbigcannons$self instanceof CanLoadBigCannon) + ContraptionRemix.writeCannonLoaderData((Contraption & CanLoadBigCannon) this.createbigcannons$self, nbt); + if (this.createbigcannons$self instanceof HasFragileContraption) + ContraptionRemix.writeFragileBlocks((Contraption & HasFragileContraption) this.createbigcannons$self, nbt); } } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/MechanicalPistonBlockMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/MechanicalPistonBlockMixin.java index 90e302ac9..bf5469af4 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/MechanicalPistonBlockMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/MechanicalPistonBlockMixin.java @@ -3,9 +3,10 @@ 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.ref.LocalRef; import com.simibubi.create.content.contraptions.piston.MechanicalPistonBlock; @@ -29,10 +30,10 @@ public abstract class MechanicalPistonBlockMixin { blockRef.set(ContraptionRemix.getInnerCannonState(level, blockRef.get(), currentPos, direction)); } - @Redirect(method = "playerWillDestroy", + @WrapOperation(method = "playerWillDestroy", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z")) - private boolean createbigcannons$playerWillDestroy$1(Level instance, BlockPos pos, boolean drops) { - return !ContraptionRemix.removeCannonContentsOnBreak(instance, pos, drops) && instance.destroyBlock(pos, drops); + private boolean createbigcannons$playerWillDestroy$1(Level instance, BlockPos pos, boolean drops, Operation original) { + return !ContraptionRemix.removeCannonContentsOnBreak(instance, pos, drops) && original.call(instance, pos, drops); } } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PistonContraptionMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PistonContraptionMixin.java index 403c6d0b1..378953061 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PistonContraptionMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PistonContraptionMixin.java @@ -15,10 +15,10 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.simibubi.create.content.contraptions.TranslatingContraption; import com.simibubi.create.content.contraptions.piston.MechanicalPistonBlockEntity; @@ -39,10 +39,10 @@ @Mixin(PistonContraption.class) public abstract class PistonContraptionMixin extends TranslatingContraption implements CanLoadBigCannon, HasFragileContraption { - @Unique private final Set fragileBlocks = new HashSet<>(); - @Unique private final Set colliderBlocks = new HashSet<>(); - @Unique private final Map encounteredBlocks = new HashMap<>(); - @Unique private boolean brokenDisassembly = false; + @Unique private final Set createbigcannons$fragileBlocks = new HashSet<>(); + @Unique private final Set createbigcannons$colliderBlocks = new HashSet<>(); + @Unique private final Map createbigcannons$encounteredBlocks = new HashMap<>(); + @Unique private boolean createbigcannons$brokenDisassembly = false; @Shadow private boolean retract; @Shadow protected Direction orientation; @@ -58,23 +58,22 @@ public abstract class PistonContraptionMixin extends TranslatingContraption impl @Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); } - @Override public Set createbigcannons$getFragileBlockPositions() { return this.fragileBlocks; } + @Override public Set createbigcannons$getFragileBlockPositions() { return this.createbigcannons$fragileBlocks; } - @Override public Set createbigcannons$getCannonLoadingColliders() { return this.colliderBlocks; } + @Override public Set createbigcannons$getCannonLoadingColliders() { return this.createbigcannons$colliderBlocks; } - @Override public void createbigcannons$setBrokenDisassembly(boolean flag) { this.brokenDisassembly = flag; } - @Override public boolean createbigcannons$isBrokenDisassembly() { return this.brokenDisassembly; } + @Override public void createbigcannons$setBrokenDisassembly(boolean flag) { this.createbigcannons$brokenDisassembly = flag; } + @Override public boolean createbigcannons$isBrokenDisassembly() { return this.createbigcannons$brokenDisassembly; } - @Override public Map createbigcannons$getEncounteredBlocks() { return this.encounteredBlocks; } + @Override public Map createbigcannons$getEncounteredBlocks() { return this.createbigcannons$encounteredBlocks; } @Inject(method = "addToInitialFrontier", at = @At(value = "INVOKE", target = "Ljava/util/Queue;add(Ljava/lang/Object;)Z", shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD, remap = false, cancellable = true) private void createbigcannons$addToInitialFrontier$1(Level level, BlockPos pos, Direction direction, Queue frontier, - CallbackInfoReturnable cir, boolean sticky, boolean retracting, - int offset, BlockPos currentPos, BlockState state) { + CallbackInfoReturnable cir, @Local(ordinal = 0) boolean retracting, + @Local(ordinal = 1) BlockPos currentPos, @Local BlockState state) { BlockPos offsetPos = currentPos.relative(direction.getOpposite()); BlockState offsetState = level.getBlockState(offsetPos); @@ -90,10 +89,12 @@ public abstract class PistonContraptionMixin extends TranslatingContraption impl } } - @Redirect(method = "collectExtensions", + @WrapOperation(method = "collectExtensions", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;")) - private BlockState createbigcannons$collectExtensions$1(Level instance, BlockPos pos, @Local Direction direction, @Local(ordinal = 0) BlockPos posArg) { - BlockState state = instance.getBlockState(pos); + private BlockState createbigcannons$collectExtensions$1(Level instance, BlockPos pos, Operation original, + @Local(argsOnly = true) Direction direction, + @Local(ordinal = 0, argsOnly = true) BlockPos posArg) { + BlockState state = original.call(instance, pos); return pos.equals(posArg) ? state : ContraptionRemix.getInnerCannonState(instance, state, pos, direction); } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PulleyBlockEntityMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PulleyBlockEntityMixin.java index f1a5221ae..d05061914 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PulleyBlockEntityMixin.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/mixin/compat/create/PulleyBlockEntityMixin.java @@ -4,10 +4,10 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.ref.LocalRef; import com.simibubi.create.AllBlocks; @@ -30,9 +30,8 @@ public abstract class PulleyBlockEntityMixin extends LinearActuatorBlockEntity { PulleyBlockEntityMixin(BlockEntityType typeIn, BlockPos pos, BlockState state) { super(typeIn, pos, state); } @Inject(method = "assemble", - at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/BlockEntry;has(Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 0, shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD) - private void createbigcannons$assemble(CallbackInfo ci, int maxLength, int i, BlockPos ropePos, @Local LocalRef ropeStateRef) { + at = @At(value = "INVOKE", target = "Lcom/tterrag/registrate/util/entry/BlockEntry;has(Lnet/minecraft/world/level/block/state/BlockState;)Z", ordinal = 0, shift = At.Shift.BEFORE)) + private void createbigcannons$assemble(CallbackInfo ci, @Local BlockPos ropePos, @Local LocalRef ropeStateRef) { BlockState ropeState = ropeStateRef.get(); if (!(ropeState.getBlock() instanceof BigCannonBlock cBlock) || !cBlock.getFacing(ropeState).getAxis().isVertical() @@ -42,9 +41,10 @@ public abstract class PulleyBlockEntityMixin extends LinearActuatorBlockEntity { ropeStateRef.set(info.state); } - @Redirect(method = "removeRopes", + @WrapOperation(method = "removeRopes", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) - private boolean createbigcannons$removeRopes(Level instance, BlockPos pos, BlockState newState, int flags, @Local BlockState oldState) { + private boolean createbigcannons$removeRopes(Level instance, BlockPos pos, BlockState newState, int flags, + Operation original, @Local BlockState oldState) { if (oldState.getBlock() instanceof BigCannonBlock cBlock && cBlock.getFacing(oldState).getAxis().isVertical() && this.level.getBlockEntity(pos) instanceof IBigCannonBlockEntity cbe) { @@ -52,36 +52,35 @@ public abstract class PulleyBlockEntityMixin extends LinearActuatorBlockEntity { cbe.cannonBehavior().blockEntity.notifyUpdate(); return false; } - return instance.setBlock(pos, newState, flags); + return original.call(instance, pos, newState, flags); } - @Redirect(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z", ordinal = 0)) - private boolean createbigcannons$disassemble$0(Level instance, BlockPos pos, boolean dropBlock) { - return !isLoadingCannon(instance, pos, AllBlocks.PULLEY_MAGNET.getDefaultState()) && instance.destroyBlock(pos, dropBlock); + @WrapOperation(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z", ordinal = 0)) + private boolean createbigcannons$disassemble$0(Level instance, BlockPos pos, boolean dropBlock, Operation original) { + return !createbigcannons$isLoadingCannon(instance, pos, AllBlocks.PULLEY_MAGNET.getDefaultState()) && original.call(instance, pos, dropBlock); } - @Redirect(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z", ordinal = 1)) - private boolean createbigcannons$disassemble$1(Level instance, BlockPos pos, boolean dropBlock) { - return !isLoadingCannon(instance, pos, AllBlocks.ROPE.getDefaultState()) && instance.destroyBlock(pos, dropBlock); + @WrapOperation(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;destroyBlock(Lnet/minecraft/core/BlockPos;Z)Z", ordinal = 1)) + private boolean createbigcannons$disassemble$1(Level instance, BlockPos pos, boolean dropBlock, Operation original) { + return !createbigcannons$isLoadingCannon(instance, pos, AllBlocks.ROPE.getDefaultState()) && original.call(instance, pos, dropBlock); } - @Redirect(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) - private boolean createbigcannons$disassemble$2(Level instance, BlockPos pos, BlockState state, int flag) { - if (isLoadingCannon(instance, pos, state)) { + @WrapOperation(method = "disassemble", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) + private boolean createbigcannons$disassemble$2(Level instance, BlockPos pos, BlockState state, int flag, Operation original) { + if (createbigcannons$isLoadingCannon(instance, pos, state)) { BlockEntity be = instance.getBlockEntity(pos); ((IBigCannonBlockEntity) be).cannonBehavior().loadBlock(new StructureBlockInfo(BlockPos.ZERO, state, new CompoundTag())); ((IBigCannonBlockEntity) be).cannonBehavior().blockEntity.notifyUpdate(); return true; } - return instance.setBlock(pos, state, flag); + return original.call(instance, pos, state, flag); } @Inject(method = "visitNewPosition", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/pulley/PulleyBlockEntity;disassemble()V", shift = At.Shift.BEFORE), - locals = LocalCapture.CAPTURE_FAILHARD, remap = false, cancellable = true) - private void createbigcannons$visitNewPosition(CallbackInfo ci, BlockPos posBelow, BlockState state) { + private void createbigcannons$visitNewPosition(CallbackInfo ci, @Local BlockPos posBelow, @Local BlockState state) { if (state.getBlock() instanceof BigCannonBlock cBlock && cBlock.getFacing(state).getAxis().isVertical() && this.level.getBlockEntity(posBelow) instanceof IBigCannonBlockEntity cbe @@ -92,7 +91,7 @@ public abstract class PulleyBlockEntityMixin extends LinearActuatorBlockEntity { } @Unique - private static boolean isLoadingCannon(Level level, BlockPos pos, BlockState loadState) { + private static boolean createbigcannons$isLoadingCannon(Level level, BlockPos pos, BlockState loadState) { BlockState state = level.getBlockState(pos); BlockEntity be = level.getBlockEntity(pos); return state.getBlock() instanceof BigCannonBlock cBlock diff --git a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/ArmTileEntityMixin.java b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/ArmTileEntityMixin.java index 0849c4b3c..6f6e1808e 100644 --- a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/ArmTileEntityMixin.java +++ b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/mixin/ArmTileEntityMixin.java @@ -1,16 +1,15 @@ package rbasamoyai.createbigcannons.fabric.mixin; -import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType; - 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.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import com.llamalad7.mixinextras.sugar.Local; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.mechanicalArm.ArmBlockEntity; import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPoint; +import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType; import net.minecraft.core.BlockPos; import net.minecraft.world.item.ItemStack; @@ -26,9 +25,8 @@ public class ArmTileEntityMixin extends KineticBlockEntity { } @Inject(method = "depositItem", - at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint;insert(Lnet/minecraft/world/item/ItemStack;Lnet/fabricmc/fabric/api/transfer/v1/transaction/TransactionContext;)Lnet/minecraft/world/item/ItemStack;"), - locals = LocalCapture.CAPTURE_FAILHARD) - private void createbigcannons$depositItem(CallbackInfo ci, ArmInteractionPoint point, ItemStack stack) { + at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint;insert(Lnet/minecraft/world/item/ItemStack;Lnet/fabricmc/fabric/api/transfer/v1/transaction/TransactionContext;)Lnet/minecraft/world/item/ItemStack;")) + private void createbigcannons$depositItem(CallbackInfo ci, @Local ArmInteractionPoint point, @Local ItemStack stack) { ArmInteractionPointType type = point.getType(); if (type != CBCArmInteractionPointTypes.CANNON_MOUNT) return; stack.getOrCreateTag().putBoolean("DontSimulate", true); From 13aca2285de7ff4fea4e968cbb122bc61448540b Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Fri, 26 Jul 2024 11:49:05 -0400 Subject: [PATCH 2/8] bug: Fixed tracer not rendering for Drop Mortar Shell --- changelog.txt | 1 + .../DropMortarShellRenderer.java | 42 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 5c2edfd08..23e20d9c4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,7 @@ Fixed: - Fixed autocannon assembly shooting projectiles the wrong way - Added assembly failure message - Fixed Fluid Shell item filling +- Fixed tracer not rendering for Drop Mortar Shell === diff --git a/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java b/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java index fb471b885..21f877373 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java @@ -1,16 +1,22 @@ package rbasamoyai.createbigcannons.munitions.big_cannon.drop_mortar_shell; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Matrix3f; +import com.mojang.math.Matrix4f; import com.simibubi.create.foundation.render.CachedBufferer; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.phys.Vec3; +import rbasamoyai.createbigcannons.CreateBigCannons; import rbasamoyai.createbigcannons.index.CBCBlockPartials; import rbasamoyai.createbigcannons.index.CBCBlocks; import rbasamoyai.createbigcannons.utils.CBCUtils; @@ -22,6 +28,7 @@ public class DropMortarShellRenderer extends EntityRenderer Date: Wed, 31 Jul 2024 11:40:32 -0400 Subject: [PATCH 3/8] bug: Fixed initial projectile chunkloading breaking Valkyrien Skies Quick-Firing Breeches --- changelog.txt | 1 + .../contraption/MountedAutocannonContraption.java | 4 ++-- .../contraption/MountedBigCannonContraption.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 23e20d9c4..f204a11fb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -22,6 +22,7 @@ Fixed: - Added assembly failure message - Fixed Fluid Shell item filling - Fixed tracer not rendering for Drop Mortar Shell +- Fixed initial projectile chunkloading breaking Valkyrien Skies Quick-Firing Breeches === diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java b/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java index c0ecca95d..4459b2234 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedAutocannonContraption.java @@ -374,8 +374,8 @@ public void fireShot(ServerLevel level, PitchOrientedContraptionEntity entity) { SoundSource.BLOCKS, 12, 1, 5f); } - if (CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) { - ChunkPos cpos1 = new ChunkPos(new BlockPos(spawnPos)); + if (projectile != null && CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) { + ChunkPos cpos1 = new ChunkPos(new BlockPos(projectile.position())); RitchiesProjectileLib.queueForceLoad(level, cpos1.x, cpos1.z); } } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedBigCannonContraption.java b/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedBigCannonContraption.java index 6f3358c24..15917c281 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedBigCannonContraption.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannon_control/contraption/MountedBigCannonContraption.java @@ -467,8 +467,8 @@ public void fireShot(ServerLevel level, PitchOrientedContraptionEntity entity) { player.connection.send(blastWavePacket); } - if (CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) { - ChunkPos cpos1 = new ChunkPos(new BlockPos(spawnPos)); + if (projectile != null && CBCConfigs.SERVER.munitions.projectilesCanChunkload.get()) { + ChunkPos cpos1 = new ChunkPos(new BlockPos(projectile.position())); RitchiesProjectileLib.queueForceLoad(level, cpos1.x, cpos1.z); } } From 13ba4ea63faedbc142a5aa6fa76847b4d2765c69 Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 31 Jul 2024 11:50:30 -0400 Subject: [PATCH 4/8] bug: Fixed illegal autocannon connections on creative block placement --- changelog.txt | 1 + .../cannons/autocannon/AutocannonBlock.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index f204a11fb..a21875d21 100644 --- a/changelog.txt +++ b/changelog.txt @@ -23,6 +23,7 @@ Fixed: - Fixed Fluid Shell item filling - Fixed tracer not rendering for Drop Mortar Shell - Fixed initial projectile chunkloading breaking Valkyrien Skies Quick-Firing Breeches +- Fixed illegal autocannon connections on creative block placement === diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java b/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java index 6f3d0e0a8..070e56a64 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java @@ -103,7 +103,8 @@ static void onPlace(Level level, BlockPos pos) { BlockState state1 = level.getBlockState(pos1); BlockEntity be1 = level.getBlockEntity(pos1); - if (state1.getBlock() instanceof AutocannonBlock cBlock1 + if (cBlock.canConnectToSide(state, facing) + && state1.getBlock() instanceof AutocannonBlock cBlock1 && cBlock1.getAutocannonMaterialInLevel(level, state1, pos1) == material && cBlock1.canConnectToSide(state1, opposite)) { if (state1.hasProperty(AutocannonBarrelBlock.BARREL_END)) { @@ -122,7 +123,8 @@ static void onPlace(Level level, BlockPos pos) { BlockState state2 = level.getBlockState(pos2); BlockEntity be2 = level.getBlockEntity(pos2); - if (state2.getBlock() instanceof AutocannonBlock cBlock2 + if (cBlock.canConnectToSide(state, opposite) + && state2.getBlock() instanceof AutocannonBlock cBlock2 && cBlock2.getAutocannonMaterialInLevel(level, state2, pos2) == material && cBlock2.canConnectToSide(state2, facing)) { if (state2.hasProperty(AutocannonBarrelBlock.BARREL_END)) { From ba1ddfb8bc55bdc14c038f8d098ee40436051a07 Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 31 Jul 2024 13:09:36 -0400 Subject: [PATCH 5/8] bug, refactor: Fixed cannon casting connecting blocks that shouldn't connect - Refactored common cannon connectivity code into CannonContraptionProviderBlock class --- changelog.txt | 1 + .../createbigcannons/cannons/CannonBehavior.java | 5 +++++ .../cannons/CannonContraptionProviderBlock.java | 10 ++++++++++ .../cannons/autocannon/AutocannonBlock.java | 13 ++----------- .../cannons/big_cannons/BigCannonBlock.java | 12 +----------- .../crafting/builtup/CannonBuildingContraption.java | 4 ++-- .../casting/AbstractCannonCastBlockEntity.java | 6 +++++- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/changelog.txt b/changelog.txt index a21875d21..421f4f8ff 100644 --- a/changelog.txt +++ b/changelog.txt @@ -24,6 +24,7 @@ Fixed: - Fixed tracer not rendering for Drop Mortar Shell - Fixed initial projectile chunkloading breaking Valkyrien Skies Quick-Firing Breeches - Fixed illegal autocannon connections on creative block placement +- Fixed cannon casting connecting blocks that shouldn't connect === diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonBehavior.java b/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonBehavior.java index d1bdb7957..064ba3bdc 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonBehavior.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonBehavior.java @@ -143,4 +143,9 @@ public void setWelded(Direction face, boolean welded) { public boolean isWelded() { return !this.weldedTowards.isEmpty(); } public boolean isWeldedOn(Direction dir) { return this.weldedTowards.contains(dir); } + public boolean canConnectToSide(Direction face) { + BlockState state = this.blockEntity.getBlockState(); + return state.getBlock() instanceof CannonContraptionProviderBlock cBlock && cBlock.canConnectToSide(state, face); + } + } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonContraptionProviderBlock.java b/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonContraptionProviderBlock.java index 3404973dd..2ba88398a 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonContraptionProviderBlock.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannons/CannonContraptionProviderBlock.java @@ -2,13 +2,23 @@ import javax.annotation.Nonnull; +import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption; +import rbasamoyai.createbigcannons.crafting.casting.CannonCastShape; public interface CannonContraptionProviderBlock { @Nonnull AbstractMountedCannonContraption getCannonContraption(); Direction getFacing(BlockState state); + default boolean canConnectToSide(BlockState state, Direction face) { return this.getFacing(state).getAxis() == face.getAxis(); } + + CannonCastShape getCannonShape(); + default CannonCastShape getCannonShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getCannonShape(); } + + boolean isComplete(BlockState state); + } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java b/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java index 070e56a64..19c72bee5 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannons/autocannon/AutocannonBlock.java @@ -25,7 +25,6 @@ import rbasamoyai.createbigcannons.cannons.InteractableCannonBlock; import rbasamoyai.createbigcannons.cannons.ItemCannonBehavior; import rbasamoyai.createbigcannons.cannons.autocannon.material.AutocannonMaterial; -import rbasamoyai.createbigcannons.crafting.casting.CannonCastShape; import rbasamoyai.createbigcannons.crafting.welding.WeldableBlock; public interface AutocannonBlock extends WeldableBlock, CannonContraptionProviderBlock, InteractableCannonBlock { @@ -33,15 +32,7 @@ public interface AutocannonBlock extends WeldableBlock, CannonContraptionProvide AutocannonMaterial getAutocannonMaterial(); default AutocannonMaterial getAutocannonMaterialInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getAutocannonMaterial(); } - CannonCastShape getCannonShape(); - default CannonCastShape getCannonShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getCannonShape(); } - - Direction getFacing(BlockState state); - - default boolean canConnectToSide(BlockState state, Direction face) { return this.getFacing(state).getAxis() == face.getAxis(); } - boolean isBreechMechanism(BlockState state); - boolean isComplete(BlockState state); default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { if (!(state.getBlock() instanceof AutocannonBlock cBlock) || state.is(newState.getBlock())) return; @@ -55,7 +46,7 @@ default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockSt } } - if (cBlock.canConnectToSide(state, facing)) { + if (this.canConnectToSide(state, facing)) { BlockPos pos1 = pos.relative(facing); BlockState state1 = level.getBlockState(pos1); BlockEntity be1 = level.getBlockEntity(pos1); @@ -69,7 +60,7 @@ default void onRemoveCannon(BlockState state, Level level, BlockPos pos, BlockSt } } - if (cBlock.canConnectToSide(state, opposite)) { + if (this.canConnectToSide(state, opposite)) { BlockPos pos2 = pos.relative(opposite); BlockState state2 = level.getBlockState(pos2); BlockEntity be2 = level.getBlockEntity(pos2); diff --git a/common/src/main/java/rbasamoyai/createbigcannons/cannons/big_cannons/BigCannonBlock.java b/common/src/main/java/rbasamoyai/createbigcannons/cannons/big_cannons/BigCannonBlock.java index 4db3cb6ad..691d93586 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/cannons/big_cannons/BigCannonBlock.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/cannons/big_cannons/BigCannonBlock.java @@ -48,8 +48,6 @@ public interface BigCannonBlock extends WeldableBlock, CannonContraptionProvider BigCannonMaterial getCannonMaterial(); - CannonCastShape getCannonShape(); - Direction getFacing(BlockState state); default BigCannonEnd getOpeningType(@Nullable Level level, BlockState state, BlockPos pos) { @@ -62,19 +60,11 @@ default BigCannonEnd getOpeningType(MountedBigCannonContraption contraption, Blo BigCannonEnd getDefaultOpeningType(); - boolean isComplete(BlockState state); - default BigCannonMaterial getCannonMaterialInLevel(LevelAccessor level, BlockState state, BlockPos pos) { return this.getCannonMaterial(); } - default CannonCastShape getShapeInLevel(LevelAccessor level, BlockState state, BlockPos pos) { - return this.getCannonShape(); - } - - default boolean canConnectToSide(BlockState state, Direction dir) { return this.getFacing(state).getAxis() == dir.getAxis(); } - - default boolean isImmovable(BlockState state) { + default boolean isImmovable(BlockState state) { return false; } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/crafting/builtup/CannonBuildingContraption.java b/common/src/main/java/rbasamoyai/createbigcannons/crafting/builtup/CannonBuildingContraption.java index 93181573e..f6b331940 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/crafting/builtup/CannonBuildingContraption.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/crafting/builtup/CannonBuildingContraption.java @@ -190,7 +190,7 @@ protected boolean addToInitialFrontier(Level level, BlockPos pos, Direction forc } fullShape = null; } else { - CannonCastShape shape = cBlock.getShapeInLevel(level, state, currentPos); + CannonCastShape shape = cBlock.getCannonShapeInLevel(level, state, currentPos); if (fullShape == null && !isConnected(connectedShapes, shape)) { if (firstBlock) { connectedShapes.add(shape); @@ -281,7 +281,7 @@ private static boolean isNonLayerConnectedTo(Level level, CannonCastShape shape, BlockPos pos, Direction dir, Direction forcedMovement) { boolean pushing = dir == forcedMovement; if (cBlock.getFacing(state).getAxis() != dir.getAxis() - || cBlock.getShapeInLevel(level, state, pos) != shape + || cBlock.getCannonShapeInLevel(level, state, pos) != shape || !(level.getBlockEntity(pos) instanceof ICannonBlockEntity cbe) || !cbe.cannonBehavior().isConnectedTo(dir) && !pushing) return false; diff --git a/common/src/main/java/rbasamoyai/createbigcannons/crafting/casting/AbstractCannonCastBlockEntity.java b/common/src/main/java/rbasamoyai/createbigcannons/crafting/casting/AbstractCannonCastBlockEntity.java index 2262b19f9..cd7d14140 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/crafting/casting/AbstractCannonCastBlockEntity.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/crafting/casting/AbstractCannonCastBlockEntity.java @@ -361,7 +361,11 @@ protected void finishCasting() { } recipe.assembleInWorld(this.level, pos); - if (y > 0 && this.level.getBlockEntity(pos) instanceof ICannonBlockEntity cbe && this.level.getBlockEntity(pos.below()) instanceof ICannonBlockEntity cbe1) { + if (y > 0 + && this.level.getBlockEntity(pos) instanceof ICannonBlockEntity cbe + && cbe.cannonBehavior().canConnectToSide(Direction.DOWN) + && this.level.getBlockEntity(pos.below()) instanceof ICannonBlockEntity cbe1 + && cbe1.cannonBehavior().canConnectToSide(Direction.UP)) { cbe.cannonBehavior().setConnectedFace(Direction.DOWN, true); cbe1.cannonBehavior().setConnectedFace(Direction.UP, true); } From c174795e6237c6b18ee427ca17b0eae69dc13849 Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 31 Jul 2024 15:44:11 -0400 Subject: [PATCH 6/8] improvement: Added version checks for compat mods on 1.18.2 - Copycats+: [1.18.2-1.2.5,) {Forge}, >=1.18.2-1.2.5 {Fabric} - FramedBlocks: [5.11.5,) - Curios: [1.18.2-5.0.9.2,) - Trinkets: >=3.3.0 --- changelog.txt | 1 + fabric/build.gradle | 12 +++++---- fabric/src/main/resources/fabric.mod.json | 6 ++++- forge/build.gradle | 11 +++++--- forge/src/main/resources/META-INF/mods.toml | 29 ++++++++++++++++++--- gradle.properties | 7 +++++ 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index 421f4f8ff..b865e3911 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Changelog Create Big Cannons 5.5.1. A few critical fixes for 5.5.0 as well as some code changes. Added: +- Added version checks for compat mods on 1.18.2 [Development] - Added ability to get big cannon projectile from all big cannon projectile item stacks Changed: - Optimized entity bounds for big cannons and autocannons to optimize lighting diff --git a/fabric/build.gradle b/fabric/build.gradle index d7304763a..fd232872d 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -112,11 +112,13 @@ dependencies { processResources { // set up properties for filling into metadata def properties = [ - version: version, - fabric_loader_version: fabric_loader_version, - fabric_api_version: fabric_api_version, - minecraft_version: minecraft_version, - create_version: create_fabric_version // on fabric, use the entire version, unlike forge + version: version, + fabric_loader_version: fabric_loader_version, + fabric_api_version: fabric_api_version, + minecraft_version: minecraft_version, + create_version: create_fabric_version, // on fabric, use the entire version, unlike forge + copycats_breaks: copycats_breaks_fabric, + trinkets_breaks: trinkets_breaks_fabric ] inputs.properties properties diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 36b4f9a28..99d3b0c0b 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -45,7 +45,11 @@ "minecraft": "${minecraft_version}", "fabricloader": ">=${fabric_loader_version}", "fabric-api": ">=${fabric_api_version}", - "create": "*" + "create": "${create_version}" + }, + "breaks": { + "copycats": "${copycats_breaks}", + "trinkets": "${trinkets_breaks}" }, "custom": { "modmenu": { diff --git a/forge/build.gradle b/forge/build.gradle index b4d499e38..a7db18f5f 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -99,10 +99,13 @@ dependencies { processResources { // set up properties for filling into metadata Map properties = Map.of( - "version", version, - "forge_version", forge_version.split("\\.")[0], // only specify major version of forge - "minecraft_version", minecraft_version, - "create_version", create_forge_version.split("-")[0] // cut off build number + "version", version, + "forge_version", forge_version.split("\\.")[0], // only specify major version of forge + "minecraft_version", minecraft_version, + "create_version", create_forge_version.split("-")[0], // cut off build number + "copycats_requirement", copycats_requirement_forge, + "framedblocks_requirement", framedblocks_requirement_forge, + "curios_requirement", curios_requirement_forge ) properties.forEach((k, v) -> inputs.property(k, v)) diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index cef64ef34..c175b7c67 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -30,8 +30,29 @@ ordering = "NONE" side = "BOTH" [[dependencies.createbigcannons]] -modId="create" -mandatory=true +modId = "create" +mandatory = true versionRange="${create_version}" -ordering="NONE" -side="BOTH" +ordering = "BEFORE" +side = "BOTH" + +[[dependencies.createbigcannons]] +modId = "copycats" +mandatory = false +versionRange = "${copycats_requirement}" +ordering = "NONE" +side = "BOTH" + +[[dependencies.createbigcannons]] +modId = "framedblocks" +mandatory = false +versionRange = "${framedblocks_requirement}" +ordering = "NONE" +side = "BOTH" + +[[dependencies.createbigcannons]] +modId = "curios" +mandatory = false +versionRange = "${curios_requirement}" +ordering = "NONE" +side = "BOTH" diff --git a/gradle.properties b/gradle.properties index a97c7df0c..97f7d3feb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -65,3 +65,10 @@ curios_forge_version=1.18.2-5.0.9.2 trinkets_fabric_version=3.3.1 cca_fabric_version=4.2.0 +# Compatibility version requirements +copycats_requirement_forge=[1.18.2-1.2.5,) +framedblocks_requirement_forge=[5.11.5,) +curios_requirement_forge=[1.18.2-5.0.9.2,) +copycats_breaks_fabric=<1.18.2-1.2.5 +trinkets_breaks_fabric=<3.3.0 + From 0b3e23456f38bac359112d82d6aad1b5430c04d1 Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 31 Jul 2024 16:40:50 -0400 Subject: [PATCH 7/8] improvement, bug: Registered custom shaders properly so that Create Big Cannons shaders don't cause logspam on crash --- changelog.txt | 1 + .../index/CBCRenderTypes.java | 23 +++++++++++--- .../mixin/client/GameRendererMixin.java | 31 ------------------- .../shaders/core/cannon_smoke_particle.fsh} | 0 .../shaders/core/cannon_smoke_particle.json} | 4 +-- .../shaders/core/cannon_smoke_particle.vsh} | 0 .../shaders/core/splinter_particle.fsh} | 0 .../shaders/core/splinter_particle.json} | 4 +-- .../shaders/core/splinter_particle.vsh} | 0 .../createbigcannons-common.mixins.json | 1 - .../fabric/CBCClientFabric.java | 14 +++++++++ .../forge/CBCClientForge.java | 14 +++++++++ 12 files changed, 52 insertions(+), 40 deletions(-) delete mode 100644 common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_cannon_smoke_particle.fsh => createbigcannons/shaders/core/cannon_smoke_particle.fsh} (100%) rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_cannon_smoke_particle.json => createbigcannons/shaders/core/cannon_smoke_particle.json} (90%) rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_cannon_smoke_particle.vsh => createbigcannons/shaders/core/cannon_smoke_particle.vsh} (100%) rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_splinter_particle.fsh => createbigcannons/shaders/core/splinter_particle.fsh} (100%) rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_splinter_particle.json => createbigcannons/shaders/core/splinter_particle.json} (92%) rename common/src/main/resources/assets/{minecraft/shaders/core/createbigcannons_splinter_particle.vsh => createbigcannons/shaders/core/splinter_particle.vsh} (100%) diff --git a/changelog.txt b/changelog.txt index b865e3911..8d530d9a2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,7 @@ Changed: - Changed impact explosion queueing to better allow compatibility with Valkyrien Skies - All Autocannon Recoil Springs on an autocannon now play the firing animation - Format for storing Autocannon Recoil Spring positions has changed, reassemble autocannons to fix any issues +- Registered custom shaders properly so that Create Big Cannons shaders don't cause logspam on crash Fixed: - Fixed Trinkets compat crashing - Fixed gas mask overlay rendering as solid color when holding Just Enough Guns firearm diff --git a/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java b/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java index 54a586e14..bf7889cb8 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java @@ -1,6 +1,9 @@ package rbasamoyai.createbigcannons.index; +import java.io.IOException; import java.util.Locale; +import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.function.Function; import javax.annotation.Nullable; @@ -11,14 +14,16 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; import rbasamoyai.createbigcannons.CreateBigCannons; public enum CBCRenderTypes { CANNON_SMOKE_PARTICLE(CBCRenderingParts.CANNON_SMOKE_PARTICLE_INPUT, VertexFormat.Mode.QUADS, CBCRenderingParts.CANNON_SMOKE_PARTICLE_STATE), - SPLINTER_PARTICLE(type -> RenderType.create(type.id, CBCRenderingParts.SPLINTER_PARTICLE_INPUT, VertexFormat.Mode.QUADS, + SPLINTER_PARTICLE(type -> RenderType.create(type.id.toString(), CBCRenderingParts.SPLINTER_PARTICLE_INPUT, VertexFormat.Mode.QUADS, 512, false, false, CBCRenderingParts.SPLINTER_PARTICLE_STATE.apply(type))); - private final String id = CreateBigCannons.MOD_ID + "_" + this.name().toLowerCase(Locale.ROOT); + private final ResourceLocation id = CreateBigCannons.resource(this.name().toLowerCase(Locale.ROOT)); private final RenderType renderType; @Nullable private ShaderInstance shaderInstance; @@ -27,10 +32,10 @@ public enum CBCRenderTypes { } CBCRenderTypes(VertexFormat format, VertexFormat.Mode mode, Function state) { - this(type -> RenderType.create(type.id, format, mode, 256, false, false, state.apply(type))); + this(type -> RenderType.create(type.id.toString(), format, mode, 256, false, false, state.apply(type))); } - public String id() { return this.id; } + public ResourceLocation id() { return this.id; } public RenderType renderType() { return this.renderType; } @Nullable public ShaderInstance getShaderInstance() { return this.shaderInstance; } public void setShaderInstance(ShaderInstance shaderInstance) { this.shaderInstance = shaderInstance; } @@ -40,4 +45,14 @@ public void setRenderTypeForBuilder(BufferBuilder builder) { builder.begin(this.renderType.mode(), this.renderType.format()); } + public static void registerAllShaders(BiConsumer> cons, + CreateShaderInstance shaderCreator, ResourceManager resourceManager) throws IOException { + for (CBCRenderTypes renderType : values()) + cons.accept(shaderCreator.create(resourceManager, renderType.id, renderType.renderType().format()), renderType::setShaderInstance); + } + + public interface CreateShaderInstance { + ShaderInstance create(ResourceManager manager, ResourceLocation location, VertexFormat format) throws IOException; + } + } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java b/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java deleted file mode 100644 index b1e99c136..000000000 --- a/common/src/main/java/rbasamoyai/createbigcannons/mixin/client/GameRendererMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package rbasamoyai.createbigcannons.mixin.client; - -import java.io.IOException; -import java.util.List; -import java.util.function.Consumer; - -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.CallbackInfo; - -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.datafixers.util.Pair; - -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.ShaderInstance; -import net.minecraft.server.packs.resources.ResourceManager; -import rbasamoyai.createbigcannons.index.CBCRenderTypes; - -@Mixin(GameRenderer.class) -public class GameRendererMixin { - - @Inject(method = "reloadShaders", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53)) - private void reloadShaders(ResourceManager resourceManager, CallbackInfo ci, - @Local(ordinal = 1) List>> shaderInstances) throws IOException { - for (CBCRenderTypes renderType : CBCRenderTypes.values()) - shaderInstances.add(Pair.of(new ShaderInstance(resourceManager, renderType.id(), renderType.renderType().format()), - renderType::setShaderInstance)); - } - -} diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.fsh b/common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.fsh similarity index 100% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.fsh rename to common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.fsh diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.json b/common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.json similarity index 90% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.json rename to common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.json index 31c9888c1..4cd5eefd1 100644 --- a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.json +++ b/common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.json @@ -4,8 +4,8 @@ "srcrgb": "srcalpha", "dstrgb": "1-srcalpha" }, - "vertex": "createbigcannons_cannon_smoke_particle", - "fragment": "createbigcannons_cannon_smoke_particle", + "vertex": "createbigcannons:cannon_smoke_particle", + "fragment": "createbigcannons:cannon_smoke_particle", "attributes": [ "Position", "UV0", diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.vsh b/common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.vsh similarity index 100% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_cannon_smoke_particle.vsh rename to common/src/main/resources/assets/createbigcannons/shaders/core/cannon_smoke_particle.vsh diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.fsh b/common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.fsh similarity index 100% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.fsh rename to common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.fsh diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.json b/common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.json similarity index 92% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.json rename to common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.json index 0623e988d..187bef6e9 100644 --- a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.json +++ b/common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.json @@ -4,8 +4,8 @@ "srcrgb": "srcalpha", "dstrgb": "1-srcalpha" }, - "vertex": "createbigcannons_splinter_particle", - "fragment": "createbigcannons_splinter_particle", + "vertex": "createbigcannons:splinter_particle", + "fragment": "createbigcannons:splinter_particle", "attributes": [ "Position", "UV0", diff --git a/common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.vsh b/common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.vsh similarity index 100% rename from common/src/main/resources/assets/minecraft/shaders/core/createbigcannons_splinter_particle.vsh rename to common/src/main/resources/assets/createbigcannons/shaders/core/splinter_particle.vsh diff --git a/common/src/main/resources/createbigcannons-common.mixins.json b/common/src/main/resources/createbigcannons-common.mixins.json index cf6074997..255fadd27 100644 --- a/common/src/main/resources/createbigcannons-common.mixins.json +++ b/common/src/main/resources/createbigcannons-common.mixins.json @@ -11,7 +11,6 @@ "client.ClientLevelAccessor", "client.EntityClientMixin", "client.EntityRenderDispatcherMixin", - "client.GameRendererMixin", "client.HumanoidPoseMixin", "client.LevelRendererMixin", "client.LightingMixin", diff --git a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java index e238983df..a958c1103 100644 --- a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java +++ b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java @@ -1,11 +1,13 @@ package rbasamoyai.createbigcannons.fabric; +import java.io.IOException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexFormat; import io.github.fabricators_of_create.porting_lib.event.client.CameraSetupCallback; import io.github.fabricators_of_create.porting_lib.event.client.ClientWorldEvents; @@ -15,6 +17,7 @@ import io.github.fabricators_of_create.porting_lib.event.client.MouseButtonCallback; import io.github.fabricators_of_create.porting_lib.event.client.MouseScrolledCallback; import io.github.fabricators_of_create.porting_lib.event.client.ParticleManagerRegistrationCallback; +import io.github.fabricators_of_create.porting_lib.event.client.RegisterShadersCallback; import io.github.fabricators_of_create.porting_lib.event.client.TextureStitchCallback; import io.github.fabricators_of_create.porting_lib.event.common.ModsLoadedCallback; import net.fabricmc.api.ClientModInitializer; @@ -36,6 +39,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; import net.minecraft.client.renderer.texture.TextureAtlas; @@ -51,6 +55,7 @@ import rbasamoyai.createbigcannons.compat.trinkets.CBCTrinketsClient; import rbasamoyai.createbigcannons.fabric.mixin.client.KeyMappingAccessor; import rbasamoyai.createbigcannons.fabric.network.CBCNetworkFabric; +import rbasamoyai.createbigcannons.index.CBCRenderTypes; public class CBCClientFabric implements ClientModInitializer { @Override @@ -77,6 +82,7 @@ public void onInitializeClient() { ClientWorldEvents.LOAD.register(CBCClientFabric::onLoadClientLevel); ClientLoginConnectionEvents.INIT.register(CBCClientFabric::onPlayerLogIn); ModsLoadedCallback.EVENT.register(CBCClientFabric::onModsLoaded); + RegisterShadersCallback.EVENT.register(CBCClientFabric::onShaderReload); } private static void wrapOverlay(String id, CBCClientCommon.CBCGuiOverlay overlay) { @@ -203,4 +209,12 @@ public CompletableFuture reload(PreparationBarrier preparationBarrier, Res ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(listener); } + public static void onShaderReload(ResourceManager resourceManager, RegisterShadersCallback.ShaderRegistry registry) throws IOException { + CBCRenderTypes.registerAllShaders(registry::registerShader, CBCClientFabric::createShader, resourceManager); + } + + private static ShaderInstance createShader(ResourceManager manager, ResourceLocation loc, VertexFormat format) throws IOException { + return new ShaderInstance(manager, loc.toString(), format); + } + } diff --git a/forge/src/main/java/rbasamoyai/createbigcannons/forge/CBCClientForge.java b/forge/src/main/java/rbasamoyai/createbigcannons/forge/CBCClientForge.java index caa43436e..e00eed976 100644 --- a/forge/src/main/java/rbasamoyai/createbigcannons/forge/CBCClientForge.java +++ b/forge/src/main/java/rbasamoyai/createbigcannons/forge/CBCClientForge.java @@ -1,7 +1,10 @@ package rbasamoyai.createbigcannons.forge; +import java.io.IOException; + import net.minecraft.client.Minecraft; import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.world.level.LevelAccessor; import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory; @@ -11,6 +14,7 @@ import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; +import net.minecraftforge.client.event.RegisterShadersEvent; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.gui.ForgeIngameGui; @@ -29,6 +33,7 @@ import rbasamoyai.createbigcannons.compat.curios.CBCCuriosRenderers; import rbasamoyai.createbigcannons.config.CBCConfigs; import rbasamoyai.createbigcannons.index.CBCBlockPartials; +import rbasamoyai.createbigcannons.index.CBCRenderTypes; public class CBCClientForge { @@ -43,6 +48,7 @@ public static void prepareClient(IEventBus modEventBus, IEventBus forgeEventBus) modEventBus.addListener(CBCClientForge::onTextureStitchAtlasPre); modEventBus.addListener(CBCClientForge::onLoadComplete); modEventBus.addListener(CBCClientForge::onRegisterClientReloadListeners); + modEventBus.addListener(CBCClientForge::onRegisterShaders); forgeEventBus.addListener(CBCClientForge::getFogColor); forgeEventBus.addListener(CBCClientForge::getFogDensity); @@ -160,4 +166,12 @@ public static void onRegisterClientReloadListeners(RegisterClientReloadListeners CBCClientCommon.registerClientReloadListeners((listener, id) -> evt.registerReloadListener(listener)); } + public static void onRegisterShaders(RegisterShadersEvent evt) { + try { + CBCRenderTypes.registerAllShaders(evt::registerShader, ShaderInstance::new, evt.getResourceManager()); + } catch (IOException e) { + throw new RuntimeException("Failed to reload Create Big Cannons shaders: ", e); + } + } + } From 959a7d196d966c2b90c5fb073bf6e864473f9161 Mon Sep 17 00:00:00 2001 From: rbasamoyai Date: Wed, 31 Jul 2024 20:18:45 -0400 Subject: [PATCH 8/8] bug: 1.20.1 5.5.1 code fixes --- .../createbigcannons/index/CBCRenderTypes.java | 6 +++--- .../drop_mortar_shell/DropMortarShellRenderer.java | 7 ++++--- .../createbigcannons/fabric/CBCClientFabric.java | 14 +++++--------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java b/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java index bf7889cb8..281279645 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/index/CBCRenderTypes.java @@ -15,7 +15,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.ResourceProvider; import rbasamoyai.createbigcannons.CreateBigCannons; public enum CBCRenderTypes { @@ -46,13 +46,13 @@ public void setRenderTypeForBuilder(BufferBuilder builder) { } public static void registerAllShaders(BiConsumer> cons, - CreateShaderInstance shaderCreator, ResourceManager resourceManager) throws IOException { + CreateShaderInstance shaderCreator, ResourceProvider resourceManager) throws IOException { for (CBCRenderTypes renderType : values()) cons.accept(shaderCreator.create(resourceManager, renderType.id, renderType.renderType().format()), renderType::setShaderInstance); } public interface CreateShaderInstance { - ShaderInstance create(ResourceManager manager, ResourceLocation location, VertexFormat format) throws IOException; + ShaderInstance create(ResourceProvider manager, ResourceLocation location, VertexFormat format) throws IOException; } } diff --git a/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java b/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java index 7da70e4d0..c240f71b4 100644 --- a/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java +++ b/common/src/main/java/rbasamoyai/createbigcannons/munitions/big_cannon/drop_mortar_shell/DropMortarShellRenderer.java @@ -1,9 +1,10 @@ package rbasamoyai.createbigcannons.munitions.big_cannon.drop_mortar_shell; +import org.joml.Matrix3f; +import org.joml.Matrix4f; + import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; import com.simibubi.create.foundation.render.CachedBufferer; import net.minecraft.client.renderer.LightTexture; @@ -48,7 +49,7 @@ public void render(DropMortarShellProjectile entity, float entityYaw, float part poseStack.popPose(); if (isTracer) { - int frame = (int)((entity.getId() + entity.level.getGameTime()) % 4L); + int frame = (int)((entity.getId() + entity.level().getGameTime()) % 4L); ResourceLocation textureLoc = CreateBigCannons.resource(String.format("textures/entity/tracer_glow%d.png", frame)); RenderType renderType = RenderType.entityCutoutNoCull(textureLoc); diff --git a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java index c5d2a8d83..01a65fc9f 100644 --- a/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java +++ b/fabric/src/main/java/rbasamoyai/createbigcannons/fabric/CBCClientFabric.java @@ -6,7 +6,6 @@ import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexFormat; import io.github.fabricators_of_create.porting_lib.event.client.CameraSetupCallback; import io.github.fabricators_of_create.porting_lib.event.client.ClientWorldEvents; @@ -22,6 +21,7 @@ import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; @@ -34,7 +34,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.ShaderInstance; import net.minecraft.client.renderer.entity.LivingEntityRenderer; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; @@ -74,7 +73,7 @@ public void onInitializeClient() { ClientWorldEvents.LOAD.register(CBCClientFabric::onLoadClientLevel); ClientLoginConnectionEvents.INIT.register(CBCClientFabric::onPlayerLogIn); ModsLoadedCallback.EVENT.register(CBCClientFabric::onModsLoaded); - RegisterShadersCallback.EVENT.register(CBCClientFabric::onShaderReload); + CoreShaderRegistrationCallback.EVENT.register(CBCClientFabric::onShaderReload); } private static void wrapOverlay(String id, CBCClientCommon.CBCGuiOverlay overlay) { @@ -196,12 +195,9 @@ public CompletableFuture reload(PreparationBarrier preparationBarrier, Res ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(listener); } - public static void onShaderReload(ResourceManager resourceManager, RegisterShadersCallback.ShaderRegistry registry) throws IOException { - CBCRenderTypes.registerAllShaders(registry::registerShader, CBCClientFabric::createShader, resourceManager); - } - - private static ShaderInstance createShader(ResourceManager manager, ResourceLocation loc, VertexFormat format) throws IOException { - return new ShaderInstance(manager, loc.toString(), format); + public static void onShaderReload(CoreShaderRegistrationCallback.RegistrationContext context) throws IOException { + for (CBCRenderTypes renderType : CBCRenderTypes.values()) + context.register(renderType.id(), renderType.renderType().format(), renderType::setShaderInstance); } }