BlockPhysics compat

#160
This commit is contained in:
FalsePattern committed 2025-06-09 19:15:40 +02:00
1 parent 49a376b48d
commit 337a34108d
5 files changed
+66

No files matched your search

@@ -0,0 +1,58 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2025 FalsePattern, The MEGA Team
* All Rights Reserved
*
* The above copyright notice, this permission notice and the word "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.blockphysics;
import com.bloodnbonesgaming.blockphysics.util.DefinitionMaps;
import lombok.val;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.HashMap;
@Mixin(value = DefinitionMaps.class,
remap = false)
public abstract class DefinitionMapsMixin {
@Shadow private static HashMap<String, String[]> blockToBlockDefMap;
/**
* @author FalsePattern
* @reason Extra null safety and stuff. Hard to do with normal mixins.
*/
@Overwrite
public static String getBlockToBlockDef(String blockName, int meta) {
val arr = blockToBlockDefMap.get(blockName);
if (arr == null) {
return "default";
}
if (arr.length <= meta) {
return "default";
}
val elem = arr[meta];
if (elem == null) {
return "default";
}
return elem;
}
}
@@ -39,6 +39,7 @@ import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.ANTIQUEATLAS;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.ATG;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.BIOMETWEAKER;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.BIOMEWAND;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.BLOCKPHYSICS;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.BOP;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.BUILDCRAFT;
import static com.falsepattern.endlessids.mixin.plugin.TargetedMod.CLIMATECONTROL;
@@ -264,6 +265,8 @@ public class Mixin {
blockitem_vanilla_StatListMixin(EXT_BLOCK_ITEM),
blockitem_vanilla_WorldMixin(EXT_BLOCK_ITEM),
blockitem_blockphysics_DefinitionMapsMixin(EXT_BLOCK_ITEM, require(BLOCKPHYSICS)),
blockitem_cofhlib_BlockHelperMixin(EXT_BLOCK_ITEM, require(COFHLIB)),
blockitem_dragonapi_BlockPropertiesMixin(EXT_BLOCK_ITEM, require(DRAGONAPI)),
@@ -38,6 +38,7 @@ public enum TargetedMod implements ITargetedMod {
AM2("Ars Magica 2", false, contains("am2").or(contains("arsmagica2"))),
ANTIQUEATLAS("Antique Atlas", false, contains("antiqueatlas")),
ANTIIDCONFLICT("Anti ID Conflict", false, contains("antiidconflict")),
BLOCKPHYSICS("Block Physics", false, contains("blockphysics-")),
BOP("Biomes O' Plenty", false, contains("biomesoplenty-")),
BIOMETWEAKER("Biome Tweaker", false, contains("biometweaker-")),
BIOMEWAND("Biome Wand", false, contains("biome-wand")),