Skip to content

Commit

Permalink
Merge branch 'master' into zb-lotsa-mui2
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorbatron committed Sep 19, 2024
2 parents b795417 + efd8617 commit c8f1cbd
Show file tree
Hide file tree
Showing 94 changed files with 3,759 additions and 1,489 deletions.
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gregtech.api.metatileentity.registry.MTEManager;
import gregtech.api.modules.IModuleManager;
import gregtech.api.network.INetworkHandler;
import gregtech.api.recipes.properties.RecipePropertyRegistry;
import gregtech.api.sound.ISoundManager;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.registry.IMaterialRegistryManager;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class GregTechAPI {
public static MTEManager mteManager;
/** GT's data migrations API */
public static final MigrationAPI MIGRATIONS = new MigrationAPI();
public static final RecipePropertyRegistry RECIPE_PROPERTIES = new RecipePropertyRegistry();

/** Will be available at the Pre-Initialization stage */
private static boolean highTier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gregtech.api.block;

import gregtech.api.recipes.recipeproperties.TemperatureProperty;
import gregtech.api.recipes.properties.impl.TemperatureProperty;
import gregtech.api.unification.material.Material;

import org.jetbrains.annotations.NotNull;
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import gregtech.api.recipes.logic.IParallelableRecipeLogic;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.CleanroomProperty;
import gregtech.api.recipes.recipeproperties.DimensionProperty;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;
import gregtech.api.recipes.properties.impl.CleanroomProperty;
import gregtech.api.recipes.properties.impl.DimensionProperty;
import gregtech.api.util.GTLog;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -441,9 +441,11 @@ protected boolean checkCleanroomRequirement(@NotNull Recipe recipe) {
}

protected boolean checkDimensionRequirement(@NotNull Recipe recipe) {
if (!recipe.hasProperty(DimensionProperty.getInstance())) return true;
return recipe.getProperty(DimensionProperty.getInstance(), DimensionProperty.DimensionPropertyList.EMPTY_LIST)
.checkDimension(this.getMetaTileEntity().getWorld().provider.getDimension());
DimensionProperty.DimensionPropertyList list = recipe.getProperty(DimensionProperty.getInstance(), null);
if (list == null) {
return true;
}
return list.checkDimension(this.getMetaTileEntity().getWorld().provider.getDimension());
}

/**
Expand Down Expand Up @@ -682,7 +684,7 @@ protected static boolean areItemStacksEqual(@NotNull ItemStack stackA, @NotNull
@NotNull IMultipleTankHandler importFluids) {
calculateOverclock(recipe);

modifyOverclockPost(ocResult, recipe.getRecipePropertyStorage());
modifyOverclockPost(ocResult, recipe.propertyStorage());

if (ocResult.parallel() > 1) {
recipe = subTickOC(ocResult, recipe, importInventory, importFluids);
Expand Down Expand Up @@ -814,7 +816,7 @@ protected boolean hasEnoughPower(long eut, int duration) {
* @param ocResult The overclock result
* @param storage the RecipePropertyStorage of the recipe being processed
*/
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull IRecipePropertyStorage storage) {}
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull RecipePropertyStorage storage) {}

/**
* Calculates the overclocked Recipe's final duration and EU/t
Expand All @@ -837,13 +839,13 @@ protected final void calculateOverclock(@NotNull Recipe recipe) {
* @param ocResult the result of overclocking
*/
protected void performOverclocking(@NotNull Recipe recipe, @NotNull OCParams ocParams, @NotNull OCResult ocResult) {
modifyOverclockPre(ocParams, recipe.getRecipePropertyStorage());
modifyOverclockPre(ocParams, recipe.propertyStorage());

if (ocParams.ocAmount() <= 0) {
// number of OCs is <= 0, so do not overclock
ocResult.init(ocParams.eut(), ocParams.duration());
} else {
runOverclockingLogic(ocParams, ocResult, recipe.getRecipePropertyStorage(), getMaximumOverclockVoltage());
runOverclockingLogic(ocParams, ocResult, recipe.propertyStorage(), getMaximumOverclockVoltage());
}
}

Expand Down Expand Up @@ -873,7 +875,7 @@ protected int getNumberOfOCs(long recipeEUt) {
* @param ocParams an array of [recipeEUt, recipeDuration, numberOfOCs]
* @param storage the RecipePropertyStorage of the recipe being processed
*/
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePropertyStorage storage) {}
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull RecipePropertyStorage storage) {}

