Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new chests (from @unicornbloods) #16

Merged
merged 24 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e122ac2
Start adding netherite chest
unicornbloods Feb 8, 2024
fe52b74
Netherite chest GUI.
unicornbloods Feb 8, 2024
ae9f5ae
Netherite chest textures.
unicornbloods Feb 8, 2024
283a0d0
Netherite English lang.
unicornbloods Feb 10, 2024
dae8601
Netherite chest upgrade.
unicornbloods Feb 10, 2024
93e2238
Netherite chest recipes.
unicornbloods Feb 10, 2024
e7d99cc
Update diamondObsidianUpgrade.png to not look similar to not look sim…
unicornbloods Feb 24, 2024
6179c60
Remove copyright from netherite chest tile entity class
unicornbloods Feb 24, 2024
1626f90
Disable loading netherite chests on GTNH
unicornbloods Feb 24, 2024
f670094
Merge pull request #1 from unicornbloods/netherite_chests
unicornbloods Feb 24, 2024
cf098f0
Properly not load chests on GTNH.
unicornbloods Feb 26, 2024
7b268c7
Merge pull request #2 from unicornbloods/revert_steel_change
unicornbloods Feb 26, 2024
5179c13
Make netherite chest blast resistant
unicornbloods Feb 27, 2024
6f1289d
Fix metadata IDs
unicornbloods Mar 1, 2024
94dec60
Make Netherite an upgrade to obsidian instead
unicornbloods Mar 2, 2024
dad2336
Update bs + enable modern java syntax
Caedis Mar 3, 2024
ceae1f8
Fix compat with gtnh
Caedis Mar 3, 2024
41ad6ef
fix dark steel upgrade icon
Caedis Mar 3, 2024
af5fd72
make dark steel chest configurable (default to gtnh existence)
Pilzinsel64 Mar 3, 2024
330780b
catch missing mappings for dark steel & ironchest
Pilzinsel64 Mar 3, 2024
16af8ad
fix mapping of obsidianNetheriteUpgrade
Pilzinsel64 Mar 3, 2024
5234695
spotlessApply
Pilzinsel64 Mar 3, 2024
bc9945e
fix translation for netherite upgrade & german translation
Pilzinsel64 Mar 3, 2024
c9190c3
git push
Pilzinsel64 Mar 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
}


33 changes: 31 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,8 @@
******************************************************************************/
package cpw.mods.ironchest;

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

Expand Down Expand Up @@ -213,9 +215,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.isGTNHLoaded) {
par3List.add(new ItemStack(this, 1, type.ordinal()));
}
}
case NETHERITE -> {
if (IronChest.isGTNHLoaded) {
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.isGTNHLoaded) {
type.buildItem(cfg);
}
}
case OBSIDIANNETHERITE -> {
if (IronChest.isGTNHLoaded) {
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
54 changes: 33 additions & 21 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,21 @@ 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 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);
ENABLE_STEEL_CHESTS = cfg.get("general", "enableSteelChests", true).getBoolean(true);
ChestChangerType.buildItems(cfg);
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "IronChest has a problem loading its configuration");
} finally {
Expand All @@ -67,13 +72,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 +108,27 @@ 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:
}
} 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_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:
}
}
}
}
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("ingotNetherite"),
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.isGTNHLoaded) {
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.isGTNHLoaded) {
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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cpw.mods.ironchest;

public class TileEntityNetheriteChest extends TileEntityIronChest {

public TileEntityNetheriteChest() {
super(IronChestType.NETHERITE);
}
}
15 changes: 15 additions & 0 deletions src/main/java/cpw/mods/ironchest/TileEntitySilverChest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright (c) 2012 cpw. All rights reserved. This program and the accompanying materials are made available under the
* terms of the GNU Public License v3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors: cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest;

public class TileEntitySilverChest extends TileEntityIronChest {

public TileEntitySilverChest() {
super(IronChestType.SILVER);
}
}
Loading