Skip to content

Commit

Permalink
Cherrypick stuff to 1.20 (#372)
Browse files Browse the repository at this point in the history
* add a KJS block type for renderer blocks. (#353)

* add ability to create renderer blocks from KJS, make the simple machines' arrays match the tier indexes

* do the same to KJS machine builders

* Implementation of Machine Modes (#359)

* first attempt at implementing machine modes

screret pls help

* fix the issue

* next attempt for the configurator

* latest commit

* latest stuff

* change activerecipetype to int

* final touch + method rename

* dev QoL stuffs

* final commit

* run data

* js^3 support added

---------

Co-authored-by: screret <[email protected]>

* shit. these should stack.

* Implementation of Gregicality Multiblocks (#369)

* gcmb first additions

* fix ABS (no textures tho)

* slight refactor

* blast alloy changes

* fix molten fluid texture (it was easy)

* more refactoring

* first attempt at implementing machine modes

screret pls help

* fix the issue

* next attempt for the configurator

* latest commit

* latest stuff

* change activerecipetype to int

* final touch + method rename

* dev QoL stuffs

* final commit

* run data

* js^3 support added

* final touch

* Update GTRecipeTypes.java

* Update GTMachines.java

* gcmb first additions

* slight refactor

* fix ABS (no textures tho)

* blast alloy changes

* fix molten fluid texture (it was easy)

* more refactoring

* first attempt at implementing machine modes

screret pls help

* fix the issue

* next attempt for the configurator

* latest stuff

* change activerecipetype to int

* final touch + method rename

* js^3 support added

* dev QoL stuffs

* run data

* gcmb first additions

* slight refactor

* fix ABS (no textures tho)

* blast alloy changes

* fix molten fluid texture (it was easy)

* gcmb first additions

* fix ABS (no textures tho)

* blast alloy changes

* fix molten fluid texture (it was easy)

* fix some KJS builders having issues in array indexing, rebase to upstream

* fix some KJS builders having issues in array indexing, rebase to upstream
HOLY SHIT THIS WAS PAINFUL

* add the parallel hatch, fix a lot of bugs, rename the casings to make sense, etc.
run data.

* parallel hatches + missing multis

* finalized

* requested fixes

* datagen

* more requested changes + datagen

* Update common/src/main/java/com/gregtechceu/gtceu/common/data/GCyMMachines.java

---------

Co-authored-by: screret <[email protected]>

* it didnt build lol

---------

Co-authored-by: Rundas <[email protected]>
  • Loading branch information
screret and Rundas01 authored Sep 15, 2023
1 parent ad22ae5 commit 8addafd
Show file tree
Hide file tree
Showing 562 changed files with 6,178 additions and 410 deletions.
2 changes: 2 additions & 0 deletions common/src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class GTValues {
public static final int OpV = 13;
public static final int MAX = 14;

public static final int TIER_COUNT = 15;

public static final String
MODID_TOP = "theoneprobe",
MODID_JEI = "jei",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
/**
* @author KilaBash
* @date 2023/7/13
* @implNote RenderGlassBlock
* @implNote RendererGlassBlock
*/
public class RenderGlassBlock extends RendererBlock{
public RenderGlassBlock(Properties properties, IRenderer renderer) {
public class RendererGlassBlock extends RendererBlock {
public RendererGlassBlock(Properties properties, IRenderer renderer) {
super(properties, renderer);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.gregtechceu.gtceu.api.capability;

public interface IParallelHatch {

/**
*
* @return the current maximum amount of parallelization provided
*/
int getCurrentParallel();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.gregtechceu.gtceu.api.data.chemical.fluid;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class FluidTypeMolten extends FluidTypeLiquid {

public FluidTypeMolten(@Nonnull String name, @Nullable String prefix, @Nullable String suffix, @Nonnull String localization) {
super(name, prefix, suffix, localization);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ public class FluidTypes {
public static final FluidType GAS = new FluidTypeGas("gas", null, null, "gtceu.fluid.generic");

public static final FluidType PLASMA = new FluidTypePlasma("plasma", "plasma", null, "gtceu.fluid.plasma");

public static final FluidType MOLTEN = new FluidTypeMolten("molten", "molten", null, "gtceu.fluid.molten");

}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ public FluidStack getFluid(long amount) {
return FluidStack.create(getFluid(), amount);
}

public Fluid getHotFluid() {
AlloyBlastProperty prop = properties.getProperty(PropertyKey.ALLOY_BLAST);
return prop == null ? null : prop.getFluid();
}

public FluidStack getHotFluid(long amount) {
AlloyBlastProperty prop = properties.getProperty(PropertyKey.ALLOY_BLAST);
return prop == null ? null : FluidStack.create(prop.getFluid(), amount);
}

public Item getBucket() {
Fluid fluid = getFluid();
return fluid.getBucket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ public String toString() {
.requireProps(PropertyKey.DUST)
.build();


// GCyM
/**
* Use to disable alloy blast recipes from generating
*/
public static final MaterialFlag DISABLE_ALLOY_BLAST = new MaterialFlag.Builder("disable_alloy_blast")
.requireProps(PropertyKey.BLAST, PropertyKey.FLUID)
.build();

/**
* Use to disable everything related to alloy blasting
*/
public static final MaterialFlag DISABLE_ALLOY_PROPERTY = new MaterialFlag.Builder("disable_alloy_property")
.requireProps(PropertyKey.BLAST, PropertyKey.FLUID)
.requireFlags(DISABLE_ALLOY_BLAST)
.build();

/////////////////
// FLUID //
/////////////////
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.gregtechceu.gtceu.api.data.chemical.material.properties;

import com.google.common.base.Preconditions;
import com.gregtechceu.gtceu.data.recipe.misc.alloyblast.AlloyBlastRecipeProducer;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.world.level.material.Fluid;

import javax.annotation.Nonnull;
import java.util.function.Supplier;

public class AlloyBlastProperty implements IMaterialProperty<AlloyBlastProperty> {

/**
* Internal material fluid field
*/
private Supplier<? extends Fluid> fluidSupplier;
private int temperature;

@Getter
@Setter
@Nonnull
private AlloyBlastRecipeProducer recipeProducer = AlloyBlastRecipeProducer.DEFAULT_PRODUCER;

public AlloyBlastProperty(int temperature) {
this.temperature = temperature;
}

@Override
public void verifyProperty(MaterialProperties materialProperties) {
materialProperties.ensureSet(PropertyKey.BLAST);
materialProperties.ensureSet(PropertyKey.FLUID);
this.temperature = materialProperties.getProperty(PropertyKey.BLAST).getBlastTemperature();
}

/**
* internal usage only
*/
public void setFluid(@Nonnull Supplier<? extends Fluid> materialFluid) {
Preconditions.checkNotNull(materialFluid);
this.fluidSupplier = materialFluid;
}

public Fluid getFluid() {
return fluidSupplier.get();
}

public void setTemperature(int fluidTemperature) {
Preconditions.checkArgument(fluidTemperature > 0, "Invalid temperature");
this.temperature = fluidTemperature;
}

public int getTemperature() {
return temperature;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class PropertyKey<T extends IMaterialProperty<T>> {

public static final PropertyKey<BlastProperty> BLAST = new PropertyKey<>("blast", BlastProperty.class);
public static final PropertyKey<AlloyBlastProperty> ALLOY_BLAST = new PropertyKey<>("blast_alloy", AlloyBlastProperty.class);
public static final PropertyKey<DustProperty> DUST = new PropertyKey<>("dust", DustProperty.class);
public static final PropertyKey<FluidPipeProperties> FLUID_PIPE = new PropertyKey<>("fluid_pipe", FluidPipeProperties.class);
public static final PropertyKey<FluidProperty> FLUID = new PropertyKey<>("fluid", FluidProperty.class);
Expand All @@ -17,6 +18,7 @@ public class PropertyKey<T extends IMaterialProperty<T>> {
public static final PropertyKey<WireProperties> WIRE = new PropertyKey<>("wire", WireProperties.class);
public static final PropertyKey<WoodProperty> WOOD = new PropertyKey<>("wood", WoodProperty.class);


// Empty property used to allow property-less Materials without removing base type enforcement
public static final PropertyKey<EmptyProperty> EMPTY = new PropertyKey<>("empty", EmptyProperty.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public class MachineDefinition implements Supplier<IMachineBlock> {
private Supplier<BlockEntityType<? extends BlockEntity>> blockEntityTypeSupplier;
@Setter
private Function<IMachineBlockEntity, MetaMachine> machineSupplier;
@Setter
@Nullable
private GTRecipeType recipeType;
@Getter
@Setter
@Getter @Setter @Nullable
private GTRecipeType[] recipeTypes;
@Getter @Setter
private int tier;
@Setter @Getter
private int defaultPaintingColor;
Expand Down Expand Up @@ -132,11 +130,6 @@ public String getName() {
return id.getPath();
}

@Nullable
public GTRecipeType getRecipeType() {
return recipeType;
}

@Override
public String toString() {
return "[Definition: %s]".formatted(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public boolean dampingWhenWaiting() {
return group;
}, (template, machine) -> {
if (machine instanceof SimpleGeneratorMachine generatorMachine) {
generatorMachine.recipeType.createEditableUITemplate(false, false).setupUI(template,
generatorMachine.getRecipeType().createEditableUITemplate(false, false).setupUI(template,
new GTRecipeType.RecipeHolder(generatorMachine.recipeLogic::getProgressPercent,
generatorMachine.importItems.storage,
generatorMachine.exportItems.storage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void attachConfigurators(ConfiguratorPanel configuratorPanel) {
return group;
}, (template, machine) -> {
if (machine instanceof SimpleTieredMachine tieredMachine) {
tieredMachine.recipeType.createEditableUITemplate(false, false).setupUI(template,
tieredMachine.getRecipeType().createEditableUITemplate(false, false).setupUI(template,
new GTRecipeType.RecipeHolder(tieredMachine.recipeLogic::getProgressPercent,
tieredMachine.importItems.storage,
tieredMachine.exportItems.storage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.EnumMap;
Expand All @@ -40,7 +41,9 @@ public abstract class WorkableTieredMachine extends TieredEnergyMachine implemen
@Persisted @DescSynced
public final RecipeLogic recipeLogic;
@Getter
public final GTRecipeType recipeType;
public final GTRecipeType[] recipeTypes;
@Getter @Setter @Persisted
public int activeRecipeType;
@Getter
public final Int2LongFunction tankScalingFunction;
@Nullable @Getter @Setter
Expand All @@ -65,7 +68,8 @@ public abstract class WorkableTieredMachine extends TieredEnergyMachine implemen
public WorkableTieredMachine(IMachineBlockEntity holder, int tier, Int2LongFunction tankScalingFunction, Object... args) {
super(holder, tier, args);
this.overclockTier = getMaxOverclockTier();
this.recipeType = getDefinition().getRecipeType();
this.recipeTypes = getDefinition().getRecipeTypes();
this.activeRecipeType = 0;
this.tankScalingFunction = tankScalingFunction;
this.capabilitiesProxy = Tables.newCustomTable(new EnumMap<>(IO.class), HashMap::new);
this.traitSubscriptions = new ArrayList<>();
Expand Down Expand Up @@ -195,4 +199,9 @@ public long getOverclockVoltage() {
public boolean keepSubscribing() {
return false;
}

@Nonnull
public GTRecipeType getRecipeType() {
return recipeTypes[activeRecipeType];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.gregtechceu.gtceu.api.machine.fancyconfigurator;

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.fancy.IFancyConfigurator;
import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;
import com.lowdragmc.lowdraglib.gui.widget.SelectorWidget;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
* @author Rundas/Screret
* @implNote MachineModeFancyConfigurator
*/
public class MachineModeFancyConfigurator implements IFancyConfigurator {
protected IRecipeLogicMachine machine;

public MachineModeFancyConfigurator(IRecipeLogicMachine machine) {
this.machine = machine;
}

@Override
public String getTitle() {
return "gtceu.gui.machinemode.title";
}

@Override
public IGuiTexture getIcon() {
return new ResourceTexture("gtceu:textures/item/lv_robot_arm.png");
}

@Override
public void writeInitialData(FriendlyByteBuf buffer) {
buffer.writeVarInt(machine.getActiveRecipeType());
}

@Override
public void readInitialData(FriendlyByteBuf buffer) {
machine.setActiveRecipeType(buffer.readVarInt());
}

@Override
public void detectAndSendChange(BiConsumer<Integer, Consumer<FriendlyByteBuf>> sender) {
sender.accept(0, buf -> buf.writeVarInt(machine.getActiveRecipeType()));
}

@Override
public void readUpdateInfo(int id, FriendlyByteBuf buffer) {
if (id == 0) {
machine.setActiveRecipeType(buffer.readVarInt());
}
}

@Override
public Widget createConfigurator() {
List<String> recipeTypeNames = Arrays.stream(machine.getRecipeTypes()).map(rt -> Component.translatable(rt.registryName.toLanguageKey()).getString()).toList();
return new WidgetGroup(0, 0, 140, 20 * recipeTypeNames.size()) {
@Override
public void initWidget() {
super.initWidget();
setBackground(GuiTextures.BACKGROUND_INVERSE);
addWidget(new SelectorWidget(2, 2, 136, 15, recipeTypeNames, -1).setOnChanged(
rt -> {
machine.setActiveRecipeType(recipeTypeNames.indexOf(rt));
machine.getRecipeLogic().resetRecipeLogic();
}).setSupplier(() -> {
var index = recipeTypeNames.indexOf(Component.translatable(machine.getRecipeType().registryName.toLanguageKey()).getString());
return recipeTypeNames.get(Math.max(index, 0));
})
);
}

@Override
public void writeInitialData(FriendlyByteBuf buffer) {
buffer.writeVarInt(machine.getActiveRecipeType());
super.writeInitialData(buffer);
}

@Override
public void readInitialData(FriendlyByteBuf buffer) {
machine.setActiveRecipeType(buffer.readVarInt());
super.readInitialData(buffer);
}

@Override
public void readUpdateInfo(int id, FriendlyByteBuf buffer) {
super.readUpdateInfo(id, buffer);
}
};
}

@Override
public List<Component> getTooltips() {
List<Component> tooltip = new ArrayList<>();
tooltip.add(Component.literal("Change active Machine Mode"));
return tooltip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.gregtechceu.gtceu.api.capability.IControllable;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.fancy.*;
import com.gregtechceu.gtceu.api.machine.WorkableTieredMachine;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.AutoOutputFancyConfigurator;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.MachineModeFancyConfigurator;
import com.gregtechceu.gtceu.api.machine.fancyconfigurator.OverclockFancyConfigurator;
import com.lowdragmc.lowdraglib.gui.modular.ModularUI;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
Expand Down Expand Up @@ -104,6 +106,9 @@ default void attachConfigurators(ConfiguratorPanel configuratorPanel) {
Component.translatable(pressed ? "behaviour.soft_hammer.enabled" : "behaviour.soft_hammer.disabled")
)));
}
if (this instanceof IRecipeLogicMachine rLMachine && rLMachine.getRecipeTypes().length > 1) {
configuratorPanel.attachConfigurators(new MachineModeFancyConfigurator(rLMachine));
}
configuratorPanel.attachConfigurators(self().getCoverContainer());
if (this instanceof IAutoOutputItem || this instanceof IAutoOutputFluid) {
configuratorPanel.attachConfigurators(new AutoOutputFancyConfigurator(self()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ default int getChanceTier() {
* RecipeType held
*/
@Nonnull
GTRecipeType[] getRecipeTypes();
@Nonnull
GTRecipeType getRecipeType();

int getActiveRecipeType();
void setActiveRecipeType(int type);

/**
* Called when recipe logic status changed
*/
Expand Down
Loading

0 comments on commit 8addafd

Please sign in to comment.