Skip to content

Commit

Permalink
bug, refactor: 5.8.0 mixin fixes
Browse files Browse the repository at this point in the history
- Override Forge methods instead of injecting into the Forge-modified method via ExplosionMixin [Forge]
- Fixed ValueSettingScreenMixin [common] by removing remap = false
  • Loading branch information
rbasamoyai committed Dec 30, 2024
1 parent dd10a2b commit edc2c25
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
import net.minecraft.core.Direction;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.munitions.big_cannon.propellant.BigCartridgeBlock;
import rbasamoyai.createbigcannons.munitions.big_cannon.propellant.BigCartridgeBlockEntity;
import rbasamoyai.createbigcannons.munitions.big_cannon.propellant.PrimedPropellant;
import rbasamoyai.createbigcannons.remix.CBCExplodableBlock;

@Mixin(BigCartridgeBlock.class)
public abstract class BigCartridgeBlockMixin extends DirectionalBlock {
public abstract class BigCartridgeBlockMixin extends DirectionalBlock implements CBCExplodableBlock {

BigCartridgeBlockMixin(Properties properties) { super(properties); }

Expand All @@ -29,6 +31,12 @@ public void onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable
level.removeBlock(pos, false);
}

@Override
public void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) {
this.createbigcannons$onBlockExplode(level, pos, state, explosion);
super.onBlockExploded(state, level, pos, explosion);
}

@Override
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return level.getBlockEntity(pos) instanceof BigCartridgeBlockEntity cartridge && cartridge.getPower() > 0 ? 30 : 0;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import net.minecraft.core.Direction;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.munitions.big_cannon.propellant.PowderChargeBlock;
import rbasamoyai.createbigcannons.munitions.big_cannon.propellant.PrimedPropellant;
import rbasamoyai.createbigcannons.remix.CBCExplodableBlock;

@Mixin(PowderChargeBlock.class)
public abstract class PowderChargeBlockMixin extends RotatedPillarBlock {
public abstract class PowderChargeBlockMixin extends RotatedPillarBlock implements CBCExplodableBlock {

PowderChargeBlockMixin(Properties properties) { super(properties); }

Expand All @@ -28,6 +30,12 @@ public void onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable
level.removeBlock(pos, false);
}

@Override
public void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) {
this.createbigcannons$onBlockExplode(level, pos, state, explosion);
super.onBlockExploded(state, level, pos, explosion);
}

@Override
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return 100;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package rbasamoyai.createbigcannons.forge.mixin;

import org.spongepowered.asm.mixin.Mixin;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.munitions.big_cannon.ProjectileBlock;
import rbasamoyai.createbigcannons.remix.CBCExplodableBlock;

@Mixin(ProjectileBlock.class)
public class ProjectileBlockMixin extends DirectionalBlock implements CBCExplodableBlock {

ProjectileBlockMixin(Properties arg) { super(arg); }

@Override
public void onBlockExploded(BlockState state, Level level, BlockPos pos, Explosion explosion) {
this.createbigcannons$onBlockExplode(level, pos, state, explosion);
super.onBlockExploded(state, level, pos, explosion);
}

}
2 changes: 1 addition & 1 deletion forge/src/main/resources/createbigcannons.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"CannonMountPointMixin",
"CBCFlowingFluidMixin",
"CBCLiquidBlockMixin",
"ExplosionMixin",
"GasMaskItemMixin",
"MountedAutocannonContraptionMixin",
"PitchOrientedContraptionEntityMixin",
"PowderChargeBlockMixin",
"ProjectileBlockMixin",
"compat.FramedAdjustableDoubleBlockEntityAccessor"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ValueSettingsClientMixin {

@Shadow public BlockPos interactHeldPos;

@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/gui/ScreenOpener;open(Lnet/minecraft/client/gui/screens/Screen;)V"), remap = false)
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/gui/ScreenOpener;open(Lnet/minecraft/client/gui/screens/Screen;)V"))
private void createbigcannons$tick$openScreen(Screen screen, Operation<Void> original, @Local ValueSettingsBehaviour valueSettingBehaviour,
@Local Player player, @Local BlockHitResult blockHitResult) {
if (valueSettingBehaviour instanceof FixedCannonMountScrollValueBehaviour fixedMountBehaviour) {
Expand Down

0 comments on commit edc2c25

Please sign in to comment.