Skip to content

Commit

Permalink
Update to KJS 6.1 (#146)
Browse files Browse the repository at this point in the history
* best update ever ong

* almost there

* DONE!

* revert this

* fix a couple crashes

* added *new* machine builder stuffs and such, updated KJS

* missed sum files

* ....and more.

* fix pipe models

* fix element builder

* fix being able to set auto output side to front

* almost there

* DONE!

* revert this

* holy hell

* fix some recipes failing because they were provided BlockEntry<?>s and only checked for ItemEntry<?> instead of ItemProviderEntry<?>

* DONE!

* revert this

* ....and more.

* DONE!

* revert this

* holy hell

* same stuff

* fix a crash with data, and rename Cetane-boosted Diesel to actually be Cetane-boosted diesel

* finish the (very much optional) bedrock ore system

* fix a crash if flawed/chipped gems are disabled

* change ProspectorMode to fix stuff

* changes to bedrock ore vein edge stuff

* Revert "change ProspectorMode to fix stuff"

This reverts commit b378f4c.

* bump version

* update kjs

* IT WORKS FUCK YESSSS... except replacing.

* replacing almost works

* IT WORKS FUCK YESSSS

* fix ores not dropping materials without raw ores

* piss off loom

* lat broke replacing :trolley:

* fix prospector tooltips

* tier chance boost

* fix solder multiplier defaulting to 0

* update some deps

* run data

* fix cleanroom

---------

Co-authored-by: KilaBash <yefancy@foxmail.com>
  • Loading branch information
screret and Yefancy authored Jul 18, 2023
1 parent 2a5684e commit 93ced1b
Show file tree
Hide file tree
Showing 138 changed files with 3,592 additions and 1,288 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
alias libs.plugins.architectury
alias libs.plugins.architectury.loom apply false
alias libs.plugins.quiltFlower apply false // Quiltflower, a better decompiler
alias libs.plugins.vineFlower apply false // VineFlower, a better decompiler
alias libs.plugins.machete // automatic jar compressing on build
}

