Updated Storage Drawers API, fixes crashes, fixes #1304

This commit is contained in:
raoulvdberge
2017-06-14 12:10:51 +02:00
parent 7d9edc8221
commit 4a15dbdf4e
15 changed files with 13 additions and 268 deletions

View File

@@ -1,5 +1,8 @@
# Refined Storage Changelog
### 1.4.15
- Updated Storage Drawers API, fixes crashes (raoulvdberge)
### 1.4.14
- Fixed Solderer not accepting books made in anvil (raoulvdberge)

View File

@@ -15,12 +15,8 @@ public interface IStorageDrawersApi {
IWailaRegistry wailaRegistry();
//IPackBlockFactory packFactory ();
/**
* User-managed configuration for the Storage Drawers mod.
*/
IUserConfig userConfig();
//void registerStandardPackRecipes (IExtendedDataResolver resolver);
}

View File

@@ -6,7 +6,7 @@ package com.jaquadro.minecraft.storagedrawers.api;
public class StorageDrawersApi {
private static IStorageDrawersApi instance;
public static final String VERSION = "1.7.10-1.2.0";
public static final String VERSION = "1.10.2-1.3.0";
/**
* API entry point.

View File

@@ -7,6 +7,7 @@ public interface IUserConfig {
/**
* Configuration options related to third party addon packs for Storage Drawers.
*/
@Deprecated
IAddonConfig addonConfig();
/**

View File

@@ -8,15 +8,7 @@ public enum BlockConfiguration {
BasicFull4(BlockType.Drawers, EnumBasicDrawer.FULL4),
BasicHalf2(BlockType.Drawers, EnumBasicDrawer.HALF2),
BasicHalf4(BlockType.Drawers, EnumBasicDrawer.HALF4),
SortingFull1(BlockType.DrawersSorting, EnumBasicDrawer.FULL1),
SortingFull2(BlockType.DrawersSorting, EnumBasicDrawer.FULL2),
SortingFull4(BlockType.DrawersSorting, EnumBasicDrawer.FULL4),
SortingHalf2(BlockType.DrawersSorting, EnumBasicDrawer.HALF2),
SortingHalf4(BlockType.DrawersSorting, EnumBasicDrawer.HALF4),
Trim(BlockType.Trim, null),
TrimSorting(BlockType.TrimSorting, null);
Trim(BlockType.Trim, null);
private final BlockType type;
private final EnumBasicDrawer drawer;

View File

@@ -2,7 +2,5 @@ package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum BlockType {
Drawers,
DrawersSorting,
Trim,
TrimSorting
Trim
}

View File

@@ -1,63 +0,0 @@
/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
public class ExtendedDataResolver extends StandardDataResolver implements IExtendedDataResolver
{
private Block[] planks = new Block[16];
private int[] planksMeta = new int[16];
private Block[] slabs = new Block[16];
private int[] slabsMeta = new int [16];
public ExtendedDataResolver (String modID, String[] unlocalizedNames) {
super(modID, unlocalizedNames);
}
public ExtendedDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
super(modID, unlocalizedNames, creativeTab);
}
@Override
public Block getBlock (BlockConfiguration blockConfig) {
return null;
}
@Override
public Block getPlankBlock (int meta) {
return planks[meta];
}
@Override
public Block getSlabBlock (int meta) {
return slabs[meta];
}
@Override
public int getPlankMeta (int meta) {
return planksMeta[meta];
}
@Override
public int getSlabMeta (int meta) {
return slabsMeta[meta];
}
public void init () {
}
protected void setPlankSlab (int meta, Block plank, int plankMeta, Block slab, int slabMeta) {
if (plank != null) {
planks[meta] = plank;
planksMeta[meta] = plankMeta;
}
if (slab != null) {
slabs[meta] = slab;
slabsMeta[meta] = slabMeta;
}
}
}
*/

View File

@@ -1,17 +0,0 @@
/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
public interface IExtendedDataResolver extends IPackDataResolver
{
Block getBlock (BlockConfiguration blockConfig);
Block getPlankBlock (int meta);
Block getSlabBlock (int meta);
int getPlankMeta (int meta);
int getSlabMeta (int meta);
}
*/

View File

@@ -1,7 +0,0 @@
/*package com.jaquadro.minecraft.storagedrawers.api.pack;
public interface IPackBlock
{
IPackDataResolver getDataResolver ();
}
*/

View File

@@ -1,35 +0,0 @@
/*package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
public interface IPackBlockFactory
{
Block createBlock (BlockConfiguration blockConfig, IPackDataResolver dataResolver);
/**
* Registers a factory-produced block with an appropriate item class.
*/
//void registerBlock (Block block, String name);
/**
* Associates a sorting variant of a block with its corresponding basic block.
* <p>
* Hides block from NEI if NEI is active.
* <p>
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
//void bindSortingBlock (Block basicBlock, Block sortingBlock);
/**
* Hides block from NEI if NEI is active.
* <p>
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
//void hideBlock (String blockID);
/**
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
//void registerResolver (IExtendedDataResolver resolver);
//}

View File

@@ -1,19 +0,0 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
/*
import net.minecraft.creativetab.CreativeTabs;
public interface IPackDataResolver
{
String getPackModID ();
String getBlockName (BlockConfiguration blockConfig);
CreativeTabs getCreativeTabs (BlockType type);
boolean isValidMetaValue (int meta);
String getUnlocalizedName (int meta);
String getTexturePath (TextureType type, int meta);
}
*/

View File

@@ -1,108 +0,0 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
/*
import net.minecraft.creativetab.CreativeTabs;
public class StandardDataResolver implements IPackDataResolver
{
private String modID;
private String[] unlocalizedNames;
private CreativeTabs creativeTab;
public StandardDataResolver (String modID, String[] unlocalizedNames) {
this.modID = modID;
this.unlocalizedNames = unlocalizedNames;
}
public StandardDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
this(modID, unlocalizedNames);
this.creativeTab = creativeTab;
}
@Override
public String getPackModID () {
return modID;
}
protected String makeBlockName (String name) {
return getPackModID().toLowerCase() + "." + name;
}
@Override
public String getBlockName (BlockConfiguration blockConfig) {
switch (blockConfig.getBlockType()) {
case Drawers:
case DrawersSorting:
if (blockConfig.getDrawerCount() == 1)
return makeBlockName("fullDrawers1");
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return makeBlockName("fullDrawers2");
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
return makeBlockName("fullDrawers4");
if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth())
return makeBlockName("halfDrawers2");
if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth())
return makeBlockName("halfDrawers4");
break;
case Trim:
case TrimSorting:
return makeBlockName("trim");
}
return null;
}
@Override
public CreativeTabs getCreativeTabs (BlockType type) {
return creativeTab;
}
@Override
public boolean isValidMetaValue (int meta) {
if (meta < 0 || meta >= unlocalizedNames.length)
return false;
return unlocalizedNames != null && unlocalizedNames[meta] != null;
}
@Override
public String getUnlocalizedName (int meta) {
if (!isValidMetaValue(meta))
return null;
return unlocalizedNames[meta];
}
protected String getBaseTexturePath () {
return getPackModID() + ":";
}
protected String getTextureMetaName (int meta) {
return getUnlocalizedName(meta);
}
@Override
public String getTexturePath (TextureType type, int meta) {
switch (type) {
case Front1:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_1";
case Front2:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_2";
case Front4:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_4";
case Side:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side";
case SideSort:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_sort";
case SideVSplit:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_v";
case SideHSplit:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_h";
case TrimBorder:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_trim";
case TrimBlock:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side";
default:
return "";
}
}
}
*/

View File

@@ -5,7 +5,6 @@ public enum TextureType {
Front2,
Front4,
Side,
SideSort,
SideVSplit,
SideHSplit,
TrimBorder,

View File

@@ -48,6 +48,12 @@ public interface IDrawer {
*/
int getMaxCapacity(@Nonnull ItemStack itemPrototype);
/**
* Gets the maxmimum number of items that could be stored in this drawer for a standard item stack size
* of 64.
*/
int getDefaultMaxCapacity();
/**
* Gets the number of items that could still be added to this drawer before it is full.
*/

View File

@@ -9,7 +9,6 @@ public interface IQuantifiable {
/**
* Sets whether or not the drawer is currently quantified.
*
* @return false if the operation is not supported, true otherwise.
*/
boolean setIsShowingQuantity(boolean state);