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
iouter authored Apr 8, 2024
2 parents 122fca5 + 16ed04a commit c5bfba1
Show file tree
Hide file tree
Showing 143 changed files with 5,841 additions and 2,881 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Anything else? Sure come to [Discord](https://discord.gg/bWSWuYvURP).
## Credited Works
Heating Coil Textures, Wooden Forms, World Accelerators, and the Extreme Combustion Engine are from the **[GregTech: New Horizons Modpack](https://www.curseforge.com/minecraft/modpacks/gt-new-horizons)**.

Primitive Water Pump and Super Tank GUI Textures are from the **[IMPACT: GREGTECH EDITION Modpack](https://gtimpact.space/)**.
Primitive Water Pump and Super Tank GUI Textures are from the **[IMPACT: GREGTECH EDITION Modpack](https://gt-impact.github.io/)**.

Ender Fluid Link Cover, Auto-Maintenance Hatch, Optical Fiber, and Data Bank Textures are from **[TecTech](https://github.com/Technus/TecTech)**.

Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
dependencies {
// Published dependencies
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.4.1") { transitive = false }
api("com.cleanroommc:groovyscript:0.7.3") { transitive = false }
api("com.cleanroommc:modularui:2.4.3") { transitive = false }
api("com.cleanroommc:groovyscript:1.0.1") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.684")
api rfg.deobf("curse.maven:ae2-extended-life-570458:4402048") // AE2UEL 0.55.6
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/gregtech/GregTechMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.modules.ModuleContainerRegistryEvent;
import gregtech.api.persistence.PersistentData;
import gregtech.client.utils.BloomEffectUtil;
import gregtech.modules.GregTechModules;
import gregtech.modules.ModuleManager;
Expand Down Expand Up @@ -32,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@[0.7.0,);" +
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.0.1,);" +
"after:theoneprobe;" + "after:hwyla;")
public class GregTechMod {

Expand All @@ -50,6 +51,7 @@ public GregTechMod() {

@EventHandler
public void onConstruction(FMLConstructionEvent event) {
PersistentData.instance().init();
moduleManager = ModuleManager.getInstance();
GregTechAPI.moduleManager = moduleManager;
moduleManager.registerContainer(new GregTechModules());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public int getLightValue(@NotNull IBlockState state, @NotNull IBlockAccess world
public int getLightOpacity(@NotNull IBlockState state, @NotNull IBlockAccess world, @NotNull BlockPos pos) {
// since it is called on neighbor blocks
MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
return metaTileEntity == null ? 0 : metaTileEntity.getLightOpacity();
return metaTileEntity == null ? 255 : metaTileEntity.getLightOpacity();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public boolean placeBlockAt(@NotNull ItemStack stack, @NotNull EntityPlayer play
// prevent rendering glitch before meta tile entity sync to client, but after block placement
// set opaque property on the placing on block, instead during set of meta tile entity
boolean superVal = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ,
newState.withProperty(BlockMachine.OPAQUE, metaTileEntity != null && metaTileEntity.isOpaqueCube()));
newState.withProperty(BlockMachine.OPAQUE, metaTileEntity == null || metaTileEntity.isOpaqueCube()));
if (superVal && !world.isRemote) {
BlockPos possiblePipe = pos.offset(side.getOpposite());
Block block = world.getBlockState(possiblePipe).getBlock();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gregtech/api/capability/GregtechDataCodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static int assignId() {
public static final int UPDATE_AUTO_OUTPUT_FLUIDS = assignId();
public static final int UPDATE_IS_VOIDING = assignId();

// Robotic Arm
public static final int UPDATE_TRANSFER_MODE = assignId();

// Drum
public static final int UPDATE_AUTO_OUTPUT = assignId();

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/gregtech/api/capability/IDataStickIntractable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gregtech.api.capability;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public interface IDataStickIntractable {

void onDataStickLeftClick(EntityPlayer player, ItemStack dataStick);

boolean onDataStickRightClick(EntityPlayer player, ItemStack dataStick);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.IParallelableRecipeLogic;
import gregtech.api.recipes.recipeproperties.CleanroomProperty;
import gregtech.api.recipes.recipeproperties.DimensionProperty;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -407,7 +408,7 @@ protected boolean checkPreviousRecipe() {
* @return true if the recipe is allowed to be used, else false
*/
public boolean checkRecipe(@NotNull Recipe recipe) {
return checkCleanroomRequirement(recipe);
return checkCleanroomRequirement(recipe) && checkDimensionRequirement(recipe);
}

/**
Expand All @@ -431,6 +432,12 @@ protected boolean checkCleanroomRequirement(@NotNull Recipe recipe) {
return false;
}

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());
}

/**
* Prepares the recipe to be run.
* <ol>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public int getParallelLimit() {
return Integer.MAX_VALUE;
}

@Override
protected long getMaxParallelVoltage() {
return getMaxVoltage();
}

/**
* Boost the energy production.
* Should not change the state of the workable logic. Only read current values.
Expand Down
122 changes: 118 additions & 4 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@

import gregtech.api.gui.IUIHolder;
import gregtech.api.gui.ModularUI;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GregTechGuiScreen;
import gregtech.api.mui.factory.CoverGuiFactory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.drawable.ItemDrawable;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.utils.Alignment;
import com.cleanroommc.modularui.utils.MouseData;
import com.cleanroommc.modularui.value.BoolValue;
import com.cleanroommc.modularui.value.sync.EnumSyncValue;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;
import com.cleanroommc.modularui.value.sync.IntSyncValue;
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Row;
import org.jetbrains.annotations.ApiStatus;

Expand Down Expand Up @@ -92,13 +98,12 @@ default void markAsDirty() {
/**
* Create the Title bar widget for a Cover.
*/
default Row createTitleRow() {
ItemStack item = getDefinition().getDropItemStack();
static Row createTitleRow(ItemStack stack) {
return new Row()
.pos(4, 4)
.height(16).coverChildrenWidth()
.child(new ItemDrawable(getDefinition().getDropItemStack()).asWidget().size(16).marginRight(4))
.child(IKey.str(item.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
.child(IKey.str(stack.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
}

/**
Expand All @@ -108,6 +113,31 @@ default ParentWidget<?> createSettingsRow() {
return new ParentWidget<>().height(16).widthRel(1.0f).marginBottom(2);
}

default int getIncrementValue(MouseData data) {
int adjust = 1;
if (data.shift) adjust *= 4;
if (data.ctrl) adjust *= 16;
if (data.alt) adjust *= 64;
return adjust;
}

default IKey createAdjustOverlay(boolean increment) {
final StringBuilder builder = new StringBuilder();
builder.append(increment ? '+' : '-');
builder.append(getIncrementValue(MouseData.create(-1)));

float scale = 1f;
if (builder.length() == 3) {
scale = 0.8f;
} else if (builder.length() == 4) {
scale = 0.6f;
} else if (builder.length() > 4) {
scale = 0.5f;
}
return IKey.str(builder.toString())
.scale(scale);
}

/**
* Get a BoolValue for use with toggle buttons which are "linked together,"
* meaning only one of them can be pressed at a time.
Expand All @@ -123,4 +153,88 @@ default <T extends Enum<T>> BoolValue.Dynamic boolValueOf(EnumSyncValue<T> syncV
default BoolValue.Dynamic boolValueOf(IntSyncValue syncValue, int value) {
return new BoolValue.Dynamic(() -> syncValue.getValue() == value, $ -> syncValue.setValue(value));
}

class EnumRowBuilder<T extends Enum<T>> {

private EnumSyncValue<T> syncValue;
private final Class<T> enumValue;
private String lang;
private IDrawable[] background;
private IDrawable selectedBackground;
private IDrawable[] overlay;

public EnumRowBuilder(Class<T> enumValue) {
this.enumValue = enumValue;
}

public EnumRowBuilder<T> value(EnumSyncValue<T> syncValue) {
this.syncValue = syncValue;
return this;
}

public EnumRowBuilder<T> lang(String lang) {
this.lang = lang;
return this;
}

public EnumRowBuilder<T> background(IDrawable... background) {
this.background = background;
return this;
}

public EnumRowBuilder<T> selectedBackground(IDrawable selectedBackground) {
this.selectedBackground = selectedBackground;
return this;
}

public EnumRowBuilder<T> overlay(IDrawable... overlay) {
this.overlay = overlay;
return this;
}

public EnumRowBuilder<T> overlay(int size, IDrawable... overlay) {
this.overlay = new IDrawable[overlay.length];
for (int i = 0; i < overlay.length; i++) {
this.overlay[i] = overlay[i].asIcon().size(size);
}
return this;
}

private BoolValue.Dynamic boolValueOf(EnumSyncValue<T> syncValue, T value) {
return new BoolValue.Dynamic(() -> syncValue.getValue() == value, $ -> syncValue.setValue(value));
}

public Row build() {
var row = new Row().marginBottom(2).coverChildrenHeight().widthRel(1f);
if (this.enumValue != null && this.syncValue != null) {
for (var enumVal : enumValue.getEnumConstants()) {
var button = new ToggleButton().size(18).marginRight(2)
.value(boolValueOf(this.syncValue, enumVal));

if (this.background != null && this.background.length > 0)
button.background(this.background);
else
button.background(GTGuiTextures.MC_BUTTON);

if (this.selectedBackground != null)
button.selectedBackground(this.selectedBackground);
else
button.selectedBackground(GTGuiTextures.MC_BUTTON_DISABLED);

if (this.overlay != null)
button.overlay(this.overlay[enumVal.ordinal()]);

if (enumVal instanceof IStringSerializable serializable) {
button.addTooltipLine(IKey.lang(serializable.getName()));
}
row.child(button);
}
}

if (this.lang != null && !this.lang.isEmpty())
row.child(IKey.lang(this.lang).asWidget().align(Alignment.CenterRight).height(18));

return row;
}
}
}
29 changes: 23 additions & 6 deletions src/main/java/gregtech/api/gui/resources/TextTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@ public class TextTexture implements IGuiTexture {
public TextType type;
@SideOnly(Side.CLIENT)
private List<String> texts;
private final boolean isClient = FMLCommonHandler.instance().getSide().isClient();

public TextTexture(String text, int color) {
this.color = color;
this.type = TextType.NORMAL;
if (FMLCommonHandler.instance().getSide().isClient()) {
if (isClient) {
this.text = I18n.format(text);
texts = Collections.singletonList(this.text);
}
}

public TextTexture() {
this.color = 0xFFFFFF;
this.type = TextType.NORMAL;
this.text = "";

if (isClient)
this.texts = Collections.singletonList(this.text);
}

public TextTexture setColor(int color) {
this.color = color;
return this;
Expand All @@ -42,11 +52,18 @@ public TextTexture setDropShadow(boolean dropShadow) {

public TextTexture setWidth(int width) {
this.width = width;
if (FMLCommonHandler.instance().getSide().isClient()) {
if (this.width > 0) {
texts = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(text, width);
} else {
texts = Collections.singletonList(text);
return this;
}

public TextTexture setText(String text) {
if (!this.text.equals(text)) {
this.text = text;
if (isClient) {
if (this.width > 0) {
texts = Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(text, width);
} else {
texts = Collections.singletonList(text);
}
}
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import gregtech.api.gui.ingredient.IGhostIngredientTarget;
import gregtech.api.gui.ingredient.IIngredientSlot;
import gregtech.api.gui.resources.IGuiTexture;
import gregtech.api.util.*;
import gregtech.api.util.GTLog;
import gregtech.api.util.LocalizationUtils;
import gregtech.api.util.Position;
import gregtech.api.util.Size;
import gregtech.api.util.TextFormattingUtil;
import gregtech.client.utils.RenderUtil;
import gregtech.client.utils.TooltipHelper;

Expand Down
Loading

0 comments on commit c5bfba1

Please sign in to comment.