Skip to content

Commit

Permalink
Customizable Lootbag icons (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickMG authored Dec 18, 2024
1 parent 710dc41 commit 1cfaad2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 25 deletions.
22 changes: 17 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ channel = stable
mappingsVersion = 12

# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/

# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
Expand Down Expand Up @@ -61,6 +61,9 @@ gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =

# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =

# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
Expand All @@ -82,6 +85,11 @@ accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false

# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false

Expand Down Expand Up @@ -114,16 +122,22 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true

# Maven repository to publish the mod to.
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/

# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
Expand Down Expand Up @@ -187,5 +201,3 @@ disableCheckstyle = true
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true

# Non-GTNH properties
gradleTokenGroupName =
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.30'
}


17 changes: 10 additions & 7 deletions src/main/java/eu/usrv/enhancedlootbags/core/items/ItemLootBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
package eu.usrv.enhancedlootbags.core.items;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
Expand Down Expand Up @@ -39,6 +41,7 @@
public class ItemLootBag extends Item {

private IIcon _mIcoDefault;
private final Map<Integer, IIcon> _mGroupIcons = new HashMap<>();
private final LootGroupsHandler _mLGHandler;
private LogHelper _mLogger = EnhancedLootBags.Logger;

Expand Down Expand Up @@ -66,16 +69,16 @@ public int getItemEnchantability() {
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister pIconRegister) {
_mIcoDefault = pIconRegister.registerIcon(String.format("%s:lootbag_generic", EnhancedLootBags.MODID));
// for (LootGroup tGrp : _mLGHandler.getLootGroups().getLootTable())
// tGrp.setGroupIcon(pIconRegister.registerIcon(String.format("%s:lootbags/lootbag_%d",
// Refstrings.MODID, tGrp.mGroupID)));
_mGroupIcons.clear();
for (LootGroup tGrp : _mLGHandler.getLootGroups().getLootTable()) {
tGrp.getGroupIconResource()
.ifPresent(icon -> _mGroupIcons.put(tGrp.getGroupID(), pIconRegister.registerIcon(icon)));
}
}

@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1) {
// LootGroup tGrp = getGroupByID(par1);
// return tGrp == null ? _mIcoDefault : tGrp.getGroupIcon();
return _mIcoDefault;
public IIcon getIconFromDamage(int meta) {
return _mGroupIcons.getOrDefault(meta, _mIcoDefault);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
Expand All @@ -24,7 +25,6 @@

import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

import eu.usrv.enhancedlootbags.EnhancedLootBags;
import eu.usrv.enhancedlootbags.core.LootGroupsHandler;
Expand Down Expand Up @@ -88,8 +88,12 @@ public int getMaxWeight() {
return mMaxWeight;
}

@XmlTransient
private IIcon mGroupIcon;
@XmlAttribute(name = "LootbagIcon")
private String mGroupIconResource;

public Optional<String> getGroupIconResource() {
return Optional.ofNullable(mGroupIconResource);
}

@XmlElement(name = "Loot")
private List<LootGroups.LootGroup.Drop> mDrops;
Expand Down Expand Up @@ -120,14 +124,6 @@ public EnumRarity getGroupRarity() {
else return EnumRarity.common;
}

public IIcon getGroupIcon() {
return mGroupIcon;
}

public void setGroupIcon(IIcon pIcon) {
mGroupIcon = pIcon;
}

public ItemStack createLootBagItemStack() {
return new ItemStack(LootGroupsHandler.getLootBagItem(), 1, getGroupID());
}
Expand Down

0 comments on commit 1cfaad2

Please sign in to comment.