Skip to content

Commit

Permalink
Implement new chests (from @unicornbloods) (#16)
Browse files Browse the repository at this point in the history
* Start adding netherite chest

* Netherite chest GUI.

* Netherite chest textures.

* Netherite English lang.

* Netherite chest upgrade.

* Netherite chest recipes.

* Update diamondObsidianUpgrade.png to not look similar to not look similar to netherite icon

* Remove copyright from netherite chest tile entity class

* Disable loading netherite chests on GTNH

* Properly not load chests on GTNH.
Add Dark Steel for GTNH Netherite equivalent.
Add config option to use steel chest instead of silver with the default being true.

* Make netherite chest blast resistant

* Fix metadata IDs

* Make Netherite an upgrade to obsidian instead

* Update bs + enable modern java syntax

* Fix compat with gtnh

* fix dark steel upgrade icon

* make dark steel chest configurable (default to gtnh existence)

* catch missing mappings for dark steel & ironchest

* fix mapping of obsidianNetheriteUpgrade

* spotlessApply

* fix translation for netherite upgrade & german translation

* git push

---------

Co-authored-by: unicornbloods <[email protected]>
Co-authored-by: Dakotah <[email protected]>
Co-authored-by: Pilzinsel64 <[email protected]>
  • Loading branch information
4 people authored Mar 3, 2024
1 parent ea3f609 commit 40aca9a
Show file tree
Hide file tree
Showing 47 changed files with 283 additions and 52 deletions.
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ 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.
developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
Expand All @@ -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 Down Expand Up @@ -123,7 +126,7 @@ includeWellKnownRepositories = true
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 +190,3 @@ curseForgeRelations =
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true

# Non-GTNH properties
gradleTokenGroupName =
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.15'
}


32 changes: 30 additions & 2 deletions src/main/java/cpw/mods/ironchest/BlockIronChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
******************************************************************************/
package cpw.mods.ironchest;

import static cpw.mods.ironchest.IronChest.ENABLE_STEEL_CHESTS;
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.UP;

Expand Down Expand Up @@ -213,9 +214,36 @@ public void dropContent(int newSize, IInventory chest, World world, int xCoord,
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (IronChestType type : IronChestType.values()) {
if (type.isValidForCreativeMode()) {
par3List.add(new ItemStack(this, 1, type.ordinal()));

if (!type.isValidForCreativeMode()) {
continue;
}
switch (type) {
case STEEL -> {
if (ENABLE_STEEL_CHESTS) {
par3List.add(new ItemStack(this, 1, type.ordinal()));
}
}
case SILVER -> {
if (ENABLE_STEEL_CHESTS) {
continue;
}
par3List.add(new ItemStack(this, 1, type.ordinal()));
}
case DARKSTEEL -> {
if (IronChest.ENABLE_DARK_STEEL_CHESTS) {
par3List.add(new ItemStack(this, 1, type.ordinal()));
}
}
case NETHERITE -> {
if (IronChest.ENABLE_DARK_STEEL_CHESTS) {
continue;
}
par3List.add(new ItemStack(this, 1, type.ordinal()));
}
default -> par3List.add(new ItemStack(this, 1, type.ordinal()));
}

}
}

Expand Down
48 changes: 36 additions & 12 deletions src/main/java/cpw/mods/ironchest/ChestChangerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,33 @@
******************************************************************************/
package cpw.mods.ironchest;

import static cpw.mods.ironchest.IronChestType.COPPER;
import static cpw.mods.ironchest.IronChestType.CRYSTAL;
import static cpw.mods.ironchest.IronChestType.DIAMOND;
import static cpw.mods.ironchest.IronChestType.GOLD;
import static cpw.mods.ironchest.IronChestType.IRON;
import static cpw.mods.ironchest.IronChestType.OBSIDIAN;
import static cpw.mods.ironchest.IronChestType.STEEL;
import static cpw.mods.ironchest.IronChestType.WOOD;
import static cpw.mods.ironchest.IronChest.ENABLE_STEEL_CHESTS;
import static cpw.mods.ironchest.IronChestType.*;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;

public enum ChestChangerType {

IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),
GOLDDIAMOND(GOLD, DIAMOND, "goldDiamondUpgrade", "Gold to Diamond Chest Upgrade", "GGG", "msm", "GGG"),
COPPERSILVER(COPPER, SILVER, "copperSilverUpgrade", "Copper to Silver Chest Upgrade", "mmm", "msm", "mmm"),
SILVERGOLD(SILVER, GOLD, "silverGoldUpgrade", "Silver to Gold Chest Upgrade", "mGm", "GsG", "mGm"),
COPPERSTEEL(COPPER, STEEL, "copperSteelUpgrade", "Copper to Steel Chest Upgrade", "mmm", "msm", "mmm"),
STEELGOLD(STEEL, GOLD, "steelGoldUpgrade", "Steel to Gold Chest Upgrade", "mGm", "GsG", "mGm"),
COPPERIRON(COPPER, IRON, "copperIronUpgrade", "Copper to Iron Chest Upgrade", "mGm", "GsG", "mGm"),
DIAMONDCRYSTAL(DIAMOND, CRYSTAL, "diamondCrystalUpgrade", "Diamond to Crystal Chest Upgrade", "GGG", "GOG", "GGG"),
WOODIRON(WOOD, IRON, "woodIronUpgrade", "Normal chest to Iron Chest Upgrade", "mmm", "msm", "mmm"),
WOODCOPPER(WOOD, COPPER, "woodCopperUpgrade", "Normal chest to Copper Chest Upgrade", "mmm", "msm", "mmm"),
DIAMONDOBSIDIAN(DIAMOND, OBSIDIAN, "diamondObsidianUpgrade", "Diamond to Obsidian Chest Upgrade", "mmm", "mGm",
"mmm");
"mmm"),
OBSIDIANNETHERITE(OBSIDIAN, NETHERITE, "obsidianNetheriteUpgrade", "Obsidian to Netherite Chest Upgrade", "OOO",
"msm", "OOO"),
DIAMONDDARKSTEEL(DIAMOND, DARKSTEEL, "diamondDarkSteelUpgrade", "Diamond to Dark Steel Chest Upgrade", "OOO", "msm",
"OOO");

