Skip to content

Commit

Permalink
basic support for non-layered veins
Browse files Browse the repository at this point in the history
closes #8
  • Loading branch information
kumquat-ir committed Oct 20, 2024
1 parent ba13767 commit be90c98
Showing 1 changed file with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,28 @@ public OreVeinInfo(OreDepositDefinition def) {
}

if (FMLCommonHandler.instance().getSide().isClient()) {
Collection<IBlockState> possiblePrimaryStates;
if (def.getBlockFiller() instanceof LayeredBlockFiller) {
Collection<IBlockState> possiblePrimaryStates = ((LayeredBlockFiller) def.getBlockFiller()).getPrimary().getPossibleResults();
for (IBlockState state : possiblePrimaryStates) {
if (state.getBlock() instanceof BlockOre) {
// gt ores need special handling due to iconset stuff
Material mat = ((BlockOre) state.getBlock()).material;
ResourceLocation shortenedLocation = MaterialIconType.ore.getBlockTexturePath(mat.getMaterialIconSet());
texture = new ResourceLocation(shortenedLocation.getNamespace(), "textures/" + shortenedLocation.getPath() + ".png");
color = mat.getMaterialRGB();
possiblePrimaryStates = ((LayeredBlockFiller) def.getBlockFiller()).getPrimary().getPossibleResults();
}
else {
possiblePrimaryStates = getAllRelevantStates(def.getBlockFiller());
}
for (IBlockState state : possiblePrimaryStates) {
if (state.getBlock() instanceof BlockOre) {
// gt ores need special handling due to iconset stuff
Material mat = ((BlockOre) state.getBlock()).material;
ResourceLocation shortenedLocation = MaterialIconType.ore.getBlockTexturePath(mat.getMaterialIconSet());
texture = new ResourceLocation(shortenedLocation.getNamespace(), "textures/" + shortenedLocation.getPath() + ".png");
color = mat.getMaterialRGB();
break;
}
else {
tas = TextureUtils.getSideIconsForBlock(state)[EnumFacing.NORTH.ordinal()];
if (tas != TextureUtils.getMissingSprite()) {
break;
}
else {
tas = TextureUtils.getSideIconsForBlock(state)[EnumFacing.NORTH.ordinal()];
if (tas != TextureUtils.getMissingSprite()) {
break;
}
// if the sprite is missing, see if theres a non-missing sprite to be found
}
// if the sprite is missing, see if theres a non-missing sprite to be found
}
}

Expand All @@ -85,8 +89,7 @@ public OreVeinInfo(OreDepositDefinition def) {
else {
tooltipStrings.add(FileUtility.trimFileName(def.getDepositName()));
}
for (FillerEntry filler : getAllFillers(def.getBlockFiller())) {
IBlockState state = (IBlockState) filler.getPossibleResults().toArray()[0];
for (IBlockState state : getAllRelevantStates(def.getBlockFiller())) {
String matName = getBaseMaterialName(state);
if (!matName.isEmpty() && state.getBlock() instanceof BlockOre) {
// gt ores need special handling due to ore variants
Expand Down Expand Up @@ -145,6 +148,31 @@ private static FillerEntry[] getAllFillers(BlockFiller filler) {
return filler.getAllPossibleStates().toArray(new FillerEntry[0]);
}

private static Collection<IBlockState> getAllRelevantStates(BlockFiller filler) {
List<IBlockState> states = new ArrayList<>();
if (filler instanceof LayeredBlockFiller) {
for (FillerEntry entry : getAllFillers(filler)) {
states.add((IBlockState) entry.getPossibleResults().toArray()[0]);
}
}
else {
FillerEntry entry = filler.getAllPossibleStates().get(0);
Set<Material> seenMaterials = new HashSet<>();
for (IBlockState state : entry.getPossibleResults()) {
if (state.getBlock() instanceof BlockOre blockOre) {
if (!seenMaterials.contains(blockOre.material)) {
seenMaterials.add(blockOre.material);
states.add(state);
}
}
else {
states.add(state);
}
}
}
return states;
}

/**
* adapted from {@link gregtech.integration.jei.multiblock.MultiblockInfoRecipeWrapper#gatherStructureBlocks}
*/
Expand Down

0 comments on commit be90c98

Please sign in to comment.