Skip to content

Commit

Permalink
update, bug: Updated Create Big Cannons version to 5.7.1, fixed pulle…
Browse files Browse the repository at this point in the history
…y sync

- Added cannon contraption registry checks to more places
  • Loading branch information
rbasamoyai committed Dec 15, 2024
1 parent bae2461 commit 502b8ab
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 19 deletions.
6 changes: 4 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Changelog

5.7.0
5.7.1

Create Big Cannon 5.7.0. Now supports Create 0.5.1 patch J on Forge/NeoForge and Fabric/Quilt.
Create Big Cannons 5.7.1. Now supports Create 0.5.1 patch J on Forge/NeoForge and Fabric/Quilt.
Only 1.20.1 is supported, as Create 0.5.1.j only supports that version. Mod versions on Minecraft 1.18.2 and 1.19.2 will no longer receive support.
5.7.0 was initially released but has been bypassed due to critical fixes required.

Added:
- Added highlighting and documentation for base fuzes
Expand All @@ -23,6 +24,7 @@ Fixed:
- Fixed strength attributes for incomplete and unbored sliding breeches to be consistent with complete sliding breeches
- Fixed elevator assembly issue
- Fixed sticky piston loading
- Fixed pulley sync

5.6.0

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.caching=true


# Mod properties
mod.version=5.7.0
mod.version=5.7.1
mod.group=com.rbasamoyai
mod.id=createbigcannons

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public interface CanLoadBigCannon {

@Nullable Direction createbigcannons$getAssemblyMovementDirection(Level level);
@Nullable Direction createbigcannons$getOriginalForcedDirection(Level level);

BlockPos createbigcannons$toLocalPos(BlockPos globalPos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ protected boolean customBlockRemoval(LevelAccessor level, BlockPos pos, BlockSta
return this.orientation != null && this.retract ? this.orientation.getOpposite() : this.orientation;
}

@Nullable
@Override
public Direction createbigcannons$getOriginalForcedDirection(Level level) {
return this.orientation != null && this.retract ? this.orientation.getOpposite() : this.orientation;
}

@Override
public void readNBT(Level level, CompoundTag tag, boolean spawnData) {
super.readNBT(level, tag, spawnData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.storage.WritableLevelData;
import rbasamoyai.createbigcannons.cannon_loading.CBCModifiedContraptionRegistry;
import rbasamoyai.createbigcannons.remix.HasFragileContraption;

@Mixin(ServerLevel.class)
Expand All @@ -32,8 +33,8 @@ public abstract class ServerLevelMixin extends Level {
@ModifyReturnValue(method = "addFreshEntity", at = @At("RETURN"))
private boolean createbigcannons$addFreshEntity(boolean original, Entity entity) {
// Lazy check but whatever
if (original && entity instanceof AbstractContraptionEntity ace && ace.getContraption() instanceof HasFragileContraption fragile)
HasFragileContraption.checkForIntersectingBlocks(this, ace, fragile);
if (original && entity instanceof AbstractContraptionEntity ace && CBCModifiedContraptionRegistry.isFragileContraption(ace.getContraption()))
HasFragileContraption.checkForIntersectingBlocks(this, ace, (HasFragileContraption) ace.getContraption());
return original;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import rbasamoyai.createbigcannons.cannon_loading.CBCModifiedContraptionRegistry;
import rbasamoyai.createbigcannons.remix.HasFragileContraption;

@Mixin(AbstractContraptionEntity.class)
Expand All @@ -32,7 +33,8 @@ public abstract class AbstractContraptionEntityMixin extends Entity {

@Inject(method = "tick", at = @At("TAIL"))
private void createbigcannons$tick(CallbackInfo ci) {
if (this.contraption instanceof HasFragileContraption fragile) {
if (CBCModifiedContraptionRegistry.isFragileContraption(this.contraption)) {
HasFragileContraption fragile = (HasFragileContraption) this.contraption;
if (this.level() != null
&& !this.level().isClientSide
&& HasFragileContraption.checkForIntersectingBlocks(this.level(), this.self, fragile)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import rbasamoyai.createbigcannons.cannon_loading.CBCModifiedContraptionRegistry;
import rbasamoyai.createbigcannons.cannon_loading.CanLoadBigCannon;
import rbasamoyai.createbigcannons.crafting.builtup.CannonBuildingContraption;
import rbasamoyai.createbigcannons.crafting.builtup.LayeredBigCannonBlockEntity;
Expand All @@ -30,8 +31,8 @@ public abstract class ContraptionColliderMixin {
@Local BlockState collidedState,
@Local StructureBlockInfo blockInfo) {
if (original) return true;
if (contraption instanceof CanLoadBigCannon loader) {
boolean specialCollider = loader.createbigcannons$getCannonLoadingColliders().contains(pos);
if (CBCModifiedContraptionRegistry.canLoadBigCannon(contraption)) {
boolean specialCollider = ((CanLoadBigCannon) contraption).createbigcannons$getCannonLoadingColliders().contains(pos);
BlockPos offsetPos = pos.relative(movementDirection);
if (contraption.entity != null || !contraption.getBlocks().containsKey(offsetPos))
return ContraptionRemix.isLoadingCannon(level, colliderPos, movementDirection, collidedState, blockInfo) && !specialCollider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ public abstract class ContraptionMixin {
ContraptionRemix.stickerMarking((Contraption & CanLoadBigCannon) this.createbigcannons$self, level, attached, offset, forcedDirection);
}

@ModifyExpressionValue(method = "moveBlock",
at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/Contraption;movementAllowed(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z", ordinal = 1))
private boolean createbigcannons$moveBlock$bypassMovementError(boolean original,
@Local(argsOnly = true) Level level,
@Local(argsOnly = true) Direction forcedDirection,
@Local(ordinal = 1) LocalRef<Direction> offset) {
if (original || !CBCModifiedContraptionRegistry.canLoadBigCannon(this.createbigcannons$self))
return original;
Direction offsetVal = offset.get();
Direction originalForcedDir = ((CanLoadBigCannon) this.createbigcannons$self).createbigcannons$getOriginalForcedDirection(level);
if (offsetVal != originalForcedDir && originalForcedDir != forcedDirection)
offset.set(offsetVal.getOpposite());
return 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<BlockPos> frontier,
Set<BlockPos> visited, CallbackInfoReturnable<Boolean> cir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public abstract class GantryContraptionMixin extends TranslatingContraption impl
return shaftBE.getPinionMovementSpeed() < 0 ? movementDirection.getOpposite() : movementDirection;
}

@Nullable
@Override
public Direction createbigcannons$getOriginalForcedDirection(Level level) {
return null;
}

@Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); }

@Override public Set<BlockPos> createbigcannons$getFragileBlockPositions() { return this.fragileBlocks; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ public abstract class PistonContraptionMixin extends TranslatingContraption impl
return this.orientation != null && this.retract ? this.orientation.getOpposite() : this.orientation;
}

@Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); }
@Nullable
@Override
public Direction createbigcannons$getOriginalForcedDirection(Level level) {
return this.orientation != null && this.retract ? this.orientation.getOpposite() : this.orientation;
}

@Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); }

@Override public Set<BlockPos> createbigcannons$getFragileBlockPositions() { return this.createbigcannons$fragileBlocks; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public abstract class PulleyContraptionMixin extends TranslatingContraption impl
return null;
}

@Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); }
@Nullable
@Override
public Direction createbigcannons$getOriginalForcedDirection(Level level) {
return null;
}

@Override public BlockPos createbigcannons$toLocalPos(BlockPos globalPos) { return this.toLocalPos(globalPos); }

@Override public Set<BlockPos> createbigcannons$getFragileBlockPositions() { return this.fragileBlocks; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import rbasamoyai.createbigcannons.cannon_loading.CBCModifiedContraptionRegistry;
import rbasamoyai.createbigcannons.cannon_loading.CanLoadBigCannon;
import rbasamoyai.createbigcannons.cannons.big_cannons.IBigCannonBlockEntity;

Expand All @@ -29,7 +30,7 @@ public abstract class TranslatingContraptionMixin extends Contraption {
private boolean createbigcannons$createColliders$0(boolean original, Level level, Direction movementDirection,
@Local StructureBlockInfo info, @Local BlockPos offsetPos) {
if (original) return true;
if (!(this instanceof CanLoadBigCannon)) return false;
if (!(CBCModifiedContraptionRegistry.canLoadBigCannon(this))) return false;
StructureBlockInfo offsetInfo = this.blocks.get(offsetPos);
Direction.Axis axis = movementDirection.getAxis();
if (info.state().getBlock() == AllBlocks.MECHANICAL_PISTON_HEAD.get()
Expand All @@ -39,9 +40,9 @@ public abstract class TranslatingContraptionMixin extends Contraption {

@Inject(method = "createColliders", at = @At("TAIL"), remap = false, cancellable = true)
private void createbigcannons$createColliders$1(Level level, Direction movementDirection, CallbackInfoReturnable<Set<BlockPos>> cir) {
if (!(this instanceof CanLoadBigCannon loader)) return;
if (!(CBCModifiedContraptionRegistry.canLoadBigCannon(this))) return;
Set<BlockPos> original = cir.getReturnValue();
original.addAll(loader.createbigcannons$getCannonLoadingColliders());
original.addAll(((CanLoadBigCannon) this).createbigcannons$getCannonLoadingColliders());
cir.setReturnValue(original); // Not sure if unnecessary but might as well --ritchie
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
import net.minecraft.world.level.material.PushReaction;
import rbasamoyai.createbigcannons.cannon_loading.CBCModifiedContraptionRegistry;
import rbasamoyai.createbigcannons.cannon_loading.CanLoadBigCannon;
import rbasamoyai.createbigcannons.cannons.CannonContraptionProviderBlock;
import rbasamoyai.createbigcannons.cannons.big_cannons.BigCannonBehavior;
Expand All @@ -58,16 +59,16 @@
public class ContraptionRemix {

public static boolean customBlockPlacement(Contraption contraption, LevelAccessor levelAccessor, BlockPos pos, BlockState state) {
if (contraption instanceof CanLoadBigCannon && contraption.entity != null) {
if (CBCModifiedContraptionRegistry.canLoadBigCannon(contraption) && contraption.entity != null) {
BlockPos entityAnchor = BlockPos.containing(contraption.entity.getAnchorVec().add(0.5d, 0.5d, 0.5d));

BlockPos blockPos = pos.subtract(entityAnchor);
StructureBlockInfo blockInfo = contraption.getBlocks().get(blockPos);
BlockEntity blockEntity1 = levelAccessor.getBlockEntity(pos);
BlockState intersectState = levelAccessor.getBlockState(pos);

if (contraption instanceof HasFragileContraption fragile) {
boolean isBrokenDisassembly = fragile.createbigcannons$isBrokenDisassembly();
if (CBCModifiedContraptionRegistry.isFragileContraption(contraption)) {
boolean isBrokenDisassembly = ((HasFragileContraption) contraption).createbigcannons$isBrokenDisassembly();
if (isBrokenDisassembly && !intersectState.isAir() && blockInfo != null && !blockInfo.state().isAir()) {
BlockEntity contraptionBE = blockInfo.nbt() == null ? null : BlockEntity.loadStatic(BlockPos.ZERO, blockInfo.state(), blockInfo.nbt());
Block.dropResources(blockInfo.state(), contraption.entity.level(), pos, contraptionBE, null, ItemStack.EMPTY);
Expand All @@ -88,7 +89,7 @@ public static boolean customBlockPlacement(Contraption contraption, LevelAccesso
}

public static boolean customBlockRemoval(Contraption contraption, LevelAccessor levelAccessor, BlockPos pos, BlockState state) {
if (contraption instanceof CanLoadBigCannon) {
if (CBCModifiedContraptionRegistry.canLoadBigCannon(contraption)) {
BlockState intersectState = levelAccessor.getBlockState(pos);
if (intersectState.getBlock() instanceof BigCannonBlock
&& levelAccessor.getBlockEntity(pos) instanceof IBigCannonBlockEntity cannon
Expand All @@ -112,7 +113,7 @@ public static void customChecks(Contraption contraption, Level level, BlockPos p
if (!(state1.getBlock() instanceof CannonContraptionProviderBlock provider)) return;
Direction facing = provider.getFacing(state1);
if (facing.getAxis().isVertical() || facing.getAxis() == mountFacing.getAxis()) {
if (contraption instanceof CanLoadBigCannon)
if (CBCModifiedContraptionRegistry.canLoadBigCannon(contraption))
simpleMarking((Contraption & CanLoadBigCannon) contraption, level, assemblyPos, Direction.DOWN, forcedDirection);
frontier.add(assemblyPos);
return;
Expand Down Expand Up @@ -683,7 +684,7 @@ public static boolean removeCannonContentsOnBreak(Level level, BlockPos pos, boo

public static void validateCannonRope(Contraption contraption, Level level, @Nullable Direction direction,
Function<BlockPos, BlockPos> toLocalPos) throws AssemblyException {
if (contraption instanceof CanLoadBigCannon && (direction == null || direction.getAxis().isVertical())) return;
if (CBCModifiedContraptionRegistry.canLoadBigCannon(contraption) && (direction == null || direction.getAxis().isVertical())) return;
BlockPos diff = toLocalPos.apply(BlockPos.ZERO).multiply(-1);

Set<BlockPos> blocksToCheck = new HashSet<>();
Expand Down

0 comments on commit 502b8ab

Please sign in to comment.