Skip to content

Commit

Permalink
improvement, bug: Added missing features to cannon mount blocks
Browse files Browse the repository at this point in the history
- Added direct item input to Fixed Cannon Mount and Cannon Mount Extension
- Added mechanical arm support to Cannon Mount Extension
- Also added item input and mechanical arm support to the Yaw Controller
- Added cannon contraption info tooltip to Fixed Cannon Mount
- Renamed CannonMountMixin to CannonMountBlockEntityMixin on Fabric and Forge
- Improved placement of Cannon Mount Extension to prioritize adjacent Cannon Mounts
- Added tooltip to Fixed Cannon Mount
  • Loading branch information
rbasamoyai committed Jan 4, 2025
1 parent 4986909 commit a3478ce
Show file tree
Hide file tree
Showing 17 changed files with 273 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

**Create Big Cannons 5.8.2. Comes with a few fixes, mainly for missing functionality.**

Added:
- Added direct item input to Fixed Cannon Mount and Cannon Mount Extension
- Also added direct item input to Yaw Controller
- Added Mechanical Arm support to Cannon Mount Extension
- Also added Mechanical Arm support to Yaw Controller
- Added cannon contraption info tooltip to Fixed Cannon Mount
- Added tooltip to Fixed Cannon Mount
Changed:
- Improved placement of Cannon Mount Extension to prioritize adjacent Cannon Mounts

## [5.8.1] - 2024-12-31

*"I'm free – I'm FREE, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;

