Skip to content

Commit

Permalink
improvement, refactor: Added more support for Copycats+ block armor p…
Browse files Browse the repository at this point in the history
…roperties

- Switched to using id references instead of field references for better old version compatibility
  • Loading branch information
rbasamoyai committed Dec 8, 2024
1 parent 5ce3b73 commit cde4160
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 39 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Changed:
- Changed AP Shell texture to better show base fuze location
- Changed wording on some tooltips
- Made the Quick-Firing Breech openable using the side lever
- Copycats+ is now supported for 2.1.4
- Added more support for Copycats+ block armor properties
- Copycats+ 1.2.5 is the minimum supported version
Fixed:
- Fixed autocannon round duplication glitch
- Fixed projectile ground tracking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import javax.annotation.Nullable;

import com.simibubi.create.content.kinetics.deployer.DeployerRecipeSearchEvent;

import io.github.fabricators_of_create.porting_lib.event.common.ModsLoadedCallback;
Expand Down Expand Up @@ -42,8 +44,6 @@
import rbasamoyai.createbigcannons.compat.trinkets.CBCTrinketsIntegration;
import rbasamoyai.createbigcannons.equipment.gas_mask.GasMaskItem;

import javax.annotation.Nullable;

public class CBCCommonFabricEvents {

public static void register() {
Expand All @@ -66,7 +66,7 @@ public static void onModsLoaded(EnvType type) {
GasMaskItem.registerDefaultHandlers();
DefaultCreateCompat.init();
DefaultCannonMountPropertiesSerializers.init();
CBCModsFabric.COPYCATS.executeIfInstalled(() -> () -> CopycatsCompat.init());
CBCModsFabric.COPYCATS.executeIfInstalled(() -> () -> CopycatsCompat.init(CBCModsFabric.COPYCATS::getBlock));
CBCModsFabric.TRINKETS.executeIfInstalled(() -> () -> CBCTrinketsIntegration.init());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void onCommonSetup(FMLCommonSetupEvent event) {
CreateBigCannons.onCommonSetup();
DefaultCreateCompat.init();
DefaultCannonMountPropertiesSerializers.init();
CBCModsForge.COPYCATS.executeIfInstalled(() -> () -> CopycatsCompat.init());
CBCModsForge.COPYCATS.executeIfInstalled(() -> () -> CopycatsCompat.init(CBCModsForge.COPYCATS::getBlock));
CBCModsForge.FRAMEDBLOCKS.executeIfInstalled(() -> () -> FramedBlocksCompat.init());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,57 @@

import static rbasamoyai.createbigcannons.block_armor_properties.mimicking_blocks.AbstractMimickingBlockArmorProperties.createMimicrySerializer;

import com.copycatsplus.copycats.CCBlocks;
import java.util.function.Function;

import javax.annotation.Nullable;

import net.minecraft.world.level.block.Block;
import rbasamoyai.createbigcannons.block_armor_properties.BlockArmorPropertiesHandler;
import rbasamoyai.createbigcannons.block_armor_properties.mimicking_blocks.CopycatBlockArmorProperties;

public class CopycatsCompat {

public static void init() {
registerCopycatSerializer(CCBlocks.COPYCAT_BLOCK.get());
registerCopycatSerializer(CCBlocks.COPYCAT_BEAM.get());
registerCopycatSerializer(CCBlocks.COPYCAT_BOARD.get());
registerCopycatSerializer(CCBlocks.COPYCAT_WOODEN_BUTTON.get());
registerCopycatSerializer(CCBlocks.COPYCAT_STONE_BUTTON.get());
registerCopycatSerializer(CCBlocks.COPYCAT_BYTE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_FENCE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_FENCE_GATE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_HALF_LAYER.get());
registerCopycatSerializer(CCBlocks.COPYCAT_HALF_PANEL.get());
registerCopycatSerializer(CCBlocks.COPYCAT_LADDER.get());
registerCopycatSerializer(CCBlocks.COPYCAT_LAYER.get());
registerCopycatSerializer(CCBlocks.COPYCAT_WOODEN_PRESSURE_PLATE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_STONE_PRESSURE_PLATE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_HEAVY_WEIGHTED_PRESSURE_PLATE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_LIGHT_WEIGHTED_PRESSURE_PLATE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_SLAB.get());
registerCopycatSerializer(CCBlocks.COPYCAT_SLICE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_STAIRS.get());
registerCopycatSerializer(CCBlocks.COPYCAT_VERTICAL_STAIRS.get());
registerCopycatSerializer(CCBlocks.COPYCAT_TRAPDOOR.get());
registerCopycatSerializer(CCBlocks.COPYCAT_IRON_TRAPDOOR.get());
registerCopycatSerializer(CCBlocks.COPYCAT_VERTICAL_SLICE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_VERTICAL_STEP.get());
registerCopycatSerializer(CCBlocks.COPYCAT_WALL.get());
registerCopycatSerializer(CCBlocks.COPYCAT_SLOPE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_VERTICAL_SLOPE.get());
registerCopycatSerializer(CCBlocks.COPYCAT_SLOPE_LAYER.get());
registerCopycatSerializer(CCBlocks.COPYCAT_DOOR.get());
registerCopycatSerializer(CCBlocks.COPYCAT_IRON_DOOR.get());

public static void init(Function<String, Block> blockGetter) {
registerCopycatSerializer(blockGetter.apply("copycat_block"));
registerCopycatSerializer(blockGetter.apply("copycat_beam"));
registerCopycatSerializer(blockGetter.apply("copycat_board"));
registerCopycatSerializer(blockGetter.apply("copycat_wooden_button"));
registerCopycatSerializer(blockGetter.apply("copycat_stone_button"));
registerCopycatSerializer(blockGetter.apply("copycat_byte"));
registerCopycatSerializer(blockGetter.apply("copycat_fence"));
registerCopycatSerializer(blockGetter.apply("copycat_fence_gate"));
registerCopycatSerializer(blockGetter.apply("copycat_half_layer"));
registerCopycatSerializer(blockGetter.apply("copycat_half_panel"));
registerCopycatSerializer(blockGetter.apply("copycat_ladder"));
registerCopycatSerializer(blockGetter.apply("copycat_layer"));
registerCopycatSerializer(blockGetter.apply("copycat_wooden_pressure_plate"));
registerCopycatSerializer(blockGetter.apply("copycat_stone_pressure_plate"));
registerCopycatSerializer(blockGetter.apply("copycat_heavy_weighted_pressure_plate"));
registerCopycatSerializer(blockGetter.apply("copycat_light_weighted_pressure_plate"));
registerCopycatSerializer(blockGetter.apply("copycat_slab"));
registerCopycatSerializer(blockGetter.apply("copycat_slice"));
registerCopycatSerializer(blockGetter.apply("copycat_stairs"));
registerCopycatSerializer(blockGetter.apply("copycat_vertical_stairs"));
registerCopycatSerializer(blockGetter.apply("copycat_trapdoor"));
registerCopycatSerializer(blockGetter.apply("copycat_iron_trapdoor"));
registerCopycatSerializer(blockGetter.apply("copycat_vertical_slice"));
registerCopycatSerializer(blockGetter.apply("copycat_vertical_step"));
registerCopycatSerializer(blockGetter.apply("copycat_wall"));
registerCopycatSerializer(blockGetter.apply("copycat_slope"));
registerCopycatSerializer(blockGetter.apply("copycat_vertical_slope"));
registerCopycatSerializer(blockGetter.apply("copycat_slope_layer"));
registerCopycatSerializer(blockGetter.apply("copycat_door"));
registerCopycatSerializer(blockGetter.apply("copycat_iron_door"));
registerCopycatSerializer(blockGetter.apply("copycat_fluid_pipe"));
registerCopycatSerializer(blockGetter.apply("copycat_glass_fluid_pipe"));
registerCopycatSerializer(blockGetter.apply("copycat_shaft"));
registerCopycatSerializer(blockGetter.apply("copycat_cogwheel"));
registerCopycatSerializer(blockGetter.apply("copycat_large_cogwheel"));
}

private static void registerCopycatSerializer(Block block) {
BlockArmorPropertiesHandler.registerCustomSerializer(block, createMimicrySerializer(CopycatBlockArmorProperties::new));
private static void registerCopycatSerializer(@Nullable Block block) {
if (block != null)
BlockArmorPropertiesHandler.registerCustomSerializer(block, createMimicrySerializer(CopycatBlockArmorProperties::new));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.25,
"material_toughness_multiplier": 0.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.25,
"material_toughness_multiplier": 0.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.25,
"material_toughness_multiplier": 0.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 1.25,
"material_toughness_multiplier": 1.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.5,
"material_toughness_multiplier": 0.5,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.25,
"material_toughness_multiplier": 0.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.25,
"material_toughness_multiplier": 0.25,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.5,
"material_toughness_multiplier": 0.5,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default_toughness": 0.5,
"material_toughness_multiplier": 0.5,
"default_hardness": 1,
"material_hardness_multiplier": 1,
"variants": {
"layers=8": {
"default_toughness": 1,
"material_toughness_multiplier": 1,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.5,
"material_toughness_multiplier": 0.5,
"default_hardness": 1,
"material_hardness_multiplier": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_toughness": 0.75,
"material_toughness_multiplier": 0.75,
"default_hardness": 1,
"material_hardness_multiplier": 1
}

0 comments on commit cde4160

Please sign in to comment.