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 Nov 11, 2024
2 parents 2562a33 + c0c5b60 commit eb7be92
Show file tree
Hide file tree
Showing 28 changed files with 217 additions and 329 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
// Published dependencies
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.5.0-rc1") { transitive = false }
api("com.cleanroommc:groovyscript:1.1.1") { transitive = false }
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
api("appeng:ae2-uel:v0.56.4") { transitive = false }
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/GregTechMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" +
"required-after:modularui@[2.3,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" +
"after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" +
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.1.0,);" +
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" +
"after:theoneprobe;" + "after:hwyla;")
public class GregTechMod {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import gregtech.api.util.Mods;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.BloomEffectUtil;
import gregtech.client.utils.RenderUtil;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.ConfigHolder;
import gregtech.common.creativetab.GTCreativeTabs;
Expand Down Expand Up @@ -88,7 +89,6 @@
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.ColourMultiplier;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.texture.TextureUtils;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.IGuiHolder;
Expand Down Expand Up @@ -270,7 +270,7 @@ public boolean showToolUsages() {

@SideOnly(Side.CLIENT)
public Pair<TextureAtlasSprite, Integer> getParticleTexture() {
return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
return Pair.of(RenderUtil.getMissingSprite(), 0xFFFFFF);
}

/**
Expand All @@ -296,7 +296,7 @@ public void setRenderContextStack(ItemStack itemStack) {
*/
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
TextureAtlasSprite atlasSprite = TextureUtils.getMissingSprite();
TextureAtlasSprite atlasSprite = RenderUtil.getMissingSprite();
IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline,
new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
for (EnumFacing face : EnumFacing.VALUES) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public boolean onScrewdriverClick(EntityPlayer playerIn, EnumHand hand, EnumFaci
index = (recipeMapIndex + 1) % recipeMaps.length;

setRecipeMapIndex(index);
this.recipeMapWorkable.forceRecipeRecheck();
} else {
playerIn.sendStatusMessage(
new TextComponentTranslation("gregtech.multiblock.multiple_recipemaps.switch_message"), true);
Expand All @@ -79,6 +78,7 @@ public void setRecipeMapIndex(int index) {
this.recipeMapIndex = index;
if (!getWorld().isRemote) {
writeCustomData(GregtechDataCodes.RECIPE_MAP_INDEX, buf -> buf.writeByte(index));
recipeMapWorkable.forceRecipeRecheck();
markDirty();
}
}
Expand Down
68 changes: 66 additions & 2 deletions src/main/java/gregtech/api/recipes/RecipeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.Optional;
Expand All @@ -44,6 +45,7 @@
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient;
import crafttweaker.CraftTweakerAPI;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.MustBeInvokedByOverriders;
Expand All @@ -53,6 +55,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -86,6 +89,9 @@ public class RecipeBuilder<R extends RecipeBuilder<R>> {
protected RecipePropertyStorage recipePropertyStorage = RecipePropertyStorage.EMPTY;
protected boolean recipePropertyStorageErrored = false;

protected boolean ignoreAllBuildActions = false;
protected Map<ResourceLocation, RecipeBuildAction<R>> ignoredBuildActions;

protected RecipeBuilder() {
this.inputs = new ArrayList<>();
this.outputs = new ArrayList<>();
Expand Down Expand Up @@ -126,6 +132,10 @@ protected RecipeBuilder(RecipeBuilder<R> recipeBuilder) {
this.hidden = recipeBuilder.hidden;
this.category = recipeBuilder.category;
this.recipePropertyStorage = recipeBuilder.recipePropertyStorage.copy();
this.ignoreAllBuildActions = recipeBuilder.ignoreAllBuildActions;
if (recipeBuilder.ignoredBuildActions != null) {
this.ignoredBuildActions = new Object2ObjectOpenHashMap<>(recipeBuilder.ignoredBuildActions);
}
}

public R cleanroom(@Nullable CleanroomType cleanroom) {
Expand Down Expand Up @@ -887,6 +897,31 @@ public R copy() {
return (R) new RecipeBuilder<>(this);
}

/**
* Only use if you absolutely don't want the recipe to be run through any build actions.
* Instead, you should blacklist specific actions with {@link #ignoreBuildAction(ResourceLocation)}
*/
public R ignoreAllBuildActions() {
this.ignoreAllBuildActions = true;
return (R) this;
}

public R ignoreBuildAction(ResourceLocation buildActionName) {
if (ignoredBuildActions == null) {
ignoredBuildActions = new Object2ObjectOpenHashMap<>();
} else if (!recipeMap.getBuildActions().containsKey(buildActionName)) {
GTLog.logger.error("Recipe map {} does not contain build action {}!", recipeMap, buildActionName,
new Throwable());
return (R) this;
} else if (ignoredBuildActions.containsKey(buildActionName)) {
return (R) this;
}

ignoredBuildActions.put(buildActionName, recipeMap.getBuildActions().get(buildActionName));

return (R) this;
}

public ValidationResult<Recipe> build() {
EnumValidationResult result = recipePropertyStorageErrored ? EnumValidationResult.INVALID : validate();
return ValidationResult.newResult(result, new Recipe(inputs, outputs,
Expand Down Expand Up @@ -985,8 +1020,14 @@ protected R invalidateOnBuildAction() {
*/
@MustBeInvokedByOverriders
public void buildAndRegister() {
for (RecipeBuildAction<R> action : recipeMap.getBuildActions()) {
action.accept((R) this);
if (!ignoreAllBuildActions) {
for (Map.Entry<ResourceLocation, RecipeBuildAction<R>> buildAction : recipeMap.getBuildActions()
.entrySet()) {
if (ignoredBuildActions != null && ignoredBuildActions.containsKey(buildAction.getKey())) {
continue;
}
buildAction.getValue().accept((R) this);
}
}
ValidationResult<Recipe> validationResult = build();
recipeMap.addRecipe(validationResult);
Expand Down Expand Up @@ -1047,6 +1088,27 @@ public int getDuration() {
return this.recipePropertyStorage.get(CleanroomProperty.getInstance(), null);
}

public boolean ignoresAllBuildActions() {
return ignoreAllBuildActions;
}

/**
* Get all ignored build actions for the recipe map.
*
* @return A map of ignored build actions.
*/
public @NotNull Map<ResourceLocation, RecipeBuildAction<R>> getIgnoredBuildActions() {
if (ignoreAllBuildActions) {
return recipeMap.getBuildActions();
}

if (ignoredBuildActions == null) {
return Collections.emptyMap();
}

return ignoredBuildActions;
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand All @@ -1064,6 +1126,8 @@ public String toString() {
.append("dimensions", getDimensionIDs().toString())
.append("dimensions_blocked", getBlockedDimensionIDs().toString())
.append("recipeStatus", recipeStatus)
.append("ignoresBuildActions", ignoresAllBuildActions())
.append("ignoredBuildActions", getIgnoredBuildActions())
.toString();
}
}
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/recipes/RecipeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ protected void onRecipeBuild(@NotNull Map<ResourceLocation, RecipeBuildAction<R>
* @return the build actions for this RecipeMap's default RecipeBuilder
*/
@ApiStatus.Internal
protected @UnmodifiableView @NotNull Collection<@NotNull RecipeBuildAction<R>> getBuildActions() {
return this.recipeBuildActions.values();
protected @UnmodifiableView @NotNull Map<ResourceLocation, RecipeBuildAction<R>> getBuildActions() {
return this.recipeBuildActions;
}

public RecipeMap<R> allowEmptyOutput() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ public static void register() {
Galena = new Material.Builder(279, gregtechId("galena"))
.dust(3).ore()
.color(0x643C64)
.flags(NO_SMELTING)
.components(Lead, 1, Sulfur, 1)
.build();

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/gregtech/api/util/GTTransferUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ public static ItemStack insertItem(IItemHandler handler, ItemStack stack, boolea
if (handler == null || stack.isEmpty()) {
return stack;
}
if (!stack.isStackable()) {
return insertToEmpty(handler, stack, simulate);
}

IntList emptySlots = new IntArrayList();
int slots = handler.getSlots();
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/gregtech/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import gregtech.client.renderer.pipe.LaserPipeRenderer;
import gregtech.client.renderer.pipe.OpticalPipeRenderer;
import gregtech.client.renderer.pipe.PipeRenderer;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.ItemRenderCompat;
import gregtech.client.utils.TooltipHelper;
import gregtech.common.CommonProxy;
Expand All @@ -33,6 +34,7 @@

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -46,6 +48,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
Expand All @@ -59,7 +62,6 @@
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;

import codechicken.lib.texture.TextureUtils;
import org.jetbrains.annotations.NotNull;
import paulscode.sound.SoundSystemConfig;

Expand Down Expand Up @@ -91,8 +93,6 @@ public void onPreLoad() {
OpticalPipeRenderer.INSTANCE.preInit();
LaserPipeRenderer.INSTANCE.preInit();
MetaEntities.initRenderers();
TextureUtils.addIconRegister(GTFluidRegistration.INSTANCE::registerSprites);
TextureUtils.addIconRegister(PipeRenderer::initializeRestrictor);
}

@Override
Expand All @@ -114,6 +114,19 @@ public static void registerColors() {
ToolItems.registerColors();
}

@SubscribeEvent
public static void textureStitchPre(@NotNull TextureStitchEvent.Pre event) {
TextureMap map = event.getMap();
GTFluidRegistration.INSTANCE.registerSprites(map);
PipeRenderer.initializeRestrictor(map);
Textures.register(map);
CableRenderer.INSTANCE.registerIcons(map);
FluidPipeRenderer.INSTANCE.registerIcons(map);
ItemPipeRenderer.INSTANCE.registerIcons(map);
OpticalPipeRenderer.INSTANCE.registerIcons(map);
LaserPipeRenderer.INSTANCE.registerIcons(map);
}

@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
MetaBlocks.registerStateMappers();
Expand Down
Loading

0 comments on commit eb7be92

Please sign in to comment.