Skip to content

Commit

Permalink
Merge pull request #11 from pluto7073/dev-1.20.1
Browse files Browse the repository at this point in the history
3.0 Release
  • Loading branch information
pluto7073 authored Oct 7, 2024
2 parents c97c7a5 + ce476be commit 5138f6b
Show file tree
Hide file tree
Showing 104 changed files with 2,732 additions and 1,964 deletions.
48 changes: 25 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,49 @@ base {
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url "https://pluto-mod-maven.web.app/maven" }
maven { url = "https://maven.parchmentmc.org" }
maven { url = "https://maven.quiltmc.org/repository/release" }
}

loom {

accessWidenerPath = file("src/main/resources/plutoscoffee.accesswidener")

runs {
configureEach {
vmArg "-XX:+AllowEnhancedClassRedefinition"
vmArg "-XX:+IgnoreUnrecognizedVMOptions"
}

server {
runDir "run/server"
}
}

}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings(loom.layered {
it.mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2"
it.parchment "org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip"
it.officialMojangMappings { nameSyntheticMembers = false }
})
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
modApi "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}"
modApi "com.terraformersmc:modmenu:${project.modmenu_version}"
modApi "ml.pluto7073:pdapi:${project.pdapi_version}"

modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"

modImplementation "ml.pluto7073:pdapi:${project.minecraft_version}+${project.pdapi_version}"

modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"
}

processResources {
Expand All @@ -58,9 +69,6 @@ tasks.withType(JavaCompile).configureEach {
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -73,19 +81,13 @@ jar {
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
15 changes: 9 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# Minecraft Stuff
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.7
loader_version=0.15.11
quilt_mappings=23
parchment_version = 2023.09.03

# Mod Properties
mod_version = 1.20.1+3.0-beta.1
# Mod Thingies
mod_version = 1.20.1+3.0
maven_group = ml.pluto7073
archives_base_name = PlutosCoffeeMod-Fabric

# Dependencies
# Things I might be dependent on
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.92.0+1.20.1
cloth_version=11.1.118
modmenu_version=7.1.0
pdapi_version=0.1.3
pdapi_version=0.2.20
rei_version=12.0.684
35 changes: 26 additions & 9 deletions src/main/java/ml/pluto7073/plutoscoffee/Client.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package ml.pluto7073.plutoscoffee;

import ml.pluto7073.plutoscoffee.config.CoffeeConfig;
import ml.pluto7073.plutoscoffee.gui.CoffeeBrewerScreen;
import ml.pluto7073.plutoscoffee.gui.CoffeeGrindrScreen;
import ml.pluto7073.plutoscoffee.gui.EspressoMachineScreen;
import ml.pluto7073.plutoscoffee.network.ModPacketsS2C;
import ml.pluto7073.plutoscoffee.registry.ModBlocks;
import ml.pluto7073.plutoscoffee.registry.ModItems;
import ml.pluto7073.plutoscoffee.registry.ModScreens;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import java.io.File;

Expand All @@ -22,14 +30,23 @@ public class Client implements ClientModInitializer {

public void onInitializeClient() {
FabricLoader.getInstance().getModContainer(PlutosCoffee.MOD_ID).ifPresent(container ->
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(PlutosCoffee.MOD_ID, "dark_gui"), container, Text.translatable("pack.plutoscoffee.dark_gui"),ResourcePackActivationType.NORMAL));
ResourceManagerHelper.registerBuiltinResourcePack(new ResourceLocation(PlutosCoffee.MOD_ID, "dark_gui"), container, Component.translatable("pack.plutoscoffee.dark_gui"),ResourcePackActivationType.NORMAL));

BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_CROP, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_BREWER, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_GRINDR, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.ESPRESSO_MACHINE, RenderLayer.getCutout());
ModPacketsS2C.register();

CONFIG = new CoffeeConfig(new File("config/plutoscoffee.properties"));
MenuScreens.register(ModScreens.BREWER_MENU_TYPE, CoffeeBrewerScreen::new);
MenuScreens.register(ModScreens.GRINDR_SCREEN_HANDLER_TYPE, CoffeeGrindrScreen::new);
MenuScreens.register(ModScreens.ESPRESSO_SCREEN_HANDLER_TYPE, EspressoMachineScreen::new);

BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_CROP, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_BREWER, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.COFFEE_GRINDR, RenderType.cutout());
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.ESPRESSO_MACHINE, RenderType.cutout());

ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : CoffeeUtil.getCoffeeColour(stack), ModItems.BREWED_COFFEE);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : CoffeeUtil.getLatteColour(stack), ModItems.LATTE);

