Skip to content

Commit

Permalink
fix crash & bump to 0.0.6e
Browse files Browse the repository at this point in the history
  • Loading branch information
xiewuzhiying committed Aug 31, 2024
1 parent 6db4664 commit 93b9fab
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 178 deletions.
9 changes: 1 addition & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Change Log
## Common
- [1.18.2] Fix crash when using deployer
- New method `getX()` `getY()` `getZ()` for cannon mount peripheral - by [nosqd](https://github.com/nosqd)
- Fix `fire()` method of cannon mount peripheral didn't work for auto cannons
- Move config file item (which means backing up configuration values and deleting old configuration files)
- Fix a crash when launching with create without clockwork
## Fabric
## Forge
- Fix rotary cannon can't fire again while on a ship (not caused by vs2)
- Add recoil for rotary cannon
- Fix medium cannon mechanical arm interaction (also not caused by vs2)
- Fix a crash when CBC Modern Warfare is not installed
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ object VSAdditionMod {
@JvmStatic var EUREKA_ACTIVE = false
@JvmStatic var INTERACTIVE_ACTIVE = false
@JvmStatic var COMPUTERCRAT_ACTIVE = false
@JvmStatic var FRAMEDBLOCKS_ACTIVE = false
@JvmStatic var CBCMW_ACTIVE = false

@JvmStatic
fun init() {
Expand All @@ -24,6 +26,8 @@ object VSAdditionMod {
EUREKA_ACTIVE = Platform.isModLoaded("vs_eureka")
INTERACTIVE_ACTIVE = Platform.isModLoaded("create_interactive")
COMPUTERCRAT_ACTIVE = Platform.isModLoaded("computercraft")
FRAMEDBLOCKS_ACTIVE = Platform.isModLoaded("framedblocks")
CBCMW_ACTIVE = Platform.isModLoaded("cbcmodernwarfare")

VSConfigClass.registerConfig("vs_addition", VSAdditionConfig::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
public class VSAdditionForgeMixinCanceller implements MixinCanceller {
@Override
public boolean shouldCancel(List<String> targetClassNames, String mixinClassName) {
if (mixinClassName.contains("riftyboi.cbcmodernwarfare.forge.mixin.CannonMountPointMixin")) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.xiewuzhiying.vs_addition.forge.mixin;

import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import io.github.xiewuzhiying.vs_addition.forge.VSAdditionModForge;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -22,9 +21,6 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.contains("io.github.xiewuzhiying.vs_addition.forge.mixin.cbcmodernwarfare")) {
VSAdditionModForge.Companion.getCBCMW_ACTIVE();
}
return true;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,86 +1,46 @@
package io.github.xiewuzhiying.vs_addition.forge.mixin.cbcmodernwarfare;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import rbasamoyai.createbigcannons.cannon_control.contraption.AbstractMountedCannonContraption;
import rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity;
import rbasamoyai.createbigcannons.config.CBCConfigs;
import riftyboi.cbcmodernwarfare.cannon_control.compact_mount.CompactCannonMountPoint;
import riftyboi.cbcmodernwarfare.cannon_control.contraption.MountedMediumcannonContraption;
import riftyboi.cbcmodernwarfare.cannons.medium_cannon.breech.MediumcannonBreechBlockEntity;
import riftyboi.cbcmodernwarfare.index.CBCModernWarfareItem;
import riftyboi.cbcmodernwarfare.munitions.medium_cannon.MediumcannonAmmoItem;
import riftyboi.cbcmodernwarfare.munitions.medium_cannon.MediumcannonCartridgeItem;

@Mixin(CompactCannonMountPoint.class)
public abstract class MixinCompactCannonMountPoint {
@Shadow(remap = false)
private static int getLoadingCooldown() {
throw new AssertionError();
}

@Inject(
method = "getInsertedResultAndDoSomething",
at = @At("RETURN"),
method = "mediumcannonInsert",
at = @At(
value = "INVOKE",
target = "Lriftyboi/cbcmodernwarfare/cannons/medium_cannon/breech/MediumcannonBreechBlockEntity;canBeAutomaticallyLoaded()Z",
shift = At.Shift.AFTER
),
cancellable = true,
remap = false
)
private void add(ItemStack stack, boolean simulate, AbstractMountedCannonContraption cannon, PitchOrientedContraptionEntity poce, CallbackInfoReturnable<ItemStack> cir) {
if (cannon instanceof MountedMediumcannonContraption mediumCannon) {
cir.setReturnValue(mediumcannonInsert(stack, simulate, mediumCannon, poce));
}
}

@Unique
private static ItemStack mediumcannonInsert(ItemStack stack, boolean simulate, MountedMediumcannonContraption mediumcannon, PitchOrientedContraptionEntity poce) {
Item item = stack.getItem();
if (!(item instanceof MediumcannonAmmoItem ammoItem)) {
return stack;
}

BlockEntity blockEntity = mediumcannon.presentBlockEntities.get(mediumcannon.getStartPos());
if (!(blockEntity instanceof MediumcannonBreechBlockEntity breech)) {
return stack;
}

if (!breech.canBeAutomaticallyLoaded()) {
return stack;
}

if (!(ammoItem instanceof MediumcannonCartridgeItem)) {
return stack;
}

if(breech.getInputBuffer().isEmpty()) {
if (!simulate) {
breech.setInputBuffer(stack);
breech.setLoadingCooldown(getLoadingCooldown());
}

ItemStack copy = stack.copy();
copy.shrink(1);
return copy;
}

private static void mediumcannonInsert(ItemStack stack, boolean simulate, MountedMediumcannonContraption mediumcannon, PitchOrientedContraptionEntity poce, CallbackInfoReturnable<ItemStack> cir, @Local MediumcannonBreechBlockEntity breech) {
Item item2 = breech.getInputBuffer().getItem();
if (CBCModernWarfareItem.EMPTY_MEDIUMCANNON_CARTRIDGE.get().equals(item2)) {
if (!simulate) {
breech.setInputBuffer(stack);
breech.setLoadingCooldown(getLoadingCooldown());
}
if (simulate) {
stack.setCount(1);
}
return new ItemStack(item2);
stack.setCount(1);
cir.setReturnValue(new ItemStack(item2));
}

return stack;
}


@Unique
private static int getLoadingCooldown() {
return CBCConfigs.SERVER.cannons.quickfiringBreechLoadingCooldown.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ import xfacthd.framedblocks.common.FBContent

@Mod(VSAdditionMod.MOD_ID)
class VSAdditionModForge {

init {
CREATE_ACTIVE = ModList.get().isLoaded("create")
CC_ACTIVE = ModList.get().isLoaded("computercraft")
FRAMEDBLOCKS_ACTIVE = ModList.get().isLoaded("framedblocks")
CBCMW_ACTIVE = ModList.get().isLoaded("cbcmodernwarfare")
init()

getModBus().addListener { event: FMLClientSetupEvent? ->
clientSetup(
Expand All @@ -51,8 +47,6 @@ class VSAdditionModForge {

EventBuses.registerModEventBus(VSAdditionMod.MOD_ID, MOD_CONTEXT.getKEventBus())

init()

ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory::class.java) {
ConfigScreenHandler.ConfigScreenFactory { _, parent ->
VSClothConfig.createConfigScreenFor(
Expand All @@ -77,7 +71,7 @@ class VSAdditionModForge {
}

private fun serverSetup(event: FMLCommonSetupEvent?) {
if(FRAMEDBLOCKS_ACTIVE && CREATE_ACTIVE)
if(VSAdditionMod.FRAMEDBLOCKS_ACTIVE && VSAdditionMod.CREATE_ACTIVE)
AllDisplayBehaviours.assignBlockEntity(
AllDisplayBehaviours.register(
ResourceLocation(
Expand All @@ -88,31 +82,27 @@ class VSAdditionModForge {
), FBContent.BE_TYPE_FRAMED_SIGN.get()
)

if(CC_ACTIVE)
if(VSAdditionMod.CC_ACTIVE)
Peripherals.register(ForgePeripheralProvider);
}

private fun rightClickBlock(event: RightClickBlock?) {
if(event==null)
return
if(CREATE_ACTIVE)
if(VSAdditionMod.CREATE_ACTIVE)
DualLinkHandler.onBlockActivated(event)
}

private fun clientTick(event: ClientTickEvent?) {
if(event==null)
return
if(CREATE_ACTIVE)
if(VSAdditionMod.CREATE_ACTIVE)
DualLinkRenderer.tick()
}

companion object {
fun getModBus(): IEventBus = MOD_BUS
fun getForgeBus(): IEventBus = FORGE_BUS
var CREATE_ACTIVE = false
var CC_ACTIVE = false
var FRAMEDBLOCKS_ACTIVE = false
var CBCMW_ACTIVE = false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.xiewuzhiying.vs_addition.forge.compats.computercraft

import dan200.computercraft.api.peripheral.IPeripheral
import io.github.xiewuzhiying.vs_addition.VSAdditionConfig
import io.github.xiewuzhiying.vs_addition.forge.VSAdditionModForge.Companion.CBCMW_ACTIVE
import io.github.xiewuzhiying.vs_addition.VSAdditionMod
import io.github.xiewuzhiying.vs_addition.forge.compats.computercraft.peripherals.CheatCompactCannonMountPeripheral
import io.github.xiewuzhiying.vs_addition.forge.compats.computercraft.peripherals.CompactCannonMountPeripheral
import net.minecraft.core.BlockPos
Expand All @@ -21,7 +21,7 @@ object PeripheralForge {
fun getPeripheralForge(level: Level, blockPos: BlockPos, direction: Direction?): IPeripheral? {
val s = level.getBlockState(blockPos)
val be = level.getBlockEntity(blockPos)
return if (CBCMW_ACTIVE && c(s, CBCModernWarfareBlocks.COMPACT_MOUNT.get())) {
return if (VSAdditionMod.CBCMW_ACTIVE && c(s, CBCModernWarfareBlocks.COMPACT_MOUNT.get())) {
if (VSAdditionConfig.SERVER.computercraft.enableCheatCannonMountPeripheral) CheatCompactCannonMountPeripheral(
"cbcmf_compact_cannon_mount",
be as CompactCannonMountBlockEntity
Expand Down
1 change: 0 additions & 1 deletion forge/src/main/resources/vs_addition.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"plugin": "io.github.xiewuzhiying.vs_addition.forge.mixin.VSAdditionForgeMixinConfigPlugin",
"mixins": [
"cbcmodernwarfare.CompactCannonMountBlockEntityAccessor",
"cbcmodernwarfare.MixinCannonMountPoint",
"cbcmodernwarfare.MixinCompactCannonMountPoint",
"cbcmodernwarfare.MixinMountedMediumcannonContraption",
"cbcmodernwarfare.MixinMountedRotarycannonContraption",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
# Identity
mod_name=vs_addition
mod_id=vs_addition
mod_version=0.0.6d
mod_version=0.0.6e
enabled_platforms=fabric,forge
archives_base_name=vs_addition
maven_group=io.github.xiewuzhiying
Expand Down

0 comments on commit 93b9fab

Please sign in to comment.