mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-27 23:45:36 +00:00
Trap and report tile entity save errors
This commit is contained in:
1 parent
d5b4276f46
commit
d737cd7048
9 files changed
+247
-29
No files matched your search
@@ -26,6 +26,7 @@ minecraft {
|
||||
assetDir = "../../runtime/assets"
|
||||
|
||||
replace '@VERSION@', project.version
|
||||
replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.4.7,)"
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
|
||||
+3
@@ -2,6 +2,7 @@ package com.jaquadro.minecraft.storagedrawers.packs.natura;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.core.ModBlocks;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.core.ModRecipes;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.core.RefinedRelocation;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -32,10 +33,12 @@ public class StorageDrawersPack
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init (FMLInitializationEvent event) {
|
||||
RefinedRelocation.init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit (FMLPostInitializationEvent event) {
|
||||
recipes.init();
|
||||
RefinedRelocation.postInit();
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.packs.natura.block;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation.BlockSortingDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.StorageDrawersPack;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.core.ModCreativeTabs;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockSortingDrawersPack extends BlockSortingDrawers
|
||||
{
|
||||
public BlockSortingDrawersPack (String blockName, int drawerCount, boolean halfDepth) {
|
||||
super(blockName, drawerCount, halfDepth);
|
||||
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int i = 1; i < BlockDrawersPack.textureNames.length; i++)
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister register) {
|
||||
super.registerBlockIcons(register);
|
||||
|
||||
String[] subtex = BlockDrawersPack.textureNames;
|
||||
|
||||
iconSide = new IIcon[subtex.length];
|
||||
iconSideH = new IIcon[subtex.length];
|
||||
iconSideV = new IIcon[subtex.length];
|
||||
iconFront1 = new IIcon[subtex.length];
|
||||
iconFront2 = new IIcon[subtex.length];
|
||||
iconFront4 = new IIcon[subtex.length];
|
||||
iconTrim = new IIcon[subtex.length];
|
||||
iconSort = new IIcon[subtex.length];
|
||||
|
||||
for (int i = 0; i < subtex.length; i++) {
|
||||
iconFront1[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_front_1");
|
||||
iconFront2[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_front_2");
|
||||
iconFront4[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_front_4");
|
||||
iconSide[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_side");
|
||||
iconSideV[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_side_v");
|
||||
iconSideH[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_side_h");
|
||||
iconTrim[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_trim");
|
||||
iconSort[i] = register.registerIcon(StorageDrawersPack.MOD_ID + ":drawers_" + subtex[i] + "_sort");
|
||||
}
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.packs.natura.core;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.block.BlockDrawersPack;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.block.BlockSortingDrawersPack;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.item.ItemSortingDrawersPack;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RefinedRelocation
|
||||
{
|
||||
public static BlockSortingDrawersPack fullDrawers1;
|
||||
public static BlockSortingDrawersPack fullDrawers2;
|
||||
public static BlockSortingDrawersPack fullDrawers4;
|
||||
public static BlockSortingDrawersPack halfDrawers2;
|
||||
public static BlockSortingDrawersPack halfDrawers4;
|
||||
|
||||
public static void init () {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
if (!Loader.isModLoaded("RefinedRelocation") || !config.cache.enableRefinedRelocationIntegration)
|
||||
return;
|
||||
|
||||
fullDrawers1 = new BlockSortingDrawersPack(ModBlocks.makeName("fullDrawers1"), 1, false);
|
||||
fullDrawers2 = new BlockSortingDrawersPack(ModBlocks.makeName("fullDrawers2"), 2, false);
|
||||
fullDrawers4 = new BlockSortingDrawersPack(ModBlocks.makeName("fullDrawers4"), 4, false);
|
||||
halfDrawers2 = new BlockSortingDrawersPack(ModBlocks.makeName("halfDrawers2"), 2, true);
|
||||
halfDrawers4 = new BlockSortingDrawersPack(ModBlocks.makeName("halfDrawers4"), 4, true);
|
||||
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers1, fullDrawers1);
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers2, fullDrawers2);
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers4, fullDrawers4);
|
||||
SortingBlockRegistry.register(ModBlocks.halfDrawers2, halfDrawers2);
|
||||
SortingBlockRegistry.register(ModBlocks.halfDrawers4, halfDrawers4);
|
||||
|
||||
if (config.isBlockEnabled("fulldrawers1")) {
|
||||
GameRegistry.registerBlock(fullDrawers1, ItemSortingDrawersPack.class, "fullDrawersSort1");
|
||||
GameRegistry.registerTileEntity(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName(fullDrawers1));
|
||||
}
|
||||
if (config.isBlockEnabled("fulldrawers2")) {
|
||||
GameRegistry.registerBlock(fullDrawers2, ItemSortingDrawersPack.class, "fullDrawersSort2");
|
||||
GameRegistry.registerTileEntity(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName(fullDrawers2));
|
||||
}
|
||||
if (config.isBlockEnabled("fulldrawers4")) {
|
||||
GameRegistry.registerBlock(fullDrawers4, ItemSortingDrawersPack.class, "fullDrawersSort4");
|
||||
GameRegistry.registerTileEntity(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName(fullDrawers4));
|
||||
}
|
||||
if (config.isBlockEnabled("halfdrawers2")) {
|
||||
GameRegistry.registerBlock(halfDrawers2, ItemSortingDrawersPack.class, "halfDrawersSort2");
|
||||
GameRegistry.registerTileEntity(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName(halfDrawers2));
|
||||
}
|
||||
if (config.isBlockEnabled("halfdrawers4")) {
|
||||
GameRegistry.registerBlock(halfDrawers4, ItemSortingDrawersPack.class, "halfDrawersSort4");
|
||||
GameRegistry.registerTileEntity(TileSortingDrawersStandard.class, ModBlocks.getQualifiedName(halfDrawers4));
|
||||
}
|
||||
}
|
||||
|
||||
public static void postInit () {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
if (!Loader.isModLoaded("RefinedRelocation") || !config.cache.enableRefinedRelocationIntegration)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < BlockDrawersPack.textureNames.length; i++) {
|
||||
if (config.isBlockEnabled("fulldrawers1"))
|
||||
GameRegistry.addRecipe(new ItemStack(fullDrawers1, 1, i), "x x", " y ", "x x",
|
||||
'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers1, 1, i));
|
||||
if (config.isBlockEnabled("fulldrawers2"))
|
||||
GameRegistry.addRecipe(new ItemStack(fullDrawers2, 1, i), "x x", " y ", "x x",
|
||||
'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers2, 1, i));
|
||||
if (config.isBlockEnabled("halfdrawers2"))
|
||||
GameRegistry.addRecipe(new ItemStack(halfDrawers2, 1, i), "x x", " y ", "x x",
|
||||
'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.halfDrawers2, 1, i));
|
||||
if (config.isBlockEnabled("fulldrawers4"))
|
||||
GameRegistry.addRecipe(new ItemStack(fullDrawers4, 1, i), "x x", " y ", "x x",
|
||||
'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.fullDrawers4, 1, i));
|
||||
if (config.isBlockEnabled("halfdrawers4"))
|
||||
GameRegistry.addRecipe(new ItemStack(halfDrawers4, 1, i), "x x", " y ", "x x",
|
||||
'x', Items.gold_nugget, 'y', new ItemStack(ModBlocks.halfDrawers4, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.packs.natura.item;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.packs.natura.core.RefinedRelocation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSortingDrawersPack extends ItemDrawersPack
|
||||
{
|
||||
public ItemSortingDrawersPack (Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(itemStack, player, list, par4);
|
||||
|
||||
Block block = Block.getBlockFromItem(itemStack.getItem());
|
||||
list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocalFormatted("storageDrawers.waila.sorting"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCapacityForBlock (Block block) {
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
int count = 0;
|
||||
|
||||
if (block == RefinedRelocation.fullDrawers1)
|
||||
count = config.getBlockBaseStorage("fulldrawers1");
|
||||
else if (block == RefinedRelocation.fullDrawers2)
|
||||
count = config.getBlockBaseStorage("fulldrawers2");
|
||||
else if (block == RefinedRelocation.fullDrawers4)
|
||||
count = config.getBlockBaseStorage("fulldrawers4");
|
||||
else if (block == RefinedRelocation.halfDrawers2)
|
||||
count = config.getBlockBaseStorage("halfdrawers2");
|
||||
else if (block == RefinedRelocation.halfDrawers4)
|
||||
count = config.getBlockBaseStorage("halfdrawers4");
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -294,27 +294,32 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
return;
|
||||
}
|
||||
|
||||
tag.setByte("Dir", (byte)direction);
|
||||
tag.setByte("Cap", (byte)drawerCapacity);
|
||||
tag.setByte("Lev", (byte) storageLevel);
|
||||
try {
|
||||
tag.setByte("Dir", (byte) direction);
|
||||
tag.setByte("Cap", (byte) drawerCapacity);
|
||||
tag.setByte("Lev", (byte) storageLevel);
|
||||
|
||||
if (statusLevel > 0)
|
||||
tag.setByte("Stat", (byte)statusLevel);
|
||||
if (statusLevel > 0)
|
||||
tag.setByte("Stat", (byte) statusLevel);
|
||||
|
||||
if (locked)
|
||||
tag.setBoolean("Lock", locked);
|
||||
if (locked)
|
||||
tag.setBoolean("Lock", locked);
|
||||
|
||||
if (voidUpgrade)
|
||||
tag.setBoolean("Void", voidUpgrade);
|
||||
if (voidUpgrade)
|
||||
tag.setBoolean("Void", voidUpgrade);
|
||||
|
||||
NBTTagList slots = new NBTTagList();
|
||||
for (IDrawer drawer : drawers) {
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
drawer.writeToNBT(slot);
|
||||
slots.appendTag(slot);
|
||||
NBTTagList slots = new NBTTagList();
|
||||
for (IDrawer drawer : drawers) {
|
||||
NBTTagCompound slot = new NBTTagCompound();
|
||||
drawer.writeToNBT(slot);
|
||||
slots.appendTag(slot);
|
||||
}
|
||||
|
||||
tag.setTag("Slots", slots);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Save Failure.");
|
||||
}
|
||||
|
||||
tag.setTag("Slots", slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,6 +56,13 @@ public class RefinedRelocation extends IntegrationModule
|
||||
|
||||
upgradeSorting = new ItemUpgradeSorting("upgradeSorting");
|
||||
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers1, fullDrawers1);
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers2, fullDrawers2);
|
||||
SortingBlockRegistry.register(ModBlocks.fullDrawers4, fullDrawers4);
|
||||
SortingBlockRegistry.register(ModBlocks.halfDrawers2, halfDrawers2);
|
||||
SortingBlockRegistry.register(ModBlocks.halfDrawers4, halfDrawers4);
|
||||
SortingBlockRegistry.register(ModBlocks.compDrawers, compDrawers);
|
||||
|
||||
ConfigManager config = StorageDrawers.config;
|
||||
|
||||
if (config.isBlockEnabled("fulldrawers1")) {
|
||||
|
||||
+6
-13
@@ -3,7 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModBlocks;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -19,7 +18,7 @@ import net.minecraft.world.World;
|
||||
public class BlockSortingDrawers extends BlockDrawers
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon[] iconSort;
|
||||
protected IIcon[] iconSort;
|
||||
|
||||
public BlockSortingDrawers (String blockName, int drawerCount, boolean halfDepth) {
|
||||
super(blockName, drawerCount, halfDepth);
|
||||
@@ -45,16 +44,10 @@ public class BlockSortingDrawers extends BlockDrawers
|
||||
world.removeTileEntity(x, y, z);
|
||||
world.setBlockToAir(x, y, z);
|
||||
|
||||
if (block == ModBlocks.fullDrawers1)
|
||||
world.setBlock(x, y, z, RefinedRelocation.fullDrawers1, meta, 3);
|
||||
else if (block == ModBlocks.fullDrawers2)
|
||||
world.setBlock(x, y, z, RefinedRelocation.fullDrawers2, meta, 3);
|
||||
else if (block == ModBlocks.fullDrawers4)
|
||||
world.setBlock(x, y, z, RefinedRelocation.fullDrawers4, meta, 3);
|
||||
else if (block == ModBlocks.halfDrawers2)
|
||||
world.setBlock(x, y, z, RefinedRelocation.halfDrawers2, meta, 3);
|
||||
else if (block == ModBlocks.halfDrawers4)
|
||||
world.setBlock(x, y, z, RefinedRelocation.halfDrawers4, meta, 3);
|
||||
Block sortingBlock = SortingBlockRegistry.resolveSortingBlock(block);
|
||||
if (sortingBlock != null) {
|
||||
world.setBlock(x, y, z, sortingBlock, meta, 3);
|
||||
}
|
||||
|
||||
world.setTileEntity(x, y, z, newDrawer);
|
||||
|
||||
@@ -76,7 +69,7 @@ public class BlockSortingDrawers extends BlockDrawers
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side, int level) {
|
||||
int meta = blockAccess.getBlockMetadata(x, y, z) % BlockWood.field_150096_a.length;
|
||||
int meta = blockAccess.getBlockMetadata(x, y, z) % iconSort.length;
|
||||
if (side == 1 && !halfDepth)
|
||||
return iconSort[meta];
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SortingBlockRegistry
|
||||
{
|
||||
private static Map<Block, Block> registry = new HashMap<Block, Block>();
|
||||
|
||||
public static void register (Block storageBlock, Block sortingBlock) {
|
||||
registry.put(storageBlock, sortingBlock);
|
||||
}
|
||||
|
||||
public static Block resolveSortingBlock (Block storageBlock) {
|
||||
return registry.get(storageBlock);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user