CONFIG = new CoffeeConfig();
}

}
71 changes: 35 additions & 36 deletions src/main/java/ml/pluto7073/plutoscoffee/CoffeeUtil.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package ml.pluto7073.plutoscoffee;

import com.mojang.datafixers.util.Pair;
import ml.pluto7073.pdapi.DrinkUtil;
import ml.pluto7073.pdapi.util.DrinkUtil;
import ml.pluto7073.pdapi.addition.DrinkAddition;
import ml.pluto7073.pdapi.addition.DrinkAdditions;
import ml.pluto7073.pdapi.addition.DrinkAdditionManager;
import ml.pluto7073.pdapi.item.AbstractCustomizableDrinkItem;
import ml.pluto7073.plutoscoffee.coffee.CoffeeType;
import ml.pluto7073.plutoscoffee.coffee.CoffeeTypes;
import ml.pluto7073.plutoscoffee.items.BrewedCoffee;
import ml.pluto7073.plutoscoffee.mixins.StructurePoolAccessor;
import ml.pluto7073.plutoscoffee.registry.ModItems;
import ml.pluto7073.plutoscoffee.registry.ModMisc;
import ml.pluto7073.plutoscoffee.tags.ModItemTags;
import net.fabricmc.fabric.api.tag.convention.v1.TagUtil;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.Registry;
import net.minecraft.structure.pool.SinglePoolElement;
import net.minecraft.structure.pool.StructurePool;
import net.minecraft.structure.pool.StructurePoolElement;
import net.minecraft.util.Identifier;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.levelgen.structure.pools.SinglePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand All @@ -33,8 +30,6 @@

public final class CoffeeUtil {

private static final double CAFFEINE_HALF_LIFE_TICKS = 2500.0;

private CoffeeUtil(){}

public static <T> boolean collectionContainsOnlyAll(Collection<T> c1, Collection<T> c2) {
Expand All @@ -51,28 +46,28 @@ public static <T> boolean collectionContainsOnlyAll(Collection<T> c1, Collection

public static CoffeeType getCoffeeType(ItemStack stack) {
DrinkUtil.convertStackFromPlutosCoffee(stack);
return getCoffeeType(stack.getSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY));
return getCoffeeType(stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY));
}

public static ItemStack setCoffeeType(ItemStack stack, CoffeeType type) {
DrinkUtil.convertStackFromPlutosCoffee(stack);
Identifier id = CoffeeTypes.getIdentifier(type);
ResourceLocation id = CoffeeTypes.getIdentifier(type);
if (type == CoffeeTypes.EMPTY) {
stack.removeSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY);
stack.removeTagKey(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY);
} else {
stack.getOrCreateSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).putString("CoffeeType", id.toString());
stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).putString("CoffeeType", id.toString());
}
return stack;
}

public static ItemStack getBaseCoffee(CoffeeType type) {
ItemStack stack = new ItemStack(ModItems.BREWED_COFFEE);
if (type == CoffeeTypes.EMPTY) return stack;
stack.getOrCreateSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).putString("CoffeeType", CoffeeTypes.getIdentifier(type).toString());
stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).putString("CoffeeType", CoffeeTypes.getIdentifier(type).toString());
return stack;
}

