Skip to content

Commit

Permalink
Merge branch '1.20.1' into bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Spicierspace153 authored Sep 27, 2024
2 parents e5fab5f + 41283f3 commit e8dfda5
Show file tree
Hide file tree
Showing 30 changed files with 343 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
SNAPSHOT: true
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/auto-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
permissions:
contents: write
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
name: GregTechCEu ${{ steps.var.outputs.version }}
version: mc${{ steps.var.outputs.version }}
version-type: ${{ inputs.releaseType }}
changelog-file: CHANGELOG.*
changelog-file: RELEASE.*

loaders: |
forge
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
permissions:
contents: write
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Clean Gradle

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup Build
uses: ./.github/actions/build_setup
with:
update-cache: true

- name: Clean
run: ./gradlew clean --build-cache
39 changes: 39 additions & 0 deletions .github/workflows/manage-pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Manages labels on PRs before allowing merging
name: Pull Request Labels

on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize

# if a second commit is pushed quickly after the first, cancel the first one's build
concurrency:
group: pr-labels-${{ github.head_ref }}
cancel-in-progress: true

jobs:
Labels:
runs-on: ubuntu-latest

permissions:
pull-requests: read # needed to utilize required-labels

steps:
- name: Check for Merge-Blocking Labels # blocks merge if present
uses: mheap/github-action-required-labels@v5
with:
mode: exactly
count: 0
labels: 'status: do not merge'
exit_type: failure

- name: Check for Required Labels # require at least one of these labels
uses: mheap/github-action-required-labels@v5
with:
mode: minimum
count: 1
labels: 'type: feature, type: bug, type: refactor, type: translation, ignore changelog'
exit_type: failure
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,39 @@
<a href="https://github.com/GregTechCEu/GregTech-Modern/releases"><img src="https://img.shields.io/github/downloads/GregTechCEu/GregTech-Modern/total?sort=semver&logo=github&label=&style=for-the-badge&color=2d2d2d&labelColor=545454&logoColor=FFFFFF" alt="GitHub"></a>
</h1>

