Skip to content

Commit

Permalink
improvement: Added Mechanical Arm interaction with Fixed Cannon Mount
Browse files Browse the repository at this point in the history
  • Loading branch information
rbasamoyai committed Dec 31, 2024
1 parent 3750a52 commit 4369748
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
and I'm waiting for you to follow me..."* \
– "I'm Free", The Who (1969)

**Create Big Cannons 5.8.1. Comes with a few critical fixes for Create Big Cannons 5.8.0.**
**Create Big Cannons 5.8.1. Comes with a few critical fixes and improvements for Create Big Cannons 5.8.0.**

### Added
- Added recipes for Fixed Cannon Mount and Wired Fuze (fixes issue #730)
- Added Mechanical Arm interaction with Fixed Cannon Mount

## [5.8.0] - 2024-12-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannons.big_cannons.breeches.quickfiring_breech.CannonMountPoint;

@Mixin(CannonMountPoint.class)
Expand All @@ -27,9 +29,17 @@ public ItemStack insert(ItemStack stack, TransactionContext ctx) {
CannonMountPoint self = (CannonMountPoint) (Object) this;
boolean simulate = !stack.getOrCreateTag().contains("DontSimulate");
if (!simulate) stack.getTag().remove("DontSimulate");
if (!(this.getLevel().getBlockEntity(this.pos) instanceof CannonMountBlockEntity mount)) return stack;
PitchOrientedContraptionEntity poce = mount.getContraption();
if (poce == null || !(poce.getContraption() instanceof AbstractMountedCannonContraption cannon)) return stack;
BlockEntity be = this.getLevel().getBlockEntity(this.pos);
PitchOrientedContraptionEntity poce;
if (be instanceof CannonMountBlockEntity mount) {
poce = mount.getContraption();
} else if (be instanceof FixedCannonMountBlockEntity mount) {
poce = mount.getContraption();
} else {
return stack;
}
if (poce == null || !(poce.getContraption() instanceof AbstractMountedCannonContraption cannon))
return stack;
return self.getInsertedResultAndDoSomething(stack, simulate, cannon, poce);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannons.big_cannons.breeches.quickfiring_breech.CannonMountPoint;

@Mixin(CannonMountPoint.class)
Expand All @@ -24,9 +26,17 @@ public abstract class CannonMountPointMixin extends ArmInteractionPoint {
@Override
public ItemStack insert(ItemStack stack, boolean simulate) {
CannonMountPoint self = (CannonMountPoint) (Object) this;
if (!(this.getLevel().getBlockEntity(this.pos) instanceof CannonMountBlockEntity mount)) return stack;
PitchOrientedContraptionEntity poce = mount.getContraption();
if (poce == null || !(poce.getContraption() instanceof AbstractMountedCannonContraption cannon)) return stack;
BlockEntity be = this.getLevel().getBlockEntity(this.pos);
PitchOrientedContraptionEntity poce;
if (be instanceof CannonMountBlockEntity mount) {
poce = mount.getContraption();
} else if (be instanceof FixedCannonMountBlockEntity mount) {
poce = mount.getContraption();
} else {
return stack;
}
if (poce == null || !(poce.getContraption() instanceof AbstractMountedCannonContraption cannon))
return stack;
return self.getInsertedResultAndDoSomething(stack, simulate, cannon, poce);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.util.List;

import javax.annotation.Nullable;

import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
Expand Down Expand Up @@ -253,6 +255,13 @@ protected void read(CompoundTag tag, boolean clientPacket) {
this.mountedContraption = null;
}

public Vec3 getInteractionLocation() {
return this.mountedContraption != null && this.mountedContraption.getContraption() instanceof AbstractMountedCannonContraption cannon
? cannon.getInteractionVec(this.mountedContraption) : Vec3.atCenterOf(this.worldPosition);
}

@Nullable public PitchOrientedContraptionEntity getContraption() { return this.mountedContraption; }

public static class FixedCannonMountScrollValueBehaviour extends ValveHandleBlockEntity.ValveHandleScrollValueBehaviour {
public static final BehaviourType<FixedCannonMountScrollValueBehaviour> PITCH_TYPE = new BehaviourType<>();
public static final BehaviourType<FixedCannonMountScrollValueBehaviour> YAW_TYPE = new BehaviourType<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import rbasamoyai.createbigcannons.cannon_control.contraption.MountedAutocannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.MountedBigCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannons.autocannon.breech.AbstractAutocannonBreechBlockEntity;
import rbasamoyai.createbigcannons.cannons.big_cannons.BigCannonBlock;
import rbasamoyai.createbigcannons.cannons.big_cannons.IBigCannonBlockEntity;
Expand All @@ -39,7 +40,12 @@ public CannonMountPoint(ArmInteractionPointType type, Level level, BlockPos pos,

@Override
protected Vec3 getInteractionPositionVector() {
return this.getLevel().getBlockEntity(this.pos) instanceof CannonMountBlockEntity mount ? mount.getInteractionLocation() : super.getInteractionPositionVector();
BlockEntity be = this.getLevel().getBlockEntity(this.pos);
if (be instanceof CannonMountBlockEntity mount)
return mount.getInteractionLocation();
if (be instanceof FixedCannonMountBlockEntity mount)
return mount.getInteractionLocation();
return super.getInteractionPositionVector();
}

public ItemStack getInsertedResultAndDoSomething(ItemStack stack, boolean simulate, AbstractMountedCannonContraption cannon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.CreateBigCannons;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannons.big_cannons.breeches.quickfiring_breech.CannonMountPoint;

public class CBCArmInteractionPointTypes {
Expand All @@ -32,7 +33,11 @@ public CannonMountType(ResourceLocation id) {

@Override
public boolean canCreatePoint(Level level, BlockPos pos, BlockState state) {
return CBCBlocks.CANNON_MOUNT.has(state) && level.getBlockEntity(pos) instanceof CannonMountBlockEntity;
if (CBCBlocks.CANNON_MOUNT.has(state))
return level.getBlockEntity(pos) instanceof CannonMountBlockEntity;
if (CBCBlocks.FIXED_CANNON_MOUNT.has(state))
return level.getBlockEntity(pos) instanceof FixedCannonMountBlockEntity;
return false;
}

@Nullable
Expand Down

0 comments on commit 4369748

Please sign in to comment.