-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for chemicals as camos on framed blocks (#8209)
- Loading branch information
Showing
20 changed files
with
812 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/mekanism/common/integration/framedblocks/ChemicalCamoClientHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/mekanism/common/integration/framedblocks/ChemicalCamoContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.