@Mixin(CannonMountBlockEntity.class)
public abstract class CannonMountMixin extends SmartBlockEntity implements SidedStorageBlockEntity {
public abstract class CannonMountBlockEntityMixin extends SmartBlockEntity implements SidedStorageBlockEntity {

CannonMountMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
CannonMountBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package rbasamoyai.createbigcannons.fabric.mixin;

import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;

import com.simibubi.create.content.kinetics.base.KineticBlockEntity;

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountExtensionBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.ExtendsCannonMount;

@Mixin(CannonMountExtensionBlockEntity.class)
public abstract class CannonMountExtensionBlockEntityMixin extends KineticBlockEntity implements ExtendsCannonMount, SidedStorageBlockEntity {

CannonMountExtensionBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { super(typeIn, pos, state); }

@Nullable
@Override
public Storage<ItemVariant> getItemStorage(@Nullable Direction face) {
CannonMountBlockEntity mount = this.getCannonMount();
return mount instanceof SidedStorageBlockEntity transferable ? transferable.getItemStorage(face) : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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.cannon_mount.ExtendsCannonMount;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
Expand All @@ -31,7 +32,10 @@ public ItemStack insert(ItemStack stack, TransactionContext ctx) {
if (!simulate) stack.getTag().remove("DontSimulate");
BlockEntity be = this.getLevel().getBlockEntity(this.pos);
PitchOrientedContraptionEntity poce;
if (be instanceof CannonMountBlockEntity mount) {
if (be instanceof ExtendsCannonMount extendsMount) {
CannonMountBlockEntity mount = extendsMount.getCannonMount();
if (mount == null)
return stack;
poce = mount.getContraption();
} else if (be instanceof FixedCannonMountBlockEntity mount) {
poce = mount.getContraption();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package rbasamoyai.createbigcannons.fabric.mixin;

import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;

@Mixin(FixedCannonMountBlockEntity.class)
public abstract class FixedCannonMountBlockEntityMixin extends SmartBlockEntity implements SidedStorageBlockEntity {

FixedCannonMountBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { super(typeIn, pos, state); }

@Shadow
protected PitchOrientedContraptionEntity mountedContraption;

@Nullable
@Override
public Storage<ItemVariant> getItemStorage(@Nullable Direction face) {
return this.mountedContraption instanceof SidedStorageBlockEntity transferable ? transferable.getItemStorage(face) : null;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package rbasamoyai.createbigcannons.fabric.mixin;

import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;

import com.simibubi.create.content.kinetics.base.KineticBlockEntity;

import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.ExtendsCannonMount;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.YawControllerBlockEntity;

@Mixin(YawControllerBlockEntity.class)
public abstract class YawControllerBlockEntityMixin extends KineticBlockEntity implements ExtendsCannonMount, SidedStorageBlockEntity {

YawControllerBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { super(typeIn, pos, state); }

@Nullable
@Override
public Storage<ItemVariant> getItemStorage(@Nullable Direction face) {
CannonMountBlockEntity mount = this.getCannonMount();
return mount instanceof SidedStorageBlockEntity transferable ? transferable.getItemStorage(face) : null;
}

}
5 changes: 4 additions & 1 deletion fabric/src/main/resources/createbigcannons.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
"ArmTileEntityMixin",
"AutocannonAmmoContainerBlockEntityMixin",
"BigCartridgeBlockMixin",
"CannonMountMixin",
"CannonMountBlockEntityMixin",
"CannonMountExtensionBlockEntityMixin",
"CannonMountPointMixin",
"CreateInitMixin",
"ExplosionMixin",
"FireBlockMixin",
"FixedCannonMountBlockEntityMixin",
"GasMaskItemMixin",
"MountedAutocannonContraptionMixin",
"PitchOrientedContraptionEntityMixin",
"PowderChargeBlockMixin",
"YawControllerBlockEntityMixin",
"compat.fabric_api.ItemStorageMixin"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;

@Mixin(CannonMountBlockEntity.class)
public abstract class CannonMountMixin extends SmartBlockEntity {
public abstract class CannonMountBlockEntityMixin extends SmartBlockEntity {

CannonMountMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
CannonMountBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package rbasamoyai.createbigcannons.forge.mixin;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;

import com.simibubi.create.content.kinetics.base.KineticBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountExtensionBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.ExtendsCannonMount;

@Mixin(CannonMountExtensionBlockEntity.class)
public abstract class CannonMountExtensionBlockEntityMixin extends KineticBlockEntity implements ExtendsCannonMount {

CannonMountExtensionBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
}

@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
CannonMountBlockEntity cannonMount = this.getCannonMount();
return cannonMount == null ? super.getCapability(cap, side) : cannonMount.getCapability(cap, side);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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.cannon_mount.ExtendsCannonMount;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;
Expand All @@ -28,7 +29,10 @@ public ItemStack insert(ItemStack stack, boolean simulate) {
CannonMountPoint self = (CannonMountPoint) (Object) this;
BlockEntity be = this.getLevel().getBlockEntity(this.pos);
PitchOrientedContraptionEntity poce;
if (be instanceof CannonMountBlockEntity mount) {
if (be instanceof ExtendsCannonMount extendsMount) {
CannonMountBlockEntity mount = extendsMount.getCannonMount();
if (mount == null)
return stack;
poce = mount.getContraption();
} else if (be instanceof FixedCannonMountBlockEntity mount) {
poce = mount.getContraption();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package rbasamoyai.createbigcannons.forge.mixin;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;

import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;

import dev.architectury.patchedmixin.staticmixin.spongepowered.asm.mixin.Shadow;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannon_control.fixed_cannon_mount.FixedCannonMountBlockEntity;

@Mixin(FixedCannonMountBlockEntity.class)
public abstract class FixedCannonMountBlockEntityMixin extends SmartBlockEntity {

FixedCannonMountBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
}

@Shadow
protected PitchOrientedContraptionEntity mountedContraption;

@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (cap == ForgeCapabilities.ITEM_HANDLER && this.mountedContraption != null) {
return this.mountedContraption.getCapability(cap, side).cast();
}
return super.getCapability(cap, side);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package rbasamoyai.createbigcannons.forge.mixin;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.spongepowered.asm.mixin.Mixin;

import com.simibubi.create.content.kinetics.base.KineticBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.ExtendsCannonMount;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.YawControllerBlockEntity;

@Mixin(YawControllerBlockEntity.class)
public abstract class YawControllerBlockEntityMixin extends KineticBlockEntity implements ExtendsCannonMount {

YawControllerBlockEntityMixin(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
}

@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
CannonMountBlockEntity cannonMount = this.getCannonMount();
return cannonMount == null ? super.getCapability(cap, side) : cannonMount.getCapability(cap, side);
}

}
5 changes: 4 additions & 1 deletion forge/src/main/resources/createbigcannons.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
"AbstractCannonProjectileMixin",
"AutocannonAmmoContainerBlockEntityMixin",
"BigCartridgeBlockMixin",
"CannonMountMixin",
"CannonMountBlockEntityMixin",
"CannonMountExtensionBlockEntityMixin",
"CannonMountPointMixin",
"CBCFlowingFluidMixin",
"CBCLiquidBlockMixin",
"FixedCannonMountBlockEntityMixin",
"GasMaskItemMixin",
"MountedAutocannonContraptionMixin",
"PitchOrientedContraptionEntityMixin",
"PowderChargeBlockMixin",
"ProjectileBlockMixin",
"YawControllerBlockEntityMixin",
"compat.FramedAdjustableDoubleBlockEntityAccessor"
],
"injectors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import com.simibubi.create.content.kinetics.base.DirectionalKineticBlock;
import com.simibubi.create.foundation.block.IBE;
import com.simibubi.create.foundation.utility.Iterate;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import rbasamoyai.createbigcannons.index.CBCBlockEntities;
import rbasamoyai.createbigcannons.index.CBCBlocks;

public class CannonMountExtensionBlock extends DirectionalKineticBlock implements IBE<CannonMountExtensionBlockEntity> {

Expand Down Expand Up @@ -36,4 +40,15 @@ public BlockEntityType<? extends CannonMountExtensionBlockEntity> getBlockEntity
return CBCBlockEntities.CANNON_MOUNT_EXTENSION.get();
}

@Override
public Direction getPreferredFacing(BlockPlaceContext context) {
Level level = context.getLevel();
BlockPos pos = context.getClickedPos();
for (Direction dir : Iterate.directions) {
if (CBCBlocks.CANNON_MOUNT.has(level.getBlockState(pos.relative(dir))))
return dir.getOpposite();
}
return super.getPreferredFacing(context);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraft.world.phys.Vec3;
import rbasamoyai.createbigcannons.CreateBigCannons;
import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption;
import rbasamoyai.createbigcannons.cannon_control.cannon_mount.ExtendsCannonMount;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.cannons.CannonContraptionProviderBlock;
Expand Down Expand Up @@ -255,6 +256,12 @@ protected void read(CompoundTag tag, boolean clientPacket) {
this.mountedContraption = null;
}

@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
ExtendsCannonMount.addCannonInfoToTooltip(tooltip, this.mountedContraption);
return true;
}

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

0 comments on commit a3478ce

Please sign in to comment.