Expand All @@ -13,7 +13,7 @@ architectury {

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "io.github.juuxel.loom-quiltflower"
apply plugin: "io.github.juuxel.loom-vineflower"

loom {
silentMojangMappingsLicense()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gregtechceu.gtceu.api.addon;

import com.gregtechceu.gtceu.api.addon.events.KJSRecipeKeyEvent;

import com.gregtechceu.gtceu.api.addon.events.MaterialCasingCollectionEvent;
import net.minecraft.data.recipes.FinishedRecipe;

Expand Down Expand Up @@ -85,4 +87,8 @@ default void initializeRecipes(Consumer<FinishedRecipe> provider) {
default void collectMaterialCasings(MaterialCasingCollectionEvent event) {

}

default void registerRecipeKeys(KJSRecipeKeyEvent event) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gregtechceu.gtceu.api.addon.events;

import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.integration.kjs.recipe.components.ContentJS;
import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents;
import com.mojang.datafixers.util.Pair;
import dev.latvian.mods.kubejs.recipe.component.ItemComponents;
import dev.latvian.mods.kubejs.recipe.component.NumberComponent;
import dev.latvian.mods.kubejs.recipe.component.RecipeComponent;
import lombok.Getter;

import java.util.*;

/**
* @author screret
* @date 2023/7/5
* @implNote An event for adding KJS recipe keys
*/
@SuppressWarnings("unused")
public class KJSRecipeKeyEvent {
@Getter
private final Map<RecipeCapability<?>, Pair<ContentJS<?>, ContentJS<?>>> registeredKeys = new HashMap<>();

/**
* Use this to register new components for KJS to use!
* @param cap the recipe capability you're adding a KJS binding for.
* @param key the components, like {@link GTRecipeComponents#ITEM_IN} and {@link GTRecipeComponents#ITEM_OUT}, as a {@link Pair}
*/
public void registerKey(RecipeCapability<?> cap, Pair<ContentJS<?>, ContentJS<?>> key) {
if (registeredKeys.put(cap, key) != null) {
throw new IllegalStateException("Can't have multiple Recipe keys with same value!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ default boolean hasProxies() {
@Nonnull
Table<IO, RecipeCapability<?>, List<IRecipeHandler<?>>> getCapabilitiesProxy();

/**
* get Tier for chance boost.
*/
default int getChanceTier() {
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import dev.latvian.mods.rhino.util.HideFromJS;
import dev.latvian.mods.rhino.util.RemapPrefixForJS;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.enchantment.Enchantment;
Expand Down Expand Up @@ -315,7 +316,7 @@ public String getUnlocalizedName() {
return "material." + materialInfo.name;
}

public Component getLocalizedName() {
public MutableComponent getLocalizedName() {
return Component.translatable(getUnlocalizedName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public record MaterialIconType(String name) {
public static final MaterialIconType ore = new MaterialIconType("ore");
public static final MaterialIconType oreSmall = new MaterialIconType("oreSmall");
public static final MaterialIconType frameGt = new MaterialIconType("frameGt");
public static final MaterialIconType wire = new MaterialIconType("wire");

// USED FOR GREGIFICATION ADDON
public static final MaterialIconType seed = new MaterialIconType("seed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,11 @@ public static TagPrefix get(String name) {
//public static final TagPrefix pipeHugeRestrictive = new TagPrefix("pipeHugeRestrictive").itemTable(() -> GTBlocks.ITEM_PIPE_BLOCKS).langValue("Huge Restrictive %s Item Pipe").miningToolTag(GTToolType.WRENCH.harvestTag).materialAmount(GTValues.M * 12).unificationEnabled(true);

// Wires and cables
public static final TagPrefix wireGtHex = new TagPrefix("wireGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).unificationEnabled(true);
public static final TagPrefix wireGtOctal = new TagPrefix("wireGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).unificationEnabled(true);
public static final TagPrefix wireGtQuadruple = new TagPrefix("wireGtQuadruple").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("4x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 2).unificationEnabled(true);
public static final TagPrefix wireGtDouble = new TagPrefix("wireGtDouble").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("2x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M).unificationEnabled(true);
public static final TagPrefix wireGtSingle = new TagPrefix("wireGtSingle").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("1x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M / 2).unificationEnabled(true);
public static final TagPrefix wireGtHex = new TagPrefix("wireGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).materialIconType(MaterialIconType.wire).unificationEnabled(true);
public static final TagPrefix wireGtOctal = new TagPrefix("wireGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).materialIconType(MaterialIconType.wire).unificationEnabled(true);
public static final TagPrefix wireGtQuadruple = new TagPrefix("wireGtQuadruple").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("4x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 2).materialIconType(MaterialIconType.wire).unificationEnabled(true);
public static final TagPrefix wireGtDouble = new TagPrefix("wireGtDouble").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("2x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M).materialIconType(MaterialIconType.wire).unificationEnabled(true);
public static final TagPrefix wireGtSingle = new TagPrefix("wireGtSingle").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("1x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M / 2).materialIconType(MaterialIconType.wire).unificationEnabled(true);

public static final TagPrefix cableGtHex = new TagPrefix("cableGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Cable").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).unificationEnabled(true);
public static final TagPrefix cableGtOctal = new TagPrefix("cableGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Cable").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).unificationEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreVeinSavedData;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.config.ConfigHolder;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -51,10 +54,13 @@ public boolean place(FeaturePlaceContext<GTOreFeatureConfiguration> context) {
if (ConfigHolder.INSTANCE.worldgen.debugWorldgen) GTCEu.LOGGER.debug("failed to place vein " + entry.id + " in biome " + biome + ". Trying with another...");
}*/

ResourceLocation id = GTOreFeatureEntry.ALL.inverse().get(entry);
ResourceLocation id = GTRegistries.ORE_VEINS.getKey(entry);
if (ConfigHolder.INSTANCE.worldgen.debugWorldgen) GTCEu.LOGGER.debug("trying to place vein " + id + " at " + origin);
if (entry.getVeinGenerator() != null && entry.getVeinGenerator().generate(level, random, entry, origin)) {
logPlaced(id, true);
if (ConfigHolder.INSTANCE.machines.doBedrockOres) {
BedrockOreVeinSavedData.getOrCreate(level.getLevel()).createVein(new ChunkPos(origin), entry);
}
return true;
}

Expand All @@ -67,7 +73,7 @@ public static boolean canPlaceOre(BlockState pState, Function<BlockPos, BlockSta
BlockPos.MutableBlockPos pMatablePos) {
if (!pTargetState.target.test(pState, pRandom))
return false;
if (shouldSkipAirCheck(pRandom, entry.discardChanceOnAirExposure))
if (shouldSkipAirCheck(pRandom, entry.getDiscardChanceOnAirExposure()))
return true;

return !isAdjacentToAir(pAdjacentStateAccessor, pMatablePos);
Expand All @@ -76,9 +82,9 @@ public static boolean canPlaceOre(BlockState pState, Function<BlockPos, BlockSta
public static boolean canPlaceOre(BlockState pState, Function<BlockPos, BlockState> pAdjacentStateAccessor,
RandomSource pRandom, GTOreFeatureEntry entry, Material pTargetState,
BlockPos.MutableBlockPos pMatablePos) {
if (!entry.layer.getTarget().test(pState, pRandom))
if (!entry.getLayer().getTarget().test(pState, pRandom))
return false;
if (shouldSkipAirCheck(pRandom, entry.discardChanceOnAirExposure))
if (shouldSkipAirCheck(pRandom, entry.getDiscardChanceOnAirExposure()))
return true;

return !isAdjacentToAir(pAdjacentStateAccessor, pMatablePos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import org.jetbrains.annotations.Nullable;

import java.util.function.Function;

/**
* @author Screret
* @date 2023/6/9
Expand All @@ -21,7 +23,7 @@
public class GTOreFeatureConfiguration implements FeatureConfiguration {
public static final Codec<GTOreFeatureConfiguration> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.either(GTOreFeatureEntry.CODEC, GTOreFeatureEntry.FULL_CODEC)
.xmap(either -> either.map(entry -> entry, entry -> entry), Either::left)
.xmap(either -> either.map(Function.identity(), Function.identity()), Either::left)
.optionalFieldOf("entry", null)
.forGetter(config -> config.entry)
).apply(instance, GTOreFeatureConfiguration::new)
Expand Down
Loading

0 comments on commit 93ced1b

Please sign in to comment.