/**
* Calls the desired overclocking logic to be run for the recipe. Performs the actual overclocking on the provided
Expand All @@ -885,7 +887,7 @@ protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePr
* @param maxVoltage the maximum voltage the recipe is allowed to be run at
*/
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
standardOC(ocParams, ocResult, maxVoltage, getOverclockingDurationFactor(), getOverclockingVoltageFactor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import gregtech.api.capability.IOpticalComputationReceiver;
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.recipeproperties.ComputationProperty;
import gregtech.api.recipes.recipeproperties.TotalComputationProperty;
import gregtech.api.recipes.properties.impl.ComputationProperty;
import gregtech.api.recipes.properties.impl.TotalComputationProperty;

import net.minecraft.nbt.NBTTagCompound;

Expand Down Expand Up @@ -49,11 +49,12 @@ public boolean checkRecipe(@NotNull Recipe recipe) {
if (!super.checkRecipe(recipe)) {
return false;
}
if (!recipe.hasProperty(ComputationProperty.getInstance())) {
int recipeCWUt = recipe.getProperty(ComputationProperty.getInstance(), 0);
if (recipeCWUt == 0) {
return true;
}

IOpticalComputationProvider provider = getComputationProvider();
int recipeCWUt = recipe.getProperty(ComputationProperty.getInstance(), 0);
return provider.requestCWUt(recipeCWUt, true) >= recipeCWUt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -40,7 +40,7 @@ protected boolean hasEnoughPower(long eut, int duration) {

@Override
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
standardOC(ocParams, ocResult, maxVoltage, getOverclockingDurationFactor(), getOverclockingVoltageFactor());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.logic.OverclockingLogic;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.recipeproperties.TemperatureProperty;
import gregtech.api.recipes.properties.RecipePropertyStorage;
import gregtech.api.recipes.properties.impl.TemperatureProperty;

import org.jetbrains.annotations.NotNull;

Expand All @@ -26,18 +26,18 @@ public HeatingCoilRecipeLogic(RecipeMapMultiblockController metaTileEntity) {
}

@Override
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull RecipePropertyStorage storage) {
super.modifyOverclockPre(ocParams, storage);
// coil EU/t discount
ocParams.setEut(OverclockingLogic.applyCoilEUtDiscount(ocParams.eut(),
((IHeatingCoil) metaTileEntity).getCurrentTemperature(),
storage.getRecipePropertyValue(TemperatureProperty.getInstance(), 0)));
storage.get(TemperatureProperty.getInstance(), 0)));
}

@Override
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
heatingCoilOC(ocParams, ocResult, maxVoltage, ((IHeatingCoil) metaTileEntity).getCurrentTemperature(),
propertyStorage.getRecipePropertyValue(TemperatureProperty.getInstance(), 0));
propertyStorage.get(TemperatureProperty.getInstance(), 0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;
import gregtech.api.util.GTUtility;
import gregtech.api.util.TextFormattingUtil;

Expand All @@ -29,7 +29,7 @@ public MultiblockFuelRecipeLogic(RecipeMapMultiblockController tileEntity) {
}

@Override
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull RecipePropertyStorage storage) {
// apply maintenance bonuses
Tuple<Integer, Double> maintenanceValues = getMaintenanceValues();

Expand All @@ -40,7 +40,7 @@ protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePr
}

@Override
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull RecipePropertyStorage storage) {
// apply maintenance penalties
Tuple<Integer, Double> maintenanceValues = getMaintenanceValues();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;
import gregtech.api.util.GTUtility;
import gregtech.common.ConfigHolder;

Expand Down Expand Up @@ -281,7 +281,7 @@ protected boolean prepareRecipeDistinct(Recipe recipe) {
}

@Override
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull RecipePropertyStorage storage) {
super.modifyOverclockPre(ocParams, storage);

// apply maintenance bonuses
Expand All @@ -295,13 +295,13 @@ protected void modifyOverclockPre(@NotNull OCParams ocParams, @NotNull IRecipePr

@Override
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
subTickParallelOC(ocParams, ocResult, maxVoltage, getOverclockingDurationFactor(),
getOverclockingVoltageFactor());
}

@Override
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull IRecipePropertyStorage storage) {
protected void modifyOverclockPost(@NotNull OCResult ocResult, @NotNull RecipePropertyStorage storage) {
super.modifyOverclockPost(ocResult, storage);

// apply maintenance penalties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -50,7 +50,7 @@ public long getMaxVoltage() {

@Override
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
ocParams.setEut(1L);
super.runOverclockingLogic(ocParams, ocResult, propertyStorage, maxVoltage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.OCParams;
import gregtech.api.recipes.logic.OCResult;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.properties.RecipePropertyStorage;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -56,7 +56,7 @@ public long getMaxVoltage() {

@Override
protected void runOverclockingLogic(@NotNull OCParams ocParams, @NotNull OCResult ocResult,
@NotNull IRecipePropertyStorage propertyStorage, long maxVoltage) {
@NotNull RecipePropertyStorage propertyStorage, long maxVoltage) {
subTickNonParallelOC(ocParams, ocResult, maxVoltage, getOverclockingDurationFactor(),
getOverclockingVoltageFactor());
}
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/gregtech/api/items/toolitem/ToolHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
import gregtech.tools.enchants.EnchantmentHardHammer;

import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCommandBlock;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockPane;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.BlockStructure;
import net.minecraft.block.BlockWeb;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentDurability;
import net.minecraft.enchantment.EnchantmentHelper;
Expand Down Expand Up @@ -57,7 +63,11 @@
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.*;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;

import static gregtech.api.GTValues.LV;
Expand Down Expand Up @@ -196,7 +206,7 @@ public static ItemStack getAndSetToolData(IGTTool tool, Material material, int m
ItemStack stack = tool.getRaw();
GTUtility.getOrCreateNbtCompound(stack).setInteger(HIDE_FLAGS, 2);
NBTTagCompound toolTag = getToolTag(stack);
toolTag.setString(MATERIAL_KEY, material.toString());
toolTag.setString(MATERIAL_KEY, material.getRegistryName());
toolTag.setInteger(MAX_DURABILITY_KEY, maxDurability);
toolTag.setInteger(HARVEST_LEVEL_KEY, harvestLevel);
toolTag.setFloat(TOOL_SPEED_KEY, toolSpeed);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ public final boolean onToolClick(EntityPlayer playerIn, @NotNull Set<String> too
if (toolClasses.contains(ToolClasses.HARD_HAMMER)) {
return onHardHammerClick(playerIn, hand, gridSideHit, hitResult);
}
if (toolClasses.contains(ToolClasses.WIRE_CUTTER)) {
return onWireCutterClick(playerIn, hand, gridSideHit, hitResult);
}
return false;
}

Expand Down Expand Up @@ -664,6 +667,16 @@ public boolean onHardHammerClick(EntityPlayer playerIn, EnumHand hand, EnumFacin
return true;
}

/**
* Called when player clicks a wire cutter on specific side of this meta tile entity
*
* @return true if something happened, so the tool will get damaged and animation will be played
*/
public boolean onWireCutterClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing,
CuboidRayTraceResult hitResult) {
return false;
}

public void onLeftClick(EntityPlayer player, EnumFacing facing, CuboidRayTraceResult hitResult) {
if (this instanceof IDataStickIntractable dsi) {
ItemStack stack = player.getHeldItemMainhand();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public static class IDs {
"textures/gui/widget/button_public_private.png",
18, 36, 18, 18, true);

public static final UITexture MENU_OVERLAY = fullImage("textures/gui/overlay/menu_overlay.png");

// todo bronze/steel/primitive fluid slots?

// SLOT OVERLAYS
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/gregtech/api/mui/GTGuis.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import net.minecraft.item.ItemStack;

import com.cleanroommc.modularui.api.widget.Interactable;
import com.cleanroommc.modularui.factory.GuiManager;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Alignment;
Expand Down Expand Up @@ -62,7 +63,15 @@ public PopupPanel(@NotNull String name, int width, int height, boolean disableBe
super(name);
size(width, height).align(Alignment.Center);
background(GTGuiTextures.BACKGROUND_POPUP);
child(ButtonWidget.panelCloseButton().top(5).right(5));
child(ButtonWidget.panelCloseButton().top(5).right(5)
.onMousePressed(mouseButton -> {
if (mouseButton == 0 || mouseButton == 1) {
this.closeIfOpen(true);
Interactable.playButtonClickSound();
return true;
}
return false;
}));
this.disableBelow = disableBelow;
this.closeOnOutsideClick = closeOnOutsideClick;
}
Expand Down
Loading

0 comments on commit c8f1cbd

Please sign in to comment.