Skip to content

Commit

Permalink
Add support for chemicals as camos on framed blocks (#8209)
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD authored Aug 22, 2024
1 parent c390c8b commit a87b00c
Show file tree
Hide file tree
Showing 20 changed files with 812 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ dependencies {
compileOnly("cc.tweaked:cc-tweaked-${previous_minor_minecraft_version}-forge-api:${cc_tweaked_version}")
//localRuntime("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_tweaked_version}")
compileOnly("curse.maven:female-gender-forge-481655:${wildfire_gender_mod_id}")
compileOnly("curse.maven:framedblocks-441647:${framedblocks_mod_id}")

//Dependencies for data generators for mod compat reference
datagenMainImplementation("appeng:appliedenergistics2:${ae2_version}")
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ json_things_version=0.12.1
top_version=1.21_neo-12.0.3-5
wildfire_gender_mod_id=5579007
wthit_version=12.3.0
framedblocks_mod_id=5629510

#Mod dependency min version ranges

Expand Down
2 changes: 1 addition & 1 deletion src/api/java/mekanism/api/MekanismAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private MekanismAPI() {
/**
* The version of the api classes - may not always match the mod's version
*/
public static final String API_VERSION = "10.7.0";
public static final String API_VERSION = "10.7.1";
/**
* Mekanism's Mod ID
*/
Expand Down
6 changes: 6 additions & 0 deletions src/api/java/mekanism/api/MekanismAPITags.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ private Chemicals() {
* Represents all clean slurries.
*/
public static final TagKey<Chemical> CLEAN = tag("clean");
/**
* Chemicals in this tag cannot be inserted into framed blocks
*
* @since 10.7.1
*/
public static final TagKey<Chemical> FRAMEDBLOCKS_BLACKLISTED = tag("framedblocks_blacklisted");

private static TagKey<Chemical> tag(String name) {
return TagKey.create(MekanismAPI.CHEMICAL_REGISTRY_NAME, rl(name));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ private void addTags() {

addTag(MekanismAPITags.Chemicals.DIRTY, "Dirty Slurry");
addTag(MekanismAPITags.Chemicals.CLEAN, "Clean Slurry");

add(MekanismAPITags.Chemicals.FRAMEDBLOCKS_BLACKLISTED, "FramedBlocks Blacklisted");
}

private void addItems() {
Expand Down Expand Up @@ -1722,6 +1724,8 @@ private void addMisc() {
add(MekanismModules.MAGNETIC_ATTRACTION_UNIT, "Magnetic Attraction Unit", "Uses powerful magnets to draw distant items towards the player. Install multiple for a greater range.");
add(MekanismModules.FROST_WALKER_UNIT, "Frost Walker Unit", "Uses liquid hydrogen to freeze any water the player walks on. Install multiple for a greater range.");
add(MekanismModules.SOUL_SURFER_UNIT, "Soul Surfer Unit", "Allows the user to surf effortlessly across the top of souls. Install multiple for a greater speed.");
// FramedBlocks integration
add(MekanismLang.FRAMEDBLOCKS_CAMO_HAS_SPECIAL_HANDLING, "Chemicals which require special handling cannot be inserted into framed blocks!");
}

private void addOre(OreType type, String description) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mekanism/common/MekanismLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@ public enum MekanismLang implements ILangEntry {
MODULE_MAGNETIC_ATTRACTION("module", "magnetic_attraction"),
MODULE_MODE_CHANGE("module", "mode_change"),
MODULE_VISION_ENHANCEMENT("module", "vision_enhancement"),
//FramedBlocks integration
FRAMEDBLOCKS_CAMO_HAS_SPECIAL_HANDLING("msg", "compat.framedblocks.camo.has_special_handling")
;

private final String key;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/mekanism/common/integration/MekanismHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mekanism.common.integration.crafttweaker.content.CrTContentUtils;
import mekanism.common.integration.curios.CuriosIntegration;
import mekanism.common.integration.energy.EnergyCompatUtils;
import mekanism.common.integration.framedblocks.FramedBlocksIntegration;
import mekanism.common.integration.jsonthings.JsonThingsIntegration;
import mekanism.common.integration.lookingat.theoneprobe.TOPProvider;
import mekanism.common.integration.projecte.MekanismNormalizedSimpleStacks;
Expand Down Expand Up @@ -43,6 +44,7 @@ public final class MekanismHooks {
public static final String RECIPE_STAGES_MOD_ID = "recipestages";
public static final String TOP_MOD_ID = "theoneprobe";
public static final String WILDFIRE_GENDER_MOD_ID = "wildfire_gender";
public static final String FRAMEDBLOCKS_MOD_ID = "framedblocks";

public final boolean CCLoaded;
public final boolean CraftTweakerLoaded;
Expand All @@ -58,6 +60,7 @@ public final class MekanismHooks {
public final boolean RecipeStagesLoaded;
public final boolean TOPLoaded;
public final boolean WildfireGenderModLoaded;
public final boolean FramedBlocksLoaded;

public MekanismHooks() {
ModList modList = ModList.get();
Expand All @@ -77,6 +80,7 @@ public MekanismHooks() {
RecipeStagesLoaded = loadedCheck.test(RECIPE_STAGES_MOD_ID);
TOPLoaded = loadedCheck.test(TOP_MOD_ID);
WildfireGenderModLoaded = loadedCheck.test(WILDFIRE_GENDER_MOD_ID);
FramedBlocksLoaded = loadedCheck.test(FRAMEDBLOCKS_MOD_ID);
}

public void hookConstructor(final IEventBus bus) {
Expand All @@ -100,6 +104,9 @@ public void hookConstructor(final IEventBus bus) {
if (ProjectELoaded) {
MekanismNormalizedSimpleStacks.NSS_SERIALIZERS.register(bus);
}
if (FramedBlocksLoaded) {
FramedBlocksIntegration.init(bus);
}
}

public void hookCapabilityRegistration() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package mekanism.common.integration.framedblocks;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import mekanism.api.chemical.Chemical;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.neoforged.neoforge.client.ChunkRenderTypeSet;
import net.neoforged.neoforge.client.model.data.ModelData;
import xfacthd.framedblocks.api.camo.CamoClientHandler;
import xfacthd.framedblocks.api.model.util.ModelUtils;

final class ChemicalCamoClientHandler extends CamoClientHandler<ChemicalCamoContent> {

static final CamoClientHandler<ChemicalCamoContent> INSTANCE = new ChemicalCamoClientHandler();
private static final Map<Chemical, BakedModel> CHEMICAL_MODEL_CACHE = new ConcurrentHashMap<>();

private ChemicalCamoClientHandler() { }

@Override
public ChunkRenderTypeSet getRenderTypes(ChemicalCamoContent camo, RandomSource random, ModelData data) {
return ModelUtils.TRANSLUCENT;
}

@Override
public BakedModel getOrCreateModel(ChemicalCamoContent camo) {
return CHEMICAL_MODEL_CACHE.computeIfAbsent(camo.getChemical(), ChemicalModel::create);
}

@Override
public Particle makeHitDestroyParticle(ClientLevel level, double x, double y, double z, double sx, double sy, double sz, ChemicalCamoContent camo, BlockPos pos) {
return new ChemicalSpriteParticle(level, x, y, z, sx, sy, sz, camo.getChemical());
}

static void clearModelCache() {
CHEMICAL_MODEL_CACHE.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package mekanism.common.integration.framedblocks;

import mekanism.api.chemical.Chemical;
import org.jetbrains.annotations.Nullable;
import xfacthd.framedblocks.api.camo.CamoContainer;
import xfacthd.framedblocks.api.camo.CamoContainerFactory;

final class ChemicalCamoContainer extends CamoContainer<ChemicalCamoContent, ChemicalCamoContainer> {

ChemicalCamoContainer(Chemical chemical) {
super(new ChemicalCamoContent(chemical));
}

Chemical getChemical() {
return content.getChemical();
}

@Override
public boolean canRotateCamo() {
return false;
}

@Override
@Nullable
public ChemicalCamoContainer rotateCamo() {
return null;
}

@Override
public int hashCode() {
return content.hashCode();
}

@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != ChemicalCamoContainer.class) return false;
return content.equals(((ChemicalCamoContainer) obj).content);
}

@Override
public String toString() {
return "ChemicalCamoContainer{" + content + "}";
}

@Override
public CamoContainerFactory<ChemicalCamoContainer> getFactory() {
return FramedBlocksIntegration.CHEMICAL_FACTORY.get();
}
}
Loading

0 comments on commit a87b00c

Please sign in to comment.