private final IronChestType source;
private final IronChestType target;
Expand Down Expand Up @@ -82,12 +81,37 @@ public void addRecipes() {

public static void buildItems(Configuration cfg) {
for (ChestChangerType type : values()) {
type.buildItem(cfg);
switch (type) {
case STEELGOLD, COPPERSTEEL -> {
if (ENABLE_STEEL_CHESTS) {
type.buildItem(cfg);
}
}
case SILVERGOLD, COPPERSILVER -> {
if (ENABLE_STEEL_CHESTS) {
continue;
}
type.buildItem(cfg);
}
case DIAMONDDARKSTEEL -> {
if (IronChest.ENABLE_DARK_STEEL_CHESTS) {
type.buildItem(cfg);
}
}
case OBSIDIANNETHERITE -> {
if (IronChest.ENABLE_DARK_STEEL_CHESTS) {
continue;
}
type.buildItem(cfg);
}
default -> type.buildItem(cfg);
}

}
}

public static void generateRecipes() {
if (Loader.isModLoaded("dreamcraft")) {
if (IronChest.isGTNHLoaded) {
return;
}
for (ChestChangerType item : values()) {
Expand Down
85 changes: 63 additions & 22 deletions src/main/java/cpw/mods/ironchest/IronChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.logging.log4j.Level;

import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
Expand Down Expand Up @@ -43,17 +44,33 @@ public class IronChest {
public static final String VERSION = "GRADLETOKEN_VERSION";
public static boolean TRANSPARENT_RENDER_INSIDE = true;
public static double TRANSPARENT_RENDER_DISTANCE = 128D;
public static boolean ENABLE_STEEL_CHESTS = true;
public static boolean ENABLE_DARK_STEEL_CHESTS = false;
public static boolean isGTNHLoaded;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
isGTNHLoaded = Loader.isModLoaded("dreamcraft");
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
try {
cfg.load();
ChestChangerType.buildItems(cfg);
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
OCELOTS_SITONCHESTS = cfg.get(Configuration.CATEGORY_GENERAL, "ocelotsSitOnChests", true).getBoolean(true);
TRANSPARENT_RENDER_INSIDE = cfg.get("general", "transparentRenderInside", true).getBoolean(true);
TRANSPARENT_RENDER_DISTANCE = cfg.get("general", "transparentRenderDistance", 128D).getDouble(128D);
TRANSPARENT_RENDER_INSIDE = cfg.get(Configuration.CATEGORY_GENERAL, "transparentRenderInside", true)
.getBoolean(true);
TRANSPARENT_RENDER_DISTANCE = cfg.get(Configuration.CATEGORY_GENERAL, "transparentRenderDistance", 128D)
.getDouble(128D);
ENABLE_STEEL_CHESTS = cfg.get(
Configuration.CATEGORY_GENERAL,
"enableSteelChests",
true,
"Enables the steel chest instead of the silver chest.").getBoolean(true);
ENABLE_DARK_STEEL_CHESTS = cfg.get(
Configuration.CATEGORY_GENERAL,
"enableDarkSteelChests",
isGTNHLoaded,
"Enables the dark steel chest instead the netherit chest.").getBoolean(isGTNHLoaded);
ChestChangerType.buildItems(cfg);
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "IronChest has a problem loading its configuration");
} finally {
Expand All @@ -67,13 +84,18 @@ public void preInit(FMLPreInitializationEvent event) {
@EventHandler
public void load(FMLInitializationEvent evt) {
for (IronChestType typ : IronChestType.values()) {
if (typ.name().equals("STEEL")) {
if (typ.name().equals("STEEL") && ENABLE_STEEL_CHESTS) {
GameRegistry.registerTileEntityWithAlternatives(
typ.clazz,
"IronChest." + typ.name(),
typ.name(),
"SILVER",
"IronChest.SILVER");
} else if (typ.name().equals("SILVER")) {
if (ENABLE_STEEL_CHESTS) {
continue;
}
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name());
} else {
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name());
}
Expand All @@ -98,25 +120,44 @@ public void modsLoaded(FMLPostInitializationEvent evt) {}
@Mod.EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()) {
if (mapping.type == GameRegistry.Type.BLOCK) {
switch (mapping.name) {
case "IronChest:copperSilverUpgrade":
mapping.remap(GameRegistry.findBlock("IronChest", "copperSteelUpgrade"));
break;
case "IronChest:silverGoldUpgrade":
mapping.remap(GameRegistry.findBlock("IronChest", "steelGoldUpgrade"));
break;
default:
if (ENABLE_STEEL_CHESTS) {
if (mapping.type == GameRegistry.Type.BLOCK) {
switch (mapping.name) {
case "IronChest:copperSilverUpgrade":
mapping.remap(GameRegistry.findBlock("IronChest", "copperSteelUpgrade"));
break;
case "IronChest:silverGoldUpgrade":
mapping.remap(GameRegistry.findBlock("IronChest", "steelGoldUpgrade"));
break;
default:
}
} else if (mapping.type == GameRegistry.Type.ITEM) {
switch (mapping.name) {
case "IronChest:copperSilverUpgrade":
mapping.remap(GameRegistry.findItem("IronChest", "copperSteelUpgrade"));
break;
case "IronChest:silverGoldUpgrade":
mapping.remap(GameRegistry.findItem("IronChest", "steelGoldUpgrade"));
break;
default:
}
}
} else if (mapping.type == GameRegistry.Type.ITEM) {
switch (mapping.name) {
case "IronChest:copperSilverUpgrade":
mapping.remap(GameRegistry.findItem("IronChest", "copperSteelUpgrade"));
break;
case "IronChest:silverGoldUpgrade":
mapping.remap(GameRegistry.findItem("IronChest", "steelGoldUpgrade"));
break;
default:
}
if (ENABLE_DARK_STEEL_CHESTS) {
if (mapping.name.equals("IronChest:obsidianNetheriteUpgrade")) {
if (mapping.type == GameRegistry.Type.BLOCK) {
mapping.remap(GameRegistry.findBlock("IronChest", "diamondDarkSteelUpgrade"));
} else {
mapping.remap(GameRegistry.findItem("IronChest", "diamondDarkSteelUpgrade"));
}
}
} else {
if (mapping.name.equals("IronChest:diamondDarkSteelUpgrade")) {
if (mapping.type == GameRegistry.Type.BLOCK) {
mapping.remap(GameRegistry.findBlock("IronChest", "obsidianNetheriteUpgrade"));
} else {
mapping.remap(GameRegistry.findItem("IronChest", "obsidianNetheriteUpgrade"));
}
}
}
}
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/cpw/mods/ironchest/IronChestType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.ShapedOreRecipe;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand All @@ -44,6 +43,12 @@ public enum IronChestType {
TileEntityObsidianChest.class, "mmmm2mmmm"),
DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png", 7, Arrays.asList("dirt"), TileEntityDirtChest.class,
Item.getItemFromBlock(Blocks.dirt), "mmmmCmmmm"),
NETHERITE(135, 15, true, "Netherite Chest", "netheritechest.png", 2, Arrays.asList("ingotNetherite"),
TileEntityNetheriteChest.class, "OOOmPmOOO", "OOOO6Ommm"),
DARKSTEEL(135, 15, true, "Dark Steel Chest", "darksteelchest.png", 2, Arrays.asList("ingotDarkSteel"),
TileEntityDarkSteelChest.class, "OOOmPmOOO", "OOOO4Ommm"),
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"),
TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null);

final int size;
Expand Down Expand Up @@ -103,6 +108,10 @@ public static TileEntityIronChest makeEntity(int metadata) {
public static void registerBlocksAndRecipes(BlockIronChest blockResult) {
Object previous = "chestWood";
for (IronChestType typ : values()) {
if ((typ == NETHERITE) && IronChest.ENABLE_DARK_STEEL_CHESTS) {
continue;
}

generateRecipesForType(blockResult, previous, typ);
ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal());
if (typ.isValidForCreativeMode()) {
Expand All @@ -115,7 +124,7 @@ public static void registerBlocksAndRecipes(BlockIronChest blockResult) {
}

public static void generateRecipesForType(BlockIronChest blockResult, Object previousTier, IronChestType type) {
if (Loader.isModLoaded("dreamcraft")) {
if (IronChest.ENABLE_DARK_STEEL_CHESTS) {
return;
}
for (String recipe : type.recipes) {
Expand All @@ -127,12 +136,15 @@ public static void generateRecipesForType(BlockIronChest blockResult, Object pre
// spotless:off
addRecipe(new ItemStack(blockResult, 1, type.ordinal()), recipeSplit,
'm', mainMaterial, 'P', previousTier, /* previous tier of chest */
'G', "blockGlass", 'C', "chestWood",
'G', "blockGlass", 'C', "chestWood", 'O', Blocks.obsidian,
'0', new ItemStack(blockResult, 1, 0), /* Iron Chest */
'1', new ItemStack(blockResult, 1, 1), /* Gold Chest */
'2', new ItemStack(blockResult, 1, 2), /* Diamond Chest */
'3', new ItemStack(blockResult, 1, 3), /* Copper Chest */
'4', new ItemStack(blockResult, 1, 4) /* Silver Chest */
'4', new ItemStack(blockResult, 1, 4), /* Silver Chest */
'5', new ItemStack(blockResult, 1, 10), /* Netherite Chest */
'6', new ItemStack(blockResult, 1, 7) /* Obsidian Chest */

);
// spotless:on
}
Expand Down Expand Up @@ -182,7 +194,7 @@ public boolean isValidForCreativeMode() {
}

public boolean isExplosionResistant() {
return this == OBSIDIAN;
return this == OBSIDIAN || this == NETHERITE;
}

@SideOnly(Side.CLIENT)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cpw/mods/ironchest/ItemChestChanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ItemChestChanger(ChestChangerType type) {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon("ironchest:" + type.itemName.replace("teel", "ilver"));
this.itemIcon = par1IconRegister.registerIcon("ironchest:" + type.itemName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cpw.mods.ironchest;

public class TileEntityDarkSteelChest extends TileEntityIronChest {

public TileEntityDarkSteelChest() {
super(IronChestType.DARKSTEEL);
}
}
Loading

0 comments on commit 40aca9a

Please sign in to comment.