## Documentation / Wiki
[`Wiki`](https://gregtechceu.github.io/gtceu-modern-docs/)


## Dev Q&A
* [Todo List](https://github.com/GregTechCEu/GregTechCEu-1.19/issues/125) for potential contributors who are interested in this project
* [Dev Q&A](https://github.com/GregTechCEu/GregTechCEu-1.19/wiki/Dev-Q&A) illustrates common questions and answers related to development.

##
## IDE Requirements (when using IntelliJ IDEA)

For developing this mod, the [Lombok plugin](https://plugins.jetbrains.com/plugin/6317-lombok) for IntelliJ IDEA is strictly required.
### [Wiki](https://gregtechceu.github.io/gtceu-modern-docs/)

## Developers

To add GTCEu: Modern (GTM) to your project as a dependency, add the following to your `build.gradle`:
```groovy
repositories {
maven {
name = 'GTCEu Maven'
url = 'https://maven.gtceu.com'
content {
includeGroup 'com.gregtechceu.gtceu'
}
}
}
```
Then, you can add it as a dependency, with `${mc_version}` being your Minecraft version target and `${gtm_version}` being the version of GTM you want to use.
```groovy
dependencies {
// Forge (see below block as well if you use Forge Gradle)
implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${mc_version}:${gtm_version}")
// NeoForge
implementation "com.gregtechceu.gtceu:gtceu-${mc_version}:${gtm_version}"
// Architectury
modImplementation "com.gregtechceu.gtceu:gtceu-${mc_version}:${gtm_version}"
}
```

### IDE Requirements (when using IntelliJ IDEA)

For contributing to this mod, the [Lombok plugin](https://plugins.jetbrains.com/plugin/6317-lombok) for IntelliJ IDEA is strictly required.
Additionally, the [Minecraft Development plugin](https://plugins.jetbrains.com/plugin/8327-minecraft-development) is recommended.


Expand Down
7 changes: 7 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## What's Changed

### Fixed
- Multiblock machines now calculate their tier correctly ([#2019](https://github.com/GregTechCEu/GregTech-Modern/pull/2019))
- Recipe fixes 🔥 ([#2022](https://github.com/GregTechCEu/GregTech-Modern/pull/2022) and [#2023](https://github.com/GregTechCEu/GregTech-Modern/pull/2023))

**Full Changelog found [here](https://github.com/GregTechCEu/GregTech-Modern/compare/1.20.1-1.4.2...1.20.1-1.4.3)**
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G
# Mod Info
mod_id = gtceu
mod_name = GregTech
mod_version = 1.4.2
mod_version = 1.4.5
mod_description = GregTech CE Unofficial, ported from 1.12.2
mod_license = LGPL-3.0 license
mod_url = https://github.com/GregTechCEu/GregTech-Modern/
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ publishing {
repositories {
// Add repositories to publish to here.
maven {
url "https://maven.firstdarkdev.xyz/snapshots"
url "https://maven.gtceu.com"
credentials {
username System.getenv("MAVEN_USER")
password System.getenv("MAVEN_PASS")
password System.getenv("MAVEN_PASSWORD")
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class GTValues {
* The Voltage Tiers. Use this Array instead of the old named Voltage Variables
*/
public static final long[] V = new long[] { 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608,
33554432, 134217728, 536870912, Integer.MAX_VALUE };
33554432, 134217728, 536870912, 2147483648L };

/**
* The Voltage Tiers divided by 2.
Expand All @@ -75,6 +75,15 @@ public class GTValues {
public static final int[] VHA = { 7, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640,
62914560, 251658240, 1006632960 };

/**
* The Voltage Tiers. Use this Array instead of the old named Voltage Variables
*/
public static final long[] VEX = new long[] { 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608,
33554432, 134217728, 536870912, 2147483648L, 8589934592L, 34359738368L, 137438953472L, 549755813888L,
2199023255552L, 8796093022208L, 35184372088832L, 140737488355328L, 562949953421312L, 2251799813685248L,
9007199254740992L, 36028797018963968L, 144115188075855872L, 576460752303423488L, 2305843009213693952L,
Long.MAX_VALUE };

public static final int ULV = 0;
public static final int LV = 1;
public static final int MV = 2;
Expand All @@ -90,6 +99,7 @@ public class GTValues {
public static final int UXV = 12;
public static final int OpV = 13;
public static final int MAX = 14;
public static final int MAX_TRUE = 30;

public static final int[] ALL_TIERS = new int[] { ULV, LV, MV, HV, EV, IV, LuV, ZPM, UV, UHV, UEV, UIV, UXV, OpV,
MAX };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gregtechceu.gtceu.GTCEu;

import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import com.mojang.datafixers.util.Unit;
import com.mojang.serialization.*;
Expand Down Expand Up @@ -44,7 +43,7 @@ public <T> DataResult<Pair<Map<K, V>, T>> decode(final DynamicOps<T> ops, final
(result, entry) -> parseEntry(result, ops, entry, entries, failed),
(r1, r2) -> r1.apply2stable((u1, u2) -> u1, r2));

final Pair<Map<K, V>, T> pair = Pair.of(ImmutableMap.copyOf(entries), input);
final Pair<Map<K, V>, T> pair = Pair.of(new Object2ObjectArrayMap<>(entries), input);
final T errors = ops.createMap(failed.build());

return finalResult.map(ignored -> pair).setPartial(pair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class GTToolType {
.attackDamage(1.0F).attackSpeed(-2.8F)
.behaviors(BlockRotatingBehavior.INSTANCE, new EntityDamageBehavior(3.0F, IronGolem.class),
ToolModeSwitchBehavior.INSTANCE))
.sound(GTSoundEntries.WRENCH_TOOL)
.sound(GTSoundEntries.WRENCH_TOOL, true)
.symbol('w')
.build();
public static final GTToolType FILE = GTToolType.builder("file")
Expand All @@ -164,7 +164,7 @@ public class GTToolType {
.toolStats(b -> b.blockBreaking().crafting()
.attackDamage(2.0F).attackSpeed(-2.4F)
.sneakBypassUse().behaviors(RotateRailBehavior.INSTANCE))
.sound(new ExistingSoundEntry(SoundEvents.ITEM_BREAK, SoundSource.BLOCKS))
.sound(new ExistingSoundEntry(SoundEvents.ITEM_BREAK, SoundSource.BLOCKS), true)
.symbol('c')
.build();
public static final GTToolType SCREWDRIVER = GTToolType.builder("screwdriver")
Expand All @@ -186,7 +186,7 @@ public class GTToolType {
.harvestTag(TagUtil.createBlockTag("mineable/wire_cutter", false))
.toolStats(b -> b.blockBreaking().crafting().sneakBypassUse()
.damagePerCraftingAction(4).attackDamage(-1.0F).attackSpeed(-2.4F))
.sound(GTSoundEntries.WIRECUTTER_TOOL)
.sound(GTSoundEntries.WIRECUTTER_TOOL, true)
.symbol('x')
.build();
public static final GTToolType KNIFE = GTToolType.builder("knife")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ public long getOverclockVoltage() {
if (amperage == 1) {
// amperage is 1 when the energy is not exactly on a tier
// the voltage for recipe search is always on tier, so take the closest lower tier
if (voltage > Integer.MAX_VALUE) return GTUtil.getVoltageFromFakeTier(GTUtil.getFakeVoltageTier(voltage));
return GTValues.V[GTUtil.getFloorTierByVoltage(voltage)];
return GTValues.VEX[GTUtil.getFloorTierByVoltage(voltage)];
} else {
// amperage != 1 means the voltage is exactly on a tier
// ignore amperage, since only the voltage is relevant for recipe search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class RecipeCondition {

public static <
RC extends RecipeCondition> Products.P1<RecordCodecBuilder.Mu<RC>, Boolean> isReverse(RecordCodecBuilder.Instance<RC> instance) {
return instance.group(Codec.BOOL.fieldOf("reverse").forGetter(val -> val.isReverse));
return instance.group(Codec.BOOL.optionalFieldOf("reverse", false).forGetter(val -> val.isReverse));
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static GTRecipe applyOverclock(OverclockingLogic logic, @NotNull GTRecipe
}
EUt = getOutputEUt(recipe);
if (EUt > 0) {
performOverclocking(logic, recipe, EUt, maxOverclockVoltage, params, result);
performOverclocking(logic, recipe, -EUt, maxOverclockVoltage, params, result);
}
return recipe;
}
Expand All @@ -91,14 +91,12 @@ public static GTRecipe applyOverclock(OverclockingLogic logic, @NotNull GTRecipe
* Then performs overclocking on the Recipe.
*
* @param recipe the recipe to overclock
* @return an int array of {OverclockedEUt, OverclockedDuration}
*/
public static void performOverclocking(OverclockingLogic logic, @NotNull GTRecipe recipe, long EUt,
long maxOverclockVoltage,
@NotNull OCParams params, @NotNull OCResult result) {
int recipeTier = GTUtil.getTierByVoltage(EUt);
int maximumTier = maxOverclockVoltage < Integer.MAX_VALUE ? logic.getOverclockForTier(maxOverclockVoltage) :
GTUtil.getFakeVoltageTier(maxOverclockVoltage);
int recipeTier = GTUtil.getTierByVoltage(Math.abs(EUt));
int maximumTier = logic.getOverclockForTier(maxOverclockVoltage);
// The maximum number of overclocks is determined by the difference between the tier the recipe is running at,
// and the maximum tier that the machine can overclock to.
int numberOfOCs = maximumTier - recipeTier;
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@ private void fillContent(IRecipeCapabilityHolder holder, Map.Entry<RecipeCapabil
}
}

int recipeTier = RecipeHelper.getPreOCRecipeEuTier(recipe);
int holderTier = holder.getChanceTier();
var cache = this.chanceCaches.get(cap);
chancedContents = logic.roll(chancedContents, function, recipeTier, holderTier, cache, recipe.parallels, cap);

if (chancedContents == null) return;
for (Content cont : chancedContents) {
if (cont.slotName == null) {
this.content.content.add(cont.content);
} else {
this.content.slots.computeIfAbsent(cont.slotName, s -> new ArrayList<>()).add(cont.content);
// Only roll if there's anything to roll for
if (!chancedContents.isEmpty()) {
int recipeTier = RecipeHelper.getPreOCRecipeEuTier(recipe);
int holderTier = holder.getChanceTier();
var cache = this.chanceCaches.get(cap);
chancedContents = logic.roll(chancedContents, function, recipeTier, holderTier, cache, recipe.parallels,
cap);

if (chancedContents == null) return;
for (Content cont : chancedContents) {
if (cont.slotName == null) {
this.content.content.add(cont.content);
} else {
this.content.slots.computeIfAbsent(cont.slotName, s -> new ArrayList<>()).add(cont.content);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.capability.IParallelHatch;
import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability;
import com.gregtechceu.gtceu.api.capability.recipe.IRecipeCapabilityHolder;
import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition;
import com.gregtechceu.gtceu.api.machine.MetaMachine;
Expand All @@ -12,6 +13,8 @@
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.OverclockingLogic;
import com.gregtechceu.gtceu.api.recipe.RecipeHelper;
import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic;
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
import com.gregtechceu.gtceu.api.recipe.logic.OCParams;
import com.gregtechceu.gtceu.api.recipe.logic.OCResult;
Expand All @@ -30,6 +33,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
Expand Down Expand Up @@ -243,19 +247,22 @@ public static GTRecipe multiSmelterParallel(MetaMachine machine, @NotNull GTReci
var maxParallel = 32 * coilMachine.getCoilType().getLevel();
final int FURNACE_DURATION = 128;
var parallel = GTRecipeModifiers.accurateParallel(machine, recipe, maxParallel, false);
// double durationForParallel = Math.max(1.0, FURNACE_DURATION * 2 * parallel.getSecond() / Math.max(1,
// maxParallel * 1.0));

recipe = parallel.getFirst() == recipe ? parallel.getFirst().copy() : parallel.getFirst();

int parallelValue = parallel.getSecond();
long eut = 4 * (parallelValue / 8) / coilMachine.getCoilType().getEnergyDiscount();
result.init(eut, Math.max(1, 256 * parallelValue / maxParallel), parallelValue, params.getOcAmount());
/*
* recipe.duration = Math.max(1, 256 * parallelValue / maxParallel);
* recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut,
* ChanceLogic.getMaxChancedValue(), ChanceLogic.getMaxChancedValue(), 0, null, null)));
*/
long eut = 4 * Math.max(1, (parallelValue / 8) / coilMachine.getCoilType().getEnergyDiscount());
int duration = (int) Math.max(1, FURNACE_DURATION * 2 * parallelValue / Math.max(1, maxParallel * 1.0));

recipe.duration = duration;
recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut,
ChanceLogic.getMaxChancedValue(), ChanceLogic.getMaxChancedValue(),
0, null, null)));

var re = RecipeHelper.applyOverclock(new OverclockingLogic((p, r, maxVoltage) -> {
OverclockingLogic.NON_PERFECT_OVERCLOCK.getLogic()
.runOverclockingLogic(params, result, maxVoltage);
}), recipe, coilMachine.getOverclockVoltage(), params, result);
recipe = recipe.copy(ContentModifier.multiplier(parallelValue), false);

return recipe;
}
return null;
Expand Down
Loading

0 comments on commit e8dfda5

Please sign in to comment.