Skip to content

Commit

Permalink
Merge branch 'GregTechCEu:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
marisathewitch authored Oct 7, 2023
2 parents e037093 + 84b0dc0 commit c2dd106
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 32 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1690966774
//version: 1695527071
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand All @@ -24,9 +24,9 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.23'
id 'net.darkhax.curseforgegradle' version '1.0.14' apply false
id 'com.modrinth.minotaur' version '2.8.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
id 'net.darkhax.curseforgegradle' version '1.1.16' apply false
id 'com.modrinth.minotaur' version '2.8.4' apply false
id 'com.diffplug.spotless' version '6.13.0' apply false
id 'com.palantir.git-version' version '3.0.0' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/gregtech/api/recipes/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public String toString() {
.append("EUt", EUt)
.append("hidden", hidden)
.append("CTRecipe", isCTRecipe)
.append("GSRecipe", groovyRecipe)
.toString();
}

Expand Down Expand Up @@ -586,6 +587,10 @@ public Set<String> getPropertyKeys() {
return recipePropertyStorage.getRecipePropertyKeys();
}

public Set<RecipeProperty<?>> getPropertyTypes() {
return recipePropertyStorage.getPropertyTypes();
}

public boolean hasProperty(RecipeProperty<?> property) {
return recipePropertyStorage.hasRecipeProperty(property);
}
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/gregtech/api/recipes/RecipeMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.api.recipes;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.google.common.collect.ImmutableList;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ZenRegister;
Expand Down Expand Up @@ -976,6 +977,18 @@ private boolean recurseIngredientTreeAdd(@Nonnull Recipe recipe, @Nonnull List<L
CraftTweakerAPI.logError("Could not identify exact duplicate/conflict.");
}
}
if (recipe.isGroovyRecipe()) {
GroovyLog log = GroovyLog.get();
log.warn("Recipe duplicate or conflict found in RecipeMap {} and was not added. See next lines for details", this.unlocalizedName);

log.warn("Attempted to add Recipe: {}", recipe.toString());

if (v.left().isPresent()) {
log.warn("Which conflicts with: {}", v.left().get().toString());
} else {
log.warn("Could not find exact duplicate/conflict.");
}
}
if (ConfigHolder.misc.debug || GTValues.isDeobfEnvironment()) {
GTLog.logger.warn("Recipe duplicate or conflict found in RecipeMap {} and was not added. See next lines for details", this.unlocalizedName);

Expand Down Expand Up @@ -1006,8 +1019,15 @@ private boolean recurseIngredientTreeAdd(@Nonnull Recipe recipe, @Nonnull List<L

// left branches are always either empty or contain recipes.
// If there's a recipe present, the addition is finished for this ingredient
// Cannot return here, since each ingredient to add is a separate path to the recipe
if (r.left().isPresent()) continue;
if (r.left().isPresent()) {
if (r.left().get() == recipe) {
// Cannot return here, since each ingredient to add is a separate path to the recipe
continue;
} else {
// exit if a different recipe is already present for this path
return false;
}
}

// recursive part: apply the addition for the next ingredient in the list, for the right branch.
// the right branch only contains ingredients, or is empty when the left branch is present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public Set<String> getRecipePropertyKeys() {
return Collections.emptySet();
}

@Override
public Set<RecipeProperty<?>> getPropertyTypes() {
return Collections.emptySet();
}

@Override
public Object getRawRecipePropertyValue(String key) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public interface IRecipePropertyStorage {

Set<String> getRecipePropertyKeys();

Set<RecipeProperty<?>> getPropertyTypes();

/**
* Provides un-casted value for one specific {@link RecipeProperty} searched by key
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ public static PrimitiveProperty getInstance() {
@Override
public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) {
}

@Override
public boolean hideTotalEU() {
return true;
}

@Override
public boolean hideEUt() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ public boolean isHidden() {
return false;
}

/**
* Whether to hide the Total EU tooltip for the recipe in JEI.
*/
public boolean hideTotalEU() {
return false;
}

/**
* Whether to hide the EU/t tooltip for the recipe in JEI.
*/
public boolean hideEUt() {
return false;
}

/**
* Whether to hide the Duration tooltip for the recipe in JEI.
*/
public boolean hideDuration() {
return false;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public Set<String> getRecipePropertyKeys() {
return keys;
}

@Override
public Set<RecipeProperty<?>> getPropertyTypes() {
return recipeProperties.keySet();
}

@Override
public Object getRawRecipePropertyValue(String key) {
RecipeProperty<?> recipeProperty = getRecipePropertyValue(key);
Expand Down
77 changes: 69 additions & 8 deletions src/main/java/gregtech/client/renderer/handler/FacadeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import codechicken.lib.vec.Vector3;
import codechicken.lib.vec.uv.UV;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import gregtech.api.cover.ICoverable;
Expand All @@ -31,27 +32,29 @@
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* Mostly based on and (copied from) ThermalDynamics with minor tweaks
* https://github.com/CoFH/ThermalDynamics/
* <p/>
* <a href="https://github.com/CoFH/ThermalDynamics/">Link</a>
*/
@SideOnly(Side.CLIENT)
public class FacadeRenderer implements IItemRenderer {
Expand Down Expand Up @@ -123,14 +126,14 @@ public static boolean renderBlockCover(CCRenderState ccrs, Matrix4 translation,
state = state.getBlock().getExtendedState(state, coverAccess, pos);
} catch (Exception ignored) {
}
long posRand = net.minecraft.util.math.MathHelper.getPositionRandom(pos);
List<BakedQuad> bakedQuads = new LinkedList<>(model.getQuads(state, null, posRand));
long posRand = MathHelper.getPositionRandom(pos);
List<BakedQuad> bakedQuads = new ArrayList<>(model.getQuads(state, null, posRand));

for (EnumFacing face2 : EnumFacing.VALUES) {
bakedQuads.addAll(model.getQuads(state, face2, posRand));
}

List<CCQuad> quads = CCQuad.fromArray(bakedQuads);
List<CCQuad> quads = fromArray(bakedQuads);
quads = sliceQuads(quads, side, bounds);

if (!quads.isEmpty()) {
Expand All @@ -156,7 +159,7 @@ public static void renderItemCover(CCRenderState ccrs, int side, ItemStack rende
quads.addAll(model.getQuads(null, face, 0));
}

renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack);
renderQuads = applyItemTint(sliceQuads(fromArray(quads), side, bounds), renderStack);
itemQuadCache.put(cacheKey, renderQuads);
}

Expand All @@ -171,7 +174,7 @@ public static void renderItemCover(CCRenderState ccrs, int side, ItemStack rende
}

public static List<CCQuad> applyItemTint(List<CCQuad> quads, ItemStack stack) {
List<CCQuad> retQuads = new LinkedList<>();
List<CCQuad> retQuads = new ArrayList<>();
for (CCQuad quad : quads) {
int colour = -1;

Expand Down Expand Up @@ -226,7 +229,7 @@ public static List<CCQuad> sliceQuads(List<CCQuad> quads, int side, Cuboid6 boun
double[][] quadPos = new double[4][3];
boolean[] flat = new boolean[3];
int verticesPerFace = 4;
List<CCQuad> finalQuads = new LinkedList<>();
List<CCQuad> finalQuads = new ArrayList<>();

for (CCQuad quad : quads) {

Expand Down Expand Up @@ -327,4 +330,62 @@ private static double clampF(double x, Cuboid6 b, int j) {
return x;
}
}

private static List<CCQuad> fromArray(List<BakedQuad> bakedQuads) {
List<CCQuad> quads = new ArrayList<>();
for (BakedQuad quad : bakedQuads) {
quads.add(new FixedCCQuad(quad));
}
return quads;
}

/**
* Fixes incorrect arithmetic operation in {@link CCQuad#pipe(IVertexConsumer)}.
*/
private static class FixedCCQuad extends CCQuad {

public FixedCCQuad(BakedQuad quad) {
super(quad);
}

@Override
public void pipe(IVertexConsumer consumer) {
quadulate();
computeNormals();
consumer.setApplyDiffuseLighting(applyDifuseLighting);
consumer.setTexture(sprite);
consumer.setQuadOrientation(getQuadFace());
consumer.setQuadTint(tintIndex);
for (int v = 0; v < 4; v++) {
for (int e = 0; e < consumer.getVertexFormat().getElementCount(); e++) {
VertexFormatElement element = consumer.getVertexFormat().getElement(e);
switch (element.getUsage()) {
case POSITION -> {
Vector3 pos = vertices[v].vec;
consumer.put(e, (float) pos.x, (float) pos.y, (float) pos.z, 1);
}
case NORMAL -> {
Vector3 normal = normals[v];
consumer.put(e, (float) normal.x, (float) normal.y, (float) normal.z, 0);
}
case COLOR -> {
Colour colour = colours[v];
consumer.put(e, (colour.r & 0xFF) / 255F, (colour.g & 0xFF) / 255F, (colour.b & 0xFF) / 255F, (colour.a & 0xFF) / 255F);
}
case UV -> {
if (element.getIndex() == 0) {
UV uv = vertices[v].uv;
consumer.put(e, (float) uv.u, (float) uv.v, 0, 1);
} else {
// fix
int brightness = lightMaps[v];
consumer.put(e, ((float) (brightness & 0xFFFF) / 0xFFFF) * 2, ((float) (brightness >> 16 & 0xFFFF) / 0xFFFF) * 2, 0, 1);
}
}
default -> consumer.put(e);
}
}
}
}
}
}
Loading

0 comments on commit c2dd106

Please sign in to comment.