Skip to content

Commit

Permalink
general QoL fixes (#74)
Browse files Browse the repository at this point in the history
* made custom (& dye, chest) tags be according to platform standard, removed CustomTagsImpl.java's in the process

* added automatic line ending convesion

* made every machine use it's own recipe type for KJS's sake, redatagen'd dye tags
also why it wanna commit unchanged files

* fixed fabric fluid amounts and ran datagen... again.

* removed unused stuff from GTRecipeBuilderJS, GTRegistriesImpl, MaterialStack
renamed some method values to make sense, and changed var typings
removed a finished TODO from SerializerFluidStack

* reverted a change, added a TODO to remind about fixing it

* fixed transformer name and made creative tab names be clearer

* some recipe fixes, namely stone type maceration and an info thing to note the "duplicate" recipes

* FIXED MACHINE OVERLAY MODELS
closes #55

* kjs & recipe stuff; hid registration methods

* renamed some machines

* tried to make custom MaterialIconSets work (it didn't work)

* made custom (& dye, chest) tags be according to platform standard, removed CustomTagsImpl.java's in the process

* added automatic line ending convesion

* made every machine use it's own recipe type for KJS's sake, redatagen'd dye tags
also why it wanna commit unchanged files

* removed unused stuff from GTRecipeBuilderJS, GTRegistriesImpl, MaterialStack
renamed some method values to make sense, and changed var typings
removed a finished TODO from SerializerFluidStack

* reverted a change, added a TODO to remind about fixing it

* fixed transformer name and made creative tab names be clearer

* some recipe fixes, namely stone type maceration and an info thing to note the "duplicate" recipes

* FIXED MACHINE OVERLAY MODELS
closes #55

* kjs & recipe stuff; hid registration methods

* renamed some machines

* tried to make custom MaterialIconSets work (it didn't work)

* it works but only on forge

* IT WORKS :LLEETTSS:

* feck i missed a file from that

* crash on datagen lol

* slight lang changes, ran datagen

* preparations for merge:
- changed back some useless things
- renamed input buses to actually be "input bus"es
- made GTRecipeBuilderJS's autogenerated id use the correct namespace
- added a nice looking newline in MaterialIconType & removed an unused import
- removed an unused parameter from RecyclingRecipes#registerMaceratorRecycling
- made TagPrefixItemRenderer#MODELS be private as it wasn't used anywhere else anymore

* fixed elements not registering

* added custom coil registration (not finished)

* Update MaterialIconType.java

---------

Co-authored-by: KilaBash <[email protected]>
  • Loading branch information
screret and Yefancy authored May 25, 2023
1 parent d286db9 commit f19ae72
Show file tree
Hide file tree
Showing 122 changed files with 1,039 additions and 574 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=autolf

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.json text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ subprojects {
includeGroup "curse.maven"
}
} // Curse Forge File
maven { url = "https://dvs1.progwml6.com/files/maven/" } // JEI
maven {
name = "Jared's maven"
url = "https://maven.blamejared.com/"
} // JEI
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.dev"
} // JEI mirror, AE2
maven { url = "https://maven.parchmentmc.org" } // Parchment mappings
maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings
maven {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.gregtechceu.gtceu.api.block;

import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import net.minecraft.resources.ResourceLocation;

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

public interface ICoilType {

/**
* @return The Unique Name of the Heating Coil
*/
@Nonnull
String getName();

/**
* @return the temperature the Heating Coil provides
*/
int getCoilTemperature();

/**
* This is used for the amount of parallel recipes in the multi smelter
*
* @return the level of the Heating Coil
*/
int getLevel();

/**
* This is used for the energy discount in the multi smelter
*
* @return the energy discount of the Heating Coil
*/
@SuppressWarnings("unused")
int getEnergyDiscount();

/**
* This is used for the energy discount in the cracking unit and pyrolyse oven
*
* @return the tier of the coil
*/
int getTier();

/**
* @return the {@link Material} of the Heating Coil if it has one, otherwise {@code null}
*/
@Nullable
Material getMaterial();

/**
* @return the {@link ResourceLocation} defining the base texture of the coil
*/
ResourceLocation getTexture();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.gregtechceu.gtlib.side.fluid.FluidStack;
import dev.latvian.mods.rhino.util.HideFromJS;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -967,6 +968,7 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) {
return this;
}

@HideFromJS
public Material buildAndRegister() {
materialInfo.componentList = ImmutableList.copyOf(composition);
var mat = new Material(materialInfo, properties, flags);
Expand Down Expand Up @@ -1068,7 +1070,7 @@ private void verifyInfo(MaterialProperties p, boolean averageRGB) {
if (p.hasProperty(PropertyKey.FLUID)) {
var fluid = p.getProperty(PropertyKey.FLUID);
if (fluid.getStillTexture() == null) {
fluid.setStillTexture(MaterialIconType.fluid.getBlockTexturePath(iconSet));
fluid.setStillTexture(MaterialIconType.fluid.getBlockTexturePath(iconSet, true));
}
if (fluid.getFlowTexture() == null) {
fluid.setFlowTexture(fluid.getStillTexture());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import com.google.common.collect.Table;
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtlib.Platform;
import com.gregtechceu.gtlib.utils.ResourceHelper;
import net.minecraft.resources.ResourceLocation;

import javax.annotation.Nonnull;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -103,17 +103,19 @@ public MaterialIconType(String name) {
}

@Nonnull
public ResourceLocation getBlockTexturePath(@Nonnull MaterialIconSet materialIconSet) {
if (BLOCK_TEXTURE_CACHE.contains(this, materialIconSet)) {
return BLOCK_TEXTURE_CACHE.get(this, materialIconSet);
public ResourceLocation getBlockTexturePath(@Nonnull MaterialIconSet materialIconSet, boolean doReadCache) {
if (doReadCache) {
if (BLOCK_TEXTURE_CACHE.contains(this, materialIconSet)) {
return BLOCK_TEXTURE_CACHE.get(this, materialIconSet);
}
}

MaterialIconSet iconSet = materialIconSet;
//noinspection ConstantConditions
if (!iconSet.isRootIconset && Platform.isClient()) { // check minecraft for null for CI environments
while (!iconSet.isRootIconset) {
URL url = MaterialIconType.class.getResource(String.format("/assets/%s/textures/block/material_sets/%s/%s.png", GTCEu.MOD_ID, iconSet.name, this.name));
if (url != null) break;
ResourceLocation location = GTCEu.id(String.format("textures/block/material_sets/%s/%s.png", iconSet.name, this.name));
if (ResourceHelper.isResourceExist(location)) break;
iconSet = iconSet.parentIconset;
}
}
Expand All @@ -125,17 +127,19 @@ public ResourceLocation getBlockTexturePath(@Nonnull MaterialIconSet materialIco
}

@Nonnull
public ResourceLocation getItemModelPath(@Nonnull MaterialIconSet materialIconSet) {
if (ITEM_MODEL_CACHE.contains(this, materialIconSet)) {
return ITEM_MODEL_CACHE.get(this, materialIconSet);
public ResourceLocation getItemModelPath(@Nonnull MaterialIconSet materialIconSet, boolean doReadCache) {
if (doReadCache) {
if (ITEM_MODEL_CACHE.contains(this, materialIconSet)) {
return ITEM_MODEL_CACHE.get(this, materialIconSet);
}
}

MaterialIconSet iconSet = materialIconSet;
//noinspection ConstantConditions
if (!iconSet.isRootIconset && Platform.isClient()) { // check minecraft for null for CI environments
while (!iconSet.isRootIconset) {
URL url = MaterialIconType.class.getResource(String.format("/assets/%s/models/item/material_sets/%s/%s.json", GTCEu.MOD_ID, iconSet.name, this.name));
if (url != null) break;
ResourceLocation location = GTCEu.id(String.format("models/item/material_sets/%s/%s.json", iconSet.name, this.name));
if (ResourceHelper.isResourceExist(location)) break;
iconSet = iconSet.parentIconset;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.gregtechceu.gtceu.api.data.chemical.material.stack;

import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.utils.FormattingUtil;

import java.util.Map;
import java.util.WeakHashMap;

public record MaterialStack(Material material, long amount) {
private static final Map<String, MaterialStack> PARSE_CACHE = new WeakHashMap<>();

public MaterialStack copy(long amount) {
return new MaterialStack(material, amount);
Expand All @@ -13,6 +18,33 @@ public MaterialStack copy() {
return new MaterialStack(material, amount);
}

public static MaterialStack fromString(CharSequence str) {
String trimmed = str.toString().trim();
String copy = trimmed;

var cached = PARSE_CACHE.get(trimmed);

if (cached != null) {
return cached.isEmpty() ? null : cached.copy();
}

var count = 1;
var spaceIndex = copy.indexOf(' ');

if (spaceIndex >= 2 && copy.indexOf('x') == spaceIndex - 1) {
count = Integer.parseInt(copy.substring(0, spaceIndex - 1));
copy = copy.substring(spaceIndex + 1);
}

cached = new MaterialStack(GTMaterials.get(copy), count);
PARSE_CACHE.put(trimmed, cached);
return cached.copy();
}

public boolean isEmpty() {
return this.material == GTMaterials.Air || this.amount < 1;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gregtechceu.gtceu.api.data.tag;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtlib.Platform;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -24,12 +25,25 @@ public static <T> TagKey<T> createTag(Registry<T> registry, String path, boolean
return optionalTag(registry, Platform.isForge() ? new ResourceLocation("forge", path) : new ResourceLocation("c", path));
}

public static <T> TagKey<T> createPlatformTag(Registry<T> registry, String forgePath, String fabricPath, boolean modTag) {
if (modTag) return optionalTag(registry, Platform.isForge() ? new ResourceLocation(GTCEu.MOD_ID, forgePath) : new ResourceLocation(GTCEu.MOD_ID, fabricPath));
return optionalTag(registry, Platform.isForge() ? new ResourceLocation("forge", forgePath) : new ResourceLocation("c", fabricPath));
}

public static <T> TagKey<T> createModTag(Registry<T> registry, String path) {
return optionalTag(registry, GTCEu.id(path));
}

public static TagKey<Block> createBlockTag(String path) {
return createTag(Registry.BLOCK, path, false);
}

public static TagKey<Item> createBlockTag(String path, boolean vanilla) {
return createTag(Registry.ITEM, path, vanilla);
public static TagKey<Block> createBlockTag(String path, boolean vanilla) {
return createTag(Registry.BLOCK, path, vanilla);
}

public static TagKey<Block> createModBlockTag(String path) {
return createModTag(Registry.BLOCK, path);
}

public static TagKey<Item> createItemTag(String path) {
Expand All @@ -40,6 +54,19 @@ public static TagKey<Item> createItemTag(String path, boolean vanilla) {
return createTag(Registry.ITEM, path, vanilla);
}

public static TagKey<Item> createPlatformItemTag(String forgePath, String fabricPath) {
return createPlatformItemTag(forgePath, fabricPath, false);
}


public static TagKey<Item> createPlatformItemTag(String forgePath, String fabricPath, boolean modTag) {
return createPlatformTag(Registry.ITEM, forgePath, fabricPath, modTag);
}

public static TagKey<Item> createModItemTag(String path) {
return createModTag(Registry.ITEM, path);
}

public static TagKey<Fluid> createFluidTag(String path) {
return createTag(Registry.FLUID, path, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;

import java.util.regex.Pattern;

/**
* @author KilaBash
* @date 2023/2/23
Expand All @@ -25,21 +27,21 @@ public enum GTToolType {
// SHOVEL("shovel", 1.5F, -3.0F),
// AXE("axe", 6.0F, -3.2F),
// HOE("hoe", 0, -3.0F),
SAW("saw", 1, 1, GTSoundEntries.SAW_TOOL),
HARD_HAMMER("hammer", 1, 1, GTSoundEntries.FORGE_HAMMER),
SOFT_MALLET("mallet", 1, 1, GTSoundEntries.SOFT_MALLET_TOOL),
WRENCH("wrench", 1, 1, GTSoundEntries.WRENCH_TOOL),
FILE("file", 1, 1, GTSoundEntries.FILE_TOOL),
CROWBAR("crowbar", 1, 1, new ExistingSoundEntry(SoundEvents.ITEM_BREAK, SoundSource.BLOCKS)),
SCREWDRIVER("screwdriver", 1, 1, GTSoundEntries.SCREWDRIVER_TOOL),
MORTAR("mortar", 1, 1, GTSoundEntries.MORTAR_TOOL),
WIRE_CUTTER("wire_cutter", 1, 1, GTSoundEntries.WIRECUTTER_TOOL),
SCYTHE("scythe", 1, 1),
SAW("saw", "saws", 1, 1, GTSoundEntries.SAW_TOOL),
HARD_HAMMER("hammer", "hammers", 1, 1, GTSoundEntries.FORGE_HAMMER),
SOFT_MALLET("mallet", "mallets", 1, 1, GTSoundEntries.SOFT_MALLET_TOOL),
WRENCH("wrench", "wrenches", 1, 1, GTSoundEntries.WRENCH_TOOL),
FILE("file", "files", 1, 1, GTSoundEntries.FILE_TOOL),
CROWBAR("crowbar", "crowbars", 1, 1, new ExistingSoundEntry(SoundEvents.ITEM_BREAK, SoundSource.BLOCKS)),
SCREWDRIVER("screwdriver", "screwdrivers", 1, 1, GTSoundEntries.SCREWDRIVER_TOOL),
MORTAR("mortar", "mortars", 1, 1, GTSoundEntries.MORTAR_TOOL),
WIRE_CUTTER("wire_cutter", "wire_cutters", 1, 1, GTSoundEntries.WIRECUTTER_TOOL),
SCYTHE("scythe", "scythes", 1, 1),
// SHEARS("shears", 1, 1, GTCEu.id("item/tools/handle_hammer"), GTCEu.id("item/tools/hammer")),
KNIFE("knife", 1, 1),
BUTCHERY_KNIFE("butchery_knife", 1, 1),
KNIFE("knife", "knives", 1, 1),
BUTCHERY_KNIFE("butchery_knife", "butchery_knives", 1, 1),
// GRAFTER("grafter", 1, 1, GTCEu.id("item/tools/handle_hammer"), GTCEu.id("item/tools/hammer")),
PLUNGER("plunger", 1, 1, GTSoundEntries.PLUNGER_TOOL);
PLUNGER("plunger", "plungers", 1, 1, GTSoundEntries.PLUNGER_TOOL);

public final String name;
public final TagKey<Item> itemTag;
Expand All @@ -60,20 +62,20 @@ public enum GTToolType {
this.soundEntry = soundEntry;
}

GTToolType(String name, TagKey<Block> harvestTag, float attackDamageModifier, float attackSpeedModifier, ResourceLocation modelLocation, SoundEntry soundEntry) {
this(name, harvestTag, TagUtil.createItemTag("tool/" + name), attackDamageModifier, attackSpeedModifier, modelLocation, soundEntry);
GTToolType(String name, String plural, TagKey<Block> harvestTag, float attackDamageModifier, float attackSpeedModifier, ResourceLocation modelLocation, SoundEntry soundEntry) {
this(name, harvestTag, TagUtil.createPlatformItemTag("tools/" + name, plural), attackDamageModifier, attackSpeedModifier, modelLocation, soundEntry);
}

GTToolType(String name, float attackDamageModifier, float attackSpeedModifier, ResourceLocation modelLocation, SoundEntry soundEntry) {
this(name, TagUtil.createBlockTag("mineable/" + name), attackDamageModifier, attackSpeedModifier, modelLocation, soundEntry);
GTToolType(String name, String plural, float attackDamageModifier, float attackSpeedModifier, ResourceLocation modelLocation, SoundEntry soundEntry) {
this(name, plural, TagUtil.createBlockTag("mineable/" + name), attackDamageModifier, attackSpeedModifier, modelLocation, soundEntry);
}

GTToolType(String name, float attackDamageModifier, float attackSpeedModifier, SoundEntry soundEntry) {
this(name, attackDamageModifier, attackSpeedModifier, GTCEu.id(String.format("item/tools/%s", name)), soundEntry);
GTToolType(String name, String plural, float attackDamageModifier, float attackSpeedModifier, SoundEntry soundEntry) {
this(name, plural, attackDamageModifier, attackSpeedModifier, GTCEu.id(String.format("item/tools/%s", name)), soundEntry);
}

GTToolType(String name, float attackDamageModifier, float attackSpeedModifier) {
this(name, attackDamageModifier, attackSpeedModifier, GTCEu.id(String.format("item/tools/%s", name)), null);
GTToolType(String name, String plural, float attackDamageModifier, float attackSpeedModifier) {
this(name, plural, attackDamageModifier, attackSpeedModifier, GTCEu.id(String.format("item/tools/%s", name)), null);
}

public boolean is(ItemStack itemStack) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gregtechceu.gtceu.api.pattern;

import com.gregtechceu.gtceu.api.block.ActiveBlock;
import com.gregtechceu.gtceu.api.block.ICoilType;
import com.gregtechceu.gtceu.api.block.IMachineBlock;
import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability;
import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability;
Expand Down Expand Up @@ -117,7 +118,7 @@ public static TraceabilityPredicate autoAbilities(GTRecipeType recipeType,
public static TraceabilityPredicate heatingCoils() {
return new TraceabilityPredicate(blockWorldState -> {
var blockState = blockWorldState.getBlockState();
for (Map.Entry<CoilBlock.CoilType, BlockEntry<CoilBlock>> entry : GTBlocks.ALL_COILS.entrySet()) {
for (Map.Entry<ICoilType, Supplier<CoilBlock>> entry : GTBlocks.ALL_COILS.entrySet()) {
if (blockState.is(entry.getValue().get())) {
var stats = entry.getKey();
Object currentCoil = blockWorldState.getMatchContext().getOrPut("CoilType", stats);
Expand All @@ -129,10 +130,10 @@ public static TraceabilityPredicate heatingCoils() {
}
}
return false;
}, () -> Arrays.stream(CoilBlock.CoilType.values())
}, () -> GTBlocks.ALL_COILS.entrySet().stream()
// sort to make autogenerated jei previews not pick random coils each game load
.sorted(Comparator.comparingInt(CoilBlock.CoilType::getTier))
.map(coil -> BlockInfo.fromBlockState(GTBlocks.ALL_COILS.get(coil).getDefaultState()))
.sorted(Comparator.comparingInt(value -> value.getKey().getTier()))
.map(coil -> BlockInfo.fromBlockState(coil.getValue().get().defaultBlockState()))
.toArray(BlockInfo[]::new))
.addTooltips(Component.translatable("gtceu.multiblock.pattern.error.coils"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Map<RecipeCapability<?>, List<Content>> capabilitiesFromJson(JsonObject j

@Override
public @NotNull GTRecipe fromJson(@NotNull ResourceLocation id, @NotNull JsonObject json) {
String recipeType = GsonHelper.getAsString(json, "recipe_type");
String recipeType = GsonHelper.getAsString(json, "type");
int duration = json.has("duration") ? GsonHelper.getAsInt(json, "duration") : 100;
Component component = json.has("text") ? Component.translatable(GsonHelper.getAsString(json, "text")) : null;
CompoundTag data = new CompoundTag();
Expand Down
Loading

0 comments on commit f19ae72

Please sign in to comment.