mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-14 01:14:06 +00:00
Handle edge cases where pack blocks could return a null icon
This commit is contained in:
1 parent
a145dbd82c
commit
2d6573309d
4 files changed
+99
-4
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.7.10-1.9.4"
|
||||
version = "1.7.10-1.9.5"
|
||||
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "StorageDrawers"
|
||||
|
||||
|
||||
@@ -703,14 +703,14 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconTrim (int meta) {
|
||||
meta %= iconTrim.length;
|
||||
meta = (meta < 0 || meta >= iconTrim.length) ? 0 : meta;
|
||||
return iconTrim[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta) {
|
||||
meta %= iconSide.length;
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
|
||||
switch (side) {
|
||||
case 0:
|
||||
@@ -757,7 +757,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
|
||||
@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) % iconSide.length;
|
||||
int meta = blockAccess.getBlockMetadata(x, y, z);
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
|
||||
TileEntityDrawers tile = getTileEntity(blockAccess, x, y, z);
|
||||
if (tile == null || side == tile.getDirection()) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.block.pack;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.pack.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModBlocks;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -11,6 +12,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,6 +58,51 @@ public class BlockDrawersPack extends BlockDrawers implements IPackBlock
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta) {
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIcon(side, meta);
|
||||
|
||||
return super.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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);
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIcon(side, meta);
|
||||
|
||||
return super.getIcon(blockAccess, x, y, z, side, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconTrim (int meta) {
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIconTrim(meta);
|
||||
|
||||
return super.getIconTrim(meta);
|
||||
}
|
||||
|
||||
private BlockDrawers getSimilarBlock () {
|
||||
if (drawerCount == 1 && !halfDepth)
|
||||
return ModBlocks.fullDrawers1;
|
||||
if (drawerCount == 2 && !halfDepth)
|
||||
return ModBlocks.fullDrawers2;
|
||||
if (drawerCount == 4 && !halfDepth)
|
||||
return ModBlocks.fullDrawers4;
|
||||
if (drawerCount == 2 && halfDepth)
|
||||
return ModBlocks.halfDrawers2;
|
||||
if (drawerCount == 4 && halfDepth)
|
||||
return ModBlocks.halfDrawers4;
|
||||
return ModBlocks.fullDrawers1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister register) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.block.pack;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.pack.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation.BlockSortingDrawers;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -11,6 +12,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,6 +58,51 @@ public class BlockSortingDrawersPack extends BlockSortingDrawers implements IPac
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta) {
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIcon(side, meta);
|
||||
|
||||
return super.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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);
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIcon(side, meta);
|
||||
|
||||
return super.getIcon(blockAccess, x, y, z, side, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconTrim (int meta) {
|
||||
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
|
||||
if (!resolver.isValidMetaValue(meta))
|
||||
getSimilarBlock().getIconTrim(meta);
|
||||
|
||||
return super.getIconTrim(meta);
|
||||
}
|
||||
|
||||
private BlockSortingDrawers getSimilarBlock () {
|
||||
if (drawerCount == 1 && !halfDepth)
|
||||
return RefinedRelocation.fullDrawers1;
|
||||
if (drawerCount == 2 && !halfDepth)
|
||||
return RefinedRelocation.fullDrawers2;
|
||||
if (drawerCount == 4 && !halfDepth)
|
||||
return RefinedRelocation.fullDrawers4;
|
||||
if (drawerCount == 2 && halfDepth)
|
||||
return RefinedRelocation.halfDrawers2;
|
||||
if (drawerCount == 4 && halfDepth)
|
||||
return RefinedRelocation.halfDrawers4;
|
||||
return RefinedRelocation.fullDrawers1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister register) {
|
||||
|
||||
Reference in new issue
Block a user