public static CoffeeType getCoffeeType(@Nullable NbtCompound nbt) {
public static CoffeeType getCoffeeType(@Nullable CompoundTag nbt) {
return nbt == null ? CoffeeTypes.EMPTY : CoffeeType.byId(nbt.getString("CoffeeType"));
}

Expand All @@ -95,7 +90,7 @@ public static int getCoffeeColour(ItemStack stack) {

public static int getCoffeeColour(DrinkAddition[] addIns) {
int colour = BrewedCoffee.DEFAULT_COLOUR;
if (Arrays.stream(addIns).map(DrinkAdditions::getId).anyMatch(identifier -> identifier.toString().equals("pdapi:milk"))) {
if (Arrays.stream(addIns).map(DrinkAdditionManager::getId).anyMatch(identifier -> identifier.toString().equals("pdapi:milk"))) {
colour = BrewedCoffee.COLOUR_WITH_MILK;
}
float r = (colour >> 16 & 255) / 255.0F;
Expand All @@ -105,7 +100,7 @@ public static int getCoffeeColour(DrinkAddition[] addIns) {
int allowedMilk = 3;
for (DrinkAddition addition : addIns) {
if (!addition.changesColor()) continue;
if (DrinkAdditions.getId(addition).toString().equals("pdapi:milk") && allowedMilk > 0) {
if (DrinkAdditionManager.getId(addition).toString().equals("pdapi:milk") && allowedMilk > 0) {
allowedMilk--;
continue;
}
Expand All @@ -122,14 +117,14 @@ public static int getCoffeeColour(DrinkAddition[] addIns) {
}

public static ItemStack getWithAdditions(ItemStack stack, String... additions) {
NbtList adds = new NbtList();
if (stack.getOrCreateSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).contains("Additions")) {
adds = stack.getOrCreateSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).getList("Additions", NbtElement.STRING_TYPE);
ListTag adds = new ListTag();
if (stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).contains("Additions")) {
adds = stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).getList("Additions", ListTag.TAG_STRING);
}
for (String s : additions) {
adds.add(DrinkUtil.stringAsNbt(s));
}
stack.getOrCreateSubNbt(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).put("Additions", adds);
stack.getOrCreateTagElement(AbstractCustomizableDrinkItem.DRINK_DATA_NBT_KEY).put("Additions", adds);
return stack;
}

Expand All @@ -144,7 +139,9 @@ public static int getLatteColour(ItemStack stack) {

public static int getLatteColour(DrinkAddition[] addIns) {
int color = 0xFFFFFF;
if (Arrays.stream(addIns).map(DrinkAdditions::getId).anyMatch(id -> id.toString().equals("plutoscoffee:espresso_shot"))) {
if (Arrays.stream(addIns).map(DrinkAdditionManager::getId).anyMatch(id -> id.toString().equals("plutoscoffee:espresso_shot")
|| id.toString().equals("plutoscoffee:blonde_espresso_shot")
|| id.toString().equals("plutoscoffee:decaf_espresso_shot"))) {
color = BrewedCoffee.COLOUR_WITH_MILK;
}
float r = (color >> 16 & 255) / 255.0F;
Expand All @@ -154,7 +151,9 @@ public static int getLatteColour(DrinkAddition[] addIns) {
int allowedShots = 2;
for (DrinkAddition addition : addIns) {
if (!addition.changesColor()) continue;
if (DrinkAdditions.getId(addition).toString().equals("plutoscoffee:espresso_shot") && allowedShots > 0) {
if ((DrinkAdditionManager.getId(addition).toString().equals("plutoscoffee:espresso_shot") ||
DrinkAdditionManager.getId(addition).toString().equals("plutoscoffee:blonde_espresso_shot") ||
DrinkAdditionManager.getId(addition).toString().equals("plutoscoffee:decaf_espresso_shot")) && allowedShots > 0) {
allowedShots--;
continue;
}
Expand All @@ -179,19 +178,19 @@ public static int calculateHealthBarHeightPixels(int health, int maxHeartsPerRow
/**
* Borrowed from the FriendsAndFoes mod by Faboslav
*/
public static void addElementToStructurePool(Registry<StructurePool> templateRegistry, Identifier poolLocation, String name, int weight) {
StructurePool pool = templateRegistry.get(poolLocation);
public static void addElementToStructurePool(Registry<StructureTemplatePool> templateRegistry, ResourceLocation poolLocation, String name, int weight) {
StructureTemplatePool pool = templateRegistry.get(poolLocation);
if (pool == null) return;

SinglePoolElement piece = SinglePoolElement.ofLegacySingle(PlutosCoffee.asId(name).toString()).apply(StructurePool.Projection.RIGID);
SinglePoolElement piece = SinglePoolElement.single(PlutosCoffee.asId(name).toString()).apply(StructureTemplatePool.Projection.RIGID);

for (int i = 0; i < weight; i++) {
((StructurePoolAccessor) pool).getElements().add(piece);
((StructurePoolAccessor) pool).getTemplates().add(piece);
}

List<Pair<StructurePoolElement, Integer>> pieceCounts = new ArrayList<>(((StructurePoolAccessor) pool).getElementCounts());
List<Pair<StructurePoolElement, Integer>> pieceCounts = new ArrayList<>(((StructurePoolAccessor) pool).getRawTemplates());
pieceCounts.add(new Pair<>(piece, weight));
((StructurePoolAccessor) pool).setElementCounts(pieceCounts);
((StructurePoolAccessor) pool).setRawTemplates(pieceCounts);
}

}
Loading

0 comments on commit 5138f6b

Please sign in to comment.