This commit is contained in:
Martin Robertz committed 2022-08-28 15:01:56 +02:00
1 parent d57ec8d6c1
commit 4830614775
210 files changed
+7290 -5887

No files matched your search

@@ -20,13 +20,16 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
import java.io.File;
import net.minecraftforge.common.MinecraftForge;
import java.io.File;
@Mod(modid = StorageDrawers.MOD_ID, name = StorageDrawers.MOD_NAME, version = StorageDrawers.MOD_VERSION, dependencies = "after:waila;", guiFactory = StorageDrawers.SOURCE_PATH + "core.ModGuiFactory")
public class StorageDrawers
{
@Mod(
modid = StorageDrawers.MOD_ID,
name = StorageDrawers.MOD_NAME,
version = StorageDrawers.MOD_VERSION,
dependencies = "after:waila;",
guiFactory = StorageDrawers.SOURCE_PATH + "core.ModGuiFactory")
public class StorageDrawers {
public static final String MOD_ID = "StorageDrawers";
public static final String MOD_NAME = "Storage Drawers";
public static final String MOD_VERSION = "GRADLETOKEN_VERSION";
@@ -56,7 +59,7 @@ public class StorageDrawers
public static CommonProxy proxy;
@Mod.EventHandler
public void preInit (FMLPreInitializationEvent event) {
public void preInit(FMLPreInitializationEvent event) {
config = new ConfigManager(new File(event.getModConfigurationDirectory(), MOD_ID + ".cfg"));
network = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
@@ -64,8 +67,7 @@ public class StorageDrawers
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
network.registerMessage(CountUpdateMessage.Handler.class, CountUpdateMessage.class, 1, Side.CLIENT);
}
else {
} else {
network.registerMessage(CountUpdateMessage.HandlerStub.class, CountUpdateMessage.class, 1, Side.CLIENT);
}
@@ -82,7 +84,7 @@ public class StorageDrawers
}
@Mod.EventHandler
public void init (FMLInitializationEvent event) {
public void init(FMLInitializationEvent event) {
proxy.registerRenderers();
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
@@ -93,7 +95,7 @@ public class StorageDrawers
}
@Mod.EventHandler
public void postInit (FMLPostInitializationEvent event) {
public void postInit(FMLPostInitializationEvent event) {
recipes.init();
IntegrationRegistry.instance().postInit();
@@ -102,8 +104,7 @@ public class StorageDrawers
}
@SubscribeEvent
public void onConfigChanged (ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals(MOD_ID))
config.syncConfig();
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals(MOD_ID)) config.syncConfig();
}
}
@@ -7,23 +7,22 @@ import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
public interface IStorageDrawersApi
{
public interface IStorageDrawersApi {
/**
* Recipe handlers are used to make custom recipes compatible with compacting drawers.
*/
IRecipeHandlerRegistry recipeHandlerRegistry ();
IRecipeHandlerRegistry recipeHandlerRegistry();
IRenderRegistry renderRegistry ();
IRenderRegistry renderRegistry();
IWailaRegistry wailaRegistry ();
IWailaRegistry wailaRegistry();
IPackBlockFactory packFactory ();
IPackBlockFactory packFactory();
/**
* User-managed configuration for the Storage Drawers mod.
*/
IUserConfig userConfig ();
IUserConfig userConfig();
void registerStandardPackRecipes (IExtendedDataResolver resolver);
void registerStandardPackRecipes(IExtendedDataResolver resolver);
}
@@ -3,8 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.api;
/**
* Entry point for the public API.
*/
public class StorageDrawersApi
{
public class StorageDrawersApi {
private static IStorageDrawersApi instance;
public static final String VERSION = "1.7.10-1.2.0";
@@ -14,13 +13,12 @@ public class StorageDrawersApi
*
* @return The {@link IStorageDrawersApi} instance or null if the API or Storage Drawers is unavailable.
*/
public static IStorageDrawersApi instance () {
public static IStorageDrawersApi instance() {
if (instance == null) {
try {
Class classApi = Class.forName( "com.jaquadro.minecraft.storagedrawers.core.Api" );
Class classApi = Class.forName("com.jaquadro.minecraft.storagedrawers.core.Api");
instance = (IStorageDrawersApi) classApi.getField("instance").get(null);
}
catch (Throwable t) {
} catch (Throwable t) {
return null;
}
}
@@ -1,21 +1,20 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
public interface IAddonConfig
{
public interface IAddonConfig {
/**
* Gets whether the user has configured a preference for addon packs to hide their blocks and items from Vanilla
* creative tabs.
*/
boolean showAddonItemsNEI ();
boolean showAddonItemsNEI();
/**
* Gets whether the user has configured a preference for addon packs to hide their blocks and items from NEI.
*/
boolean showAddonItemsVanilla ();
boolean showAddonItemsVanilla();
/**
* Gets whether the user has configured a preference for addon packs to provide their blocks and items through
* their own vanilla tab.
*/
boolean addonItemsUseSeparateTab ();
boolean addonItemsUseSeparateTab();
}
@@ -2,13 +2,12 @@ package com.jaquadro.minecraft.storagedrawers.api.config;
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration;
public interface IBlockConfig
{
String getBlockConfigName (BlockConfiguration blockConfig);
public interface IBlockConfig {
String getBlockConfigName(BlockConfiguration blockConfig);
boolean isBlockEnabled (String blockConfigName);
boolean isBlockEnabled(String blockConfigName);
int getBlockRecipeOutput (String blockConfigName);
int getBlockRecipeOutput(String blockConfigName);
int getBaseCapacity (String blockConfigName);
int getBaseCapacity(String blockConfigName);
}
@@ -1,8 +1,9 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
public interface IIntegrationConfig
{
boolean isRefinedRelocationEnabled ();
boolean isChiselEnabled ();
boolean isGTNHEnabled ();
public interface IIntegrationConfig {
boolean isRefinedRelocationEnabled();
boolean isChiselEnabled();
boolean isGTNHEnabled();
}
@@ -3,20 +3,19 @@ package com.jaquadro.minecraft.storagedrawers.api.config;
/**
* The main hub for user-managed mod configuration.
*/
public interface IUserConfig
{
public interface IUserConfig {
/**
* Configuration options related to third party addon packs for Storage Drawers.
*/
IAddonConfig addonConfig ();
IAddonConfig addonConfig();
/**
* Configuration options related to individual blocks.
*/
IBlockConfig blockConfig ();
IBlockConfig blockConfig();
/**
* Configuration options related to third party mod integration.
*/
IIntegrationConfig integrationConfig ();
IIntegrationConfig integrationConfig();
}
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.config;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -9,11 +9,10 @@ import cpw.mods.fml.common.eventhandler.Event;
*
* This event is also called when the drawer is changed to empty.
*/
public class DrawerPopulatedEvent extends Event
{
public class DrawerPopulatedEvent extends Event {
public final IDrawer drawer;
public DrawerPopulatedEvent (IDrawer drawer) {
public DrawerPopulatedEvent(IDrawer drawer) {
this.drawer = drawer;
}
}
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.event;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -3,14 +3,13 @@ package com.jaquadro.minecraft.storagedrawers.api.inventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
public interface IDrawerInventory extends ISidedInventory
{
public interface IDrawerInventory extends ISidedInventory {
/**
* Gets a drawer's group slot index from an IInventory slot index.
*
* @param inventorySlot An IInventory slot index returned from getInventorySlot.
*/
int getDrawerSlot (int inventorySlot);
int getDrawerSlot(int inventorySlot);
/**
* Gets an IInventory slot index suitable for operations for the given type.
@@ -18,18 +17,18 @@ public interface IDrawerInventory extends ISidedInventory
* @param drawerSlot The index of the drawer within its group.
* @param type The type of IInventory slot to return an index for.
*/
int getInventorySlot (int drawerSlot, SlotType type);
int getInventorySlot(int drawerSlot, SlotType type);
/**
* Gets the type associated with a given IInventory slot index.
*
* @param inventorySlot An IInventory slot index returned from getInventorySlot.
*/
SlotType getInventorySlotType (int inventorySlot);
SlotType getInventorySlotType(int inventorySlot);
boolean canInsertItem (int slot, ItemStack stack);
boolean canInsertItem(int slot, ItemStack stack);
boolean canExtractItem (int slot, ItemStack stack);
boolean canExtractItem(int slot, ItemStack stack);
boolean syncInventoryIfNeeded ();
boolean syncInventoryIfNeeded();
}
@@ -2,15 +2,14 @@ package com.jaquadro.minecraft.storagedrawers.api.inventory;
import net.minecraft.item.ItemStack;
public interface IInventoryAdapter
{
ItemStack getInventoryStack (SlotType slotType);
public interface IInventoryAdapter {
ItemStack getInventoryStack(SlotType slotType);
void setInStack (ItemStack stack);
void setInStack(ItemStack stack);
void setOutStack (ItemStack stack);
void setOutStack(ItemStack stack);
void syncInventory ();
void syncInventory();
boolean syncInventoryIfNeeded ();
boolean syncInventoryIfNeeded();
}
@@ -3,8 +3,7 @@ package com.jaquadro.minecraft.storagedrawers.api.inventory;
/**
* Classifies different IInventory slots according to how they should be used.
*/
public enum SlotType
{
public enum SlotType {
/** An inventory slot for input-only operations; stack sizes artificially held low. */
INPUT,
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.inventory;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -1,7 +1,6 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum BlockConfiguration
{
public enum BlockConfiguration {
BasicFull1(BlockType.Drawers, 1, false),
BasicFull2(BlockType.Drawers, 2, false),
BasicFull4(BlockType.Drawers, 4, false),
@@ -21,25 +20,25 @@ public enum BlockConfiguration
private final int drawerCount;
private final boolean halfDepth;
BlockConfiguration (BlockType type, int count, boolean half) {
BlockConfiguration(BlockType type, int count, boolean half) {
this.type = type;
this.drawerCount = count;
this.halfDepth = half;
this.halfDepth = half;
}
public BlockType getBlockType () {
public BlockType getBlockType() {
return type;
}
public int getDrawerCount () {
public int getDrawerCount() {
return drawerCount;
}
public boolean isHalfDepth () {
public boolean isHalfDepth() {
return halfDepth;
}
public static BlockConfiguration by (BlockType type, int drawerCount, boolean halfDepth) {
public static BlockConfiguration by(BlockType type, int drawerCount, boolean halfDepth) {
for (BlockConfiguration config : values()) {
if (config.type == type && config.drawerCount == drawerCount && config.halfDepth == halfDepth)
return config;
@@ -1,7 +1,6 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum BlockType
{
public enum BlockType {
Drawers,
DrawersSorting,
Trim,
@@ -3,52 +3,49 @@ package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
public class ExtendedDataResolver extends StandardDataResolver implements IExtendedDataResolver
{
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];
private int[] slabsMeta = new int[16];
public ExtendedDataResolver (String modID, String[] unlocalizedNames) {
public ExtendedDataResolver(String modID, String[] unlocalizedNames) {
super(modID, unlocalizedNames);
}
public ExtendedDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
public ExtendedDataResolver(String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
super(modID, unlocalizedNames, creativeTab);
}
@Override
public Block getBlock (BlockConfiguration blockConfig) {
public Block getBlock(BlockConfiguration blockConfig) {
return null;
}
@Override
public Block getPlankBlock (int meta) {
public Block getPlankBlock(int meta) {
return planks[meta];
}
@Override
public Block getSlabBlock (int meta) {
public Block getSlabBlock(int meta) {
return slabs[meta];
}
@Override
public int getPlankMeta (int meta) {
public int getPlankMeta(int meta) {
return planksMeta[meta];
}
@Override
public int getSlabMeta (int meta) {
public int getSlabMeta(int meta) {
return slabsMeta[meta];
}
public void init () {
public void init() {}
}
protected void setPlankSlab (int meta, Block plank, int plankMeta, Block slab, int slabMeta) {
protected void setPlankSlab(int meta, Block plank, int plankMeta, Block slab, int slabMeta) {
if (plank != null) {
planks[meta] = plank;
planksMeta[meta] = plankMeta;
@@ -2,15 +2,14 @@ package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.block.Block;
public interface IExtendedDataResolver extends IPackDataResolver
{
Block getBlock (BlockConfiguration blockConfig);
public interface IExtendedDataResolver extends IPackDataResolver {
Block getBlock(BlockConfiguration blockConfig);
Block getPlankBlock (int meta);
Block getPlankBlock(int meta);
Block getSlabBlock (int meta);
Block getSlabBlock(int meta);
int getPlankMeta (int meta);
int getPlankMeta(int meta);
int getSlabMeta (int meta);
int getSlabMeta(int meta);
}
@@ -1,6 +1,5 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public interface IPackBlock
{
IPackDataResolver getDataResolver ();
public interface IPackBlock {
IPackDataResolver getDataResolver();
}
@@ -1,29 +1,27 @@
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);
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);
void registerBlock(Block block, String name);
/**
* Associates a sorting variant of a block with its corresponding basic block.
*/
void bindSortingBlock (Block basicBlock, Block sortingBlock);
void bindSortingBlock(Block basicBlock, Block sortingBlock);
/**
* Hides block from NEI if NEI is active.
*/
void hideBlock (String blockID);
void hideBlock(String blockID);
/**
* Registers block metadata from an initialized DataResolver with Storage Drawers.
*/
void registerResolver (IExtendedDataResolver resolver);
void registerResolver(IExtendedDataResolver resolver);
}
@@ -2,17 +2,16 @@ package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.creativetab.CreativeTabs;
public interface IPackDataResolver
{
String getPackModID ();
public interface IPackDataResolver {
String getPackModID();
String getBlockName (BlockConfiguration blockConfig);
String getBlockName(BlockConfiguration blockConfig);
CreativeTabs getCreativeTabs (BlockType type);
CreativeTabs getCreativeTabs(BlockType type);
boolean isValidMetaValue (int meta);
boolean isValidMetaValue(int meta);
String getUnlocalizedName (int meta);
String getUnlocalizedName(int meta);
String getTexturePath (TextureType type, int meta);
String getTexturePath(TextureType type, int meta);
}
@@ -2,38 +2,36 @@ package com.jaquadro.minecraft.storagedrawers.api.pack;
import net.minecraft.creativetab.CreativeTabs;
public class StandardDataResolver implements IPackDataResolver
{
public class StandardDataResolver implements IPackDataResolver {
private String modID;
private String[] unlocalizedNames;
private CreativeTabs creativeTab;
public StandardDataResolver (String modID, String[] unlocalizedNames) {
public StandardDataResolver(String modID, String[] unlocalizedNames) {
this.modID = modID;
this.unlocalizedNames = unlocalizedNames;
}
public StandardDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
public StandardDataResolver(String modID, String[] unlocalizedNames, CreativeTabs creativeTab) {
this(modID, unlocalizedNames);
this.creativeTab = creativeTab;
}
@Override
public String getPackModID () {
public String getPackModID() {
return modID;
}
protected String makeBlockName (String name) {
protected String makeBlockName(String name) {
return getPackModID().toLowerCase() + "." + name;
}
@Override
public String getBlockName (BlockConfiguration blockConfig) {
public String getBlockName(BlockConfiguration blockConfig) {
switch (blockConfig.getBlockType()) {
case Drawers:
case DrawersSorting:
if (blockConfig.getDrawerCount() == 1)
return makeBlockName("fullDrawers1");
if (blockConfig.getDrawerCount() == 1) return makeBlockName("fullDrawers1");
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return makeBlockName("fullDrawers2");
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
@@ -51,36 +49,34 @@ public class StandardDataResolver implements IPackDataResolver
}
@Override
public CreativeTabs getCreativeTabs (BlockType type) {
public CreativeTabs getCreativeTabs(BlockType type) {
return creativeTab;
}
@Override
public boolean isValidMetaValue (int meta) {
if (meta < 0 || meta >= unlocalizedNames.length)
return false;
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;
public String getUnlocalizedName(int meta) {
if (!isValidMetaValue(meta)) return null;
return unlocalizedNames[meta];
}
protected String getBaseTexturePath () {
protected String getBaseTexturePath() {
return getPackModID() + ":";
}
protected String getTextureMetaName (int meta) {
protected String getTextureMetaName(int meta) {
return getUnlocalizedName(meta);
}
@Override
public String getTexturePath (TextureType type, int meta) {
public String getTexturePath(TextureType type, int meta) {
switch (type) {
case Front1:
return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_1";
@@ -1,7 +1,6 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
public enum TextureType
{
public enum TextureType {
Front1,
Front2,
Front4,
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.pack;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -1,4 +1,4 @@
@API(owner = "StorageDrawers", provides = "StorageDrawersAPI", apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -7,13 +7,12 @@ import net.minecraft.item.ItemStack;
* registered an IRecipeHandler that returns lists of objects that aren't ItemStacks, then you will need to
* implement an ingredient handler for those objects.
*/
public interface IIngredientHandler
{
public interface IIngredientHandler {
/**
* Gets an ItemStack from an object that represents an ingredient in an IRecipe.
*
* @param object An ingredient object.
* @return An ItemStack for the given ingredient.
*/
ItemStack getItemStack (Object object);
ItemStack getItemStack(Object object);
}
@@ -1,15 +1,13 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import net.minecraft.item.crafting.IRecipe;
import java.util.List;
import net.minecraft.item.crafting.IRecipe;
/**
* Recipe handlers are used by compacting drawers to find more-compressed forms of blocks and items. If your recipe
* to craft compressed items is a custom IRecipe implementation, you will need to register a handler for it.
*/
public interface IRecipeHandler
{
public interface IRecipeHandler {
/**
* Get the recipe ingredient list as an array of objects (usually used for shaped recipes).
* If your array does not contain ItemStack objects, you will need to register an {@link IIngredientHandler} to
@@ -20,7 +18,7 @@ public interface IRecipeHandler
* @param recipe An instance of a custom {@link IRecipe}.
* @return An array of ItemStacks or objects with a registered {@link IIngredientHandler}.
*/
Object[] getInputAsArray (IRecipe recipe);
Object[] getInputAsArray(IRecipe recipe);
/**
* Get the recipe ingredient list as a list of objects (usually used for shapeless recipes).
@@ -32,5 +30,5 @@ public interface IRecipeHandler
* @param recipe An instance of a custom {@link IRecipe}.
* @return A list of ItemStacks or objects with a registered {@link IIngredientHandler}.
*/
List getInputAsList (IRecipe recipe);
List getInputAsList(IRecipe recipe);
}
@@ -1,12 +1,11 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
public interface IRecipeHandlerRegistry
{
void registerRecipeHandler (Class clazz, IRecipeHandler handler);
public interface IRecipeHandlerRegistry {
void registerRecipeHandler(Class clazz, IRecipeHandler handler);
void registerIngredientHandler (Class clazz, IIngredientHandler handler);
void registerIngredientHandler(Class clazz, IIngredientHandler handler);
IRecipeHandler getRecipeHandler (Class clazz);
IRecipeHandler getRecipeHandler(Class clazz);
IIngredientHandler getIngredientHandler (Class clazz);
IIngredientHandler getIngredientHandler(Class clazz);
}
@@ -2,7 +2,6 @@ package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
public interface IRenderRegistry
{
void registerPreLabelRenderHandler (IRenderLabel renderHandler);
public interface IRenderRegistry {
void registerPreLabelRenderHandler(IRenderLabel renderHandler);
}
@@ -1,6 +1,5 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
public interface IWailaRegistry
{
void registerTooltipHandler (IWailaTooltipHandler handler);
public interface IWailaRegistry {
void registerTooltipHandler(IWailaTooltipHandler handler);
}
@@ -2,7 +2,6 @@ package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
public interface IWailaTooltipHandler
{
String transformItemName (IDrawer drawer, String defaultName);
public interface IWailaTooltipHandler {
String transformItemName(IDrawer drawer, String defaultName);
}
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.registry;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -3,7 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.api.render;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import net.minecraft.tileentity.TileEntity;
public interface IRenderLabel
{
void render (TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime);
public interface IRenderLabel {
void render(TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime);
}
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.render;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -3,11 +3,10 @@ package com.jaquadro.minecraft.storagedrawers.api.security;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable;
import com.mojang.authlib.GameProfile;
public interface ISecurityProvider
{
String getProviderID ();
public interface ISecurityProvider {
String getProviderID();
boolean hasOwnership (GameProfile profile, IProtectable target);
boolean hasOwnership(GameProfile profile, IProtectable target);
boolean hasAccess (GameProfile profile, IProtectable target);
boolean hasAccess(GameProfile profile, IProtectable target);
}
@@ -3,19 +3,18 @@ package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public interface IDrawer
{
public interface IDrawer {
/**
* Gets an ItemStack of size 1 representing the type, metadata, and tags of the stored items.
* The returned ItemStack should not be modified for any reason. Make a copy if you need to store or modify it.
*/
ItemStack getStoredItemPrototype ();
ItemStack getStoredItemPrototype();
/**
* Gets an ItemStack initialized to the number of items stored in this drawer.
* The returned ItemStack is guaranteed to be a new copy and can be used for any purpose. Does not affect drawer contents.
*/
ItemStack getStoredItemCopy ();
ItemStack getStoredItemCopy();
/**
* Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced.
@@ -25,7 +24,7 @@ public interface IDrawer
* @deprecated setStoredItem may redirect its set to another IDrawer, so use setStoredItemRedir instead.
*/
@Deprecated
void setStoredItem (ItemStack itemPrototype, int amount);
void setStoredItem(ItemStack itemPrototype, int amount);
/**
* Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced.
@@ -34,12 +33,12 @@ public interface IDrawer
* @param amount The amount to initialize the stored item count to.
* @return The IDrawer actually set with the prototype. Some drawer groups can redirect a set operation to another member.
*/
IDrawer setStoredItemRedir (ItemStack itemPrototype, int amount);
IDrawer setStoredItemRedir(ItemStack itemPrototype, int amount);
/**
* Gets the number of items stored in this drawer.
*/
int getStoredItemCount ();
int getStoredItemCount();
/**
* Sets the number of items stored in this drawer. Triggers syncing of inventories and client data.
@@ -47,30 +46,30 @@ public interface IDrawer
*
* @param amount The new amount of items stored in this drawer.
*/
void setStoredItemCount (int amount);
void setStoredItemCount(int amount);
/**
* Gets the maximum number of items that can be stored in this drawer.
* This value will vary depending on the max stack size of the stored item type.
*/
int getMaxCapacity ();
int getMaxCapacity();
/**
* Gets the maximum number of items that could be stored in this drawer if it held the given item.
*
* @param itemPrototype The item type to query.
*/
int getMaxCapacity (ItemStack itemPrototype);
int getMaxCapacity(ItemStack itemPrototype);
/**
* Gets the number of items that could still be added to this drawer before it is full.
*/
int getRemainingCapacity ();
int getRemainingCapacity();
/**
* Gets the max stack size of the item type stored in this drawer. Convenience method.
*/
int getStoredItemStackSize ();
int getStoredItemStackSize();
/**
* Gets whether or not an item of the given type and data can be stored in this drawer.
@@ -82,7 +81,7 @@ public interface IDrawer
*
* @param itemPrototype An ItemStack representing the type, metadata, and tags of an item.
*/
boolean canItemBeStored (ItemStack itemPrototype);
boolean canItemBeStored(ItemStack itemPrototype);
/**
* Gets whether or not an item of the given type and data can be extracted from this drawer.
@@ -92,13 +91,13 @@ public interface IDrawer
*
* @param itemPrototype An ItemStack representing the type, metadata, and tags of an item.
*/
boolean canItemBeExtracted (ItemStack itemPrototype);
boolean canItemBeExtracted(ItemStack itemPrototype);
/**
* Gets whether or not the drawer has items.
* A drawer set with an item type and 0 count is not considered empty.
*/
boolean isEmpty ();
boolean isEmpty();
/**
* Gets auxiliary data that has been associated with this drawer.
@@ -106,16 +105,16 @@ public interface IDrawer
* @param key The key used to identify the data.
* @return An opaque object that was previously stored.
*/
Object getExtendedData (String key);
Object getExtendedData(String key);
/**
* Stores auxiliary data with this drawer, mainly for use in integration.
* @param key The key to identify the data with.
* @param data The data to store.
*/
void setExtendedData (String key, Object data);
void setExtendedData(String key, Object data);
void writeToNBT (NBTTagCompound tag);
void writeToNBT(NBTTagCompound tag);
void readFromNBT (NBTTagCompound tag);
void readFromNBT(NBTTagCompound tag);
}
@@ -2,24 +2,23 @@ package com.jaquadro.minecraft.storagedrawers.api.storage;
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
public interface IDrawerGroup
{
public interface IDrawerGroup {
/**
* Gets the number of drawers contained within this group.
*/
int getDrawerCount ();
int getDrawerCount();
/**
* Gets the drawer at the given slot within this group.
*/
IDrawer getDrawer (int slot);
IDrawer getDrawer(int slot);
/**
* Gets whether the drawer in the given slot is usable.
*/
boolean isDrawerEnabled (int slot);
boolean isDrawerEnabled(int slot);
IDrawerInventory getDrawerInventory ();
IDrawerInventory getDrawerInventory();
boolean markDirtyIfNeeded ();
boolean markDirtyIfNeeded();
}
@@ -3,13 +3,12 @@ package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IDrawerGroupInteractive extends IDrawerGroup
{
ItemStack takeItemsFromSlot (int slot, int count);
public interface IDrawerGroupInteractive extends IDrawerGroup {
ItemStack takeItemsFromSlot(int slot, int count);
int putItemsIntoSlot (int slot, ItemStack stack, int count);
int putItemsIntoSlot(int slot, ItemStack stack, int count);
int interactPutCurrentItemIntoSlot (int slot, EntityPlayer player);
int interactPutCurrentItemIntoSlot(int slot, EntityPlayer player);
int interactPutCurrentInventoryIntoSlot (int slot, EntityPlayer player);
int interactPutCurrentInventoryIntoSlot(int slot, EntityPlayer player);
}
@@ -4,25 +4,24 @@ package com.jaquadro.minecraft.storagedrawers.api.storage;
* Represents a drawer with items that are a fractional component of another item within the drawer group. Compacting
* Drawers are a primary example of this drawer type.
*/
public interface IFractionalDrawer extends IDrawer
{
public interface IFractionalDrawer extends IDrawer {
/**
* Gets the storage ratio between the held item and the most compressed item within the drawer group.
*
* For example, most ingots have a conversion rate of 9 compared to metal blocks, and nuggets a rate of 81.
* Actual conversion rates are implementation-defined.
*/
int getConversionRate ();
int getConversionRate();
/**
* Gets the number of items left in the drawer if the maximum number of equivalent compressed items had been removed.
* The equivalency is determined by the next compression tier, and not necessarily the conversion rate.
*/
int getStoredItemRemainder ();
int getStoredItemRemainder();
/**
* Gets whether or not the stored item represents the smallest granularity of material that can be stored within
* the drawer group.
*/
boolean isSmallestUnit ();
boolean isSmallestUnit();
}
@@ -1,5 +1,3 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
public interface INetworked
{
}
public interface INetworked {}
@@ -1,10 +1,8 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
public interface IPriorityGroup
{
public interface IPriorityGroup {
/**
* Gets the list of available drawer slots in priority order.
*/
int[] getAccessibleDrawerSlots ();
int[] getAccessibleDrawerSlots();
}
@@ -2,17 +2,16 @@ package com.jaquadro.minecraft.storagedrawers.api.storage;
import net.minecraft.item.ItemStack;
public interface ISmartGroup
{
public interface ISmartGroup {
/**
* Gets a lazy enumeration of all slots that will accept at least one item of the given stack, ordered by
* insertion preference.
*/
Iterable<Integer> enumerateDrawersForInsertion (ItemStack stack, boolean strict);
Iterable<Integer> enumerateDrawersForInsertion(ItemStack stack, boolean strict);
/**
* Gets a lazy enumeration of all slots that will provide at least one item of the given stack, ordered by
* extraction preference.
*/
Iterable<Integer> enumerateDrawersForExtraction (ItemStack stack, boolean strict);
Iterable<Integer> enumerateDrawersForExtraction(ItemStack stack, boolean strict);
}
@@ -9,5 +9,4 @@ public interface IDowngradable {
boolean checkDowngraded();
void setDowngraded(boolean state);
}
@@ -1,21 +1,20 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface ILockable
{
public interface ILockable {
/**
* Gets whether or not a drawer or group is locked for the given lock attribute.
*/
boolean isLocked (LockAttribute attr);
boolean isLocked(LockAttribute attr);
/**
* Gets whether or not the lock state can be changed for the given lock attribute.
* If this method returns false, isLocked may still return true.
*/
boolean canLock (LockAttribute attr);
boolean canLock(LockAttribute attr);
/**
* Sets the lock state of a drawer or group for the given lock attribute.
* If canLock returns false, this is a no-op.
*/
void setLocked (LockAttribute attr, boolean isLocked);
void setLocked(LockAttribute attr, boolean isLocked);
}
@@ -1,31 +1,29 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
import java.util.UUID;
public interface IProtectable
{
public interface IProtectable {
/**
* Gets the owner of the drawer, or null if there is no owner.
*/
UUID getOwner ();
UUID getOwner();
/**
* Sets the owner of the drawer. Set to null to set no owner.
* @return false if the operation is not supported, true otherwise.
*/
boolean setOwner (UUID owner);
boolean setOwner(UUID owner);
/**
* Gets the provider managing security for the target.
* @return null to use the default provider, which enforces strict owner access.
*/
ISecurityProvider getSecurityProvider ();
ISecurityProvider getSecurityProvider();
/**
* Sets the provider managing security for the target. Set to null for default provider.
* @return false if the operation is not supported, true otherwise.
*/
boolean setSecurityProvider (ISecurityProvider provder);
boolean setSecurityProvider(ISecurityProvider provder);
}
@@ -1,16 +1,15 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface ISealable
{
public interface ISealable {
/**
* Gets whether or not the drawer has the sealed attribute.
* A sealed drawer cannot be interacted with, and when broken will retain all of its items and upgrades.
*/
boolean isSealed ();
boolean isSealed();
/**
* Sets whether or not the drawer is currently sealed.
* @return false if the operation is not supported, true otherwise.
*/
boolean setIsSealed (boolean state);
boolean setIsSealed(boolean state);
}
@@ -1,16 +1,15 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface IShroudable
{
public interface IShroudable {
/**
* Gets whether or not the drawer has the shrouded attribute.
* The shrouded attribute instructs the drawer to not render its item label.
*/
boolean isShrouded ();
boolean isShrouded();
/**
* Sets whether or not the drawer is currently shrouded.
* @return false if the operation is not supported, true otherwise.
*/
boolean setIsShrouded (boolean state);
boolean setIsShrouded(boolean state);
}
@@ -1,9 +1,8 @@
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
public interface IVoidable
{
public interface IVoidable {
/**
* Gets whether or not the drawer has a voiding attribute.
*/
boolean isVoid ();
boolean isVoid();
}
@@ -2,34 +2,29 @@ package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import java.util.EnumSet;
public enum LockAttribute
{
public enum LockAttribute {
LOCK_POPULATED,
LOCK_EMPTY;
public int getFlagValue () {
public int getFlagValue() {
return 1 << ordinal();
}
public static int getBitfield (EnumSet<LockAttribute> attributes) {
public static int getBitfield(EnumSet<LockAttribute> attributes) {
int value = 0;
if (attributes == null)
return value;
if (attributes == null) return value;
for (LockAttribute attr : attributes)
value |= attr.getFlagValue();
for (LockAttribute attr : attributes) value |= attr.getFlagValue();
return value;
}
public static EnumSet<LockAttribute> getEnumSet (int bitfield) {
if (bitfield == 0)
return null;
public static EnumSet<LockAttribute> getEnumSet(int bitfield) {
if (bitfield == 0) return null;
EnumSet<LockAttribute> set = EnumSet.noneOf(LockAttribute.class);
for (LockAttribute attr : values()) {
if ((bitfield & attr.getFlagValue()) != 0)
set.add(attr);
if ((bitfield & attr.getFlagValue()) != 0) set.add(attr);
}
return set;
@@ -1,5 +1,8 @@
@API(owner = "StorageDrawersAPI", provides = "StorageDrawersAPI|storage-attribute", apiVersion = StorageDrawersApi.VERSION)
@API(
owner = "StorageDrawersAPI",
provides = "StorageDrawersAPI|storage-attribute",
apiVersion = StorageDrawersApi.VERSION)
package com.jaquadro.minecraft.storagedrawers.api.storage.attribute;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -2,4 +2,4 @@
package com.jaquadro.minecraft.storagedrawers.api.storage;
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
import cpw.mods.fml.common.API;
import cpw.mods.fml.common.API;
@@ -8,6 +8,7 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersComp;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -19,10 +20,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
public class BlockCompDrawers extends BlockDrawers implements INetworked
{
public class BlockCompDrawers extends BlockDrawers implements INetworked {
@SideOnly(Side.CLIENT)
private IIcon[] iconFront;
@@ -31,52 +29,51 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked
@SideOnly(Side.CLIENT)
private IIcon iconTrim;
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconSideEtched;
public BlockCompDrawers (String blockName) {
public BlockCompDrawers(String blockName) {
super(Material.rock, blockName, 3, false);
setStepSound(Block.soundTypeStone);
}
@Override
protected int getDrawerSlot (int side, float hitX, float hitY, float hitZ) {
if (hitTop(hitY))
return 0;
protected int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
if (hitTop(hitY)) return 0;
if (hitLeft(side, hitX, hitZ))
return 1;
else
return 2;
if (hitLeft(side, hitX, hitZ)) return 1;
else return 2;
}
@Override
public BlockType retrimType () {
public BlockType retrimType() {
return null;
}
@Override
public TileEntityDrawers createNewTileEntity (World world, int meta) {
public TileEntityDrawers createNewTileEntity(World world, int meta) {
return new TileEntityDrawersComp();
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
list.add(new ItemStack(item, 1, 0));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconTrim (int meta) {
public IIcon getIconTrim(int meta) {
return iconTrim;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
switch (side) {
case 0:
case 1:
@@ -89,21 +86,16 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked
}
@Override
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
TileEntityDrawers tile = getTileEntity(blockAccess, x, y, z);
if (tile == null)
return iconFront[0];
if (tile == null) return iconFront[0];
if (side == tile.getDirection()) {
if (tile.getEffectiveStatusLevel() == 0) {
if (tile.isDrawerEnabled(2) && tile.getDrawer(2).getStoredItemStackSize() > 0)
return iconFront[2];
else if (tile.isDrawerEnabled(1) && tile.getDrawer(1).getStoredItemStackSize() > 0)
return iconFront[1];
else
return iconFront[0];
}
else {
if (tile.isDrawerEnabled(2) && tile.getDrawer(2).getStoredItemStackSize() > 0) return iconFront[2];
else if (tile.isDrawerEnabled(1) && tile.getDrawer(1).getStoredItemStackSize() > 0) return iconFront[1];
else return iconFront[0];
} else {
IDrawer main = tile.getDrawer(0);
int plev = 0;
@@ -118,8 +110,7 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked
return iconFrontInd[2][plev];
else if (tile.isDrawerEnabled(1) && tile.getDrawer(1).getStoredItemStackSize() > 0)
return iconFrontInd[1][plev];
else
return iconFrontInd[0][plev];
else return iconFrontInd[0][plev];
}
}
@@ -133,7 +124,7 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked
}
@Override
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
iconFront = new IIcon[3];
@@ -143,7 +134,8 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked
iconFront[i] = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_front_" + i);
iconFrontInd[i][0] = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_front_" + i + "_ind");
for (int j = 1; j <= 6; j++)
iconFrontInd[i][j] = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_front_" + i + "_ind" + j);
iconFrontInd[i][j] =
register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_front_" + i + "_ind" + j);
}
iconTrim = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_trim");
@@ -10,6 +10,8 @@ import com.jaquadro.minecraft.storagedrawers.core.ModItems;
import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -24,21 +26,20 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.EnumSet;
import java.util.Random;
public class BlockController extends BlockContainer implements INetworked
{
public class BlockController extends BlockContainer implements INetworked {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconSideEtched;
@SideOnly(Side.CLIENT)
private IIcon iconTrim;
public BlockController (String blockName) {
public BlockController(String blockName) {
super(Material.rock);
this.useNeighborBrightness = true;
@@ -53,30 +54,29 @@ public class BlockController extends BlockContainer implements INetworked
}
@Override
public boolean renderAsNormalBlock () {
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube () {
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType () {
public int getRenderType() {
return StorageDrawers.proxy.controllerRenderID;
}
@Override
public int tickRate (World world) {
public int tickRate(World world) {
return 100;
}
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
TileEntityController tile = getTileEntitySafe(world, x, y, z);
if (tile.getDirection() > 1)
return;
if (tile.getDirection() > 1) return;
int quadrant = MathHelper.floor_double((entity.rotationYaw * 4f / 360f) + .5) & 3;
switch (quadrant) {
@@ -94,8 +94,7 @@ public class BlockController extends BlockContainer implements INetworked
break;
}
if (itemStack.hasDisplayName())
tile.setInventoryName(itemStack.getDisplayName());
if (itemStack.hasDisplayName()) tile.setInventoryName(itemStack.getDisplayName());
if (world.isRemote) {
tile.invalidate();
@@ -104,36 +103,34 @@ public class BlockController extends BlockContainer implements INetworked
}
@Override
public void onPostBlockPlaced (World world, int x, int y, int z, int meta) {
if (world.isRemote)
return;
public void onPostBlockPlaced(World world, int x, int y, int z, int meta) {
if (world.isRemote) return;
TileEntityController te = getTileEntity(world, x, y, z);
if (te == null)
return;
if (te == null) return;
te.updateCache();
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntityController te = getTileEntitySafe(world, x, y, z);
ItemStack item = player.inventory.getCurrentItem();
if (item != null && item.getItem() != null) {
if (item.getItem() == ModItems.shroudKey) {
if (!world.isRemote)
te.toggleShroud(player.getGameProfile());
if (!world.isRemote) te.toggleShroud(player.getGameProfile());
return true;
}
else if (item.getItem() == ModItems.upgradeLock) {
} else if (item.getItem() == ModItems.upgradeLock) {
if (!world.isRemote)
te.toggleLock(EnumSet.allOf(LockAttribute.class), LockAttribute.LOCK_POPULATED, player.getGameProfile());
te.toggleLock(
EnumSet.allOf(LockAttribute.class), LockAttribute.LOCK_POPULATED, player.getGameProfile());
return true;
}
else if (item.getItem() == ModItems.personalKey) {
} else if (item.getItem() == ModItems.personalKey) {
if (!world.isRemote) {
String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage());
String securityKey =
((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage());
ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey);
te.toggleProtection(player.getGameProfile(), provider);
@@ -143,24 +140,20 @@ public class BlockController extends BlockContainer implements INetworked
}
}
if (te.getDirection() != side)
return false;
if (te.getDirection() != side) return false;
if (!world.isRemote)
te.interactPutItemsIntoInventory(player);
if (!world.isRemote) te.interactPutItemsIntoInventory(player);
return true;
}
@Override
public boolean rotateBlock (World world, int x, int y, int z, ForgeDirection axis) {
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
TileEntityController tile = getTileEntitySafe(world, x, y, z);
if (tile.getDirection() == axis.ordinal())
return false;
if (tile.getDirection() == axis.ordinal()) return false;
if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN)
return false;
if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) return false;
tile.setDirection(axis.ordinal());
world.markBlockForUpdate(x, y, z);
@@ -169,23 +162,19 @@ public class BlockController extends BlockContainer implements INetworked
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (getTileEntity(world, x, y, z) == null)
return true;
if (side.ordinal() != getTileEntity(world, x, y, z).getDirection())
return true;
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (getTileEntity(world, x, y, z) == null) return true;
if (side.ordinal() != getTileEntity(world, x, y, z).getDirection()) return true;
return false;
}
@Override
public void updateTick (World world, int x, int y, int z, Random rand) {
if (world.isRemote)
return;
public void updateTick(World world, int x, int y, int z, Random rand) {
if (world.isRemote) return;
TileEntityController te = getTileEntity(world, x, y, z);
if (te == null)
return;
if (te == null) return;
te.updateCache();
@@ -194,7 +183,7 @@ public class BlockController extends BlockContainer implements INetworked
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
switch (side) {
case 0:
case 1:
@@ -208,13 +197,11 @@ public class BlockController extends BlockContainer implements INetworked
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
TileEntityController tile = getTileEntity(blockAccess, x, y, z);
if (tile == null)
return iconFront;
if (tile == null) return iconFront;
if (side == tile.getDirection())
return iconFront;
if (side == tile.getDirection()) return iconFront;
switch (side) {
case 0:
@@ -226,21 +213,21 @@ public class BlockController extends BlockContainer implements INetworked
}
@SideOnly(Side.CLIENT)
public IIcon getIconTrim (int meta) {
public IIcon getIconTrim(int meta) {
return iconTrim;
}
@Override
public TileEntityController createNewTileEntity (World world, int meta) {
public TileEntityController createNewTileEntity(World world, int meta) {
return new TileEntityController();
}
public TileEntityController getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
public TileEntityController getTileEntity(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity tile = blockAccess.getTileEntity(x, y, z);
return (tile instanceof TileEntityController) ? (TileEntityController) tile : null;
}
public TileEntityController getTileEntitySafe (World world, int x, int y, int z) {
public TileEntityController getTileEntitySafe(World world, int x, int y, int z) {
TileEntityController tile = getTileEntity(world, x, y, z);
if (tile == null) {
tile = createNewTileEntity(world, world.getBlockMetadata(x, y, z));
@@ -252,7 +239,7 @@ public class BlockController extends BlockContainer implements INetworked
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
iconFront = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_controller_front");
iconSide = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side");
iconSideEtched = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side_2");
@@ -19,11 +19,16 @@ import com.jaquadro.minecraft.storagedrawers.item.ItemTrim;
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgrade;
import com.jaquadro.minecraft.storagedrawers.item.ItemUpgradeCreative;
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
import com.jaquadro.minecraft.storagedrawers.security.SecurityManager;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@@ -48,16 +53,9 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.logging.log4j.Level;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class BlockDrawers extends BlockContainer implements IExtendedBlockClickHandler, INetworked
{
private static final ResourceLocation blockConfig = new ResourceLocation(StorageDrawers.MOD_ID + ":textures/blocks/block_config.mcmeta");
public class BlockDrawers extends BlockContainer implements IExtendedBlockClickHandler, INetworked {
private static final ResourceLocation blockConfig =
new ResourceLocation(StorageDrawers.MOD_ID + ":textures/blocks/block_config.mcmeta");
public final boolean halfDepth;
public final int drawerCount;
@@ -72,41 +70,55 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
@SideOnly(Side.CLIENT)
protected IIcon[] iconSide;
@SideOnly(Side.CLIENT)
protected IIcon[] iconSideV;
@SideOnly(Side.CLIENT)
protected IIcon[] iconSideH;
@SideOnly(Side.CLIENT)
protected IIcon[] iconFront1;
@SideOnly(Side.CLIENT)
protected IIcon[] iconFront2;
@SideOnly(Side.CLIENT)
protected IIcon[] iconFront4;
@SideOnly(Side.CLIENT)
protected IIcon[] iconTrim;
@SideOnly(Side.CLIENT)
private IIcon[] iconOverlay;
@SideOnly(Side.CLIENT)
private IIcon[] iconOverlayV;
@SideOnly(Side.CLIENT)
private IIcon[] iconOverlayH;
@SideOnly(Side.CLIENT)
private IIcon[] iconOverlayTrim;
@SideOnly(Side.CLIENT)
private IIcon[] iconIndicator1;
@SideOnly(Side.CLIENT)
private IIcon[] iconIndicator2;
@SideOnly(Side.CLIENT)
private IIcon[] iconIndicator4;
@SideOnly(Side.CLIENT)
private IIcon iconLock;
@SideOnly(Side.CLIENT)
private IIcon iconClaim;
@SideOnly(Side.CLIENT)
private IIcon iconClaimLock;
@SideOnly(Side.CLIENT)
private IIcon iconVoid;
@@ -115,11 +127,11 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
private long ignoreEventTime;
public BlockDrawers (String blockName, int drawerCount, boolean halfDepth) {
public BlockDrawers(String blockName, int drawerCount, boolean halfDepth) {
this(Material.wood, blockName, drawerCount, halfDepth);
}
protected BlockDrawers (Material material, String blockName, int drawerCount, boolean halfDepth) {
protected BlockDrawers(Material material, String blockName, int drawerCount, boolean halfDepth) {
super(material);
this.drawerCount = drawerCount;
@@ -134,9 +146,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
setLightOpacity(255);
}
public boolean retrimBlock (World world, int x, int y, int z, ItemStack prototype) {
if (retrimType() == null)
return false;
public boolean retrimBlock(World world, int x, int y, int z, ItemStack prototype) {
if (retrimType() == null) return false;
Block protoBlock = Block.getBlockFromItem(prototype.getItem());
int protoMeta = prototype.getItemDamage();
@@ -149,8 +160,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
Block newBlock = StorageDrawers.blockRegistry.getBlock(config, plankBlock, plankMeta);
int newMeta = StorageDrawers.blockRegistry.getMeta(config, plankBlock, plankMeta);
if (newBlock == null)
return false;
if (newBlock == null) return false;
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (newBlock == this && newMeta == world.getBlockMetadata(x, y, z) && !tile.shouldHideUpgrades()) {
@@ -158,8 +168,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return true;
}
if (newBlock == this)
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
if (newBlock == this) world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
else {
TileEntity newDrawer = createNewTileEntity(world, newMeta);
@@ -178,56 +187,56 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return true;
}
public BlockType retrimType () {
public BlockType retrimType() {
return BlockType.Drawers;
}
public float getTrimWidth () {
public float getTrimWidth() {
return trimWidth;
}
public float getTrimDepth () {
public float getTrimDepth() {
return trimDepth;
}
public float getIndStart () {
public float getIndStart() {
return indStart;
}
public float getIndEnd () {
public float getIndEnd() {
return indEnd;
}
public int getIndSteps () {
public int getIndSteps() {
return indSteps;
}
public BlockDrawers setConfigName (String name) {
public BlockDrawers setConfigName(String name) {
blockConfigName = name;
return this;
}
public String getConfigName () {
public String getConfigName() {
return blockConfigName;
}
@Override
public boolean renderAsNormalBlock () {
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube () {
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType () {
public int getRenderType() {
return StorageDrawers.proxy.drawersRenderID;
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess blockAccess, int x, int y, int z) {
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
TileEntityDrawers tile = getTileEntity(blockAccess, x, y, z);
if (tile == null) {
setBlockBounds(0, 0, 0, 1, 1, 1);
@@ -252,24 +261,22 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public void setBlockBoundsForItemRender () {
if (halfDepth)
setBlockBounds(0, 0, 0, 1, 1, .5f);
else
setBlockBounds(0, 0, 0, 1, 1, 1);
public void setBlockBoundsForItemRender() {
if (halfDepth) setBlockBounds(0, 0, 0, 1, 1, .5f);
else setBlockBounds(0, 0, 0, 1, 1, 1);
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
public void addCollisionBoxesToList(
World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
}
@Override
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
TileEntityDrawers tile = getTileEntitySafe(world, x, y, z);
if (tile.getDirection() > 1)
return;
if (tile.getDirection() > 1) return;
int quadrant = MathHelper.floor_double((entity.rotationYaw * 4f / 360f) + .5) & 3;
switch (quadrant) {
@@ -287,8 +294,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
break;
}
if (itemStack.hasDisplayName())
tile.setInventoryName(itemStack.getDisplayName());
if (itemStack.hasDisplayName()) tile.setInventoryName(itemStack.getDisplayName());
if (world.isRemote) {
tile.invalidate();
@@ -297,7 +303,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote && Minecraft.getMinecraft().getSystemTime() == ignoreEventTime) {
ignoreEventTime = 0;
return false;
@@ -306,8 +313,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z);
ItemStack item = player.inventory.getCurrentItem();
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers))
return false;
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) return false;
if (StorageDrawers.config.cache.debugTrace) {
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockActivated");
@@ -316,8 +322,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
if (item != null && item.getItem() != null) {
if (item.getItem() instanceof ItemTrim && player.isSneaking()) {
if (!retrimBlock(world, x, y, z, item))
return false;
if (!retrimBlock(world, x, y, z, item)) return false;
if (player != null && !player.capabilities.isCreativeMode) {
if (--item.stackSize <= 0)
@@ -331,8 +336,12 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
* and it would great if we could just find if it was an instance of said thing.
* Crazy concept!
* */
else if (item.getItem() == ModItems.upgrade || item.getItem() == ModItems.upgradeStatus || item.getItem() == ModItems.upgradeVoid ||
item.getItem() == ModItems.upgradeCreative || item.getItem() == ModItems.upgradeRedstone || item.getItem() == ModItems.upgradeDowngrade) {
else if (item.getItem() == ModItems.upgrade
|| item.getItem() == ModItems.upgradeStatus
|| item.getItem() == ModItems.upgradeVoid
|| item.getItem() == ModItems.upgradeCreative
|| item.getItem() == ModItems.upgradeRedstone
|| item.getItem() == ModItems.upgradeDowngrade) {
if (!tileDrawers.addUpgrade(item)) {
player.addChatMessage(new ChatComponentTranslation("storagedrawers.msg.maxUpgrades"));
return false;
@@ -346,82 +355,65 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
return true;
}
else if (item.getItem() == ModItems.upgradeLock) {
} else if (item.getItem() == ModItems.upgradeLock) {
boolean locked = tileDrawers.isLocked(LockAttribute.LOCK_POPULATED);
tileDrawers.setLocked(LockAttribute.LOCK_POPULATED, !locked);
tileDrawers.setLocked(LockAttribute.LOCK_EMPTY, !locked);
return true;
}
else if (item.getItem() == ModItems.shroudKey) {
} else if (item.getItem() == ModItems.shroudKey) {
tileDrawers.setIsShrouded(!tileDrawers.isShrouded());
return true;
}
else if (item.getItem() instanceof ItemPersonalKey) {
} else if (item.getItem() instanceof ItemPersonalKey) {
String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage());
ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey);
if (tileDrawers.getOwner() == null) {
tileDrawers.setOwner(player.getPersistentID());
tileDrawers.setSecurityProvider(provider);
}
else if (SecurityManager.hasOwnership(player.getGameProfile(), tileDrawers)) {
} else if (SecurityManager.hasOwnership(player.getGameProfile(), tileDrawers)) {
tileDrawers.setOwner(null);
tileDrawers.setSecurityProvider(null);
}
else
return false;
} else return false;
return true;
}
else if (item.getItem() == ModItems.tape)
return false;
}
else if (item == null && player.isSneaking()) {
} else if (item.getItem() == ModItems.tape) return false;
} else if (item == null && player.isSneaking()) {
if (tileDrawers.isSealed()) {
tileDrawers.setIsSealed(false);
return true;
}
else if (StorageDrawers.config.cache.enableDrawerUI) {
} else if (StorageDrawers.config.cache.enableDrawerUI) {
player.openGui(StorageDrawers.instance, GuiHandler.drawersGuiID, world, x, y, z);
return true;
}
}
if (tileDrawers.getDirection() != side)
return false;
if (tileDrawers.getDirection() != side) return false;
if (tileDrawers.isSealed())
return false;
if (tileDrawers.isSealed()) return false;
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
IDrawer drawer = tileDrawers.getDrawer(slot);
ItemStack currentStack = drawer.getStoredItemPrototype();
int countAdded = tileDrawers.interactPutItemsIntoSlot(slot, player);
if (countAdded > 0 && currentStack != null)
world.markBlockForUpdate(x, y, z);
if (countAdded > 0 && currentStack != null) world.markBlockForUpdate(x, y, z);
return true;
}
protected int getDrawerSlot (int side, float hitX, float hitY, float hitZ) {
if (drawerCount == 1)
return 0;
if (drawerCount == 2)
return hitTop(hitY) ? 0 : 1;
protected int getDrawerSlot(int side, float hitX, float hitY, float hitZ) {
if (drawerCount == 1) return 0;
if (drawerCount == 2) return hitTop(hitY) ? 0 : 1;
if (hitLeft(side, hitX, hitZ))
return hitTop(hitY) ? 0 : 1;
else
return hitTop(hitY) ? 2 : 3;
if (hitLeft(side, hitX, hitZ)) return hitTop(hitY) ? 0 : 1;
else return hitTop(hitY) ? 2 : 3;
}
protected boolean hitTop (float hitY) {
protected boolean hitTop(float hitY) {
return hitY > .5;
}
protected boolean hitLeft (int side, float hitX, float hitZ) {
protected boolean hitLeft(int side, float hitX, float hitZ) {
switch (side) {
case 2:
return hitX > .5;
@@ -437,14 +429,15 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player) {
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (world.isRemote) {
MovingObjectPosition posn = Minecraft.getMinecraft().objectMouseOver;
float hitX = (float)(posn.hitVec.xCoord - posn.blockX);
float hitY = (float)(posn.hitVec.yCoord - posn.blockY);
float hitZ = (float)(posn.hitVec.zCoord - posn.blockZ);
float hitX = (float) (posn.hitVec.xCoord - posn.blockX);
float hitY = (float) (posn.hitVec.yCoord - posn.blockY);
float hitZ = (float) (posn.hitVec.zCoord - posn.blockZ);
StorageDrawers.network.sendToServer(new BlockClickMessage(x, y, z, posn.sideHit, hitX, hitY, hitZ, StorageDrawers.config.cache.invertShift));
StorageDrawers.network.sendToServer(new BlockClickMessage(
x, y, z, posn.sideHit, hitX, hitY, hitZ, StorageDrawers.config.cache.invertShift));
if (StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockClicked with " + posn.toString());
@@ -452,25 +445,32 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ, boolean invertShift) {
public void onBlockClicked(
World world,
int x,
int y,
int z,
EntityPlayer player,
int side,
float hitX,
float hitY,
float hitZ,
boolean invertShift) {
if (StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "IExtendedBlockClickHandler.onBlockClicked");
if (!player.capabilities.isCreativeMode) {
PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(player, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, x, y, z, side, world);
if (event.isCanceled())
return;
PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(
player, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, x, y, z, side, world);
if (event.isCanceled()) return;
}
TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z);
if (tileDrawers.getDirection() != side)
return;
if (tileDrawers.getDirection() != side) return;
if (tileDrawers.isSealed())
return;
if (tileDrawers.isSealed()) return;
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers))
return;
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) return;
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
IDrawer drawer = tileDrawers.getDrawer(slot);
@@ -479,8 +479,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
// if invertSHift is true this will happen when the player is not shifting
if (player.isSneaking() != invertShift)
item = tileDrawers.takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
else
item = tileDrawers.takeItemsFromSlot(slot, 1);
else item = tileDrawers.takeItemsFromSlot(slot, 1);
if (StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item.toString());
@@ -490,14 +489,19 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
ForgeDirection dir = ForgeDirection.getOrientation(side);
dropItemStack(world, x + dir.offsetX, y, z + dir.offsetZ, player, item);
world.markBlockForUpdate(x, y, z);
}
else
world.playSoundEffect(x + .5f, y + .5f, z + .5f, "random.pop", .2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * .7f + 1) * 2);
} else
world.playSoundEffect(
x + .5f,
y + .5f,
z + .5f,
"random.pop",
.2f,
((world.rand.nextFloat() - world.rand.nextFloat()) * .7f + 1) * 2);
}
}
@Override
public boolean rotateBlock (World world, int x, int y, int z, ForgeDirection axis) {
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
TileEntityDrawers tile = getTileEntitySafe(world, x, y, z);
if (tile.isSealed()) {
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
@@ -505,49 +509,42 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return true;
}
if (tile.getDirection() == axis.ordinal())
return false;
if (tile.getDirection() == axis.ordinal()) return false;
if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN)
return false;
if (axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) return false;
tile.setDirection(axis.ordinal());
world.markBlockForUpdate(x, y, z);
if (world.isRemote)
ignoreEventTime = Minecraft.getMinecraft().getSystemTime();
if (world.isRemote) ignoreEventTime = Minecraft.getMinecraft().getSystemTime();
return true;
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (halfDepth)
return false;
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if (halfDepth) return false;
if (side == ForgeDirection.DOWN) {
Block blockUnder = world.getBlock(x, y - 1, z);
if (blockUnder instanceof BlockChest || blockUnder instanceof BlockEnderChest)
return false;
if (blockUnder instanceof BlockChest || blockUnder instanceof BlockEnderChest) return false;
}
if (getTileEntity(world, x, y, z) == null)
return true;
if (side.ordinal() != getTileEntity(world, x, y, z).getDirection())
return true;
if (getTileEntity(world, x, y, z) == null) return true;
if (side.ordinal() != getTileEntity(world, x, y, z).getDirection()) return true;
return false;
}
private void dropItemStack (World world, int x, int y, int z, EntityPlayer player, ItemStack stack) {
private void dropItemStack(World world, int x, int y, int z, EntityPlayer player, ItemStack stack) {
EntityItem entity = new EntityItem(world, x + .5f, y + .5f, z + .5f, stack);
entity.addVelocity(-entity.motionX, -entity.motionY, -entity.motionZ);
world.spawnEntityInWorld(entity);
}
@Override
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z) {
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
if (world.isRemote && player.capabilities.isCreativeMode) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
MovingObjectPosition posn = Minecraft.getMinecraft().objectMouseOver;
@@ -562,29 +559,26 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int meta) {
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile != null && !tile.isSealed()) {
for (int i = 0; i < tile.getUpgradeSlotCount(); i++) {
ItemStack stack = tile.getUpgrade(i);
if (stack != null) {
if (stack.getItem() instanceof ItemUpgradeCreative)
continue;
if (stack.getItem() instanceof ItemUpgradeCreative) continue;
dropBlockAsItem(world, x, y, z, stack);
}
}
if (!tile.isVending()) {
for (int i = 0; i < tile.getDrawerCount(); i++) {
if (!tile.isDrawerEnabled(i))
continue;
if (!tile.isDrawerEnabled(i)) continue;
IDrawer drawer = tile.getDrawer(i);
while (drawer.getStoredItemCount() > 0) {
ItemStack stack = tile.takeItemsFromSlot(i, drawer.getStoredItemStackSize());
if (stack == null || stack.stackSize == 0)
break;
if (stack == null || stack.stackSize == 0) break;
dropStackInBatches(world, x, y, z, stack);
}
@@ -597,7 +591,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
super.breakBlock(world, x, y, z, block, meta);
}
private void dropStackInBatches (World world, int x, int y, int z, ItemStack stack) {
private void dropStackInBatches(World world, int x, int y, int z, ItemStack stack) {
Random rand = world.rand;
float ex = rand.nextFloat() * .8f + .1f;
@@ -607,11 +601,15 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
EntityItem entity;
for (; stack.stackSize > 0; world.spawnEntityInWorld(entity)) {
int stackPartSize = rand.nextInt(21) + 10;
if (stackPartSize > stack.stackSize)
stackPartSize = stack.stackSize;
if (stackPartSize > stack.stackSize) stackPartSize = stack.stackSize;
stack.stackSize -= stackPartSize;
entity = new EntityItem(world, x + ex, y + ey, z + ez, new ItemStack(stack.getItem(), stackPartSize, stack.getItemDamage()));
entity = new EntityItem(
world,
x + ex,
y + ey,
z + ez,
new ItemStack(stack.getItem(), stackPartSize, stack.getItemDamage()));
float motionUnit = .05f;
entity.motionX = rand.nextGaussian() * motionUnit;
@@ -619,46 +617,44 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
entity.motionZ = rand.nextGaussian() * motionUnit;
if (stack.hasTagCompound())
entity.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
entity.getEntityItem()
.setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
}
@Override
public int damageDropped (int meta) {
public int damageDropped(int meta) {
return meta;
}
@Override
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (willHarvest)
return true;
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (willHarvest) return true;
return super.removedByPlayer(world, player, x, y, z, willHarvest);
}
@Override
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta) {
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
super.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
}
@Override
public ArrayList<ItemStack> getDrops (World world, int x, int y, int z, int metadata, int fortune) {
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ItemStack dropStack = getMainDrop(world, x, y, z, metadata);
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(dropStack);
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile == null || !tile.isSealed())
return drops;
if (tile == null || !tile.isSealed()) return drops;
NBTTagCompound tiledata = new NBTTagCompound();
tile.writeToNBT(tiledata);
NBTTagCompound data = dropStack.getTagCompound();
if (data == null)
data = new NBTTagCompound();
if (data == null) data = new NBTTagCompound();
data.setTag("tile", tiledata);
dropStack.setTagCompound(data);
@@ -666,18 +662,25 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return drops;
}
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
protected ItemStack getMainDrop(World world, int x, int y, int z, int metadata) {
return new ItemStack(Item.getItemFromBlock(this), 1, metadata);
}
@Override
public float getExplosionResistance (Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
public float getExplosionResistance(
Entity par1Entity,
World world,
int x,
int y,
int z,
double explosionX,
double explosionY,
double explosionZ) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile != null) {
for (int slot = 0; slot < 5; slot++) {
ItemStack stack = tile.getUpgrade(slot);
if (stack == null || !(stack.getItem() instanceof ItemUpgrade) || stack.getItemDamage() != 4)
continue;
if (stack == null || !(stack.getItem() instanceof ItemUpgrade) || stack.getItemDamage() != 4) continue;
return 1000;
}
@@ -687,16 +690,16 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@Override
public TileEntityDrawers createNewTileEntity (World world, int meta) {
public TileEntityDrawers createNewTileEntity(World world, int meta) {
return new TileEntityDrawersStandard();
}
public TileEntityDrawers getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
public TileEntityDrawers getTileEntity(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity tile = blockAccess.getTileEntity(x, y, z);
return (tile instanceof TileEntityDrawers) ? (TileEntityDrawers) tile : null;
}
public TileEntityDrawers getTileEntitySafe (World world, int x, int y, int z) {
public TileEntityDrawers getTileEntitySafe(World world, int x, int y, int z) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile == null) {
tile = createNewTileEntity(world, world.getBlockMetadata(x, y, z));
@@ -708,11 +711,10 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
TileEntity tile = worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ);
if (tile instanceof TileEntityDrawers) {
if (((TileEntityDrawers) tile).getDirection() == target.sideHit)
return true;
if (((TileEntityDrawers) tile).getDirection() == target.sideHit) return true;
}
return super.addHitEffects(worldObj, target, effectRenderer);
@@ -727,46 +729,43 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}*/
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
list.add(new ItemStack(item, 1, 0));
if (StorageDrawers.config.cache.creativeTabVanillaWoods) {
for (int i = 1; i < BlockWood.field_150096_a.length; i++)
list.add(new ItemStack(item, 1, i));
for (int i = 1; i < BlockWood.field_150096_a.length; i++) list.add(new ItemStack(item, 1, i));
}
}
@Override
public boolean canProvidePower () {
public boolean canProvidePower() {
return true;
}
@Override
public int isProvidingWeakPower (IBlockAccess blockAccess, int x, int y, int z, int dir) {
if (!canProvidePower())
return 0;
public int isProvidingWeakPower(IBlockAccess blockAccess, int x, int y, int z, int dir) {
if (!canProvidePower()) return 0;
TileEntityDrawers tile = getTileEntity(blockAccess, x, y, z);
if (tile == null || !tile.isRedstone())
return 0;
if (tile == null || !tile.isRedstone()) return 0;
return tile.getRedstoneLevel();
}
@Override
public int isProvidingStrongPower (IBlockAccess blockAccess, int x, int y, int z, int dir) {
public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int dir) {
return (dir == 1) ? isProvidingWeakPower(blockAccess, x, y, z, dir) : 0;
}
@SideOnly(Side.CLIENT)
public IIcon getIconTrim (int meta) {
public IIcon getIconTrim(int meta) {
meta = (meta < 0 || meta >= iconTrim.length) ? 0 : meta;
return iconTrim[meta];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
switch (side) {
@@ -778,9 +777,12 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return halfDepth ? iconSideV[meta] : iconSide[meta];
case 4:
switch (drawerCount) {
case 1: return iconFront1[meta];
case 2: return iconFront2[meta];
case 4: return iconFront4[meta];
case 1:
return iconFront1[meta];
case 2:
return iconFront2[meta];
case 4:
return iconFront4[meta];
}
return null;
case 5:
@@ -792,22 +794,20 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side) {
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
return getIcon(blockAccess, x, y, z, side, 0);
}
@SideOnly(Side.CLIENT)
public IIcon getOverlayIcon (IBlockAccess blockAccess, int x, int y, int z, int side, int level) {
if (level == 0)
return null;
public IIcon getOverlayIcon(IBlockAccess blockAccess, int x, int y, int z, int side, int level) {
if (level == 0) return null;
return getIcon(blockAccess, x, y, z, side, level);
}
@SideOnly(Side.CLIENT)
public IIcon getOverlayIconTrim (int level) {
if (level == 0)
return null;
public IIcon getOverlayIconTrim(int level) {
if (level == 0) return null;
level = (level < 0 || level >= iconOverlayTrim.length) ? 0 : level;
@@ -815,19 +815,16 @@ 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) {
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;
level = (level < 0 || level >= iconOverlay.length) ? 0 : level;
TileEntityDrawers tile = getTileEntity(blockAccess, x, y, z);
if (tile == null || side == tile.getDirection()) {
if (drawerCount == 1)
return iconFront1[meta];
else if (drawerCount == 2)
return iconFront2[meta];
else
return iconFront4[meta];
if (drawerCount == 1) return iconFront1[meta];
else if (drawerCount == 2) return iconFront2[meta];
else return iconFront4[meta];
}
switch (side) {
@@ -875,40 +872,41 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@SideOnly(Side.CLIENT)
public IIcon getIndicatorIcon (int drawerCount, boolean on) {
public IIcon getIndicatorIcon(int drawerCount, boolean on) {
int onIndex = on ? 1 : 0;
switch (drawerCount) {
case 1: return iconIndicator1[onIndex];
case 2: return iconIndicator2[onIndex];
case 4: return iconIndicator4[onIndex];
case 1:
return iconIndicator1[onIndex];
case 2:
return iconIndicator2[onIndex];
case 4:
return iconIndicator4[onIndex];
}
return null;
}
@SideOnly(Side.CLIENT)
public IIcon getLockIcon (boolean locked, boolean claimed) {
if (locked && claimed)
return iconClaimLock;
else if (locked)
return iconLock;
else if (claimed)
return iconClaim;
else
return null;
public IIcon getLockIcon(boolean locked, boolean claimed) {
if (locked && claimed) return iconClaimLock;
else if (locked) return iconLock;
else if (claimed) return iconClaim;
else return null;
}
@SideOnly(Side.CLIENT)
public IIcon getVoidIcon () {
public IIcon getVoidIcon() {
return iconVoid;
}
@SideOnly(Side.CLIENT)
public IIcon getTapeIcon () { return iconTaped; }
public IIcon getTapeIcon() {
return iconTaped;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
String[] subtex = BlockWood.field_150096_a;
iconSide = new IIcon[subtex.length];
@@ -931,7 +929,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
iconTaped = register.registerIcon(StorageDrawers.MOD_ID + ":tape");
String[] overlays = new String[] { null, null, "iron", "gold", "obsidian", "diamond", "emerald" };
String[] overlays = new String[] {null, null, "iron", "gold", "obsidian", "diamond", "emerald"};
iconOverlay = new IIcon[overlays.length];
iconOverlayH = new IIcon[overlays.length];
@@ -965,9 +963,10 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
}
@SideOnly(Side.CLIENT)
protected void loadBlockConfig () {
protected void loadBlockConfig() {
try {
IResource configResource = Minecraft.getMinecraft().getResourceManager().getResource(blockConfig);
IResource configResource =
Minecraft.getMinecraft().getResourceManager().getResource(blockConfig);
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(configResource.getInputStream()));
@@ -979,15 +978,11 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
trimWidth = entry.get("trimWidth").getAsFloat();
if (entry.has("trimDepth"))
trimDepth = entry.get("trimDepth").getAsFloat();
if (entry.has("indStart"))
indStart = entry.get("indStart").getAsFloat();
if (entry.has("indEnd"))
indEnd = entry.get("indEnd").getAsFloat();
if (entry.has("indSteps"))
indSteps = entry.get("indSteps").getAsInt();
if (entry.has("indStart")) indStart = entry.get("indStart").getAsFloat();
if (entry.has("indEnd")) indEnd = entry.get("indEnd").getAsFloat();
if (entry.has("indSteps")) indSteps = entry.get("indSteps").getAsInt();
}
}
finally {
} finally {
IOUtils.closeQuietly(reader);
}
} catch (IOException e) {
@@ -7,24 +7,22 @@ import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomDrawers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
public class BlockDrawersCustom extends BlockDrawers
{
public class BlockDrawersCustom extends BlockDrawers {
@SideOnly(Side.CLIENT)
private IIcon overlayHandle;
@SideOnly(Side.CLIENT)
private IIcon overlayFaceShadow;
@SideOnly(Side.CLIENT)
private IIcon overlayTrimShadow;
@@ -33,89 +31,87 @@ public class BlockDrawersCustom extends BlockDrawers
@SideOnly(Side.CLIENT)
private IIcon defaultFace;
@SideOnly(Side.CLIENT)
private IIcon defaultTrim;
public BlockDrawersCustom (String blockName, int drawerCount, boolean halfDepth) {
public BlockDrawersCustom(String blockName, int drawerCount, boolean halfDepth) {
super(blockName, drawerCount, halfDepth);
}
@Override
public int getRenderType () {
public int getRenderType() {
return StorageDrawers.proxy.drawersCustomRenderID;
}
@Override
public int getRenderBlockPass () {
public int getRenderBlockPass() {
return 1;
}
@Override
public boolean canRenderInPass (int pass) {
public boolean canRenderInPass(int pass) {
ClientProxy.renderPass = pass;
return true;
}
@Override
public BlockType retrimType () {
public BlockType retrimType() {
return null;
}
@Override
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
protected ItemStack getMainDrop(World world, int x, int y, int z, int metadata) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile == null)
return ItemCustomDrawers.makeItemStack(this, 1, null, null, null);
if (tile == null) return ItemCustomDrawers.makeItemStack(this, 1, null, null, null);
return ItemCustomDrawers.makeItemStack(this, 1, tile.getMaterialSide(), tile.getMaterialTrim(), tile.getMaterialFront());
return ItemCustomDrawers.makeItemStack(
this, 1, tile.getMaterialSide(), tile.getMaterialTrim(), tile.getMaterialFront());
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (StorageDrawers.config.cache.addonShowVanilla)
list.add(new ItemStack(item));
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (StorageDrawers.config.cache.addonShowVanilla) list.add(new ItemStack(item));
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntityDrawers tile = getTileEntity(world, x, y, z);
if (tile != null && tile.getMaterialSide() == null)
return false;
if (tile != null && tile.getMaterialSide() == null) return false;
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
@SideOnly(Side.CLIENT)
public IIcon getHandleOverlay () {
public IIcon getHandleOverlay() {
return overlayHandle;
}
@SideOnly(Side.CLIENT)
public IIcon getFaceShadowOverlay () {
public IIcon getFaceShadowOverlay() {
return overlayFaceShadow;
}
@SideOnly(Side.CLIENT)
public IIcon getTrimShadowOverlay (boolean strong) {
if (strong)
return overlayTrimFace;
else
return overlayTrimShadow;
public IIcon getTrimShadowOverlay(boolean strong) {
if (strong) return overlayTrimFace;
else return overlayTrimShadow;
}
@SideOnly(Side.CLIENT)
public IIcon getDefaultFaceIcon () {
public IIcon getDefaultFaceIcon() {
return defaultFace;
}
@SideOnly(Side.CLIENT)
public IIcon getDefaultTrimIcon () {
public IIcon getDefaultTrimIcon() {
return defaultTrim;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
overlayHandle = register.registerIcon(StorageDrawers.MOD_ID + ":overlay/handle_" + drawerCount);
@@ -8,6 +8,7 @@ import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -21,10 +22,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.Random;
public class BlockFramingTable extends BlockContainer
{
public class BlockFramingTable extends BlockContainer {
public static final int[][] leftOffset = new int[][] {{0, 0}, {0, 0}, {1, 0}, {-1, 0}, {0, -1}, {0, 1}};
public static final int[][] rightOffset = new int[][] {{0, 0}, {0, 0}, {-1, 0}, {1, 0}, {0, 1}, {0, -1}};
@@ -32,15 +30,17 @@ public class BlockFramingTable extends BlockContainer
@SideOnly(Side.CLIENT)
IIcon iconBase;
@SideOnly(Side.CLIENT)
IIcon iconTrim;
@SideOnly(Side.CLIENT)
IIcon iconOverlayLeft;
@SideOnly(Side.CLIENT)
IIcon iconOverlayRight;
public BlockFramingTable (String blockName) {
public BlockFramingTable(String blockName) {
super(Material.wood);
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
@@ -50,114 +50,107 @@ public class BlockFramingTable extends BlockContainer
}
@Override
public TileEntity createNewTileEntity (World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFramingTable();
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float vx, float vy, float vz) {
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int side, float vx, float vy, float vz) {
int meta = world.getBlockMetadata(x, y, z);
int priX = x + getXOff(meta);
int priZ = z + getZOff(meta);
if (world.getBlock(priX, y, priZ) != this || (world.getBlockMetadata(priX, y, priZ) & 0x8) != 0)
return false;
if (world.getBlock(priX, y, priZ) != this || (world.getBlockMetadata(priX, y, priZ) & 0x8) != 0) return false;
player.openGui(StorageDrawers.instance, GuiHandler.framingGuiID, world, priX, y, priZ);
return true;
}
private int getXOff (int meta) {
if (isRightBlock(meta))
return 0;
private int getXOff(int meta) {
if (isRightBlock(meta)) return 0;
return rightOffset[getDirection(meta)][0];
}
private int getZOff (int meta) {
if (isRightBlock(meta))
return 0;
private int getZOff(int meta) {
if (isRightBlock(meta)) return 0;
return rightOffset[getDirection(meta)][1];
}
@Override
public boolean isOpaqueCube () {
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock () {
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType () {
public int getRenderType() {
return StorageDrawers.proxy.framingTableRenderID;
}
@Override
public int getRenderBlockPass () {
public int getRenderBlockPass() {
return 1;
}
@Override
public boolean canRenderInPass (int pass) {
public boolean canRenderInPass(int pass) {
ClientProxy.renderPass = pass;
return true;
}
@Override
public void onNeighborBlockChange (World world, int x, int y, int z, Block block) {
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
int meta = world.getBlockMetadata(x, y, z);
int side = getDirection(meta);
if (isRightBlock(meta)) {
if (world.getBlock(x + leftOffset[side][0], y, z + leftOffset[side][1]) != this) {
world.setBlockToAir(x, y, z);
if (!world.isRemote)
dropBlockAsItem(world, x, y, z, 1, 0);
if (!world.isRemote) dropBlockAsItem(world, x, y, z, 1, 0);
}
}
else if (world.getBlock(x + rightOffset[side][0], y, z + rightOffset[side][1]) != this)
} else if (world.getBlock(x + rightOffset[side][0], y, z + rightOffset[side][1]) != this)
world.setBlockToAir(x, y, z);
}
@Override
public Item getItemDropped (int meta, Random random, int fortune) {
public Item getItemDropped(int meta, Random random, int fortune) {
return isPrimaryBlock(meta) ? Item.getItemFromBlock(ModBlocks.framingTable) : Item.getItemById(0);
}
@Override
public void dropBlockAsItemWithChance (World world, int x, int y, int z, int meta, float chance, int fortune) {
if (isPrimaryBlock(meta))
super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, fortune);
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int fortune) {
if (isPrimaryBlock(meta)) super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, fortune);
}
@Override
public int getMobilityFlag () {
public int getMobilityFlag() {
return 1;
}
@Override
public void onBlockHarvested (World world, int x, int y, int z, int meta, EntityPlayer player) {
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if (player.capabilities.isCreativeMode && !isPrimaryBlock(meta)) {
int side = getDirection(meta);
x += rightOffset[side][0];
z += rightOffset[side][1];
if (world.getBlock(x, y, z) == this)
world.setBlockToAir(x, y, z);
if (world.getBlock(x, y, z) == this) world.setBlockToAir(x, y, z);
}
}
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int side) {
TileEntityFramingTable tile = (TileEntityFramingTable)world.getTileEntity(x, y, z);
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
TileEntityFramingTable tile = (TileEntityFramingTable) world.getTileEntity(x, y, z);
if (tile != null && isPrimaryBlock(world.getBlockMetadata(x, y, z))) {
for (int i = 0, n = tile.getSizeInventory(); i < n; i++) {
ItemStack stack = tile.getStackInSlot(i);
if (stack == null)
continue;
if (stack == null) continue;
float fx = random.nextFloat() * .8f + .1f;
float fy = random.nextFloat() * .8f + .1f;
@@ -165,14 +158,19 @@ public class BlockFramingTable extends BlockContainer
while (stack.stackSize > 0) {
int amount = random.nextInt(21) + 10;
if (amount > stack.stackSize)
amount = stack.stackSize;
if (amount > stack.stackSize) amount = stack.stackSize;
stack.stackSize -= amount;
EntityItem entity = new EntityItem(world, x + fx, y + fy, z + fz, new ItemStack(stack.getItem(), amount, stack.getItemDamage()));
EntityItem entity = new EntityItem(
world,
x + fx,
y + fy,
z + fz,
new ItemStack(stack.getItem(), amount, stack.getItemDamage()));
if (stack.hasTagCompound())
entity.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
entity.getEntityItem().setTagCompound((NBTTagCompound)
stack.getTagCompound().copy());
entity.motionX = random.nextGaussian() * .05f;
entity.motionY = random.nextGaussian() * .05f + .2f;
@@ -188,35 +186,35 @@ public class BlockFramingTable extends BlockContainer
super.breakBlock(world, x, y, z, block, side);
}
public static int getDirection (int meta) {
public static int getDirection(int meta) {
return meta & 0x7;
}
public static boolean isRightBlock (int meta) {
public static boolean isRightBlock(int meta) {
return (meta & 0x8) == 0;
}
public static boolean isPrimaryBlock (int meta) {
public static boolean isPrimaryBlock(int meta) {
return isRightBlock(meta);
}
@SideOnly(Side.CLIENT)
public IIcon getIconBase () {
public IIcon getIconBase() {
return iconBase;
}
@SideOnly(Side.CLIENT)
public IIcon getIconTrim () {
public IIcon getIconTrim() {
return iconTrim;
}
@SideOnly(Side.CLIENT)
public IIcon getIconOverlay (boolean left) {
public IIcon getIconOverlay(boolean left) {
return left ? iconOverlayLeft : iconOverlayRight;
}
@Override
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
iconBase = register.registerIcon(StorageDrawers.MOD_ID + ":base/base_oak");
iconTrim = register.registerIcon(StorageDrawers.MOD_ID + ":base/trim_oak");
@@ -15,14 +15,14 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockSlave extends BlockContainer implements INetworked
{
public class BlockSlave extends BlockContainer implements INetworked {
@SideOnly(Side.CLIENT)
private IIcon iconSide;
@SideOnly(Side.CLIENT)
private IIcon iconSideEtched;
public BlockSlave (String blockName) {
public BlockSlave(String blockName) {
super(Material.rock);
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
@@ -33,7 +33,7 @@ public class BlockSlave extends BlockContainer implements INetworked
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
switch (side) {
case 0:
case 1:
@@ -44,20 +44,20 @@ public class BlockSlave extends BlockContainer implements INetworked
}
@Override
public TileEntitySlave createNewTileEntity (World world, int meta) {
public TileEntitySlave createNewTileEntity(World world, int meta) {
return new TileEntitySlave();
}
public void bindController (World world, int x, int y, int z) {
public void bindController(World world, int x, int y, int z) {
TileEntitySlave te = getTileEntitySafe(world, x, y, z);
}
public TileEntitySlave getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
public TileEntitySlave getTileEntity(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity tile = blockAccess.getTileEntity(x, y, z);
return (tile instanceof TileEntitySlave) ? (TileEntitySlave) tile : null;
}
public TileEntitySlave getTileEntitySafe (World world, int x, int y, int z) {
public TileEntitySlave getTileEntitySafe(World world, int x, int y, int z) {
TileEntitySlave tile = getTileEntity(world, x, y, z);
if (tile == null) {
tile = createNewTileEntity(world, world.getBlockMetadata(x, y, z));
@@ -70,7 +70,7 @@ public class BlockSlave extends BlockContainer implements INetworked
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
iconSide = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side");
iconSideEtched = register.registerIcon(StorageDrawers.MOD_ID + ":drawers_comp_side_2");
}
@@ -5,6 +5,8 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked;
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWood;
import net.minecraft.block.material.Material;
@@ -16,15 +18,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class BlockTrim extends Block implements INetworked
{
public class BlockTrim extends Block implements INetworked {
@SideOnly(Side.CLIENT)
protected IIcon[] iconTrim;
public BlockTrim (String name) {
public BlockTrim(String name) {
super(Material.wood);
setBlockName(name);
@@ -34,30 +32,29 @@ public class BlockTrim extends Block implements INetworked
}
@Override
public int damageDropped (int meta) {
public int damageDropped(int meta) {
return meta;
}
@Override
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (willHarvest)
return true;
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (willHarvest) return true;
return super.removedByPlayer(world, player, x, y, z, willHarvest);
}
@Override
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta) {
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
super.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
}
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
protected ItemStack getMainDrop(World world, int x, int y, int z, int metadata) {
return new ItemStack(Item.getItemFromBlock(this), 1, metadata);
}
@Override
public ArrayList<ItemStack> getDrops (World world, int x, int y, int z, int metadata, int fortune) {
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ItemStack dropStack = getMainDrop(world, x, y, z, metadata);
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
@@ -67,24 +64,23 @@ public class BlockTrim extends Block implements INetworked
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
list.add(new ItemStack(item, 1, 0));
if (StorageDrawers.config.cache.creativeTabVanillaWoods) {
for (int i = 1; i < BlockWood.field_150096_a.length; i++)
list.add(new ItemStack(item, 1, i));
for (int i = 1; i < BlockWood.field_150096_a.length; i++) list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = meta % iconTrim.length;
return iconTrim[meta];
}
@Override
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
String[] subtex = BlockWood.field_150096_a;
iconTrim = new IIcon[subtex.length];
@@ -6,6 +6,7 @@ import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
import com.jaquadro.minecraft.storagedrawers.item.ItemCustomTrim;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -17,74 +18,70 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
public class BlockTrimCustom extends BlockTrim implements ITileEntityProvider
{
public class BlockTrimCustom extends BlockTrim implements ITileEntityProvider {
@SideOnly(Side.CLIENT)
private IIcon defaultFace;
@SideOnly(Side.CLIENT)
private IIcon defaultTrim;
public BlockTrimCustom (String name) {
public BlockTrimCustom(String name) {
super(name);
isBlockContainer = true;
}
@Override
public int getRenderType () {
public int getRenderType() {
return StorageDrawers.proxy.trimCustomRenderID;
}
@Override
public int getRenderBlockPass () {
public int getRenderBlockPass() {
return 1;
}
@Override
public boolean canRenderInPass (int pass) {
public boolean canRenderInPass(int pass) {
ClientProxy.renderPass = pass;
return true;
}
@Override
public boolean isOpaqueCube () {
public boolean isOpaqueCube() {
return false;
}
@Override
protected ItemStack getMainDrop (World world, int x, int y, int z, int metadata) {
protected ItemStack getMainDrop(World world, int x, int y, int z, int metadata) {
TileEntityTrim tile = getTileEntity(world, x, y, z);
if (tile == null)
return ItemCustomTrim.makeItemStack(this, 1, null, null);
if (tile == null) return ItemCustomTrim.makeItemStack(this, 1, null, null);
return ItemCustomTrim.makeItemStack(this, 1, tile.getMaterialSide(), tile.getMaterialTrim());
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (StorageDrawers.config.cache.addonShowVanilla)
list.add(new ItemStack(item));
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (StorageDrawers.config.cache.addonShowVanilla) list.add(new ItemStack(item));
}
public TileEntityTrim getTileEntity (IBlockAccess blockAccess, int x, int y, int z) {
public TileEntityTrim getTileEntity(IBlockAccess blockAccess, int x, int y, int z) {
TileEntity tile = blockAccess.getTileEntity(x, y, z);
return (tile instanceof TileEntityTrim) ? (TileEntityTrim) tile : null;
}
@SideOnly(Side.CLIENT)
public IIcon getDefaultFaceIcon () {
public IIcon getDefaultFaceIcon() {
return defaultFace;
}
@SideOnly(Side.CLIENT)
public IIcon getDefaultTrimIcon () {
public IIcon getDefaultTrimIcon() {
return defaultTrim;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
defaultFace = register.registerIcon(StorageDrawers.MOD_ID + ":base/base_default");
@@ -94,18 +91,18 @@ public class BlockTrimCustom extends BlockTrim implements ITileEntityProvider
}
@Override
public TileEntity createNewTileEntity (World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityTrim();
}
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int meta) {
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
super.breakBlock(world, x, y, z, block, meta);
world.removeTileEntity(x, y, z);
}
@Override
public boolean onBlockEventReceived (World world, int x, int y, int z, int eventNum, int eventArg) {
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventNum, int eventArg) {
super.onBlockEventReceived(world, x, y, z, eventNum, eventArg);
TileEntity tile = world.getTileEntity(x, y, z);
return (tile != null) && tile.receiveClientEvent(eventNum, eventArg);
@@ -11,37 +11,30 @@ import net.minecraft.block.BlockWood;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
public class DataResolver extends ExtendedDataResolver
{
public class DataResolver extends ExtendedDataResolver {
private static String[] textureNames = BlockWood.field_150096_a;
public DataResolver (String modID) {
public DataResolver(String modID) {
super(modID, textureNames);
}
@Override
public CreativeTabs getCreativeTabs (BlockType type) {
public CreativeTabs getCreativeTabs(BlockType type) {
return ModCreativeTabs.tabStorageDrawers;
}
@Override
public Block getBlock (BlockConfiguration blockConfig) {
public Block getBlock(BlockConfiguration blockConfig) {
switch (blockConfig.getBlockType()) {
case Drawers:
if (blockConfig.getDrawerCount() == 1)
return ModBlocks.fullDrawers1;
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return ModBlocks.fullDrawers2;
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
return ModBlocks.fullDrawers4;
if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth())
return ModBlocks.halfDrawers2;
if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth())
return ModBlocks.halfDrawers4;
if (blockConfig.getDrawerCount() == 1) return ModBlocks.fullDrawers1;
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) return ModBlocks.fullDrawers2;
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) return ModBlocks.fullDrawers4;
if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) return ModBlocks.halfDrawers2;
if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) return ModBlocks.halfDrawers4;
break;
case DrawersSorting:
if (blockConfig.getDrawerCount() == 1)
return RefinedRelocation.fullDrawers1;
if (blockConfig.getDrawerCount() == 1) return RefinedRelocation.fullDrawers1;
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return RefinedRelocation.fullDrawers2;
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
@@ -60,8 +53,7 @@ public class DataResolver extends ExtendedDataResolver
}
@Override
public void init () {
for (int i = 0, p = 0, m = 0; i < 6; i++, p++, m++)
setPlankSlab(i, Blocks.planks, p, Blocks.wooden_slab, m);
public void init() {
for (int i = 0, p = 0, m = 0; i < 6; i++, p++, m++) setPlankSlab(i, Blocks.planks, p, Blocks.wooden_slab, m);
}
}
@@ -3,7 +3,16 @@ package com.jaquadro.minecraft.storagedrawers.block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public interface IExtendedBlockClickHandler
{
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ, boolean invertShift);
public interface IExtendedBlockClickHandler {
public void onBlockClicked(
World world,
int x,
int y,
int z,
EntityPlayer player,
int side,
float hitX,
float hitY,
float hitZ,
boolean invertShift);
}
@@ -7,6 +7,7 @@ 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;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@@ -14,98 +15,85 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import java.util.List;
public class BlockDrawersPack extends BlockDrawers implements IPackBlock
{
public class BlockDrawersPack extends BlockDrawers implements IPackBlock {
private IPackDataResolver resolver;
public BlockDrawersPack (IPackDataResolver resolver, int drawerCount, boolean halfDepth) {
super(resolver.getBlockName(BlockConfiguration.by(BlockType.Drawers, drawerCount, halfDepth)), drawerCount, halfDepth);
public BlockDrawersPack(IPackDataResolver resolver, int drawerCount, boolean halfDepth) {
super(
resolver.getBlockName(BlockConfiguration.by(BlockType.Drawers, drawerCount, halfDepth)),
drawerCount,
halfDepth);
this.resolver = resolver;
CreativeTabs tabs = resolver.getCreativeTabs(BlockType.Drawers);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null)
setCreativeTab(tabs);
else
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null) setCreativeTab(tabs);
else setCreativeTab(ModCreativeTabs.tabStorageDrawers);
}
public String[] getUnlocalizedNames () {
public String[] getUnlocalizedNames() {
String[] names = new String[16];
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
names[i] = resolver.getUnlocalizedName(i);
if (resolver.isValidMetaValue(i)) names[i] = resolver.getUnlocalizedName(i);
}
return names;
}
@Override
public IPackDataResolver getDataResolver () {
public IPackDataResolver getDataResolver() {
return resolver;
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla)
return;
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla) return;
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
list.add(new ItemStack(item, 1, i));
if (resolver.isValidMetaValue(i)) list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
if (!resolver.isValidMetaValue(meta))
getSimilarBlock().getIcon(side, 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) {
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);
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) {
public IIcon getIconTrim(int meta) {
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
if (!resolver.isValidMetaValue(meta))
getSimilarBlock().getIconTrim(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;
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) {
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
iconSide = new IIcon[16];
@@ -117,8 +105,7 @@ public class BlockDrawersPack extends BlockDrawers implements IPackBlock
iconTrim = new IIcon[16];
for (int i = 0; i < 16; i++) {
if (!resolver.isValidMetaValue(i))
continue;
if (!resolver.isValidMetaValue(i)) continue;
iconFront1[i] = register.registerIcon(resolver.getTexturePath(TextureType.Front1, i));
iconFront2[i] = register.registerIcon(resolver.getTexturePath(TextureType.Front2, i));
@@ -7,6 +7,7 @@ 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;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@@ -14,98 +15,85 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import java.util.List;
public class BlockSortingDrawersPack extends BlockSortingDrawers implements IPackBlock
{
public class BlockSortingDrawersPack extends BlockSortingDrawers implements IPackBlock {
private IPackDataResolver resolver;
public BlockSortingDrawersPack (IPackDataResolver resolver, int drawerCount, boolean halfDepth) {
super(resolver.getBlockName(BlockConfiguration.by(BlockType.DrawersSorting, drawerCount, halfDepth)), drawerCount, halfDepth);
public BlockSortingDrawersPack(IPackDataResolver resolver, int drawerCount, boolean halfDepth) {
super(
resolver.getBlockName(BlockConfiguration.by(BlockType.DrawersSorting, drawerCount, halfDepth)),
drawerCount,
halfDepth);
this.resolver = resolver;
CreativeTabs tabs = resolver.getCreativeTabs(BlockType.DrawersSorting);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null)
setCreativeTab(tabs);
else
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null) setCreativeTab(tabs);
else setCreativeTab(ModCreativeTabs.tabStorageDrawers);
}
public String[] getUnlocalizedNames () {
public String[] getUnlocalizedNames() {
String[] names = new String[16];
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
names[i] = resolver.getUnlocalizedName(i);
if (resolver.isValidMetaValue(i)) names[i] = resolver.getUnlocalizedName(i);
}
return names;
}
@Override
public IPackDataResolver getDataResolver () {
public IPackDataResolver getDataResolver() {
return resolver;
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla)
return;
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla) return;
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
list.add(new ItemStack(item, 1, i));
if (resolver.isValidMetaValue(i)) list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
if (!resolver.isValidMetaValue(meta))
getSimilarBlock().getIcon(side, 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) {
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);
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) {
public IIcon getIconTrim(int meta) {
meta = (meta < 0 || meta >= iconSide.length) ? 0 : meta;
if (!resolver.isValidMetaValue(meta))
getSimilarBlock().getIconTrim(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;
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) {
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
iconSide = new IIcon[16];
@@ -118,8 +106,7 @@ public class BlockSortingDrawersPack extends BlockSortingDrawers implements IPac
iconSort = new IIcon[16];
for (int i = 0; i < 16; i++) {
if (!resolver.isValidMetaValue(i))
continue;
if (!resolver.isValidMetaValue(i)) continue;
iconFront1[i] = register.registerIcon(resolver.getTexturePath(TextureType.Front1, i));
iconFront2[i] = register.registerIcon(resolver.getTexturePath(TextureType.Front2, i));
@@ -6,71 +6,63 @@ import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
import com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation.BlockSortingTrim;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
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.IIcon;
import java.util.List;
public class BlockSortingTrimPack extends BlockSortingTrim implements IPackBlock
{
public class BlockSortingTrimPack extends BlockSortingTrim implements IPackBlock {
IPackDataResolver resolver;
public BlockSortingTrimPack (IPackDataResolver resolver) {
public BlockSortingTrimPack(IPackDataResolver resolver) {
super(resolver.getBlockName(BlockConfiguration.TrimSorting));
this.resolver = resolver;
CreativeTabs tabs = resolver.getCreativeTabs(BlockType.TrimSorting);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null)
setCreativeTab(tabs);
else
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null) setCreativeTab(tabs);
else setCreativeTab(ModCreativeTabs.tabStorageDrawers);
}
public String[] getUnlocalizedNames () {
public String[] getUnlocalizedNames() {
String[] names = new String[16];
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
names[i] = resolver.getUnlocalizedName(i);
if (resolver.isValidMetaValue(i)) names[i] = resolver.getUnlocalizedName(i);
}
return names;
}
@Override
public IPackDataResolver getDataResolver () {
public IPackDataResolver getDataResolver() {
return resolver;
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla)
return;
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla) return;
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
list.add(new ItemStack(item, 1, i));
if (resolver.isValidMetaValue(i)) list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = meta % 16;
return iconTrim[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
iconTrim = new IIcon[16];
for (int i = 0; i < 16; i++) {
if (!resolver.isValidMetaValue(i))
continue;
if (!resolver.isValidMetaValue(i)) continue;
iconTrim[i] = register.registerIcon(resolver.getTexturePath(TextureType.TrimBlock, i));
}
@@ -6,71 +6,63 @@ import com.jaquadro.minecraft.storagedrawers.block.BlockTrim;
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
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.IIcon;
import java.util.List;
public class BlockTrimPack extends BlockTrim implements IPackBlock
{
public class BlockTrimPack extends BlockTrim implements IPackBlock {
private IPackDataResolver resolver;
public BlockTrimPack (IPackDataResolver resolver) {
public BlockTrimPack(IPackDataResolver resolver) {
super(resolver.getBlockName(BlockConfiguration.Trim));
this.resolver = resolver;
CreativeTabs tabs = resolver.getCreativeTabs(BlockType.Trim);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null)
setCreativeTab(tabs);
else
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
if (StorageDrawers.config.cache.addonSeparateVanilla && tabs != null) setCreativeTab(tabs);
else setCreativeTab(ModCreativeTabs.tabStorageDrawers);
}
public String[] getUnlocalizedNames () {
public String[] getUnlocalizedNames() {
String[] names = new String[16];
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
names[i] = resolver.getUnlocalizedName(i);
if (resolver.isValidMetaValue(i)) names[i] = resolver.getUnlocalizedName(i);
}
return names;
}
@Override
public IPackDataResolver getDataResolver () {
public IPackDataResolver getDataResolver() {
return resolver;
}
@Override
public void getSubBlocks (Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla)
return;
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
if (!StorageDrawers.config.cache.addonShowVanilla) return;
for (int i = 0; i < 16; i++) {
if (resolver.isValidMetaValue(i))
list.add(new ItemStack(item, 1, i));
if (resolver.isValidMetaValue(i)) list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta) {
public IIcon getIcon(int side, int meta) {
meta = meta % 16;
return iconTrim[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister register) {
public void registerBlockIcons(IIconRegister register) {
iconTrim = new IIcon[16];
for (int i = 0; i < 16; i++) {
if (!resolver.isValidMetaValue(i))
continue;
if (!resolver.isValidMetaValue(i)) continue;
iconTrim[i] = register.registerIcon(resolver.getTexturePath(TextureType.TrimBlock, i));
}
@@ -2,18 +2,16 @@ package com.jaquadro.minecraft.storagedrawers.block.tile;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import cpw.mods.fml.common.FMLLog;
import java.util.Iterator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import org.apache.logging.log4j.Level;
import java.util.Iterator;
public class BaseTileEntity extends TileEntity
{
public class BaseTileEntity extends TileEntity {
private NBTTagCompound failureSnapshot;
@Override
public void readFromNBT (NBTTagCompound tag) {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
failureSnapshot = null;
@@ -21,14 +19,13 @@ public class BaseTileEntity extends TileEntity
try {
readFromFixedNBT(tag);
readFromPortableNBT(tag);
}
catch (Throwable t) {
} catch (Throwable t) {
trapLoadFailure(t, tag);
}
}
@Override
public void writeToNBT (NBTTagCompound tag) {
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
if (failureSnapshot != null) {
@@ -39,35 +36,33 @@ public class BaseTileEntity extends TileEntity
try {
writeToFixedNBT(tag);
writeToPortableNBT(tag);
}
catch (Throwable t) {
} catch (Throwable t) {
FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Save Failure.");
}
}
public void readFromPortableNBT (NBTTagCompound tag) { }
public void readFromPortableNBT(NBTTagCompound tag) {}
public void writeToPortableNBT (NBTTagCompound tag) { }
public void writeToPortableNBT(NBTTagCompound tag) {}
protected void readFromFixedNBT (NBTTagCompound tag) { }
protected void readFromFixedNBT(NBTTagCompound tag) {}
protected void writeToFixedNBT (NBTTagCompound tag) { }
protected void writeToFixedNBT(NBTTagCompound tag) {}
protected void trapLoadFailure (Throwable t, NBTTagCompound tag) {
failureSnapshot = (NBTTagCompound)tag.copy();
protected void trapLoadFailure(Throwable t, NBTTagCompound tag) {
failureSnapshot = (NBTTagCompound) tag.copy();
FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Load Failure.");
}
protected void restoreLoadFailure (NBTTagCompound tag) {
protected void restoreLoadFailure(NBTTagCompound tag) {
Iterator<String> iter = failureSnapshot.func_150296_c().iterator();
while (iter.hasNext()) {
String key = iter.next();
if (!tag.hasKey(key))
tag.setTag(key, failureSnapshot.getTag(key).copy());
if (!tag.hasKey(key)) tag.setTag(key, failureSnapshot.getTag(key).copy());
}
}
protected boolean loadDidFail () {
protected boolean loadDidFail() {
return failureSnapshot != null;
}
}
@@ -1,43 +1,41 @@
package com.jaquadro.minecraft.storagedrawers.block.tile;
/**
* Created by Justin on 4/25/2015.
*/
class BlockCoord
{
* Created by Justin on 4/25/2015.
*/
class BlockCoord {
private int x;
private int y;
private int z;
public BlockCoord (int x, int y, int z) {
public BlockCoord(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public int x () {
public int x() {
return x;
}
public int y () {
public int y() {
return y;
}
public int z () {
public int z() {
return z;
}
@Override
public boolean equals (Object obj) {
if (obj == null || obj.getClass() != getClass())
return false;
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass()) return false;
BlockCoord that = (BlockCoord)obj;
BlockCoord that = (BlockCoord) obj;
return x == that.x && y == that.y && z == that.z;
}
@Override
public int hashCode () {
public int hashCode() {
int hash = 23;
hash = hash * 31 + x;
hash = hash * 31 + y;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -7,7 +7,6 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
import com.jaquadro.minecraft.storagedrawers.config.CompTierRegistry;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationModule;
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
import com.jaquadro.minecraft.storagedrawers.storage.*;
import cpw.mods.fml.common.FMLLog;
@@ -15,6 +14,10 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -23,13 +26,7 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import org.apache.logging.log4j.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TileEntityDrawersComp extends TileEntityDrawers
{
public class TileEntityDrawersComp extends TileEntityDrawers {
private static InventoryLookup lookup1 = new InventoryLookup(1, 1);
private static InventoryLookup lookup2 = new InventoryLookup(2, 2);
private static InventoryLookup lookup3 = new InventoryLookup(3, 3);
@@ -42,20 +39,19 @@ public class TileEntityDrawersComp extends TileEntityDrawers
private ItemStack[] protoStack;
private int[] convRate;
public TileEntityDrawersComp () {
public TileEntityDrawersComp() {
super(3);
protoStack = new ItemStack[getDrawerCount()];
convRate = new int[getDrawerCount()];
}
protected ICentralInventory getCentralInventory () {
if (centralInventory == null)
centralInventory = new CompCentralInventory();
protected ICentralInventory getCentralInventory() {
if (centralInventory == null) centralInventory = new CompCentralInventory();
return centralInventory;
}
public int getStoredItemRemainder (int slot) {
public int getStoredItemRemainder(int slot) {
int count = centralInventory.getStoredItemCount(slot);
if (slot > 0 && convRate[slot] > 0)
count -= centralInventory.getStoredItemCount(slot - 1) * (convRate[slot - 1] / convRate[slot]);
@@ -64,43 +60,38 @@ public class TileEntityDrawersComp extends TileEntityDrawers
}
@Override
protected IDrawer createDrawer (int slot) {
protected IDrawer createDrawer(int slot) {
return new CompDrawerData(getCentralInventory(), slot);
}
@Override
public boolean isDrawerEnabled (int slot) {
if (slot > 0 && convRate[slot] == 0)
return false;
public boolean isDrawerEnabled(int slot) {
if (slot > 0 && convRate[slot] == 0) return false;
return super.isDrawerEnabled(slot);
}
@Override
public int putItemsIntoSlot (int slot, ItemStack stack, int count) {
public int putItemsIntoSlot(int slot, ItemStack stack, int count) {
int added = 0;
if (stack != null && convRate != null && convRate[0] == 0) {
populateSlots(stack);
for (int i = 0; i < getDrawerCount(); i++) {
if (BaseDrawerData.areItemsEqual(protoStack[i], stack))
added = super.putItemsIntoSlot(i, stack, count);
if (BaseDrawerData.areItemsEqual(protoStack[i], stack)) added = super.putItemsIntoSlot(i, stack, count);
}
for (int i = 0; i < getDrawerCount(); i++) {
IDrawer drawer = getDrawer(i);
if (drawer instanceof CompDrawerData)
((CompDrawerData) drawer).refresh();
if (drawer instanceof CompDrawerData) ((CompDrawerData) drawer).refresh();
}
}
return added + super.putItemsIntoSlot(slot, stack, count);
}
@Override
public void readFromPortableNBT (NBTTagCompound tag) {
public void readFromPortableNBT(NBTTagCompound tag) {
pooledCount = 0;
for (int i = 0; i < getDrawerCount(); i++) {
@@ -112,41 +103,34 @@ public class TileEntityDrawersComp extends TileEntityDrawers
pooledCount = tag.getInteger("Count");
if (tag.hasKey("Conv0"))
convRate[0] = tag.getByte("Conv0");
if (tag.hasKey("Conv1"))
convRate[1] = tag.getByte("Conv1");
if (tag.hasKey("Conv2"))
convRate[2] = tag.getByte("Conv2");
if (tag.hasKey("Conv0")) convRate[0] = tag.getByte("Conv0");
if (tag.hasKey("Conv1")) convRate[1] = tag.getByte("Conv1");
if (tag.hasKey("Conv2")) convRate[2] = tag.getByte("Conv2");
for (int i = 0; i < getDrawerCount(); i++) {
IDrawer drawer = getDrawer(i);
if (drawer instanceof CompDrawerData)
((CompDrawerData) drawer).refresh();
if (drawer instanceof CompDrawerData) ((CompDrawerData) drawer).refresh();
}
if (worldObj != null && !worldObj.isRemote) {
//TileEntityDrawersComp.this.markDirty();
// TileEntityDrawersComp.this.markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@Override
public void writeToPortableNBT (NBTTagCompound tag) {
public void writeToPortableNBT(NBTTagCompound tag) {
super.writeToPortableNBT(tag);
tag.setInteger("Count", pooledCount);
if (convRate[0] > 0)
tag.setByte("Conv0", (byte)convRate[0]);
if (convRate[1] > 0)
tag.setByte("Conv1", (byte)convRate[1]);
if (convRate[2] > 0)
tag.setByte("Conv2", (byte)convRate[2]);
if (convRate[0] > 0) tag.setByte("Conv0", (byte) convRate[0]);
if (convRate[1] > 0) tag.setByte("Conv1", (byte) convRate[1]);
if (convRate[2] > 0) tag.setByte("Conv2", (byte) convRate[2]);
}
@Override
public void clientUpdateCount (int slot, int count) {
public void clientUpdateCount(int slot, int count) {
if (count != pooledCount) {
pooledCount = count;
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
@@ -154,23 +138,29 @@ public class TileEntityDrawersComp extends TileEntityDrawers
}
@Override
public String getInventoryName () {
public String getInventoryName() {
return hasCustomInventoryName() ? super.getInventoryName() : "storageDrawers.container.compDrawers";
}
private void populateSlots (ItemStack stack) {
private void populateSlots(ItemStack stack) {
int index = 0;
ItemStack uTier1 = findHigherTier(stack);
if (uTier1 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + uTier1.toString() + " with conv=" + lookupSizeResult);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Picked candidate " + uTier1.toString() + " with conv=" + lookupSizeResult);
int uCount1 = lookupSizeResult;
ItemStack uTier2 = findHigherTier(uTier1);
if (uTier2 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + uTier2.toString() + " with conv=" + lookupSizeResult);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Picked candidate " + uTier2.toString() + " with conv=" + lookupSizeResult);
populateSlot(index++, uTier2, lookupSizeResult * uCount1);
}
@@ -180,51 +170,56 @@ public class TileEntityDrawersComp extends TileEntityDrawers
populateSlot(index++, stack, 1);
if (index == 3)
return;
if (index == 3) return;
ItemStack lTier1 = findLowerTier(stack);
if (lTier1 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + lTier1.toString() + " with conv=" + lookupSizeResult);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Picked candidate " + lTier1.toString() + " with conv=" + lookupSizeResult);
populateSlot(index++, lTier1, 1);
for (int i = 0; i < index - 1; i++)
convRate[i] *= lookupSizeResult;
for (int i = 0; i < index - 1; i++) convRate[i] *= lookupSizeResult;
}
if (index == 3 || lTier1 == null)
return;
if (index == 3 || lTier1 == null) return;
ItemStack lTier2 = findLowerTier(lTier1);
if (lTier2 != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Picked candidate " + lTier2.toString() + " with conv=" + lookupSizeResult);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Picked candidate " + lTier2.toString() + " with conv=" + lookupSizeResult);
populateSlot(index++, lTier2, 1);
for (int i = 0; i < index - 1; i++)
convRate[i] *= lookupSizeResult;
for (int i = 0; i < index - 1; i++) convRate[i] *= lookupSizeResult;
}
}
private void populateSlot (int slot, ItemStack stack, int conversion) {
private void populateSlot(int slot, ItemStack stack, int conversion) {
convRate[slot] = conversion;
protoStack[slot] = stack.copy();
//centralInventory.setStoredItem(slot, stack, 0);
//getDrawer(slot).setStoredItem(stack, 0);
// centralInventory.setStoredItem(slot, stack, 0);
// getDrawer(slot).setStoredItem(stack, 0);
if (worldObj != null && worldObj.isRemote)
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
private ItemStack findHigherTier (ItemStack stack) {
private ItemStack findHigherTier(ItemStack stack) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Finding ascending candidates for " + stack.toString());
CompTierRegistry.Record record = StorageDrawers.compRegistry.findHigherTier(stack);
if (record != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found " + record.upper.toString() + " in registry with conv=" + record.convRate);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Found " + record.upper.toString() + " in registry with conv=" + record.convRate);
lookupSizeResult = record.convRate;
return record.upper;
@@ -251,15 +246,17 @@ public class TileEntityDrawersComp extends TileEntityDrawers
for (int j = 0, n2 = backCandidates.size(); j < n2; j++) {
ItemStack comp = backCandidates.get(j);
if (comp.stackSize != size)
continue;
if (comp.stackSize != size) continue;
if (!DrawerData.areItemsEqual(comp, stack, false))
continue;
if (!DrawerData.areItemsEqual(comp, stack, false)) continue;
candidates.add(match);
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found ascending candidate for " + stack.toString() + ": " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Found ascending candidate for " + stack.toString() + ": " + match.toString() + " size="
+ lookupSizeResult + ", inverse=" + comp.toString());
break;
}
@@ -269,11 +266,9 @@ public class TileEntityDrawersComp extends TileEntityDrawers
}
ItemStack modMatch = findMatchingModCandidate(stack, candidates);
if (modMatch != null)
return modMatch;
if (modMatch != null) return modMatch;
if (candidates.size() > 0)
return candidates.get(0);
if (candidates.size() > 0) return candidates.get(0);
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "No candidates found");
@@ -281,7 +276,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return null;
}
private List<ItemStack> findAllMatchingRecipes (InventoryCrafting crafting) {
private List<ItemStack> findAllMatchingRecipes(InventoryCrafting crafting) {
List<ItemStack> candidates = new ArrayList<ItemStack>();
CraftingManager cm = CraftingManager.getInstance();
@@ -291,22 +286,24 @@ public class TileEntityDrawersComp extends TileEntityDrawers
IRecipe recipe = (IRecipe) recipeList.get(i);
if (recipe.matches(crafting, worldObj)) {
ItemStack result = recipe.getCraftingResult(crafting);
if (result != null && result.getItem() != null)
candidates.add(result);
if (result != null && result.getItem() != null) candidates.add(result);
}
}
return candidates;
}
private ItemStack findLowerTier (ItemStack stack) {
private ItemStack findLowerTier(ItemStack stack) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Finding descending candidates for " + stack.toString());
CompTierRegistry.Record record = StorageDrawers.compRegistry.findLowerTier(stack);
if (record != null) {
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found " + record.lower.toString() + " in registry with conv=" + record.convRate);
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Found " + record.lower.toString() + " in registry with conv=" + record.convRate);
lookupSizeResult = record.convRate;
return record.lower;
@@ -323,8 +320,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
ItemStack match = null;
ItemStack output = recipe.getRecipeOutput();
if (!DrawerData.areItemsEqual(stack, output, true))
continue;
if (!DrawerData.areItemsEqual(stack, output, true)) continue;
IRecipeHandler handler = StorageDrawers.recipeHandlerRegistry.getRecipeHandler(recipe.getClass());
while (handler != null) {
@@ -353,9 +349,17 @@ public class TileEntityDrawersComp extends TileEntityDrawers
candidatesRate.put(match, lookupSizeResult);
if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Found descending candidate for " + stack.toString() + ": " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Found descending candidate for " + stack.toString() + ": " + match.toString()
+ " size=" + lookupSizeResult + ", inverse=" + comp.toString());
} else if (!worldObj.isRemote && StorageDrawers.config.cache.debugTrace)
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "Back-check failed for " + match.toString() + " size=" + lookupSizeResult + ", inverse=" + comp.toString());
FMLLog.log(
StorageDrawers.MOD_ID,
Level.INFO,
"Back-check failed for " + match.toString() + " size=" + lookupSizeResult + ", inverse="
+ comp.toString());
}
}
}
@@ -379,7 +383,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return null;
}
private ItemStack findMatchingModCandidate (ItemStack reference, List<ItemStack> candidates) {
private ItemStack findMatchingModCandidate(ItemStack reference, List<ItemStack> candidates) {
String referenceName = GameData.getItemRegistry().getNameForObject(reference.getItem());
if (referenceName != null) {
GameRegistry.UniqueIdentifier referneceID = new GameRegistry.UniqueIdentifier(referenceName);
@@ -387,8 +391,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
String matchName = GameData.getItemRegistry().getNameForObject(candidate.getItem());
if (matchName != null) {
GameRegistry.UniqueIdentifier matchID = new GameRegistry.UniqueIdentifier(matchName);
if (referneceID.modId.equals(matchID.modId))
return candidate;
if (referneceID.modId.equals(matchID.modId)) return candidate;
}
}
}
@@ -396,93 +399,73 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return null;
}
private ItemStack tryMatch (ItemStack stack, List list) {
if (list.size() != 9 && list.size() != 4)
return null;
private ItemStack tryMatch(ItemStack stack, List list) {
if (list.size() != 9 && list.size() != 4) return null;
Object item = list.get(0);
if (item instanceof ItemStack) {
ItemStack item1 = (ItemStack)item;
ItemStack item1 = (ItemStack) item;
for (int i = 1, n = list.size(); i < n; i++) {
Object item2 = list.get(i);
if (item2.getClass() != ItemStack.class)
return null;
if (!item1.isItemEqual((ItemStack)item2))
return null;
if (item2.getClass() != ItemStack.class) return null;
if (!item1.isItemEqual((ItemStack) item2)) return null;
}
return item1;
}
else if (item instanceof ArrayList) {
} else if (item instanceof ArrayList) {
for (int i = 1, n = list.size(); i < n; i++) {
if (item != list.get(i))
return null;
if (item != list.get(i)) return null;
}
ArrayList itemList = (ArrayList)item;
ArrayList itemList = (ArrayList) item;
if (itemList.size() > 0) {
Object item1 = itemList.get(0);
if (item1 instanceof ItemStack)
return (ItemStack)item1;
if (item1 instanceof ItemStack) return (ItemStack) item1;
}
}
return null;
}
private ItemStack tryMatch (ItemStack stack, Object[] list) {
if (list.length != 9 && list.length != 4)
return null;
private ItemStack tryMatch(ItemStack stack, Object[] list) {
if (list.length != 9 && list.length != 4) return null;
Object item = list[0];
if (item == null)
return null;
if (item == null) return null;
if (item instanceof ItemStack) {
ItemStack item1 = (ItemStack)item;
ItemStack item1 = (ItemStack) item;
for (int i = 1, n = list.length; i < n; i++) {
Object item2 = list[i];
if (item2 == null || item2.getClass() != ItemStack.class)
return null;
if (!item1.isItemEqual((ItemStack)item2))
return null;
if (item2 == null || item2.getClass() != ItemStack.class) return null;
if (!item1.isItemEqual((ItemStack) item2)) return null;
}
return item1;
}
else if (item instanceof ArrayList) {
} else if (item instanceof ArrayList) {
for (int i = 1, n = list.length; i < n; i++) {
if (item != list[i])
return null;
if (item != list[i]) return null;
}
ArrayList itemList = (ArrayList)item;
ArrayList itemList = (ArrayList) item;
if (itemList.size() > 0) {
Object item1 = findMatchingModCandidate(stack, itemList);
if (item1 == null)
item1 = itemList.get(0);
if (item1 == null) item1 = itemList.get(0);
if (item1 instanceof ItemStack)
return (ItemStack)item1;
if (item1 instanceof ItemStack) return (ItemStack) item1;
}
}
else {
} else {
IIngredientHandler handler = StorageDrawers.recipeHandlerRegistry.getIngredientHandler(item.getClass());
if (handler == null)
return null;
if (handler == null) return null;
ItemStack item1 = handler.getItemStack(item);
if (item1 == null)
return null;
if (item1 == null) return null;
for (int i = 1, n = list.length; i < n; i++) {
Object item2 = list[i];
if (item2 == null || item.getClass() != item2.getClass())
return null;
if (item2 == null || item.getClass() != item2.getClass()) return null;
item2 = handler.getItemStack(item2);
if (item2 == null || item2.getClass() != ItemStack.class)
return null;
if (!item1.isItemEqual((ItemStack)item2))
return null;
if (item2 == null || item2.getClass() != ItemStack.class) return null;
if (!item1.isItemEqual((ItemStack) item2)) return null;
}
return item1;
@@ -491,22 +474,20 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return null;
}
private void setupLookup (InventoryLookup inv, ItemStack stack) {
for (int i = 0, n = inv.getSizeInventory(); i < n; i++)
inv.setInventorySlotContents(i, stack);
private void setupLookup(InventoryLookup inv, ItemStack stack) {
for (int i = 0, n = inv.getSizeInventory(); i < n; i++) inv.setInventorySlotContents(i, stack);
lookupSizeResult = inv.getSizeInventory();
}
private class CompCentralInventory implements ICentralInventory
{
private class CompCentralInventory implements ICentralInventory {
@Override
public ItemStack getStoredItemPrototype (int slot) {
public ItemStack getStoredItemPrototype(int slot) {
return protoStack[slot];
}
@Override
public IDrawer setStoredItem (int slot, ItemStack itemPrototype, int amount) {
public IDrawer setStoredItem(int slot, ItemStack itemPrototype, int amount) {
if (itemPrototype != null && convRate != null && convRate[0] == 0) {
IDrawer target = null;
populateSlots(itemPrototype);
@@ -518,57 +499,48 @@ public class TileEntityDrawersComp extends TileEntityDrawers
}
for (int i = 0; i < getDrawerCount(); i++) {
if (i == slot)
continue;
if (i == slot) continue;
IDrawer drawer = getDrawer(i);
if (drawer instanceof CompDrawerData)
((CompDrawerData) drawer).refresh();
if (drawer instanceof CompDrawerData) ((CompDrawerData) drawer).refresh();
}
if (worldObj != null && !worldObj.isRemote) {
//TileEntityDrawersComp.this.markDirty();
// TileEntityDrawersComp.this.markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return target;
}
else if (itemPrototype == null) {
//setStoredItemCount(slot, 0);
} else if (itemPrototype == null) {
// setStoredItemCount(slot, 0);
pooledCount = 0;
clear();
if (worldObj != null && !worldObj.isRemote)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (worldObj != null && !worldObj.isRemote) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
return getDrawer(slot);
}
@Override
public int getStoredItemCount (int slot) {
if (convRate == null || convRate[slot] == 0)
return 0;
public int getStoredItemCount(int slot) {
if (convRate == null || convRate[slot] == 0) return 0;
if (TileEntityDrawersComp.this.isVending())
return Integer.MAX_VALUE;
if (TileEntityDrawersComp.this.isVending()) return Integer.MAX_VALUE;
return pooledCount / convRate[slot];
}
@Override
public void setStoredItemCount (int slot, int amount) {
if (convRate == null || convRate[slot] == 0)
return;
public void setStoredItemCount(int slot, int amount) {
if (convRate == null || convRate[slot] == 0) return;
if (TileEntityDrawersComp.this.isVending())
return;
if (TileEntityDrawersComp.this.isVending()) return;
int oldCount = pooledCount;
pooledCount = (pooledCount % convRate[slot]) + convRate[slot] * amount;
int poolMax = getMaxCapacity(0) * convRate[0];
if (pooledCount > poolMax)
pooledCount = poolMax;
if (pooledCount > poolMax) pooledCount = poolMax;
if (pooledCount != oldCount) {
if (pooledCount != 0 || TileEntityDrawersComp.this.isLocked(LockAttribute.LOCK_POPULATED))
@@ -576,7 +548,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers
else {
clear();
if (worldObj != null && !worldObj.isRemote) {
//TileEntityDrawersComp.this.markDirty();
// TileEntityDrawersComp.this.markDirty();
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@@ -584,134 +556,123 @@ public class TileEntityDrawersComp extends TileEntityDrawers
}
@Override
public int getMaxCapacity (int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return 0;
public int getMaxCapacity(int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0) return 0;
if (TileEntityDrawersComp.this.isUnlimited() || TileEntityDrawersComp.this.isVending()) {
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0)
return Integer.MAX_VALUE;
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0) return Integer.MAX_VALUE;
return Integer.MAX_VALUE / convRate[slot];
}
return protoStack[0].getItem().getItemStackLimit(protoStack[0]) * getStackCapacity(0) * getConversionRate(slot);
return protoStack[0].getItem().getItemStackLimit(protoStack[0])
* getStackCapacity(0)
* getConversionRate(slot);
}
@Override
public int getMaxCapacity (int slot, ItemStack itemPrototype) {
if (itemPrototype == null || itemPrototype.getItem() == null)
return 0;
public int getMaxCapacity(int slot, ItemStack itemPrototype) {
if (itemPrototype == null || itemPrototype.getItem() == null) return 0;
if (TileEntityDrawersComp.this.isUnlimited() || TileEntityDrawersComp.this.isVending()) {
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0)
return Integer.MAX_VALUE;
if (convRate == null || protoStack[slot] == null || convRate[slot] == 0) return Integer.MAX_VALUE;
return Integer.MAX_VALUE / convRate[slot];
}
if (convRate == null || protoStack[0] == null || convRate[0] == 0)
return itemPrototype.getItem().getItemStackLimit(itemPrototype) * getBaseStackCapacity();
if (BaseDrawerData.areItemsEqual(protoStack[slot], itemPrototype))
return getMaxCapacity(slot);
if (BaseDrawerData.areItemsEqual(protoStack[slot], itemPrototype)) return getMaxCapacity(slot);
return 0;
}
@Override
public int getRemainingCapacity (int slot) {
if (TileEntityDrawersComp.this.isVending())
return Integer.MAX_VALUE;
public int getRemainingCapacity(int slot) {
if (TileEntityDrawersComp.this.isVending()) return Integer.MAX_VALUE;
return getMaxCapacity(slot) - getStoredItemCount(slot);
}
@Override
public int getStoredItemStackSize (int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return 0;
public int getStoredItemStackSize(int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0) return 0;
return protoStack[slot].getItem().getItemStackLimit(protoStack[slot]);
}
@Override
public int getItemCapacityForInventoryStack (int slot) {
if (isVoid())
return Integer.MAX_VALUE;
else
return getMaxCapacity(slot);
public int getItemCapacityForInventoryStack(int slot) {
if (isVoid()) return Integer.MAX_VALUE;
else return getMaxCapacity(slot);
}
@Override
public int getConversionRate (int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return 0;
public int getConversionRate(int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0) return 0;
return convRate[0] / convRate[slot];
}
@Override
public int getStoredItemRemainder (int slot) {
public int getStoredItemRemainder(int slot) {
return TileEntityDrawersComp.this.getStoredItemRemainder(slot);
}
@Override
public boolean isSmallestUnit (int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return false;
public boolean isSmallestUnit(int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0) return false;
return convRate[slot] == 1;
}
@Override
public boolean isVoidSlot (int slot) {
public boolean isVoidSlot(int slot) {
return isVoid();
}
@Override
public boolean isShroudedSlot (int slot) {
public boolean isShroudedSlot(int slot) {
return isShrouded();
}
@Override
public boolean setIsSlotShrouded (int slot, boolean state) {
public boolean setIsSlotShrouded(int slot, boolean state) {
setIsShrouded(state);
return true;
}
@Override
public boolean isLocked (int slot, LockAttribute attr) {
public boolean isLocked(int slot, LockAttribute attr) {
return TileEntityDrawersComp.this.isLocked(attr);
}
@Override
public void writeToNBT (int slot, NBTTagCompound tag) {
public void writeToNBT(int slot, NBTTagCompound tag) {
ItemStack protoStack = getStoredItemPrototype(slot);
if (protoStack != null && protoStack.getItem() != null) {
tag.setShort("Item", (short) Item.getIdFromItem(protoStack.getItem()));
tag.setShort("Meta", (short) protoStack.getItemDamage());
tag.setInteger("Count", 0); // TODO: Remove when ready to break 1.1.7 compat
if (protoStack.getTagCompound() != null)
tag.setTag("Tags", protoStack.getTagCompound());
if (protoStack.getTagCompound() != null) tag.setTag("Tags", protoStack.getTagCompound());
}
}
@Override
public void readFromNBT (int slot, NBTTagCompound tag) {
public void readFromNBT(int slot, NBTTagCompound tag) {
if (tag.hasKey("Item")) {
Item item = Item.getItemById(tag.getShort("Item"));
if (item != null) {
ItemStack stack = new ItemStack(item);
stack.setItemDamage(tag.getShort("Meta"));
if (tag.hasKey("Tags"))
stack.setTagCompound(tag.getCompoundTag("Tags"));
if (tag.hasKey("Tags")) stack.setTagCompound(tag.getCompoundTag("Tags"));
protoStack[slot] = stack;
}
}
}
private void clear () {
private void clear() {
for (int i = 0; i < getDrawerCount(); i++) {
protoStack[i] = null;
convRate[i] = 0;
@@ -721,17 +682,15 @@ public class TileEntityDrawersComp extends TileEntityDrawers
TileEntityDrawersComp.this.markDirty();
}
public void refresh () {
public void refresh() {
for (int i = 0; i < getDrawerCount(); i++) {
IDrawer drawer = getDrawer(i);
if (drawer instanceof CompDrawerData)
((CompDrawerData) drawer).refresh();
if (drawer instanceof CompDrawerData) ((CompDrawerData) drawer).refresh();
}
}
private int getStackCapacity (int slot) {
if (convRate == null || convRate[slot] == 0)
return 0;
private int getStackCapacity(int slot) {
if (convRate == null || convRate[slot] == 0) return 0;
int slotStacks = getBaseStackCapacity();
@@ -739,62 +698,59 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return stackLimit / convRate[slot];
}
private int getBaseStackCapacity () {
private int getBaseStackCapacity() {
ConfigManager config = StorageDrawers.config;
return TileEntityDrawersComp.this.getEffectiveStorageMultiplier() * TileEntityDrawersComp.this.getDrawerCapacity();
return TileEntityDrawersComp.this.getEffectiveStorageMultiplier()
* TileEntityDrawersComp.this.getDrawerCapacity();
}
public void markAmountDirty () {
if (getWorldObj().isRemote)
return;
public void markAmountDirty() {
if (getWorldObj().isRemote) return;
IMessage message = new CountUpdateMessage(xCoord, yCoord, zCoord, 0, pooledCount);
NetworkRegistry.TargetPoint targetPoint = new NetworkRegistry.TargetPoint(getWorldObj().provider.dimensionId, xCoord, yCoord, zCoord, 500);
NetworkRegistry.TargetPoint targetPoint =
new NetworkRegistry.TargetPoint(getWorldObj().provider.dimensionId, xCoord, yCoord, zCoord, 500);
StorageDrawers.network.sendToAllAround(message, targetPoint);
}
public void markDirty (int slot) {
if (getWorldObj().isRemote)
return;
public void markDirty(int slot) {
if (getWorldObj().isRemote) return;
getWorldObj().markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
private static class InventoryLookup extends InventoryCrafting
{
private static class InventoryLookup extends InventoryCrafting {
private ItemStack[] stackList;
public InventoryLookup (int width, int height) {
public InventoryLookup(int width, int height) {
super(null, width, height);
stackList = new ItemStack[width * height];
}
@Override
public int getSizeInventory ()
{
public int getSizeInventory() {
return this.stackList.length;
}
@Override
public ItemStack getStackInSlot (int slot)
{
public ItemStack getStackInSlot(int slot) {
return slot >= this.getSizeInventory() ? null : this.stackList[slot];
}
@Override
public ItemStack getStackInSlotOnClosing (int slot) {
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
}
@Override
public ItemStack decrStackSize (int slot, int count) {
public ItemStack decrStackSize(int slot, int count) {
return null;
}
@Override
public void setInventorySlotContents (int slot, ItemStack stack) {
public void setInventorySlotContents(int slot, ItemStack stack) {
stackList[slot] = stack;
}
}
@@ -1,14 +1,11 @@
package com.jaquadro.minecraft.storagedrawers.block.tile;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.storage.*;
import com.jaquadro.minecraft.storagedrawers.storage.IStorageProvider;
import net.minecraft.tileentity.TileEntity;
public class TileEntityDrawersStandard extends TileEntityDrawers {
@@ -23,8 +20,7 @@ public class TileEntityDrawersStandard extends TileEntityDrawers {
}
protected IStorageProvider getStorageProvider() {
if (storageProvider == null)
storageProvider = new StandardStorageProvider();
if (storageProvider == null) storageProvider = new StandardStorageProvider();
return storageProvider;
}
@@ -33,7 +29,6 @@ public class TileEntityDrawersStandard extends TileEntityDrawers {
return new DrawerData(getStorageProvider(), slot);
}
private class StandardStorageProvider extends DefaultStorageProvider {
public StandardStorageProvider() {
super(TileEntityDrawersStandard.this, TileEntityDrawersStandard.this);
@@ -60,7 +55,6 @@ public class TileEntityDrawersStandard extends TileEntityDrawers {
return TileEntityDrawersStandard.this.isShrouded();
}
@Override
public boolean isDowngraded(int slot) {
return TileEntityDrawersStandard.this.isDowngraded();
@@ -15,129 +15,112 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.Constants;
public class TileEntityFramingTable extends TileEntity implements IInventory
{
public class TileEntityFramingTable extends TileEntity implements IInventory {
private ItemStack[] tableItemStacks = new ItemStack[5];
private String customName;
@Override
public int getSizeInventory () {
public int getSizeInventory() {
return tableItemStacks.length;
}
@Override
public ItemStack getStackInSlot (int slot) {
public ItemStack getStackInSlot(int slot) {
return tableItemStacks[slot];
}
@Override
public ItemStack decrStackSize (int slot, int count) {
public ItemStack decrStackSize(int slot, int count) {
if (tableItemStacks[slot] != null) {
if (tableItemStacks[slot].stackSize <= count) {
ItemStack stack = tableItemStacks[slot];
tableItemStacks[slot] = null;
markDirty();
return stack;
}
else {
} else {
ItemStack stack = tableItemStacks[slot].splitStack(count);
if (tableItemStacks[slot].stackSize == 0)
tableItemStacks[slot] = null;
if (tableItemStacks[slot].stackSize == 0) tableItemStacks[slot] = null;
markDirty();
return stack;
}
}
else
return null;
} else return null;
}
@Override
public ItemStack getStackInSlotOnClosing (int slot) {
public ItemStack getStackInSlotOnClosing(int slot) {
return null;
}
@Override
public void setInventorySlotContents (int slot, ItemStack stack) {
public void setInventorySlotContents(int slot, ItemStack stack) {
tableItemStacks[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit())
stack.stackSize = getInventoryStackLimit();
if (stack != null && stack.stackSize > getInventoryStackLimit()) stack.stackSize = getInventoryStackLimit();
markDirty();
}
@Override
public String getInventoryName () {
public String getInventoryName() {
return hasCustomInventoryName() ? customName : "storageDrawers.container.framingTable";
}
@Override
public boolean hasCustomInventoryName () {
public boolean hasCustomInventoryName() {
return customName != null && customName.length() > 0;
}
public void setCustomName (String name) {
public void setCustomName(String name) {
customName = name;
}
@Override
public int getInventoryStackLimit () {
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer (EntityPlayer player) {
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
return false;
public boolean isUseableByPlayer(EntityPlayer player) {
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) return false;
return player.getDistanceSq(xCoord + .5, yCoord + .5, zCoord + .5) <= 64;
}
@Override
public void openInventory () {
}
public void openInventory() {}
@Override
public void closeInventory () {
}
public void closeInventory() {}
@Override
public boolean isItemValidForSlot (int slot, ItemStack stack) {
if (slot == 0)
return isItemValidDrawer(stack);
if (slot == 4)
return false;
if (slot >= 1 && slot < 4)
return isItemValidMaterial(stack);
public boolean isItemValidForSlot(int slot, ItemStack stack) {
if (slot == 0) return isItemValidDrawer(stack);
if (slot == 4) return false;
if (slot >= 1 && slot < 4) return isItemValidMaterial(stack);
return false;
}
public static boolean isItemValidDrawer (ItemStack stack) {
if (stack == null)
return false;
public static boolean isItemValidDrawer(ItemStack stack) {
if (stack == null) return false;
Block block = Block.getBlockFromItem(stack.getItem());
return block instanceof BlockDrawersCustom || block instanceof BlockTrimCustom;
}
public static boolean isItemValidMaterial (ItemStack stack) {
if (stack == null)
return false;
public static boolean isItemValidMaterial(ItemStack stack) {
if (stack == null) return false;
Block block = Block.getBlockFromItem(stack.getItem());
if (block == null)
return false;
if (block == null) return false;
return block.isOpaqueCube();
}
@Override
public void readFromNBT (NBTTagCompound tag) {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagList itemList = tag.getTagList("Items", 10);
@@ -151,19 +134,18 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
tableItemStacks[slot] = ItemStack.loadItemStackFromNBT(item);
}
if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
customName = tag.getString("CustomName");
if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING)) customName = tag.getString("CustomName");
}
@Override
public void writeToNBT (NBTTagCompound tag) {
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < tableItemStacks.length; i++) {
if (tableItemStacks[i] != null) {
NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte)i);
item.setByte("Slot", (byte) i);
tableItemStacks[i].writeToNBT(item);
itemList.appendTag(item);
}
@@ -171,12 +153,11 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
tag.setTag("Items", itemList);
if (hasCustomInventoryName())
tag.setString("CustomName", customName);
if (hasCustomInventoryName()) tag.setString("CustomName", customName);
}
@Override
public Packet getDescriptionPacket () {
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
@@ -184,31 +165,26 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt) {
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
//getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
// getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
private static final AxisAlignedBB ZERO_EXTENT_AABB = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
@Override
public AxisAlignedBB getRenderBoundingBox () {
public AxisAlignedBB getRenderBoundingBox() {
int meta = getBlockMetadata();
if ((meta & 0x8) != 0)
return ZERO_EXTENT_AABB;
if ((meta & 0x8) != 0) return ZERO_EXTENT_AABB;
int side = meta & 0x7;
int xOff = 0;
int zOff = 0;
if (side == 2)
xOff = 1;
if (side == 3)
xOff = -1;
if (side == 4)
zOff = -1;
if (side == 5)
zOff = 1;
if (side == 2) xOff = 1;
if (side == 3) xOff = -1;
if (side == 4) zOff = -1;
if (side == 5) zOff = 1;
int xMin = Math.min(xCoord, xCoord + xOff);
int xMax = Math.max(xCoord, xCoord + xOff) + 1;
@@ -5,6 +5,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import com.jaquadro.minecraft.storagedrawers.api.storage.IPriorityGroup;
import com.jaquadro.minecraft.storagedrawers.api.storage.ISmartGroup;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@@ -15,17 +16,14 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants;
import java.util.ArrayList;
public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriorityGroup, ISmartGroup, ISidedInventory
{
public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriorityGroup, ISmartGroup, ISidedInventory {
private BlockCoord controllerCoord;
private BlockCoord selfCoord;
private int[] inventorySlots = new int[] { 0 };
private int[] drawerSlots = new int[] { 0 };
private int[] inventorySlots = new int[] {0};
private int[] drawerSlots = new int[] {0};
public void ensureInitialized () {
public void ensureInitialized() {
if (selfCoord == null) {
selfCoord = new BlockCoord(xCoord, yCoord, zCoord);
markDirty();
@@ -33,7 +31,7 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
}
@Override
public void readFromNBT (NBTTagCompound tag) {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
selfCoord = new BlockCoord(xCoord, yCoord, zCoord);
@@ -45,7 +43,7 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
}
@Override
public void writeToNBT (NBTTagCompound tag) {
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
if (controllerCoord != null) {
@@ -58,7 +56,7 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
}
@Override
public Packet getDescriptionPacket () {
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
@@ -66,12 +64,12 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt) {
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
public void bindController (int x, int y, int z) {
public void bindController(int x, int y, int z) {
if (controllerCoord != null && controllerCoord.x() == x && controllerCoord.y() == y && controllerCoord.z() == z)
return;
@@ -79,9 +77,8 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
markDirty();
}
public TileEntityController getController () {
if (controllerCoord == null)
return null;
public TileEntityController getController() {
if (controllerCoord == null) return null;
ensureInitialized();
@@ -92,205 +89,181 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, IPriori
return null;
}
return (TileEntityController)te;
return (TileEntityController) te;
}
@Override
public int[] getAccessibleDrawerSlots () {
public int[] getAccessibleDrawerSlots() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return drawerSlots;
if (controller == null || !controller.isValidSlave(selfCoord)) return drawerSlots;
return controller.getAccessibleDrawerSlots();
}
@Override
public int[] getAccessibleSlotsFromSide (int side) {
public int[] getAccessibleSlotsFromSide(int side) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return inventorySlots;
if (controller == null || !controller.isValidSlave(selfCoord)) return inventorySlots;
return controller.getAccessibleSlotsFromSide(0);
}
@Override
public boolean canInsertItem (int slot, ItemStack stack, int side) {
public boolean canInsertItem(int slot, ItemStack stack, int side) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return false;
if (controller == null || !controller.isValidSlave(selfCoord)) return false;
return controller.canInsertItem(slot, stack, 0);
}
@Override
public boolean canExtractItem (int slot, ItemStack stack, int side) {
public boolean canExtractItem(int slot, ItemStack stack, int side) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return false;
if (controller == null || !controller.isValidSlave(selfCoord)) return false;
return controller.canExtractItem(slot, stack, side);
}
@Override
public int getSizeInventory () {
public int getSizeInventory() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return 1;
if (controller == null || !controller.isValidSlave(selfCoord)) return 1;
return controller.getSizeInventory();
}
@Override
public ItemStack getStackInSlot (int slot) {
public ItemStack getStackInSlot(int slot) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return null;
if (controller == null || !controller.isValidSlave(selfCoord)) return null;
return controller.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize (int slot, int count) {
public ItemStack decrStackSize(int slot, int count) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return null;
if (controller == null || !controller.isValidSlave(selfCoord)) return null;
return controller.decrStackSize(slot, count);
}
@Override
public ItemStack getStackInSlotOnClosing (int slot) {
public ItemStack getStackInSlotOnClosing(int slot) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return null;
if (controller == null || !controller.isValidSlave(selfCoord)) return null;
return controller.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents (int slot, ItemStack stack) {
public void setInventorySlotContents(int slot, ItemStack stack) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return;
if (controller == null || !controller.isValidSlave(selfCoord)) return;
controller.setInventorySlotContents(slot, stack);
}
@Override
public String getInventoryName () {
public String getInventoryName() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return "storageDrawers.container.unboundSlave";
if (controller == null || !controller.isValidSlave(selfCoord)) return "storageDrawers.container.unboundSlave";
return controller.getInventoryName();
}
@Override
public boolean hasCustomInventoryName () {
public boolean hasCustomInventoryName() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return false;
if (controller == null || !controller.isValidSlave(selfCoord)) return false;
return controller.hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit () {
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer (EntityPlayer player) {
public boolean isUseableByPlayer(EntityPlayer player) {
return false;
}
@Override
public void openInventory () {
}
public void openInventory() {}
@Override
public void closeInventory () {
}
public void closeInventory() {}
@Override
public boolean isItemValidForSlot (int slot, ItemStack stack) {
public boolean isItemValidForSlot(int slot, ItemStack stack) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return false;
if (controller == null || !controller.isValidSlave(selfCoord)) return false;
return controller.isItemValidForSlot(slot, stack);
}
@Override
public int getDrawerCount () {
public int getDrawerCount() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return 0;
if (controller == null || !controller.isValidSlave(selfCoord)) return 0;
return controller.getDrawerCount();
}
@Override
public IDrawer getDrawer (int slot) {
public IDrawer getDrawer(int slot) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return null;
if (controller == null || !controller.isValidSlave(selfCoord)) return null;
return controller.getDrawer(slot);
}
@Override
public boolean isDrawerEnabled (int slot) {
public boolean isDrawerEnabled(int slot) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return false;
if (controller == null || !controller.isValidSlave(selfCoord)) return false;
return controller.isDrawerEnabled(slot);
}
@Override
public IDrawerInventory getDrawerInventory () {
public IDrawerInventory getDrawerInventory() {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return null;
if (controller == null || !controller.isValidSlave(selfCoord)) return null;
return controller.getDrawerInventory();
}
@Override
public Iterable<Integer> enumerateDrawersForInsertion (ItemStack stack, boolean strict) {
public Iterable<Integer> enumerateDrawersForInsertion(ItemStack stack, boolean strict) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return new ArrayList<Integer>();
if (controller == null || !controller.isValidSlave(selfCoord)) return new ArrayList<Integer>();
return controller.enumerateDrawersForInsertion(stack, strict);
}
@Override
public Iterable<Integer> enumerateDrawersForExtraction (ItemStack stack, boolean strict) {
public Iterable<Integer> enumerateDrawersForExtraction(ItemStack stack, boolean strict) {
TileEntityController controller = getController();
if (controller == null || !controller.isValidSlave(selfCoord))
return new ArrayList<Integer>();
if (controller == null || !controller.isValidSlave(selfCoord)) return new ArrayList<Integer>();
return controller.enumerateDrawersForExtraction(stack, strict);
}
@Override
public void markDirty () {
public void markDirty() {
TileEntityController controller = getController();
if (controller != null && controller.isValidSlave(selfCoord))
controller.markDirty();
if (controller != null && controller.isValidSlave(selfCoord)) controller.markDirty();
super.markDirty();
}
@Override
public boolean markDirtyIfNeeded () {
public boolean markDirtyIfNeeded() {
TileEntityController controller = getController();
if (controller != null && controller.isValidSlave(selfCoord))
return controller.markDirtyIfNeeded();
if (controller != null && controller.isValidSlave(selfCoord)) return controller.markDirtyIfNeeded();
return false;
}
@@ -7,50 +7,47 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
public class TileEntityTrim extends TileEntity
{
public class TileEntityTrim extends TileEntity {
private ItemStack materialSide;
private ItemStack materialTrim;
public ItemStack getMaterialSide () {
public ItemStack getMaterialSide() {
return materialSide;
}
public ItemStack getMaterialTrim () {
public ItemStack getMaterialTrim() {
return materialTrim;
}
public ItemStack getEffectiveMaterialSide () {
public ItemStack getEffectiveMaterialSide() {
return materialSide;
}
public ItemStack getEffectiveMaterialTrim () {
public ItemStack getEffectiveMaterialTrim() {
return materialTrim != null ? materialTrim : materialSide;
}
public void setMaterialSide (ItemStack material) {
public void setMaterialSide(ItemStack material) {
materialSide = material;
}
public void setMaterialTrim (ItemStack material) {
public void setMaterialTrim(ItemStack material) {
materialTrim = material;
}
@Override
public void readFromNBT (NBTTagCompound tag) {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
materialSide = null;
if (tag.hasKey("MatS"))
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
if (tag.hasKey("MatS")) materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
materialTrim = null;
if (tag.hasKey("MatT"))
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
if (tag.hasKey("MatT")) materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
}
@Override
public void writeToNBT (NBTTagCompound tag) {
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
if (materialSide != null) {
@@ -67,7 +64,7 @@ public class TileEntityTrim extends TileEntity
}
@Override
public Packet getDescriptionPacket () {
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
@@ -75,7 +72,7 @@ public class TileEntityTrim extends TileEntity
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt) {
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
@@ -5,6 +5,7 @@ import com.jaquadro.minecraft.storagedrawers.client.renderer.StorageRenderItem;
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
import com.jaquadro.minecraft.storagedrawers.integration.NotEnoughItems;
import com.jaquadro.minecraft.storagedrawers.inventory.*;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.I18n;
@@ -14,14 +15,15 @@ import net.minecraft.inventory.Slot;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.util.List;
public class GuiDrawers extends GuiContainer
{
private static final ResourceLocation guiTextures1 = new ResourceLocation("storagedrawers", "textures/gui/drawers_1.png");
private static final ResourceLocation guiTextures2 = new ResourceLocation("storagedrawers", "textures/gui/drawers_2.png");
private static final ResourceLocation guiTextures4 = new ResourceLocation("storagedrawers", "textures/gui/drawers_4.png");
private static final ResourceLocation guiTexturesComp = new ResourceLocation("storagedrawers", "textures/gui/drawers_comp.png");
public class GuiDrawers extends GuiContainer {
private static final ResourceLocation guiTextures1 =
new ResourceLocation("storagedrawers", "textures/gui/drawers_1.png");
private static final ResourceLocation guiTextures2 =
new ResourceLocation("storagedrawers", "textures/gui/drawers_2.png");
private static final ResourceLocation guiTextures4 =
new ResourceLocation("storagedrawers", "textures/gui/drawers_4.png");
private static final ResourceLocation guiTexturesComp =
new ResourceLocation("storagedrawers", "textures/gui/drawers_comp.png");
private static final int smDisabledX = 176;
private static final int smDisabledY = 0;
@@ -32,7 +34,7 @@ public class GuiDrawers extends GuiContainer
private TileEntityDrawers tileDrawers;
public GuiDrawers (InventoryPlayer inventory, TileEntityDrawers tileEntity) {
public GuiDrawers(InventoryPlayer inventory, TileEntityDrawers tileEntity) {
super(getContainer(inventory, tileEntity));
tileDrawers = tileEntity;
@@ -42,7 +44,7 @@ public class GuiDrawers extends GuiContainer
itemRender = storageItemRender;
}
private static Container getContainer (InventoryPlayer inventory, TileEntityDrawers tile) {
private static Container getContainer(InventoryPlayer inventory, TileEntityDrawers tile) {
switch (tile.getDrawerCount()) {
case 1:
return new ContainerDrawers1(inventory, tile);
@@ -58,7 +60,7 @@ public class GuiDrawers extends GuiContainer
}
@Override
public void drawScreen (int p_73863_1_, int p_73863_2_, float p_73863_3_) {
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
RenderItem ri = setItemRender(storageItemRender);
if (inventorySlots instanceof ContainerDrawers) {
@@ -76,25 +78,22 @@ public class GuiDrawers extends GuiContainer
}
@Override
protected void drawGuiContainerForegroundLayer (int p_146979_1_, int p_146979_2_) {
String name = tileDrawers.hasCustomInventoryName() ? tileDrawers.getInventoryName() : I18n.format(tileDrawers.getInventoryName(), empty);
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
String name = tileDrawers.hasCustomInventoryName()
? tileDrawers.getInventoryName()
: I18n.format(tileDrawers.getInventoryName(), empty);
fontRendererObj.drawString(name, 8, 6, 4210752);
fontRendererObj.drawString(I18n.format("storageDrawers.container.upgrades", empty), 8, 75, 4210752);
fontRendererObj.drawString(I18n.format("container.inventory",empty), 8, ySize - 96 + 2, 4210752);
fontRendererObj.drawString(I18n.format("container.inventory", empty), 8, ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer (float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1, 1, 1, 1);
if (tileDrawers.getDrawerCount() == 1)
mc.getTextureManager().bindTexture(guiTextures1);
else if (tileDrawers.getDrawerCount() == 2)
mc.getTextureManager().bindTexture(guiTextures2);
else if (tileDrawers.getDrawerCount() == 4)
mc.getTextureManager().bindTexture(guiTextures4);
else
mc.getTextureManager().bindTexture(guiTexturesComp);
if (tileDrawers.getDrawerCount() == 1) mc.getTextureManager().bindTexture(guiTextures1);
else if (tileDrawers.getDrawerCount() == 2) mc.getTextureManager().bindTexture(guiTextures2);
else if (tileDrawers.getDrawerCount() == 4) mc.getTextureManager().bindTexture(guiTextures4);
else mc.getTextureManager().bindTexture(guiTexturesComp);
int guiX = (width - xSize) / 2;
int guiY = (height - ySize) / 2;
@@ -105,20 +104,27 @@ public class GuiDrawers extends GuiContainer
List<Slot> storageSlots = container.getStorageSlots();
for (int i = 0, n = storageSlots.size(); i < n; i++) {
Slot slot = storageSlots.get(i);
drawTexturedModalRect(guiX + slot.xDisplayPosition, guiY + slot.yDisplayPosition, smDisabledX, smDisabledY, 16, 16);
drawTexturedModalRect(
guiX + slot.xDisplayPosition, guiY + slot.yDisplayPosition, smDisabledX, smDisabledY, 16, 16);
}
List<Slot> upgradeSlots = container.getUpgradeSlots();
for (int i = 0, n = upgradeSlots.size(); i < n; i++) {
Slot slot = upgradeSlots.get(i);
if (slot instanceof SlotUpgrade && !((SlotUpgrade)slot).canTakeStack())
drawTexturedModalRect(guiX + slot.xDisplayPosition, guiY + slot.yDisplayPosition, smDisabledX, smDisabledY, 16, 16);
if (slot instanceof SlotUpgrade && !((SlotUpgrade) slot).canTakeStack())
drawTexturedModalRect(
guiX + slot.xDisplayPosition,
guiY + slot.yDisplayPosition,
smDisabledX,
smDisabledY,
16,
16);
}
}
}
@Override
protected boolean func_146978_c (int x, int y, int width, int height, int originX, int originY) {
protected boolean func_146978_c(int x, int y, int width, int height, int originX, int originY) {
if (inventorySlots instanceof ContainerDrawers) {
ContainerDrawers container = (ContainerDrawers) inventorySlots;
List<Slot> storageSlots = container.getStorageSlots();
@@ -131,15 +137,17 @@ public class GuiDrawers extends GuiContainer
List<Slot> upgradeSlots = container.getUpgradeSlots();
for (int i = 0, n = upgradeSlots.size(); i < n; i++) {
Slot slot = upgradeSlots.get(i);
if (slot instanceof SlotUpgrade && !((SlotUpgrade)slot).canTakeStack() && slot.xDisplayPosition == x && slot.yDisplayPosition == y)
return false;
if (slot instanceof SlotUpgrade
&& !((SlotUpgrade) slot).canTakeStack()
&& slot.xDisplayPosition == x
&& slot.yDisplayPosition == y) return false;
}
}
return super.func_146978_c(x, y, width, height, originX, originY);
}
private RenderItem setItemRender (RenderItem renderItem) {
private RenderItem setItemRender(RenderItem renderItem) {
if (IntegrationRegistry.instance().isModLoaded("NotEnoughItems"))
return NotEnoughItems.setItemRender(renderItem);
else {
@@ -12,12 +12,12 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiFraming extends GuiContainer
{
private static final ResourceLocation guiTextires = new ResourceLocation(StorageDrawers.MOD_ID.toLowerCase(), "textures/gui/framing.png");
public class GuiFraming extends GuiContainer {
private static final ResourceLocation guiTextires =
new ResourceLocation(StorageDrawers.MOD_ID.toLowerCase(), "textures/gui/framing.png");
private TileEntityFramingTable tileFramingTable;
public GuiFraming (InventoryPlayer inventory, TileEntityFramingTable tileEntity) {
public GuiFraming(InventoryPlayer inventory, TileEntityFramingTable tileEntity) {
super(new ContainerFramingTable(inventory, tileEntity));
tileFramingTable = tileEntity;
@@ -26,14 +26,16 @@ public class GuiFraming extends GuiContainer
}
@Override
protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY) {
String name = tileFramingTable.hasCustomInventoryName() ? tileFramingTable.getInventoryName() : I18n.format(tileFramingTable.getInventoryName());
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = tileFramingTable.hasCustomInventoryName()
? tileFramingTable.getInventoryName()
: I18n.format(tileFramingTable.getInventoryName());
fontRendererObj.drawString(name, 8, 6, 4210752);
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer (float dt, int mouseX, int mouseY) {
protected void drawGuiContainerBackgroundLayer(float dt, int mouseX, int mouseY) {
GL11.glColor4f(1, 1, 1, 1);
mc.getTextureManager().bindTexture(guiTextires);
@@ -3,8 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.client.renderer;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.block.BlockController;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
import com.jaquadro.minecraft.storagedrawers.core.CommonProxy;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelperState;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@@ -14,33 +12,31 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class ControllerRenderer implements ISimpleBlockRenderingHandler
{
public class ControllerRenderer implements ISimpleBlockRenderingHandler {
private static final double unit = .0625f;
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockController))
return;
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockController)) return;
renderInventoryBlock((BlockController) block, metadata, modelId, renderer);
}
private void renderInventoryBlock (BlockController block, int metadata, int modelId, RenderBlocks renderer) {
private void renderInventoryBlock(BlockController block, int metadata, int modelId, RenderBlocks renderer) {
int side = 4;
boxRenderer.setUnit(unit);
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
for (int i = 0; i < 6; i++)
boxRenderer.setIcon(block.getIcon(i, metadata), i);
for (int i = 0; i < 6; i++) boxRenderer.setIcon(block.getIcon(i, metadata), i);
GL11.glRotatef(90, 0, 1, 0);
GL11.glTranslatef(-.5f, -.5f, -.5f);
RenderHelper.instance.state.setUVRotation(RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
RenderHelper.instance.state.setUVRotation(
RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
renderExterior(block, 0, 0, 0,side, renderer);
renderExterior(block, 0, 0, 0, side, renderer);
boxRenderer.setUnit(0);
boxRenderer.setInteriorIcon(block.getIcon(side, metadata), ForgeDirection.OPPOSITES[side]);
@@ -53,26 +49,26 @@ public class ControllerRenderer implements ISimpleBlockRenderingHandler
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockController))
return false;
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockController)) return false;
return renderWorldBlock(world, x, y, z, (BlockController) block, modelId, renderer);
}
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockController block, int modelId, RenderBlocks renderer) {
private boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, BlockController block, int modelId, RenderBlocks renderer) {
TileEntityController tile = block.getTileEntity(world, x, y, z);
if (tile == null)
return false;
if (tile == null) return false;
int side = tile.getDirection();
RenderHelper.instance.state.setUVRotation(RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
RenderHelper.instance.state.setUVRotation(
RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
boxRenderer.setUnit(unit);
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
for (int i = 0; i < 6; i++)
boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
for (int i = 0; i < 6; i++) boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
boxRenderer.setCutIcon(block.getIconTrim(0));
boxRenderer.setInteriorIcon(block.getIconTrim(0));
@@ -89,66 +85,108 @@ public class ControllerRenderer implements ISimpleBlockRenderingHandler
return true;
}
private void renderExterior (BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderExterior(BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
double depth = 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = 0; xMax = 1;
zMin = 1 - depth; zMax = 1;
xMin = 0;
xMax = 1;
zMin = 1 - depth;
zMax = 1;
break;
case 3:
xMin = 0; xMax = 1;
zMin = 0; zMax = depth;
xMin = 0;
xMax = 1;
zMin = 0;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1;
zMin = 0; zMax = 1;
xMin = 1 - depth;
xMax = 1;
zMin = 0;
zMax = 1;
break;
case 5:
xMin = 0; xMax = depth;
zMin = 0; zMax = 1;
xMin = 0;
xMax = depth;
zMin = 0;
zMax = 1;
break;
}
boxRenderer.renderExterior(renderer.blockAccess, block, x, y, z, xMin, 0, zMin, xMax, 1, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderExterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
0,
zMin,
xMax,
1,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
private void renderInterior (BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderInterior(BlockController block, int x, int y, int z, int side, RenderBlocks renderer) {
double unit = .0625;
double depth = 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = unit; xMax = 1 - unit;
zMin = 1 - depth; zMax = 1 - depth + unit;
xMin = unit;
xMax = 1 - unit;
zMin = 1 - depth;
zMax = 1 - depth + unit;
break;
case 3:
xMin = unit; xMax = 1 - unit;
zMin = depth - unit; zMax = depth;
xMin = unit;
xMax = 1 - unit;
zMin = depth - unit;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1 - depth + unit;
zMin = unit; zMax = 1 - unit;
xMin = 1 - depth;
xMax = 1 - depth + unit;
zMin = unit;
zMax = 1 - unit;
break;
case 5:
xMin = depth - unit; xMax = depth;
zMin = unit; zMax = 1 - unit;
xMin = depth - unit;
xMax = depth;
zMin = unit;
zMax = 1 - unit;
break;
}
boxRenderer.renderInterior(renderer.blockAccess, block, x, y, z, xMin, unit, zMin, xMax, 1 - unit, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderInterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
unit,
zMin,
xMax,
1 - unit,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
@Override
public boolean shouldRender3DInInventory (int modelId) {
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId () {
public int getRenderId() {
return StorageDrawers.proxy.controllerRenderID;
}
}
@@ -6,44 +6,42 @@ import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import com.jaquadro.minecraft.storagedrawers.client.renderer.common.CommonDrawerRenderer;
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class DrawersCustomRenderer extends DrawersRenderer
{
public class DrawersCustomRenderer extends DrawersRenderer {
private CommonDrawerRenderer commonRender = new CommonDrawerRenderer();
@Override
protected void renderBaseBlock (IBlockAccess world, TileEntityDrawers tile, int x, int y, int z, BlockDrawers block, RenderBlocks renderer) {
BlockDrawersCustom custom = (BlockDrawersCustom)block;
protected void renderBaseBlock(
IBlockAccess world,
TileEntityDrawers tile,
int x,
int y,
int z,
BlockDrawers block,
RenderBlocks renderer) {
BlockDrawersCustom custom = (BlockDrawersCustom) block;
ItemStack materialSide = tile.getMaterialSide();
if (materialSide == null)
materialSide = new ItemStack(block);
if (materialSide == null) materialSide = new ItemStack(block);
ItemStack materialFront = tile.getMaterialFront();
if (materialFront == null)
materialFront = materialSide;
if (materialFront == null) materialFront = materialSide;
ItemStack materialTrim = tile.getMaterialTrim();
if (materialTrim == null)
materialTrim = materialSide;
if (materialTrim == null) materialTrim = materialSide;
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
IIcon frontIcon = Block.getBlockFromItem(materialFront.getItem()).getIcon(4, materialFront.getItemDamage());
if (trimIcon == null)
trimIcon = custom.getDefaultTrimIcon();
if (panelIcon == null)
panelIcon = custom.getDefaultFaceIcon();
if (frontIcon == null)
frontIcon = custom.getDefaultFaceIcon();
if (trimIcon == null) trimIcon = custom.getDefaultTrimIcon();
if (panelIcon == null) panelIcon = custom.getDefaultFaceIcon();
if (frontIcon == null) frontIcon = custom.getDefaultFaceIcon();
if (ClientProxy.renderPass == 0)
commonRender.renderBasePass(world, x, y, z, custom, tile.getDirection(), panelIcon, trimIcon, frontIcon);
@@ -52,7 +50,7 @@ public class DrawersCustomRenderer extends DrawersRenderer
}
@Override
public int getRenderId () {
public int getRenderId() {
return StorageDrawers.proxy.drawersCustomRenderID;
}
}
@@ -3,7 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.client.renderer;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
import com.jaquadro.minecraft.storagedrawers.client.renderer.common.CommonDrawerRenderer;
import com.jaquadro.minecraft.storagedrawers.core.ClientProxy;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelperState;
import net.minecraft.block.Block;
@@ -15,52 +14,45 @@ import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class DrawersItemRenderer implements IItemRenderer
{
//private RenderHelper renderHelper = new RenderHelper();
public class DrawersItemRenderer implements IItemRenderer {
// private RenderHelper renderHelper = new RenderHelper();
private CommonDrawerRenderer commonRender = new CommonDrawerRenderer();
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
//private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
//private float[] colorScratch = new float[3];
// private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
// private float[] colorScratch = new float[3];
@Override
public boolean handleRenderType (ItemStack item, ItemRenderType type) {
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
RenderBlocks renderer = getRenderer(data);
if (renderer == null)
return;
if (renderer == null) return;
Block block = Block.getBlockFromItem(item.getItem());
if (!(block instanceof BlockDrawers))
return;
if (!(block instanceof BlockDrawers)) return;
renderDrawer((BlockDrawers) block, item, renderer, type);
}
private void renderDrawer (BlockDrawers block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
private void renderDrawer(BlockDrawers block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
int side = 4;
if (renderType == ItemRenderType.INVENTORY)
GL11.glRotatef(90, 0, 1, 0);
if (renderType == ItemRenderType.ENTITY)
GL11.glRotatef(180, 0, 1, 0);
if (renderType == ItemRenderType.INVENTORY) GL11.glRotatef(90, 0, 1, 0);
if (renderType == ItemRenderType.ENTITY) GL11.glRotatef(180, 0, 1, 0);
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
GL11.glTranslatef(block.halfDepth ? -.75f : -.5f, -.5f, -.5f);
if (block instanceof BlockDrawersCustom)
renderCustomBlock(block, item, renderer);
else
renderBaseBlock(block, item, renderer);
if (block instanceof BlockDrawersCustom) renderCustomBlock(block, item, renderer);
else renderBaseBlock(block, item, renderer);
if (item.hasTagCompound() && item.getTagCompound().hasKey("tile")) {
double depth = block.halfDepth ? .5 : 1;
@@ -72,17 +64,17 @@ public class DrawersItemRenderer implements IItemRenderer
GL11.glTranslatef(block.halfDepth ? .75f : .5f, .5f, .5f);
}
private void renderBaseBlock (BlockDrawers block, ItemStack item, RenderBlocks renderer) {
private void renderBaseBlock(BlockDrawers block, ItemStack item, RenderBlocks renderer) {
int side = 4;
RenderHelper.instance.state.setUVRotation(RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZPOS][side]);
RenderHelper.instance.state.setUVRotation(
RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZPOS][side]);
boxRenderer.setUnit(block.getTrimWidth());
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
for (int i = 0; i < 6; i++)
boxRenderer.setIcon(block.getIcon(i, item.getItemDamage()), i);
for (int i = 0; i < 6; i++) boxRenderer.setIcon(block.getIcon(i, item.getItemDamage()), i);
renderExterior(block, 0, 0, 0,side, renderer);
renderExterior(block, 0, 0, 0, side, renderer);
RenderHelper.instance.state.clearUVRotation(RenderHelper.YPOS);
@@ -92,101 +84,133 @@ public class DrawersItemRenderer implements IItemRenderer
renderInterior(block, 0, 0, 0, side, renderer);
}
private void renderCustomBlock (BlockDrawers block, ItemStack item, RenderBlocks renderer) {
BlockDrawersCustom custom = (BlockDrawersCustom)block;
private void renderCustomBlock(BlockDrawers block, ItemStack item, RenderBlocks renderer) {
BlockDrawersCustom custom = (BlockDrawersCustom) block;
ItemStack materialSide = null;
ItemStack materialTrim = null;
ItemStack materialFront = null;
if (item.hasTagCompound()) {
NBTTagCompound tag = item.getTagCompound();
if (tag.hasKey("MatS"))
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
if (tag.hasKey("MatT"))
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
if (tag.hasKey("MatF"))
materialFront = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatF"));
if (tag.hasKey("MatS")) materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
if (tag.hasKey("MatT")) materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
if (tag.hasKey("MatF")) materialFront = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatF"));
}
if (materialSide == null)
materialSide = new ItemStack(block);
if (materialTrim == null)
materialTrim = materialSide;
if (materialFront == null)
materialFront = materialSide;
if (materialSide == null) materialSide = new ItemStack(block);
if (materialTrim == null) materialTrim = materialSide;
if (materialFront == null) materialFront = materialSide;
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
IIcon frontIcon = Block.getBlockFromItem(materialFront.getItem()).getIcon(4, materialFront.getItemDamage());
if (trimIcon == null)
trimIcon = custom.getDefaultTrimIcon();
if (panelIcon == null)
panelIcon = custom.getDefaultFaceIcon();
if (frontIcon == null)
frontIcon = custom.getDefaultFaceIcon();
if (trimIcon == null) trimIcon = custom.getDefaultTrimIcon();
if (panelIcon == null) panelIcon = custom.getDefaultFaceIcon();
if (frontIcon == null) frontIcon = custom.getDefaultFaceIcon();
commonRender.renderBasePass(null, 0, 0, 0, custom, RenderHelper.XNEG, panelIcon, trimIcon, frontIcon);
commonRender.renderOverlayPass(null, 0, 0, 0, custom, RenderHelper.XNEG, trimIcon, frontIcon);
}
private void renderExterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderExterior(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = 0; xMax = 1;
zMin = 1 - depth; zMax = 1;
xMin = 0;
xMax = 1;
zMin = 1 - depth;
zMax = 1;
break;
case 3:
xMin = 0; xMax = 1;
zMin = 0; zMax = depth;
xMin = 0;
xMax = 1;
zMin = 0;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1;
zMin = 0; zMax = 1;
xMin = 1 - depth;
xMax = 1;
zMin = 0;
zMax = 1;
break;
case 5:
xMin = 0; xMax = depth;
zMin = 0; zMax = 1;
xMin = 0;
xMax = depth;
zMin = 0;
zMax = 1;
break;
}
boxRenderer.renderExterior(renderer.blockAccess, block, x, y, z, xMin, 0, zMin, xMax, 1, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderExterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
0,
zMin,
xMax,
1,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
private void renderInterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderInterior(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double unit = block.getTrimDepth();
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = unit; xMax = 1 - unit;
zMin = 1 - depth; zMax = 1 - depth + unit;
xMin = unit;
xMax = 1 - unit;
zMin = 1 - depth;
zMax = 1 - depth + unit;
break;
case 3:
xMin = unit; xMax = 1 - unit;
zMin = depth - unit; zMax = depth;
xMin = unit;
xMax = 1 - unit;
zMin = depth - unit;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1 - depth + unit;
zMin = unit; zMax = 1 - unit;
xMin = 1 - depth;
xMax = 1 - depth + unit;
zMin = unit;
zMax = 1 - unit;
break;
case 5:
xMin = depth - unit; xMax = depth;
zMin = unit; zMax = 1 - unit;
xMin = depth - unit;
xMax = depth;
zMin = unit;
zMax = 1 - unit;
break;
}
boxRenderer.renderInterior(renderer.blockAccess, block, x, y, z, xMin, unit, zMin, xMax, 1 - unit, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderInterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
unit,
zMin,
xMax,
1 - unit,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
private RenderBlocks getRenderer (Object[] data) {
private RenderBlocks getRenderer(Object[] data) {
for (Object obj : data) {
if (obj instanceof RenderBlocks)
return (RenderBlocks)obj;
if (obj instanceof RenderBlocks) return (RenderBlocks) obj;
}
return null;
@@ -3,7 +3,6 @@ package com.jaquadro.minecraft.storagedrawers.client.renderer;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
import com.jaquadro.minecraft.storagedrawers.block.BlockCompDrawers;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
@@ -11,65 +10,75 @@ import com.jaquadro.minecraft.storagedrawers.util.RenderHelperState;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class DrawersRenderer implements ISimpleBlockRenderingHandler
{
public class DrawersRenderer implements ISimpleBlockRenderingHandler {
private static final double unit = .0625f;
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
return;
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockDrawers))
return false;
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockDrawers)) return false;
return renderWorldBlock(world, x, y, z, (BlockDrawers) block, modelId, renderer);
}
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockDrawers block, int modelId, RenderBlocks renderer) {
private boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, BlockDrawers block, int modelId, RenderBlocks renderer) {
TileEntityDrawers tile = block.getTileEntity(world, x, y, z);
if (tile == null)
return false;
if (tile == null) return false;
renderBaseBlock(world, tile, x, y, z, block, renderer);
if (renderer.overrideBlockTexture != null && renderer.overrideBlockTexture.getIconName().startsWith("destroy_stage"))
return true;
if (renderer.overrideBlockTexture != null
&& renderer.overrideBlockTexture.getIconName().startsWith("destroy_stage")) return true;
int side = tile.getDirection();
if (StorageDrawers.config.cache.enableIndicatorUpgrades)
renderIndicator(block, x, y, z, side, renderer, tile.getEffectiveStatusLevel());
if (StorageDrawers.config.cache.enableLockUpgrades)
renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED), tile.getOwner() != null);
if (StorageDrawers.config.cache.enableVoidUpgrades)
renderVoid(block, x, y, z, side, renderer, tile.isVoid());
if (StorageDrawers.config.cache.enableTape)
renderTape(block, x, y, z, side, renderer, tile.isSealed());
renderLock(
block,
x,
y,
z,
side,
renderer,
tile.isLocked(LockAttribute.LOCK_POPULATED),
tile.getOwner() != null);
if (StorageDrawers.config.cache.enableVoidUpgrades) renderVoid(block, x, y, z, side, renderer, tile.isVoid());
if (StorageDrawers.config.cache.enableTape) renderTape(block, x, y, z, side, renderer, tile.isSealed());
renderShroud(block, x, y, z, side, renderer, tile.isShrouded());
return true;
}
protected void renderBaseBlock (IBlockAccess world, TileEntityDrawers tile, int x, int y, int z, BlockDrawers block, RenderBlocks renderer) {
protected void renderBaseBlock(
IBlockAccess world,
TileEntityDrawers tile,
int x,
int y,
int z,
BlockDrawers block,
RenderBlocks renderer) {
int side = tile.getDirection();
int meta = world.getBlockMetadata(x, y, z);
RenderHelper.instance.state.setUVRotation(RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
RenderHelper.instance.state.setUVRotation(
RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][side]);
boxRenderer.setUnit(block.getTrimWidth());
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
for (int i = 0; i < 6; i++)
boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
for (int i = 0; i < 6; i++) boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
boxRenderer.setCutIcon(block.getIconTrim(meta));
boxRenderer.setInteriorIcon(block.getIconTrim(meta));
@@ -95,35 +104,35 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
renderInterior(block, x, y, z, side, renderer);
}
private void renderLock (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean locked, boolean owned) {
if (!locked && !owned)
return;
private void renderLock(
BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean locked, boolean owned) {
if (!locked && !owned) return;
double depth = block.halfDepth ? .5 : 1;
IIcon iconLock = block.getLockIcon(locked, owned);
RenderHelper.instance.setRenderBounds(0.46875, 0.9375, 0, 0.53125, 1, depth + .005);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderPartialFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconLock, 0, 0, 1, 1);
RenderHelper.instance.renderPartialFace(
RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconLock, 0, 0, 1, 1);
RenderHelper.instance.state.clearRotateTransform();
}
private void renderVoid (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean voided) {
if (!voided)
return;
private void renderVoid(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean voided) {
if (!voided) return;
double depth = block.halfDepth ? .5 : 1;
IIcon iconVoid = block.getVoidIcon();
RenderHelper.instance.setRenderBounds(1 - .0625, 0.9375, 0, 1, 1, depth + .005);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderPartialFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconVoid, 0, 0, 1, 1);
RenderHelper.instance.renderPartialFace(
RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconVoid, 0, 0, 1, 1);
RenderHelper.instance.state.clearRotateTransform();
}
private void renderTape (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean taped) {
if (!taped)
return;
private void renderTape(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean taped) {
if (!taped) return;
double depth = block.halfDepth ? .5 : 1;
IIcon iconTape = block.getTapeIcon();
@@ -135,31 +144,47 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
}
private static final int[] cut = new int[] {
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZPOS,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS,
ModularBoxRenderer.CUT_YPOS
| ModularBoxRenderer.CUT_YNEG
| ModularBoxRenderer.CUT_XPOS
| ModularBoxRenderer.CUT_XNEG
| ModularBoxRenderer.CUT_ZPOS,
ModularBoxRenderer.CUT_YPOS
| ModularBoxRenderer.CUT_YNEG
| ModularBoxRenderer.CUT_XPOS
| ModularBoxRenderer.CUT_XNEG
| ModularBoxRenderer.CUT_ZNEG,
ModularBoxRenderer.CUT_YPOS
| ModularBoxRenderer.CUT_YNEG
| ModularBoxRenderer.CUT_XPOS
| ModularBoxRenderer.CUT_ZNEG
| ModularBoxRenderer.CUT_ZPOS,
ModularBoxRenderer.CUT_YPOS
| ModularBoxRenderer.CUT_YNEG
| ModularBoxRenderer.CUT_XNEG
| ModularBoxRenderer.CUT_ZNEG
| ModularBoxRenderer.CUT_ZPOS,
};
private static final float[][] drawerXYWH1 = new float[][] {
{ 0, 0, 16, 16 },
{0, 0, 16, 16},
};
private static final float[][] drawerXYWH2 = new float[][] {
{ 0, 8, 16, 8 }, { 0, 0, 16, 8 },
{0, 8, 16, 8}, {0, 0, 16, 8},
};
private static final float[][] drawerXYWH4 = new float[][] {
{ 0, 8, 8, 8 }, { 0, 0, 8, 8 }, { 8, 8, 8, 8 }, { 8, 0, 8, 8 },
{0, 8, 8, 8}, {0, 0, 8, 8}, {8, 8, 8, 8}, {8, 0, 8, 8},
};
private static final float[][] drawerXYWH3 = new float[][] {
{ 0, 8, 16, 8 }, { 0, 0, 8, 8 }, { 8, 0, 8, 8 },
{0, 8, 16, 8}, {0, 0, 8, 8}, {8, 0, 8, 8},
};
private void renderShroud (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean shrouded) {
if (!shrouded || side < 2 || side > 5)
return;
private void renderShroud(
BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean shrouded) {
if (!shrouded || side < 2 || side > 5) return;
TileEntityDrawers tile = block.getTileEntity(renderer.blockAccess, x, y, z);
@@ -176,16 +201,13 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
w = 4;
h = 4;
xywhSet = drawerXYWH1;
}
else if (block.drawerCount == 2) {
} else if (block.drawerCount == 2) {
count = 2;
xywhSet = drawerXYWH2;
}
else if (block.drawerCount == 3) {
} else if (block.drawerCount == 3) {
count = 3;
xywhSet = drawerXYWH3;
}
else if (block.drawerCount == 4) {
} else if (block.drawerCount == 4) {
count = 4;
xywhSet = drawerXYWH4;
}
@@ -194,23 +216,22 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
for (int i = 0; i < count; i++) {
IDrawer drawer = tile.getDrawer(i);
if (drawer == null || drawer.isEmpty())
continue;
if (drawer == null || drawer.isEmpty()) continue;
float[] xywh = xywhSet[i];
float subX = xywh[0] + (xywh[2] - w) / 2;
float subY = xywh[1] + (xywh[3] - h) / 2;
RenderHelper.instance.setRenderBounds(subX * unit, subY * unit, 0, (subX + w) * unit, (subY + h) * unit, (depth - depthAdj + .05) * unit);
RenderHelper.instance.setRenderBounds(
subX * unit, subY * unit, 0, (subX + w) * unit, (subY + h) * unit, (depth - depthAdj + .05) * unit);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, icon);
RenderHelper.instance.state.clearRotateTransform();
}
}
private void renderIndicator (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, int level) {
if (level <= 0 || side < 2 || side > 5)
return;
private void renderIndicator(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, int level) {
if (level <= 0 || side < 2 || side > 5) return;
TileEntityDrawers tile = block.getTileEntity(renderer.blockAccess, x, y, z);
@@ -222,12 +243,10 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
if (block.drawerCount == 1) {
count = 1;
xywhSet = drawerXYWH1;
}
else if (block.drawerCount == 2) {
} else if (block.drawerCount == 2) {
count = 2;
xywhSet = drawerXYWH2;
}
else if (block.drawerCount == 4) {
} else if (block.drawerCount == 4) {
count = 4;
xywhSet = drawerXYWH4;
}
@@ -239,28 +258,40 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
for (int i = 0; i < count; i++) {
IDrawer drawer = tile.getDrawer(i);
if (drawer == null)
continue;
if (drawer == null) continue;
float[] xywh = xywhSet[i];
RenderHelper.instance.setRenderBounds(xywh[0] * unit, xywh[1] * unit, 0, (xywh[0] + xywh[2]) * unit, (xywh[1] + xywh[3]) * unit, (depth - depthAdj + .05) * unit);
RenderHelper.instance.setRenderBounds(
xywh[0] * unit,
xywh[1] * unit,
0,
(xywh[0] + xywh[2]) * unit,
(xywh[1] + xywh[3]) * unit,
(depth - depthAdj + .05) * unit);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconOff);
RenderHelper.instance.state.clearRotateTransform();
if (level == 1 && drawer.getMaxCapacity() > 0 && drawer.getRemainingCapacity() == 0) {
RenderHelper.instance.state.setColorMult(1, 1, .9f, 1);
RenderHelper.instance.setRenderBounds(xywh[0] * unit, xywh[1] * unit, 0, (xywh[0] + xywh[2]) * unit, (xywh[1] + xywh[3]) * unit, (depth - depthAdj + .06) * unit);
RenderHelper.instance.setRenderBounds(
xywh[0] * unit,
xywh[1] * unit,
0,
(xywh[0] + xywh[2]) * unit,
(xywh[1] + xywh[3]) * unit,
(depth - depthAdj + .06) * unit);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconOn);
RenderHelper.instance.state.clearRotateTransform();
RenderHelper.instance.state.resetColorMult();
}
else if (level >= 2) {
} else if (level >= 2) {
double indXStart = xywh[0] + block.getIndStart() / unit;
double indXEnd = xywh[0] + block.getIndEnd() / unit;
double indXCur = (block.getIndSteps() == 0) ? indXEnd : getIndEnd(block, tile, i, indXStart, (block.getIndEnd() - block.getIndStart()) / unit);
double indXCur = (block.getIndSteps() == 0)
? indXEnd
: getIndEnd(block, tile, i, indXStart, (block.getIndEnd() - block.getIndStart()) / unit);
double indYStart = xywh[1];
double indYEnd = xywh[1] + xywh[3];
@@ -268,7 +299,13 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
if (indXCur > indXStart) {
RenderHelper.instance.state.setColorMult(1, 1, .9f, 1);
RenderHelper.instance.setRenderBounds(indXStart * unit, indYStart * unit, 0, indXCur * unit, indYCur * unit, (depth - depthAdj + .06) * unit);
RenderHelper.instance.setRenderBounds(
indXStart * unit,
indYStart * unit,
0,
indXCur * unit,
indYCur * unit,
(depth - depthAdj + .06) * unit);
RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side);
RenderHelper.instance.renderFace(RenderHelper.ZPOS, renderer.blockAccess, block, x, y, z, iconOn);
RenderHelper.instance.state.clearRotateTransform();
@@ -278,82 +315,122 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
}
}
private double getIndEnd (BlockDrawers block, TileEntityDrawers tile, int slot, double x, double w) {
private double getIndEnd(BlockDrawers block, TileEntityDrawers tile, int slot, double x, double w) {
IDrawer drawer = tile.getDrawer(slot);
if (drawer == null)
return x;
if (drawer == null) return x;
int cap = drawer.getMaxCapacity();
int count = drawer.getStoredItemCount();
if (cap == 0 || count == 0)
return x;
if (cap == 0 || count == 0) return x;
int step = block.getIndSteps() > 0 ? block.getIndSteps() : 1000;
float fillAmt = (float)((double)step * count / cap) / step;
float fillAmt = (float) ((double) step * count / cap) / step;
return x + (w * fillAmt);
}
private void renderExterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderExterior(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = 0; xMax = 1;
zMin = 1 - depth; zMax = 1;
xMin = 0;
xMax = 1;
zMin = 1 - depth;
zMax = 1;
break;
case 3:
xMin = 0; xMax = 1;
zMin = 0; zMax = depth;
xMin = 0;
xMax = 1;
zMin = 0;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1;
zMin = 0; zMax = 1;
xMin = 1 - depth;
xMax = 1;
zMin = 0;
zMax = 1;
break;
case 5:
xMin = 0; xMax = depth;
zMin = 0; zMax = 1;
xMin = 0;
xMax = depth;
zMin = 0;
zMax = 1;
break;
}
boxRenderer.renderExterior(renderer.blockAccess, block, x, y, z, xMin, 0, zMin, xMax, 1, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderExterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
0,
zMin,
xMax,
1,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
private void renderInterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
private void renderInterior(BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double unit = block.getTrimDepth();
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
switch (side) {
case 2:
xMin = unit; xMax = 1 - unit;
zMin = 1 - depth; zMax = 1 - depth + unit;
xMin = unit;
xMax = 1 - unit;
zMin = 1 - depth;
zMax = 1 - depth + unit;
break;
case 3:
xMin = unit; xMax = 1 - unit;
zMin = depth - unit; zMax = depth;
xMin = unit;
xMax = 1 - unit;
zMin = depth - unit;
zMax = depth;
break;
case 4:
xMin = 1 - depth; xMax = 1 - depth + unit;
zMin = unit; zMax = 1 - unit;
xMin = 1 - depth;
xMax = 1 - depth + unit;
zMin = unit;
zMax = 1 - unit;
break;
case 5:
xMin = depth - unit; xMax = depth;
zMin = unit; zMax = 1 - unit;
xMin = depth - unit;
xMax = depth;
zMin = unit;
zMax = 1 - unit;
break;
}
boxRenderer.renderInterior(renderer.blockAccess, block, x, y, z, xMin, unit, zMin, xMax, 1 - unit, zMax, 0, ModularBoxRenderer.sideCut[side]);
boxRenderer.renderInterior(
renderer.blockAccess,
block,
x,
y,
z,
xMin,
unit,
zMin,
xMax,
1 - unit,
zMax,
0,
ModularBoxRenderer.sideCut[side]);
}
@Override
public boolean shouldRender3DInInventory (int modelId) {
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId () {
public int getRenderId() {
return StorageDrawers.proxy.drawersRenderID;
}
}
@@ -11,24 +11,20 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
public class FramingTableRenderer implements ISimpleBlockRenderingHandler
{
public class FramingTableRenderer implements ISimpleBlockRenderingHandler {
private CommonFramingRenderer framingRenderer = new CommonFramingRenderer();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockFramingTable))
return;
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockFramingTable)) return;
BlockFramingTable framingTable = (BlockFramingTable)block;
BlockFramingTable framingTable = (BlockFramingTable) block;
boolean blendEnabled = GL11.glIsEnabled(GL11.GL_BLEND);
if (blendEnabled)
GL11.glDisable(GL11.GL_BLEND);
if (blendEnabled) GL11.glDisable(GL11.GL_BLEND);
boolean depthMask = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK);
if (!depthMask)
GL11.glDepthMask(true);
if (!depthMask) GL11.glDepthMask(true);
GL11.glPushMatrix();
GL11.glRotatef(90, 0, 1, 0);
@@ -42,41 +38,33 @@ public class FramingTableRenderer implements ISimpleBlockRenderingHandler
RenderHelper.instance.state.clearUVRotation(RenderHelper.YPOS);
if (!blendEnabled)
GL11.glDisable(GL11.GL_BLEND);
if (!depthMask)
GL11.glDepthMask(false);
if (!blendEnabled) GL11.glDisable(GL11.GL_BLEND);
if (!depthMask) GL11.glDepthMask(false);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockFramingTable))
return false;
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockFramingTable)) return false;
BlockFramingTable framingTable = (BlockFramingTable)block;
BlockFramingTable framingTable = (BlockFramingTable) block;
int meta = world.getBlockMetadata(x, y, z);
int side = meta & 0x7;
boolean right = (meta & 0x08) == 0;
if (side == 2 || side == 3)
right = !right;
if (side == 2 || side == 3) right = !right;
RenderHelper.instance.state.setRotateTransform(side, RenderHelper.ZNEG);
RenderHelper.instance.state.setUVRotation(RenderHelper.YPOS, RenderHelper.instance.state.rotateTransform);
if (ClientProxy.renderPass == 0) {
if (right)
framingRenderer.renderRight(world, x, y, z, framingTable);
else
framingRenderer.renderLeft(world, x, y, z, framingTable);
}
else if (ClientProxy.renderPass == 1) {
if (right)
framingRenderer.renderOverlayRight(world, x, y, z, framingTable);
else
framingRenderer.renderOverlayLeft(world, x, y, z, framingTable);
if (right) framingRenderer.renderRight(world, x, y, z, framingTable);
else framingRenderer.renderLeft(world, x, y, z, framingTable);
} else if (ClientProxy.renderPass == 1) {
if (right) framingRenderer.renderOverlayRight(world, x, y, z, framingTable);
else framingRenderer.renderOverlayLeft(world, x, y, z, framingTable);
}
RenderHelper.instance.state.clearRotateTransform();
@@ -86,12 +74,12 @@ public class FramingTableRenderer implements ISimpleBlockRenderingHandler
}
@Override
public boolean shouldRender3DInInventory (int modelId) {
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId () {
public int getRenderId() {
return StorageDrawers.proxy.framingTableRenderID;
}
}
@@ -1,48 +1,42 @@
package com.jaquadro.minecraft.storagedrawers.client.renderer;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
public final class GLUtil
{
private GLUtil () { }
public final class GLUtil {
private GLUtil() {}
public static List<int[]> makeGLState () {
public static List<int[]> makeGLState() {
return new ArrayList<int[]>(8);
}
public static List<int[]> makeGLState (int[] saveList) {
public static List<int[]> makeGLState(int[] saveList) {
List<int[]> state = new ArrayList<int[]>(saveList.length);
for (int i = 0, n = saveList.length; i < n; i++)
state.add(new int[] { 0, 0 });
for (int i = 0, n = saveList.length; i < n; i++) state.add(new int[] {0, 0});
return state;
}
public static List<int[]> saveGLState (int[] saveList) {
public static List<int[]> saveGLState(int[] saveList) {
List<int[]> state = makeGLState(saveList);
saveGLStateCore(state, saveList);
return state;
}
public static void saveGLState (List<int[]> state, int[] saveList) {
if (state == null || saveList == null)
return;
public static void saveGLState(List<int[]> state, int[] saveList) {
if (state == null || saveList == null) return;
for (int i = state.size(), n = saveList.length; i < n; i++)
state.add(new int[2]);
for (int i = state.size(), n = saveList.length; i < n; i++) state.add(new int[2]);
for (int i = 0, n = state.size(); i < n; i++)
state.get(i)[0] = 0;
for (int i = 0, n = state.size(); i < n; i++) state.get(i)[0] = 0;
saveGLStateCore(state, saveList);
}
private static void saveGLStateCore (List<int[]> state, int[] saveList) {
private static void saveGLStateCore(List<int[]> state, int[] saveList) {
for (int i = 0, n = saveList.length; i < n; i++) {
int[] entry = state.get(i);
entry[0] = saveList[i];
@@ -50,19 +44,15 @@ public final class GLUtil
}
}
public static void restoreGLState (List<int[]> state) {
if (state == null)
return;
public static void restoreGLState(List<int[]> state) {
if (state == null) return;
for (int i = 0, n = state.size(); i < n; i++) {
int[] entry = state.get(i);
if (entry[0] == 0)
break;
if (entry[0] == 0) break;
if (entry[1] == 0)
GL11.glDisable(entry[0]);
else
GL11.glEnable(entry[0]);
if (entry[1] == 0) GL11.glDisable(entry[0]);
else GL11.glEnable(entry[0]);
}
}
}
@@ -5,8 +5,7 @@ import net.minecraft.block.Block;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class ModularBoxRenderer
{
public class ModularBoxRenderer {
public static final int CONNECT_YNEG = 1 << 0;
public static final int CONNECT_YPOS = 1 << 1;
public static final int CONNECT_ZNEG = 1 << 2;
@@ -64,12 +63,14 @@ public class ModularBoxRenderer
private static final int TEST_YPOS_ZPOS_XNEG = CUT_YPOS | CUT_ZPOS | CUT_XNEG;
private static final int TEST_YPOS_ZPOS_XPOS = CUT_YPOS | CUT_ZPOS | CUT_XPOS;
private static final int PLANE_YNEG = CONNECT_YNEG | CONNECT_YNEG_ZNEG | CONNECT_YNEG_ZPOS | CONNECT_YNEG_XNEG | CONNECT_YNEG_XPOS;
private static final int PLANE_YPOS = CONNECT_YPOS | CONNECT_YPOS_ZNEG | CONNECT_YPOS_ZPOS | CONNECT_YPOS_XNEG | CONNECT_YPOS_XPOS;
private static final int PLANE_YNEG =
CONNECT_YNEG | CONNECT_YNEG_ZNEG | CONNECT_YNEG_ZPOS | CONNECT_YNEG_XNEG | CONNECT_YNEG_XPOS;
private static final int PLANE_YPOS =
CONNECT_YPOS | CONNECT_YPOS_ZNEG | CONNECT_YPOS_ZPOS | CONNECT_YPOS_XNEG | CONNECT_YPOS_XPOS;
public static final float[] COLOR_WHITE = new float[] { 1, 1, 1 };
public static final float[] COLOR_WHITE = new float[] {1, 1, 1};
public static final int[] sideCut = new int[] { CUT_YNEG, CUT_YPOS, CUT_ZNEG, CUT_ZPOS, CUT_XNEG, CUT_XPOS };
public static final int[] sideCut = new int[] {CUT_YNEG, CUT_YPOS, CUT_ZNEG, CUT_ZPOS, CUT_XNEG, CUT_XPOS};
private double unit = 0.0625;
@@ -83,122 +84,114 @@ public class ModularBoxRenderer
public boolean flipOpposite;
private void copyFrom (float[] target, float[] source) {
private void copyFrom(float[] target, float[] source) {
target[0] = source[0];
target[1] = source[1];
target[2] = source[2];
}
private void copyFrom (float[] target, float r, float g, float b) {
private void copyFrom(float[] target, float r, float g, float b) {
target[0] = r;
target[1] = g;
target[2] = b;
}
public void setColor (float[] color) {
public void setColor(float[] color) {
setExteriorColor(color);
setInteriorColor(color);
setCutColor(color);
}
public void setScaledColor (float[] color, float scale) {
public void setScaledColor(float[] color, float scale) {
setScaledExteriorColor(color, scale);
setScaledInteriorColor(color, scale);
setScaledCutColor(color, scale);
}
public void setExteriorColor (float[] color) {
for (int i = 0; i < 6; i++)
copyFrom(exteriorColor[i], color);
public void setExteriorColor(float[] color) {
for (int i = 0; i < 6; i++) copyFrom(exteriorColor[i], color);
}
public void setExteriorColor (float[] color, int side) {
public void setExteriorColor(float[] color, int side) {
copyFrom(exteriorColor[side], color);
}
public void setScaledExteriorColor (float[] color, float scale) {
for (int i = 0; i < 6; i++)
copyFrom(exteriorColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
public void setScaledExteriorColor(float[] color, float scale) {
for (int i = 0; i < 6; i++) copyFrom(exteriorColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
}
public void setScaledExteriorColor (float[] color, float scale, int side) {
public void setScaledExteriorColor(float[] color, float scale, int side) {
copyFrom(exteriorColor[side], color[0] * scale, color[1] * scale, color[2] * scale);
}
public void setInteriorColor (float[] color) {
for (int i = 0; i < 6; i++)
copyFrom(interiorColor[i], color);
public void setInteriorColor(float[] color) {
for (int i = 0; i < 6; i++) copyFrom(interiorColor[i], color);
}
public void setInteriorColor (float[] color, int side) {
public void setInteriorColor(float[] color, int side) {
side = (side % 2 == 0) ? side + 1 : side - 1;
copyFrom(interiorColor[side], color);
}
public void setScaledInteriorColor (float[] color, float scale) {
for (int i = 0; i < 6; i++)
copyFrom(interiorColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
public void setScaledInteriorColor(float[] color, float scale) {
for (int i = 0; i < 6; i++) copyFrom(interiorColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
}
public void setCutColor (float[] color) {
for (int i = 0; i < 6; i++)
copyFrom(cutColor[i], color);
public void setCutColor(float[] color) {
for (int i = 0; i < 6; i++) copyFrom(cutColor[i], color);
}
public void setCutColor (float[] color, int side) {
public void setCutColor(float[] color, int side) {
copyFrom(cutColor[side], color);
}
public void setScaledCutColor (float[] color, float scale) {
for (int i = 0; i < 6; i++)
copyFrom(cutColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
public void setScaledCutColor(float[] color, float scale) {
for (int i = 0; i < 6; i++) copyFrom(cutColor[i], color[0] * scale, color[1] * scale, color[2] * scale);
}
public void setIcon (IIcon icon) {
public void setIcon(IIcon icon) {
setExteriorIcon(icon);
setInteriorIcon(icon);
setCutIcon(icon);
}
public void setIcon (IIcon icon, int side) {
public void setIcon(IIcon icon, int side) {
setExteriorIcon(icon, side);
setInteriorIcon(icon, side);
setCutIcon(icon, side);
}
public void setExteriorIcon (IIcon icon) {
for (int i = 0; i < 6; i++)
exteriorIcon[i] = icon;
public void setExteriorIcon(IIcon icon) {
for (int i = 0; i < 6; i++) exteriorIcon[i] = icon;
}
public void setExteriorIcon (IIcon icon, int side) {
public void setExteriorIcon(IIcon icon, int side) {
exteriorIcon[side] = icon;
}
public void setInteriorIcon (IIcon icon) {
for (int i = 0; i < 6; i++)
interiorIcon[i] = icon;
public void setInteriorIcon(IIcon icon) {
for (int i = 0; i < 6; i++) interiorIcon[i] = icon;
}
public void setInteriorIcon (IIcon icon, int side) {
public void setInteriorIcon(IIcon icon, int side) {
side = (side % 2 == 0) ? side + 1 : side - 1;
interiorIcon[side] = icon;
}
public void setCutIcon (IIcon icon) {
for (int i = 0; i < 6; i++)
cutIcon[i] = icon;
public void setCutIcon(IIcon icon) {
for (int i = 0; i < 6; i++) cutIcon[i] = icon;
}
public void setCutIcon (IIcon icon, int side) {
public void setCutIcon(IIcon icon, int side) {
cutIcon[side] = icon;
}
public void setUnit (double unit) {
public void setUnit(double unit) {
this.unit = unit;
}
public void renderOctant (IBlockAccess blockAccess, Block block, double x, double y, double z, int connectedFlags, int cutFlags) {
public void renderOctant(
IBlockAccess blockAccess, Block block, double x, double y, double z, int connectedFlags, int cutFlags) {
double xBase = Math.floor(x);
double yBase = Math.floor(y);
double zBase = Math.floor(z);
@@ -209,53 +202,79 @@ public class ModularBoxRenderer
double yPos = yNeg + .5;
double zPos = zNeg + .5;
renderExterior(blockAccess, block, xBase, yBase, zBase, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
renderInterior(blockAccess, block, xBase, yBase, zBase, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
renderExterior(
blockAccess, block, xBase, yBase, zBase, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
renderInterior(
blockAccess, block, xBase, yBase, zBase, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
}
public void renderBox (IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos, int connectedFlags, int cutFlags) {
public void renderBox(
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos,
int connectedFlags,
int cutFlags) {
renderExterior(blockAccess, block, x, y, z, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
renderInterior(blockAccess, block, x, y, z, xNeg, yNeg, zNeg, xPos, yPos, zPos, connectedFlags, cutFlags);
}
public void renderSolidBox (IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos) {
public void renderSolidBox(
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos) {
renderExterior(blockAccess, block, x, y, z, xNeg, yNeg, zNeg, xPos, yPos, zPos, 0, 0);
}
public void renderExterior (IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos, int connectedFlags, int cutFlags) {
public void renderExterior(
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos,
int connectedFlags,
int cutFlags) {
RenderHelper renderHelper = RenderHelper.instance;
if ((cutFlags & CUT_YNEG) != 0)
connectedFlags |= CONNECT_YNEG;
if ((cutFlags & CUT_YPOS) != 0)
connectedFlags |= CONNECT_YPOS;
if ((cutFlags & CUT_ZNEG) != 0)
connectedFlags |= CONNECT_ZNEG;
if ((cutFlags & CUT_ZPOS) != 0)
connectedFlags |= CONNECT_ZPOS;
if ((cutFlags & CUT_XNEG) != 0)
connectedFlags |= CONNECT_XNEG;
if ((cutFlags & CUT_XPOS) != 0)
connectedFlags |= CONNECT_XPOS;
if ((cutFlags & CUT_YNEG) != 0) connectedFlags |= CONNECT_YNEG;
if ((cutFlags & CUT_YPOS) != 0) connectedFlags |= CONNECT_YPOS;
if ((cutFlags & CUT_ZNEG) != 0) connectedFlags |= CONNECT_ZNEG;
if ((cutFlags & CUT_ZPOS) != 0) connectedFlags |= CONNECT_ZPOS;
if ((cutFlags & CUT_XNEG) != 0) connectedFlags |= CONNECT_XNEG;
if ((cutFlags & CUT_XPOS) != 0) connectedFlags |= CONNECT_XPOS;
renderHelper.setRenderBounds(xNeg, yNeg, zNeg, xPos, yPos, zPos);
// Render solid faces
if ((connectedFlags & CONNECT_YNEG) == 0)
renderExteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) == 0)
renderExteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) == 0)
renderExteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) == 0)
renderExteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) == 0)
renderExteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) == 0)
renderExteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YNEG) == 0) renderExteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) == 0) renderExteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) == 0) renderExteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) == 0) renderExteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) == 0) renderExteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) == 0) renderExteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if (unit == 0)
return;
if (unit == 0) return;
// Render edge faces
if ((cutFlags & TEST_YNEG_ZNEG) != 0) {
@@ -346,93 +365,124 @@ public class ModularBoxRenderer
// Render corner faces
if ((cutFlags & TEST_YNEG_ZNEG_XNEG) != 0) {
renderHelper.setRenderBounds(xNeg, yNeg, zNeg, xNeg + unit, yNeg + unit, zNeg + unit);
if ((cutFlags & CUT_YNEG) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags)
if ((cutFlags & CUT_YNEG) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags)
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags)
if ((cutFlags & CUT_ZNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags)
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags)
if ((cutFlags & CUT_XNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags)
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YNEG_ZNEG_XPOS) != 0) {
renderHelper.setRenderBounds(xPos - unit, yNeg, zNeg, xPos, yNeg + unit, zNeg + unit);
if ((cutFlags & CUT_YNEG) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags)
if ((cutFlags & CUT_YNEG) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags)
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags)
if ((cutFlags & CUT_ZNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags)
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags)
if ((cutFlags & CUT_XPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags)
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YNEG_ZPOS_XNEG) != 0) {
renderHelper.setRenderBounds(xNeg, yNeg, zPos - unit, xNeg + unit, yNeg + unit, zPos);
if ((cutFlags & CUT_YNEG) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags)
if ((cutFlags & CUT_YNEG) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags)
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags)
if ((cutFlags & CUT_ZPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags)
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags)
if ((cutFlags & CUT_XNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags)
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YNEG_ZPOS_XPOS) != 0) {
renderHelper.setRenderBounds(xPos - unit, yNeg, zPos - unit, xPos, yNeg + unit, zPos);
if ((cutFlags & CUT_YNEG) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags)
if ((cutFlags & CUT_YNEG) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags)
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags)
if ((cutFlags & CUT_ZPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags)
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags)
if ((cutFlags & CUT_XPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags)
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YPOS_ZNEG_XNEG) != 0) {
renderHelper.setRenderBounds(xNeg, yPos - unit, zNeg, xNeg + unit, yPos, zNeg + unit);
if ((cutFlags & CUT_YPOS) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags)
if ((cutFlags & CUT_YPOS) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags)
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags)
if ((cutFlags & CUT_ZNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags)
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags)
if ((cutFlags & CUT_XNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags)
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YPOS_ZNEG_XPOS) != 0) {
renderHelper.setRenderBounds(xPos - unit, yPos - unit, zNeg, xPos, yPos, zNeg + unit);
if ((cutFlags & CUT_YPOS) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags)
if ((cutFlags & CUT_YPOS) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags)
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags)
if ((cutFlags & CUT_ZNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags)
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags)
if ((cutFlags & CUT_XPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags)
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YPOS_ZPOS_XNEG) != 0) {
renderHelper.setRenderBounds(xNeg, yPos - unit, zPos - unit, xNeg + unit, yPos, zPos);
if ((cutFlags & CUT_YPOS) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags)
if ((cutFlags & CUT_YPOS) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags)
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags)
if ((cutFlags & CUT_ZPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags)
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags)
if ((cutFlags & CUT_XNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags)
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
}
if ((cutFlags & TEST_YPOS_ZPOS_XPOS) != 0) {
renderHelper.setRenderBounds(xPos - unit, yPos - unit, zPos - unit, xPos, yPos, zPos);
if ((cutFlags & CUT_YPOS) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags)
if ((cutFlags & CUT_YPOS) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags)
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_ZPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags)
if ((cutFlags & CUT_ZPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags)
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((cutFlags & CUT_XPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags)
if ((cutFlags & CUT_XPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags)
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
}
}
public void renderInterior (IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos, int connectedFlags, int cutFlags) {
public void renderInterior(
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos,
int connectedFlags,
int cutFlags) {
RenderHelper renderHelper = RenderHelper.instance;
if ((cutFlags & CUT_YNEG) != 0)
connectedFlags |= PLANE_YNEG;
if ((cutFlags & CUT_YPOS) != 0)
connectedFlags |= PLANE_YPOS;
if ((cutFlags & CUT_ZNEG) != 0)
connectedFlags |= CONNECT_ZNEG;
if ((cutFlags & CUT_ZPOS) != 0)
connectedFlags |= CONNECT_ZPOS;
if ((cutFlags & CUT_XNEG) != 0)
connectedFlags |= CONNECT_XNEG;
if ((cutFlags & CUT_XPOS) != 0)
connectedFlags |= CONNECT_XPOS;
if ((cutFlags & CUT_YNEG) != 0) connectedFlags |= PLANE_YNEG;
if ((cutFlags & CUT_YPOS) != 0) connectedFlags |= PLANE_YPOS;
if ((cutFlags & CUT_ZNEG) != 0) connectedFlags |= CONNECT_ZNEG;
if ((cutFlags & CUT_ZPOS) != 0) connectedFlags |= CONNECT_ZPOS;
if ((cutFlags & CUT_XNEG) != 0) connectedFlags |= CONNECT_XNEG;
if ((cutFlags & CUT_XPOS) != 0) connectedFlags |= CONNECT_XPOS;
renderHelper.setRenderBounds(xNeg + unit, yNeg + unit, zNeg + unit, xPos - unit, yPos - unit, zPos - unit);
@@ -462,98 +512,93 @@ public class ModularBoxRenderer
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
}
if (unit == 0)
return;
if (unit == 0) return;
// Render edge faces
if ((connectedFlags & TEST_YNEG_ZNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_YNEG_ZNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg + unit, yNeg, zNeg, xPos - unit, yNeg + unit, zNeg + unit);
if ((connectedFlags & CONNECT_YNEG) != 0)
renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YNEG) != 0) renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0) renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_ZPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_YNEG_ZPOS) != connectedFlags) {
renderHelper.setRenderBounds(xNeg + unit, yNeg, zPos - unit, xPos - unit, yNeg + unit, zPos);
if ((connectedFlags & CONNECT_YNEG) != 0)
renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YNEG) != 0) renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0) renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_XNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_XNEG) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XNEG | CONNECT_YNEG_XNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg, yNeg, zNeg + unit, xNeg + unit, yNeg + unit, zPos - unit);
if ((connectedFlags & CONNECT_YNEG) != 0)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YNEG) != 0) renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0) renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_XPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_XPOS) != 0
&& (connectedFlags | CONNECT_YNEG | CONNECT_XPOS | CONNECT_YNEG_XPOS) != connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yNeg, zNeg + unit, xPos, yNeg + unit, zPos - unit);
if ((connectedFlags & CONNECT_YNEG) != 0)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YNEG) != 0) renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0) renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_YPOS_ZNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg + unit, yPos - unit, zNeg, xPos - unit, yPos, zNeg + unit);
if ((connectedFlags & CONNECT_YPOS) != 0)
renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) != 0) renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0) renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_YPOS_ZPOS) != connectedFlags) {
renderHelper.setRenderBounds(xNeg + unit, yPos - unit, zPos - unit, xPos - unit, yPos, zPos);
if ((connectedFlags & CONNECT_YPOS) != 0)
renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) != 0) renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0) renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_XNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_XNEG) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XNEG | CONNECT_YPOS_XNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg, yPos - unit, zNeg + unit, xNeg + unit, yPos, zPos - unit);
if ((connectedFlags & CONNECT_YPOS) != 0)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) != 0) renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0) renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_XPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_XPOS) != 0
&& (connectedFlags | CONNECT_YPOS | CONNECT_XPOS | CONNECT_YPOS_XPOS) != connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yPos - unit, zNeg + unit, xPos, yPos, zPos - unit);
if ((connectedFlags & CONNECT_YPOS) != 0)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_YPOS) != 0) renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0) renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_ZNEG_XNEG) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_ZNEG_XNEG) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg, yNeg + unit, zNeg, xNeg + unit, yPos - unit, zNeg + unit);
if ((connectedFlags & CONNECT_ZNEG) != 0)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0)
renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0) renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0) renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_ZNEG_XPOS) != 0 && (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_ZNEG_XPOS) != 0
&& (connectedFlags | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yNeg + unit, zNeg, xPos, yPos - unit, zNeg + unit);
if ((connectedFlags & CONNECT_ZNEG) != 0)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0)
renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZNEG) != 0) renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0) renderInteriorFace(FACE_ZPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_ZPOS_XNEG) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_ZPOS_XNEG) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags) {
renderHelper.setRenderBounds(xNeg, yNeg + unit, zPos - unit, xNeg + unit, yPos - unit, zPos);
if ((connectedFlags & CONNECT_ZPOS) != 0)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0)
renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0) renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XNEG) != 0) renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_ZPOS_XPOS) != 0 && (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_ZPOS_XPOS) != 0
&& (connectedFlags | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yNeg + unit, zPos - unit, xPos, yPos - unit, zPos);
if ((connectedFlags & CONNECT_ZPOS) != 0)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0)
renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_ZPOS) != 0) renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
if ((connectedFlags & CONNECT_XPOS) != 0) renderInteriorFace(FACE_ZNEG, blockAccess, block, x, y, z);
}
// Render corner faces
if ((connectedFlags & TEST_YNEG_ZNEG_XNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_YNEG_ZNEG | CONNECT_YNEG_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZNEG_XNEG) != 0
&& (connectedFlags
| CONNECT_YNEG
| CONNECT_ZNEG
| CONNECT_XNEG
| CONNECT_YNEG_ZNEG
| CONNECT_YNEG_XNEG
| CONNECT_ZNEG_XNEG)
!= connectedFlags) {
renderHelper.setRenderBounds(xNeg, yNeg, zNeg, xNeg + unit, yNeg + unit, zNeg + unit);
if ((connectedFlags | CONNECT_YNEG | CONNECT_ZNEG) == connectedFlags)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
@@ -562,7 +607,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZNEG | CONNECT_XNEG) == connectedFlags)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_ZNEG_XPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_YNEG_ZNEG | CONNECT_YNEG_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZNEG_XPOS) != 0
&& (connectedFlags
| CONNECT_YNEG
| CONNECT_ZNEG
| CONNECT_XPOS
| CONNECT_YNEG_ZNEG
| CONNECT_YNEG_XPOS
| CONNECT_ZNEG_XPOS)
!= connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yNeg, zNeg, xPos, yNeg + unit, zNeg + unit);
if ((connectedFlags | CONNECT_YNEG | CONNECT_ZNEG) == connectedFlags)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
@@ -571,7 +624,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZNEG | CONNECT_XPOS) == connectedFlags)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_ZPOS_XNEG) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_YNEG_ZPOS | CONNECT_YNEG_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZPOS_XNEG) != 0
&& (connectedFlags
| CONNECT_YNEG
| CONNECT_ZPOS
| CONNECT_XNEG
| CONNECT_YNEG_ZPOS
| CONNECT_YNEG_XNEG
| CONNECT_ZPOS_XNEG)
!= connectedFlags) {
renderHelper.setRenderBounds(xNeg, yNeg, zPos - unit, xNeg + unit, yNeg + unit, zPos);
if ((connectedFlags | CONNECT_YNEG | CONNECT_ZPOS) == connectedFlags)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
@@ -580,7 +641,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZPOS | CONNECT_XNEG) == connectedFlags)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YNEG_ZPOS_XPOS) != 0 && (connectedFlags | CONNECT_YNEG | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_YNEG_ZPOS | CONNECT_YNEG_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YNEG_ZPOS_XPOS) != 0
&& (connectedFlags
| CONNECT_YNEG
| CONNECT_ZPOS
| CONNECT_XPOS
| CONNECT_YNEG_ZPOS
| CONNECT_YNEG_XPOS
| CONNECT_ZPOS_XPOS)
!= connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yNeg, zPos - unit, xPos, yNeg + unit, zPos);
if ((connectedFlags | CONNECT_YNEG | CONNECT_ZPOS) == connectedFlags)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
@@ -589,7 +658,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZPOS | CONNECT_XPOS) == connectedFlags)
renderInteriorFace(FACE_YPOS, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZNEG_XNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_XNEG | CONNECT_YPOS_ZNEG | CONNECT_YPOS_XNEG | CONNECT_ZNEG_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZNEG_XNEG) != 0
&& (connectedFlags
| CONNECT_YPOS
| CONNECT_ZNEG
| CONNECT_XNEG
| CONNECT_YPOS_ZNEG
| CONNECT_YPOS_XNEG
| CONNECT_ZNEG_XNEG)
!= connectedFlags) {
renderHelper.setRenderBounds(xNeg, yPos - unit, zNeg, xNeg + unit, yPos, zNeg + unit);
if ((connectedFlags | CONNECT_YPOS | CONNECT_ZNEG) == connectedFlags)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
@@ -598,7 +675,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZNEG | CONNECT_XNEG) == connectedFlags)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZNEG_XPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZNEG | CONNECT_XPOS | CONNECT_YPOS_ZNEG | CONNECT_YPOS_XPOS | CONNECT_ZNEG_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZNEG_XPOS) != 0
&& (connectedFlags
| CONNECT_YPOS
| CONNECT_ZNEG
| CONNECT_XPOS
| CONNECT_YPOS_ZNEG
| CONNECT_YPOS_XPOS
| CONNECT_ZNEG_XPOS)
!= connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yPos - unit, zNeg, xPos, yPos, zNeg + unit);
if ((connectedFlags | CONNECT_YPOS | CONNECT_ZNEG) == connectedFlags)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
@@ -607,7 +692,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZNEG | CONNECT_XPOS) == connectedFlags)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZPOS_XNEG) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_XNEG | CONNECT_YPOS_ZPOS | CONNECT_YPOS_XNEG | CONNECT_ZPOS_XNEG) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZPOS_XNEG) != 0
&& (connectedFlags
| CONNECT_YPOS
| CONNECT_ZPOS
| CONNECT_XNEG
| CONNECT_YPOS_ZPOS
| CONNECT_YPOS_XNEG
| CONNECT_ZPOS_XNEG)
!= connectedFlags) {
renderHelper.setRenderBounds(xNeg, yPos - unit, zPos - unit, xNeg + unit, yPos, zPos);
if ((connectedFlags | CONNECT_YPOS | CONNECT_ZPOS) == connectedFlags)
renderInteriorFace(FACE_XPOS, blockAccess, block, x, y, z);
@@ -616,7 +709,15 @@ public class ModularBoxRenderer
if ((connectedFlags | CONNECT_ZPOS | CONNECT_XNEG) == connectedFlags)
renderInteriorFace(FACE_YNEG, blockAccess, block, x, y, z);
}
if ((connectedFlags & TEST_YPOS_ZPOS_XPOS) != 0 && (connectedFlags | CONNECT_YPOS | CONNECT_ZPOS | CONNECT_XPOS | CONNECT_YPOS_ZPOS | CONNECT_YPOS_XPOS | CONNECT_ZPOS_XPOS) != connectedFlags) {
if ((connectedFlags & TEST_YPOS_ZPOS_XPOS) != 0
&& (connectedFlags
| CONNECT_YPOS
| CONNECT_ZPOS
| CONNECT_XPOS
| CONNECT_YPOS_ZPOS
| CONNECT_YPOS_XPOS
| CONNECT_ZPOS_XPOS)
!= connectedFlags) {
renderHelper.setRenderBounds(xPos - unit, yPos - unit, zPos - unit, xPos, yPos, zPos);
if ((connectedFlags | CONNECT_YPOS | CONNECT_ZPOS) == connectedFlags)
renderInteriorFace(FACE_XNEG, blockAccess, block, x, y, z);
@@ -627,7 +728,17 @@ public class ModularBoxRenderer
}
}
private void renderFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z, IIcon icon, float r, float g, float b) {
private void renderFace(
int face,
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
IIcon icon,
float r,
float g,
float b) {
RenderHelper renderHelper = RenderHelper.instance;
switch (face) {
case FACE_YNEG:
@@ -645,11 +756,21 @@ public class ModularBoxRenderer
}
}
private void renderExteriorFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
renderFace(face, blockAccess, block, x, y, z, exteriorIcon[face], exteriorColor[face][0], exteriorColor[face][1], exteriorColor[face][2]);
private void renderExteriorFace(int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
renderFace(
face,
blockAccess,
block,
x,
y,
z,
exteriorIcon[face],
exteriorColor[face][0],
exteriorColor[face][1],
exteriorColor[face][2]);
}
private void renderInteriorFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
private void renderInteriorFace(int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
IIcon icon = interiorIcon[face];
float r = interiorColor[face][0];
float g = interiorColor[face][1];
@@ -658,7 +779,17 @@ public class ModularBoxRenderer
renderFace(face, blockAccess, block, x, y, z, icon, r, g, b);
}
private void renderCutFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
renderFace(face, blockAccess, block, x, y, z, cutIcon[face], cutColor[face][0], cutColor[face][1], cutColor[face][2]);
private void renderCutFace(int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
renderFace(
face,
blockAccess,
block,
x,
y,
z,
cutIcon[face],
cutColor[face][0],
cutColor[face][1],
cutColor[face][2]);
}
}
@@ -5,8 +5,7 @@ import net.minecraft.block.Block;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class PanelBoxRenderer
{
public class PanelBoxRenderer {
public static final int FACE_YNEG = 0;
public static final int FACE_YPOS = 1;
public static final int FACE_ZNEG = 2;
@@ -14,8 +13,12 @@ public class PanelBoxRenderer
public static final int FACE_XNEG = 4;
public static final int FACE_XPOS = 5;
private static final int TRIM_CUT = ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_ZNEG
| ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_ZPOS;
private static final int TRIM_CUT = ModularBoxRenderer.CUT_XNEG
| ModularBoxRenderer.CUT_YNEG
| ModularBoxRenderer.CUT_ZNEG
| ModularBoxRenderer.CUT_XPOS
| ModularBoxRenderer.CUT_YPOS
| ModularBoxRenderer.CUT_ZPOS;
private ModularBoxRenderer trimRenderer = new ModularBoxRenderer();
@@ -28,139 +31,235 @@ public class PanelBoxRenderer
private float[] panelColor = new float[3];
private IIcon panelIcon;
public void setTrimWidth (double width) {
public void setTrimWidth(double width) {
trimWidth = width;
}
public void setTrimDepth (double depth) {
public void setTrimDepth(double depth) {
trimDepth = depth;
}
public void setTrimIcon (IIcon icon) {
public void setTrimIcon(IIcon icon) {
trimIcon = icon;
}
public void setTrimColor (float[] color) {
public void setTrimColor(float[] color) {
copyFrom(trimColor, color);
}
public void setPanelIcon (IIcon icon) {
public void setPanelIcon(IIcon icon) {
panelIcon = icon;
}
public void setPanelColor (float[] color) {
public void setPanelColor(float[] color) {
copyFrom(panelColor, color);
}
public void renderFacePanel (int face, IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos) {
public void renderFacePanel(
int face,
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos) {
RenderHelper renderer = RenderHelper.instance;
switch (face) {
case FACE_YNEG:
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimDepth, zNeg + trimWidth, xPos - trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth,
yNeg + trimDepth,
zNeg + trimWidth,
xPos - trimWidth,
yNeg + trimDepth,
zPos - trimWidth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
case FACE_YPOS:
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimDepth, zNeg + trimWidth, xPos - trimWidth, yPos - trimDepth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth,
yPos - trimDepth,
zNeg + trimWidth,
xPos - trimWidth,
yPos - trimDepth,
zPos - trimWidth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
case FACE_ZNEG:
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zNeg + trimDepth, xPos - trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderer.setRenderBounds(
xNeg + trimWidth,
yNeg + trimWidth,
zNeg + trimDepth,
xPos - trimWidth,
yPos - trimWidth,
zNeg + trimDepth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
case FACE_ZPOS:
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zPos - trimDepth, xPos - trimWidth, yPos - trimWidth, zPos - trimDepth);
renderer.setRenderBounds(
xNeg + trimWidth,
yNeg + trimWidth,
zPos - trimDepth,
xPos - trimWidth,
yPos - trimWidth,
zPos - trimDepth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
case FACE_XNEG:
renderer.setRenderBounds(xNeg + trimDepth, yNeg + trimWidth, zNeg + trimWidth, xNeg + trimDepth, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimDepth,
yNeg + trimWidth,
zNeg + trimWidth,
xNeg + trimDepth,
yPos - trimWidth,
zPos - trimWidth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
case FACE_XPOS:
renderer.setRenderBounds(xPos - trimDepth, yNeg + trimWidth, zNeg + trimWidth, xPos - trimDepth, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimDepth,
yNeg + trimWidth,
zNeg + trimWidth,
xPos - trimDepth,
yPos - trimWidth,
zPos - trimWidth);
renderPaneltFace(face, blockAccess, block, x, y, z);
break;
}
}
public void renderInteriorTrim (int face, IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos) {
public void renderInteriorTrim(
int face,
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos) {
RenderHelper renderer = RenderHelper.instance;
switch (face) {
case FACE_YNEG:
renderer.setRenderBounds(xNeg + trimWidth, yNeg, zPos - trimWidth, xPos - trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg, zPos - trimWidth, xPos - trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg, zNeg + trimWidth, xPos - trimWidth, yNeg + trimDepth, zNeg + trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg, zNeg + trimWidth, xPos - trimWidth, yNeg + trimDepth, zNeg + trimWidth);
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimWidth, yNeg, zNeg + trimWidth, xPos - trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimWidth, yNeg, zNeg + trimWidth, xPos - trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg, zNeg + trimWidth, xNeg + trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg, zNeg + trimWidth, xNeg + trimWidth, yNeg + trimDepth, zPos - trimWidth);
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
break;
case FACE_YPOS:
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimDepth, zPos - trimWidth, xPos - trimWidth, yPos, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yPos - trimDepth, zPos - trimWidth, xPos - trimWidth, yPos, zPos - trimWidth);
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimDepth, zNeg + trimWidth, xPos - trimWidth, yPos, zNeg + trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yPos - trimDepth, zNeg + trimWidth, xPos - trimWidth, yPos, zNeg + trimWidth);
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimWidth, yPos - trimDepth, zNeg + trimWidth, xPos - trimWidth, yPos, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimWidth, yPos - trimDepth, zNeg + trimWidth, xPos - trimWidth, yPos, zPos - trimWidth);
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimDepth, zNeg + trimWidth, xNeg + trimWidth, yPos, zPos - trimWidth);
renderer.setRenderBounds(
xNeg + trimWidth, yPos - trimDepth, zNeg + trimWidth, xNeg + trimWidth, yPos, zPos - trimWidth);
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
break;
case FACE_ZNEG:
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimWidth, zNeg, xPos - trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderer.setRenderBounds(
xNeg + trimWidth, yPos - trimWidth, zNeg, xPos - trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zNeg, xPos - trimWidth, yNeg + trimWidth, zNeg + trimDepth);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg + trimWidth, zNeg, xPos - trimWidth, yNeg + trimWidth, zNeg + trimDepth);
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimWidth, yNeg + trimWidth, zNeg, xPos - trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderer.setRenderBounds(
xPos - trimWidth, yNeg + trimWidth, zNeg, xPos - trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zNeg, xNeg + trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg + trimWidth, zNeg, xNeg + trimWidth, yPos - trimWidth, zNeg + trimDepth);
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
break;
case FACE_ZPOS:
renderer.setRenderBounds(xNeg + trimWidth, yPos - trimWidth, zPos - trimDepth, xPos - trimWidth, yPos - trimWidth, zPos);
renderer.setRenderBounds(
xNeg + trimWidth, yPos - trimWidth, zPos - trimDepth, xPos - trimWidth, yPos - trimWidth, zPos);
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zPos - trimDepth, xPos - trimWidth, yNeg + trimWidth, zPos);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg + trimWidth, zPos - trimDepth, xPos - trimWidth, yNeg + trimWidth, zPos);
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimWidth, yNeg + trimWidth, zPos - trimDepth, xPos - trimWidth, yPos - trimWidth, zPos);
renderer.setRenderBounds(
xPos - trimWidth, yNeg + trimWidth, zPos - trimDepth, xPos - trimWidth, yPos - trimWidth, zPos);
renderCutFace(FACE_XNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg + trimWidth, yNeg + trimWidth, zPos - trimDepth, xNeg + trimWidth, yPos - trimWidth, zPos);
renderer.setRenderBounds(
xNeg + trimWidth, yNeg + trimWidth, zPos - trimDepth, xNeg + trimWidth, yPos - trimWidth, zPos);
renderCutFace(FACE_XPOS, blockAccess, block, x, y, z);
break;
case FACE_XNEG:
renderer.setRenderBounds(xNeg, yNeg + trimWidth, zPos - trimWidth, xNeg + trimDepth, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg, yNeg + trimWidth, zPos - trimWidth, xNeg + trimDepth, yPos - trimWidth, zPos - trimWidth);
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg, yNeg + trimWidth, zNeg + trimWidth, xNeg + trimDepth, yPos - trimWidth, zNeg + trimWidth);
renderer.setRenderBounds(
xNeg, yNeg + trimWidth, zNeg + trimWidth, xNeg + trimDepth, yPos - trimWidth, zNeg + trimWidth);
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg, yPos - trimWidth, zNeg + trimWidth, xNeg + trimDepth, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg, yPos - trimWidth, zNeg + trimWidth, xNeg + trimDepth, yPos - trimWidth, zPos - trimWidth);
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xNeg, yNeg + trimWidth, zNeg + trimWidth, xNeg + trimDepth, yNeg + trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xNeg, yNeg + trimWidth, zNeg + trimWidth, xNeg + trimDepth, yNeg + trimWidth, zPos - trimWidth);
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
break;
case FACE_XPOS:
renderer.setRenderBounds(xPos - trimDepth, yNeg + trimWidth, zPos - trimWidth, xPos, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimDepth, yNeg + trimWidth, zPos - trimWidth, xPos, yPos - trimWidth, zPos - trimWidth);
renderCutFace(FACE_ZNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimDepth, yNeg + trimWidth, zNeg + trimWidth, xPos, yPos - trimWidth, zNeg + trimWidth);
renderer.setRenderBounds(
xPos - trimDepth, yNeg + trimWidth, zNeg + trimWidth, xPos, yPos - trimWidth, zNeg + trimWidth);
renderCutFace(FACE_ZPOS, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimDepth, yPos - trimWidth, zNeg + trimWidth, xPos, yPos - trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimDepth, yPos - trimWidth, zNeg + trimWidth, xPos, yPos - trimWidth, zPos - trimWidth);
renderCutFace(FACE_YNEG, blockAccess, block, x, y, z);
renderer.setRenderBounds(xPos - trimDepth, yNeg + trimWidth, zNeg + trimWidth, xPos, yNeg + trimWidth, zPos - trimWidth);
renderer.setRenderBounds(
xPos - trimDepth, yNeg + trimWidth, zNeg + trimWidth, xPos, yNeg + trimWidth, zPos - trimWidth);
renderCutFace(FACE_YPOS, blockAccess, block, x, y, z);
break;
}
}
public void renderFaceTrim (int face, IBlockAccess blockAccess, Block block, double x, double y, double z, double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos) {
public void renderFaceTrim(
int face,
IBlockAccess blockAccess,
Block block,
double x,
double y,
double z,
double xNeg,
double yNeg,
double zNeg,
double xPos,
double yPos,
double zPos) {
double unit = trimWidth;
RenderHelper renderer = RenderHelper.instance;
@@ -184,7 +283,7 @@ public class PanelBoxRenderer
renderer.setRenderBounds(xPos - unit, yNeg, zNeg + unit, xPos, yNeg, zPos - unit);
renderCutFace(face, blockAccess, block, x, y, z);
break;
case FACE_YPOS:
renderer.setRenderBounds(xNeg, yPos, zNeg, xNeg + unit, yPos, zNeg + unit);
renderCutFace(face, blockAccess, block, x, y, z);
@@ -287,21 +386,41 @@ public class PanelBoxRenderer
}
}
private void renderCutFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
RenderHelper.instance.renderFace(face, blockAccess, block, (int)x, (int)y, (int)z, trimIcon, trimColor[0], trimColor[1], trimColor[2]);
private void renderCutFace(int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
RenderHelper.instance.renderFace(
face,
blockAccess,
block,
(int) x,
(int) y,
(int) z,
trimIcon,
trimColor[0],
trimColor[1],
trimColor[2]);
}
private void renderPaneltFace (int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
RenderHelper.instance.renderFace(face, blockAccess, block, (int)x, (int)y, (int)z, panelIcon, panelColor[0], panelColor[1], panelColor[2]);
private void renderPaneltFace(int face, IBlockAccess blockAccess, Block block, double x, double y, double z) {
RenderHelper.instance.renderFace(
face,
blockAccess,
block,
(int) x,
(int) y,
(int) z,
panelIcon,
panelColor[0],
panelColor[1],
panelColor[2]);
}
private void copyFrom (float[] target, float[] source) {
private void copyFrom(float[] target, float[] source) {
target[0] = source[0];
target[1] = source[1];
target[2] = source[2];
}
private void copyFrom (float[] target, float r, float g, float b) {
private void copyFrom(float[] target, float r, float g, float b) {
target[0] = r;
target[1] = g;
target[2] = b;
File diff suppressed because it is too large. Load diff
@@ -7,20 +7,18 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
public class StorageRenderItem extends RenderItem
{
public class StorageRenderItem extends RenderItem {
public ItemStack overrideStack;
@Override
public void renderItemOverlayIntoGUI (FontRenderer font, TextureManager texManager, ItemStack item, int x, int y, String text)
{
public void renderItemOverlayIntoGUI(
FontRenderer font, TextureManager texManager, ItemStack item, int x, int y, String text) {
if (item != overrideStack) {
super.renderItemOverlayIntoGUI(font, texManager, item, x, y, text);
return;
}
if (item != null)
{
if (item != null) {
float scale = .5f;
float xoff = 0;
if (font.getUnicodeFlag()) {
@@ -28,8 +26,7 @@ public class StorageRenderItem extends RenderItem
xoff = 1;
}
if (item.stackSize > 1 || text != null)
{
if (item.stackSize > 1 || text != null) {
if (item.stackSize >= 100000000 || (item.stackSize >= 1000000 && font.getUnicodeFlag()))
text = (text == null) ? String.format("%.0fM", item.stackSize / 1000000f) : text;
else if (item.stackSize >= 1000000)
@@ -38,11 +35,10 @@ public class StorageRenderItem extends RenderItem
text = (text == null) ? String.format("%.0fK", item.stackSize / 1000f) : text;
else if (item.stackSize >= 10000)
text = (text == null) ? String.format("%.1fK", item.stackSize / 1000f) : text;
else
text = (text == null) ? String.valueOf(item.stackSize) : text;
else text = (text == null) ? String.valueOf(item.stackSize) : text;
int textX = (int)((x + 16 + xoff - font.getStringWidth(text) * scale) / scale) - 1;
int textY = (int)((y + 16 - 7 * scale) / scale) - 1;
int textX = (int) ((x + 16 + xoff - font.getStringWidth(text) * scale) / scale) - 1;
int textY = (int) ((y + 16 - 7 * scale) / scale) - 1;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
@@ -55,11 +51,10 @@ public class StorageRenderItem extends RenderItem
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
if (item.getItem().showDurabilityBar(item))
{
if (item.getItem().showDurabilityBar(item)) {
double health = item.getItem().getDurabilityForDisplay(item);
int j1 = (int)Math.round(13.0D - health * 13.0D);
int k = (int)Math.round(255.0D - health * 255.0D);
int j1 = (int) Math.round(13.0D - health * 13.0D);
int k = (int) Math.round(255.0D - health * 255.0D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -71,7 +66,8 @@ public class StorageRenderItem extends RenderItem
this.renderQuad(tessellator, x + 2, y + 13, 13, 2, 0);
this.renderQuad(tessellator, x + 2, y + 13, 12, 1, i1);
this.renderQuad(tessellator, x + 2, y + 13, j1, 1, l);
//GL11.glEnable(GL11.GL_BLEND); // Forge: Disable Bled because it screws with a lot of things down the line.
// GL11.glEnable(GL11.GL_BLEND); // Forge: Disable Bled because it screws with a lot of things down the
// line.
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_LIGHTING);
@@ -81,8 +77,7 @@ public class StorageRenderItem extends RenderItem
}
}
private void renderQuad (Tessellator tessellator, int x, int y, int w, int h, int color)
{
private void renderQuad(Tessellator tessellator, int x, int y, int w, int h, int color) {
tessellator.startDrawingQuads();
tessellator.setColorOpaque_I(color);
tessellator.addVertex(x + 0, y + 0, 0);
@@ -8,6 +8,8 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
@@ -32,13 +34,10 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.ArrayList;
import java.util.List;
@SideOnly(Side.CLIENT)
public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
{
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer {
private static final ResourceLocation RES_ITEM_GLINT =
new ResourceLocation("textures/misc/enchanted_item_glint.png");
private Vec3[] dirVectors = {
Vec3.createVectorHelper(0, -1, 0),
@@ -53,17 +52,17 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
private RenderBlocks renderBlocksRi = new RenderBlocks();
@Override
public byte getMiniBlockCount (ItemStack stack, byte original) {
public byte getMiniBlockCount(ItemStack stack, byte original) {
return 1;
}
@Override
public boolean shouldBob () {
public boolean shouldBob() {
return false;
}
@Override
public boolean shouldSpreadItems () {
public boolean shouldSpreadItems() {
return false;
}
@@ -71,8 +70,16 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
// setting. This modified implementation will render these items without unsightly Z-fighting.
@Override
public void renderItemIntoGUI (FontRenderer fontRenderer, TextureManager texManager, ItemStack itemStack, int x, int y, boolean renderEffect) {
if (itemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())) {
public void renderItemIntoGUI(
FontRenderer fontRenderer,
TextureManager texManager,
ItemStack itemStack,
int x,
int y,
boolean renderEffect) {
if (itemStack.getItemSpriteNumber() == 0
&& RenderBlocks.renderItemIn3d(
Block.getBlockFromItem(itemStack.getItem()).getRenderType())) {
renderItemIntoGUIBlock(fontRenderer, texManager, itemStack, x, y, renderEffect);
return;
}
@@ -81,27 +88,25 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
int meta = itemStack.getItemDamage();
ResourceLocation loc = itemStack.getItem().requiresMultipleRenderPasses()
? (item.getSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture)
: (texManager.getResourceLocation(itemStack.getItemSpriteNumber()));
? (item.getSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture)
: (texManager.getResourceLocation(itemStack.getItemSpriteNumber()));
for (int i = 0; i < item.getRenderPasses(meta); ++i) {
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
texManager.bindTexture(loc);
IIcon icon = itemStack.getItem().requiresMultipleRenderPasses()
? item.getIcon(itemStack, i)
: itemStack.getIconIndex();
? item.getIcon(itemStack, i)
: itemStack.getIconIndex();
if (icon == null)
continue;
if (icon == null) continue;
int color = itemStack.getItem().getColorFromItemStack(itemStack, i);
float r = (float)(color >> 16 & 255) / 255.0F;
float g = (float)(color >> 8 & 255) / 255.0F;
float b = (float)(color & 255) / 255.0F;
float r = (float) (color >> 16 & 255) / 255.0F;
float g = (float) (color >> 8 & 255) / 255.0F;
float b = (float) (color & 255) / 255.0F;
if (renderWithColor)
GL11.glColor4f(r, g, b, 1.0F);
if (renderWithColor) GL11.glColor4f(r, g, b, 1.0F);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPolygonOffset(-1f, -1);
@@ -116,15 +121,14 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
if (renderEffect && itemStack.hasEffect(i))
renderEffect(texManager, x, y);
if (renderEffect && itemStack.hasEffect(i)) renderEffect(texManager, x, y);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
}
}
@Override
public void renderEffect (TextureManager manager, int x, int y) {
public void renderEffect(TextureManager manager, int x, int y) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
@@ -140,10 +144,8 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
private void renderGlint (int x, int y, int w, int h)
{
for (int i = 0; i < 2; ++i)
{
private void renderGlint(int x, int y, int w, int h) {
for (int i = 0; i < 2; ++i) {
OpenGlHelper.glBlendFunc(772, 1, 0, 0);
float uScale = 0.00390625F;
float vScale = 0.00390625F;
@@ -154,15 +156,23 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x + 0, y + h, 0, (u + (float)h * hScale) * uScale, (v + (float)h) * vScale);
tessellator.addVertexWithUV(x + w, y + h, 0, (u + (float)w + (float)h * hScale) * uScale, (v + (float)h) * vScale);
tessellator.addVertexWithUV(x + w, y + 0, 0, (u + (float)w) * uScale, (v + 0.0F) * vScale);
tessellator.addVertexWithUV(
x + 0, y + h, 0, (u + (float) h * hScale) * uScale, (v + (float) h) * vScale);
tessellator.addVertexWithUV(
x + w, y + h, 0, (u + (float) w + (float) h * hScale) * uScale, (v + (float) h) * vScale);
tessellator.addVertexWithUV(x + w, y + 0, 0, (u + (float) w) * uScale, (v + 0.0F) * vScale);
tessellator.addVertexWithUV(x + 0, y + 0, 0, (u + 0.0F) * uScale, (v + 0.0F) * vScale);
tessellator.draw();
}
}
private void renderItemIntoGUIBlock (FontRenderer fontRenderer, TextureManager texManager, ItemStack itemStack, int x, int y, boolean renderEffect) {
private void renderItemIntoGUIBlock(
FontRenderer fontRenderer,
TextureManager texManager,
ItemStack itemStack,
int x,
int y,
boolean renderEffect) {
texManager.bindTexture(TextureMap.locationBlocksTexture);
Block block = Block.getBlockFromItem(itemStack.getItem());
@@ -170,8 +180,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
}
else {
} else {
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);
GL11.glDisable(GL11.GL_BLEND);
}
@@ -185,12 +194,11 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glRotatef(45, 0, 1, 0);
int color = itemStack.getItem().getColorFromItemStack(itemStack, 0);
float r = (float)(color >> 16 & 255) / 255.0F;
float g = (float)(color >> 8 & 255) / 255.0F;
float b = (float)(color & 255) / 255.0F;
float r = (float) (color >> 16 & 255) / 255.0F;
float g = (float) (color >> 8 & 255) / 255.0F;
float b = (float) (color & 255) / 255.0F;
if (this.renderWithColor)
GL11.glColor4f(r * 1, g * 1, b * 1, 1.0F);
if (this.renderWithColor) GL11.glColor4f(r * 1, g * 1, b * 1, 1.0F);
GL11.glRotatef(-90, 0, 1, 0);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
@@ -202,24 +210,23 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
if (block.getRenderBlockPass() == 0)
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
if (block.getRenderBlockPass() == 0) GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glPopMatrix();
}
};
private float itemOffset1X[] = new float[] { .5f };
private float itemOffset1Y[] = new float[] { 8.25f };
private float itemOffset1X[] = new float[] {.5f};
private float itemOffset1Y[] = new float[] {8.25f};
private float itemOffset2X[] = new float[] { .5f, .5f };
private float itemOffset2Y[] = new float[] { 10.25f, 2.25f };
private float itemOffset2X[] = new float[] {.5f, .5f};
private float itemOffset2Y[] = new float[] {10.25f, 2.25f};
private float itemOffset4X[] = new float[] { .25f, .25f, .75f, .75f };
private float itemOffset4Y[] = new float[] { 10.25f, 2.25f, 10.25f, 2.25f };
private float itemOffset4X[] = new float[] {.25f, .25f, .75f, .75f};
private float itemOffset4Y[] = new float[] {10.25f, 2.25f, 10.25f, 2.25f};
private float itemOffset3X[] = new float[] { .5f, .25f, .75f };
private float itemOffset3Y[] = new float[] { 9.75f, 2.25f, 2.25f };
private float itemOffset3X[] = new float[] {.5f, .25f, .75f};
private float itemOffset3Y[] = new float[] {9.75f, 2.25f, 2.25f};
private RenderBlocks renderBlocks = new RenderBlocks();
@@ -227,41 +234,37 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
private static final float unit = .0625f;
private static int[] glStateRender = { GL11.GL_LIGHTING, GL11.GL_BLEND };
private static int[] glStateRender = {GL11.GL_LIGHTING, GL11.GL_BLEND};
private List<int[]> savedGLStateRender = GLUtil.makeGLState(glStateRender);
private static int[] glStateItemRender = { GL11.GL_LIGHTING, GL11.GL_ALPHA_TEST, GL11.GL_BLEND };
private static int[] glStateItemRender = {GL11.GL_LIGHTING, GL11.GL_ALPHA_TEST, GL11.GL_BLEND};
private List<int[]> savedGLStateItemRender = GLUtil.makeGLState(glStateItemRender);
private static int[] glLightRender = { GL11.GL_LIGHT0, GL11.GL_LIGHT1, GL11.GL_COLOR_MATERIAL, GL12.GL_RESCALE_NORMAL };
private static int[] glLightRender = {GL11.GL_LIGHT0, GL11.GL_LIGHT1, GL11.GL_COLOR_MATERIAL, GL12.GL_RESCALE_NORMAL
};
private List<int[]> savedGLLightRender = GLUtil.makeGLState(glLightRender);
private List<IRenderLabel> preLabelRenderHandlers = new ArrayList<IRenderLabel>();
@Override
public void renderTileEntityAt (TileEntity tile, double x, double y, double z, float partialTickTime) {
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) {
TileEntityDrawers tileDrawers = (TileEntityDrawers) tile;
if (tileDrawers == null)
return;
if (tileDrawers == null) return;
if (tileDrawers.isShrouded() || tileDrawers.isSealed())
return;
if (tileDrawers.isShrouded() || tileDrawers.isSealed()) return;
// Don't bother rendering anything that is (probably) facing away from the player.
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
Vec3 faceVector = dirVectors[tileDrawers.getDirection()];
float lookProduct = (float)player.getLook(partialTickTime).dotProduct(faceVector);
float lookProduct = (float) player.getLook(partialTickTime).dotProduct(faceVector);
if (lookProduct > .75f)
return;
if (lookProduct > .75f) return;
float depth;
Block block = tile.getWorldObj().getBlock(tile.xCoord, tile.yCoord, tile.zCoord);
if (block instanceof BlockDrawers)
depth = ((BlockDrawers) block).halfDepth ? .5f : 1;
else
return;
if (block instanceof BlockDrawers) depth = ((BlockDrawers) block).halfDepth ? .5f : 1;
else return;
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
@@ -269,14 +272,18 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
itemRenderer.setRenderManager(RenderManager.instance);
ForgeDirection side = ForgeDirection.getOrientation(tileDrawers.getDirection());
int ambLight = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ, 0);
int ambLight = tile.getWorldObj()
.getLightBrightnessForSkyBlocks(
tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ, 0);
int lu = ambLight % 65536;
int lv = ambLight / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lu, lv);
brightness = tile.getWorldObj().getLightBrightness(tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ) * 1.25f;
if (brightness > 1)
brightness = 1;
brightness = tile.getWorldObj()
.getLightBrightness(
tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ)
* 1.25f;
if (brightness > 1) brightness = 1;
Minecraft mc = Minecraft.getMinecraft();
boolean cache = mc.gameSettings.fancyGraphics;
@@ -285,10 +292,8 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
try {
if (StorageDrawers.config.isFancyItemRenderEnabled())
renderFancyItemSet(tileDrawers, side, depth, partialTickTime);
else
renderFastItemSet(tileDrawers, side, depth, partialTickTime);
}
catch (Exception e) {
else renderFastItemSet(tileDrawers, side, depth, partialTickTime);
} catch (Exception e) {
// Swallow exception
}
@@ -297,18 +302,16 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glPopMatrix();
}
private void renderFancyItemSet (TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
private void renderFancyItemSet(TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
boolean restoreGLState = false;
int drawerCount = tile.getDrawerCount();
for (int i = 0; i < drawerCount; i++) {
if (!tile.isDrawerEnabled(i))
continue;
if (!tile.isDrawerEnabled(i)) continue;
IDrawer drawer = tile.getDrawer(i);
ItemStack itemStack = drawer.getStoredItemPrototype();
if (itemStack == null)
continue;
if (itemStack == null) continue;
if (!restoreGLState) {
restoreGLState = true;
@@ -318,35 +321,30 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
renderFancyItem(itemStack, tile, i, side, depth, partialTickTime);
}
if (restoreGLState)
GLUtil.restoreGLState(savedGLStateRender);
if (restoreGLState) GLUtil.restoreGLState(savedGLStateRender);
}
private boolean[] renderAsBlock = new boolean[4];
private ItemStack[] renderStacks = new ItemStack[4];
private void renderFastItemSet (TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
private void renderFastItemSet(TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
int drawerCount = tile.getDrawerCount();
boolean restoreItemState = false;
boolean restoreBlockState = false;
for (int i = 0; i < drawerCount; i++) {
renderStacks[i] = null;
if (!tile.isDrawerEnabled(i))
continue;
if (!tile.isDrawerEnabled(i)) continue;
IDrawer drawer = tile.getDrawer(i);
ItemStack itemStack = drawer.getStoredItemPrototype();
if (itemStack == null)
continue;
if (itemStack == null) continue;
renderStacks[i] = itemStack;
renderAsBlock[i] = isItemBlockType(itemStack);
if (renderAsBlock[i])
restoreBlockState = true;
else
restoreItemState = true;
if (renderAsBlock[i]) restoreBlockState = true;
else restoreItemState = true;
}
if (restoreItemState || restoreBlockState) {
@@ -368,11 +366,17 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
}
}
private void renderFancyItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth, float partialTickTime) {
private void renderFancyItem(
ItemStack itemStack,
TileEntityDrawers tile,
int slot,
ForgeDirection side,
float depth,
float partialTickTime) {
int drawerCount = tile.getDrawerCount();
boolean isBlockType = isItemBlockType(itemStack);
BlockDrawers block = (BlockDrawers)tile.getBlockType();
BlockDrawers block = (BlockDrawers) tile.getBlockType();
float xunit = getXOffset(drawerCount, slot);
float yunit = getYOffset(drawerCount, slot);
@@ -390,8 +394,9 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
double zDepth = 1 / relScale - itemBlock.getBlockBoundsMaxZ();
itemDepth += zDepth * zunit;
} catch (Exception e) {
}
catch (Exception e) { };
;
}
switch (tile.getDirection()) {
@@ -414,10 +419,8 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
}
float yAdj = 0;
if (drawerCount == 2 || drawerCount == 4)
yAdj = -.5f;
else if (drawerCount == 1)
yAdj = -3f;
if (drawerCount == 2 || drawerCount == 4) yAdj = -.5f;
else if (drawerCount == 1) yAdj = -3f;
GL11.glPushMatrix();
@@ -438,19 +441,24 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
EntityItem itemEnt = new EntityItem(null, 0, 0, 0, itemStack);
itemEnt.hoverStart = 0;
itemRenderer.doRender(itemEnt, 0, 0, 0, 0, 0);
} catch (Exception e) {
}
catch (Exception e) { }
GL11.glPopMatrix();
}
private void renderFastItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth, float partialTickTime) {
private void renderFastItem(
ItemStack itemStack,
TileEntityDrawers tile,
int slot,
ForgeDirection side,
float depth,
float partialTickTime) {
boolean skipRenderHook = false;
Block itemBlock = Block.getBlockFromItem(itemStack.getItem());
if (itemBlock != null) {
String itemBlockName = GameData.getBlockRegistry().getNameForObject(itemBlock);
if (itemBlockName != null && itemBlockName.equals("Mariculture:tanks"))
skipRenderHook = true;
if (itemBlockName != null && itemBlockName.equals("Mariculture:tanks")) skipRenderHook = true;
}
Minecraft mc = Minecraft.getMinecraft();
@@ -459,12 +467,16 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
float yunit = getYOffset(drawerCount, slot);
float size = (drawerCount == 1) ? .5f : .25f;
BlockDrawers block = (BlockDrawers)tile.getBlockType();
BlockDrawers block = (BlockDrawers) tile.getBlockType();
GL11.glPushMatrix();
alignRendering(side);
moveRendering(size, getOffsetXForSide(side, xunit) * 16 - (8 * size), 12.25f - yunit, 1f - depth + block.getTrimDepth() - .005f);
moveRendering(
size,
getOffsetXForSide(side, xunit) * 16 - (8 * size),
12.25f - yunit,
1f - depth + block.getTrimDepth() - .005f);
List<IRenderLabel> renderHandlers = StorageDrawers.renderRegistry.getRenderHandlers();
for (int i = 0, n = renderHandlers.size(); i < n; i++) {
@@ -476,8 +488,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glScalef(2.6f, 2.6f, 1);
GL11.glRotatef(171.6f, 0, 1, 0);
GL11.glRotatef(84.9f, 1, 0, 0);
}
else {
} else {
GL11.glScalef(1.92f, 1.92f, 1);
GL11.glRotatef(169.2f, 0, 1, 0);
GL11.glRotatef(79.0f, 1, 0, 0);
@@ -490,69 +501,82 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glDisable(GL11.GL_NORMALIZE);
try {
if (skipRenderHook || !ForgeHooksClient.renderInventoryItem(this.renderBlocks, mc.renderEngine, itemStack, true, 0, 0, 0))
if (skipRenderHook
|| !ForgeHooksClient.renderInventoryItem(
this.renderBlocks, mc.renderEngine, itemStack, true, 0, 0, 0))
itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, 0, 0, true);
} catch (Exception e) {
}
catch (Exception e) { }
GL11.glPopMatrix();
}
private boolean isItemBlockType (ItemStack itemStack) {
private boolean isItemBlockType(ItemStack itemStack) {
return itemStack.getItemSpriteNumber() == 0
&& itemStack.getItem() instanceof ItemBlock
&& RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType());
&& itemStack.getItem() instanceof ItemBlock
&& RenderBlocks.renderItemIn3d(
Block.getBlockFromItem(itemStack.getItem()).getRenderType());
}
private float getXOffset (int drawerCount, int slot) {
private float getXOffset(int drawerCount, int slot) {
switch (drawerCount) {
case 1: return itemOffset1X[slot];
case 2: return itemOffset2X[slot];
case 3: return itemOffset3X[slot];
case 4: return itemOffset4X[slot];
default: return 0;
case 1:
return itemOffset1X[slot];
case 2:
return itemOffset2X[slot];
case 3:
return itemOffset3X[slot];
case 4:
return itemOffset4X[slot];
default:
return 0;
}
}
private float getYOffset (int drawerCount, int slot) {
private float getYOffset(int drawerCount, int slot) {
switch (drawerCount) {
case 1: return itemOffset1Y[slot];
case 2: return itemOffset2Y[slot];
case 3: return itemOffset3Y[slot];
case 4: return itemOffset4Y[slot];
default: return 0;
case 1:
return itemOffset1Y[slot];
case 2:
return itemOffset2Y[slot];
case 3:
return itemOffset3Y[slot];
case 4:
return itemOffset4Y[slot];
default:
return 0;
}
}
private void alignRendering (ForgeDirection side) {
private void alignRendering(ForgeDirection side) {
GL11.glTranslatef(.5f, .5f, .5f);
GL11.glRotatef(180f, 0, 0, 1f); // Render is upside-down: correct it.
GL11.glRotatef(180f, 0, 0, 1f); // Render is upside-down: correct it.
GL11.glRotatef(getRotationYForSide2D(side), 0, 1, 0);
GL11.glTranslatef(-.5f, -.5f, -.5f);
}
private void moveRendering (float size, float offsetX, float offsetY, float offsetZ) {
private void moveRendering(float size, float offsetX, float offsetY, float offsetZ) {
GL11.glTranslatef(0, 0, offsetZ);
GL11.glScalef(1 / 16f, 1 / 16f, -.0001f);
GL11.glTranslatef(offsetX, offsetY, 0);
GL11.glScalef(size, size, 1);
}
private static final float[] sideRotationY = { 0, 0, 0, 2, 1, 3 };
private static final float[] sideRotationY = {0, 0, 0, 2, 1, 3};
private float getRotationYForSide (ForgeDirection side) {
private float getRotationYForSide(ForgeDirection side) {
return sideRotationY[side.ordinal()] * 90;
}
private static final float[] sideRotationY2D = { 0, 0, 0, 2, 3, 1 };
private static final float[] sideRotationY2D = {0, 0, 0, 2, 3, 1};
private float getRotationYForSide2D (ForgeDirection side) {
private float getRotationYForSide2D(ForgeDirection side) {
return sideRotationY2D[side.ordinal()] * 90;
}
private static final float[] offsetX = { 0, 0, 0, 0, 0, 0 };
private static final float[] offsetX = {0, 0, 0, 0, 0, 0};
private float getOffsetXForSide (ForgeDirection side, float x) {
private float getOffsetXForSide(ForgeDirection side, float x) {
return Math.abs(offsetX[side.ordinal()] - x);
}
}
@@ -17,34 +17,31 @@ import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
{
public class TileEntityFramingRenderer extends TileEntitySpecialRenderer {
private RenderItem itemRenderer = new RenderItem() {
@Override
public byte getMiniBlockCount (ItemStack stack, byte original) {
public byte getMiniBlockCount(ItemStack stack, byte original) {
return 1;
}
@Override
public boolean shouldBob () {
public boolean shouldBob() {
return false;
}
@Override
public boolean shouldSpreadItems () {
public boolean shouldSpreadItems() {
return false;
}
};
@Override
public void renderTileEntityAt (TileEntity tile, double x, double y, double z, float partialTickTime) {
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTickTime) {
TileEntityFramingTable tileTable = (TileEntityFramingTable) tile;
if (tileTable == null)
return;
if (tileTable == null) return;
int meta = tile.getBlockMetadata();
if ((meta & 8) != 0)
return;
if ((meta & 8) != 0) return;
itemRenderer.setRenderManager(RenderManager.instance);
@@ -52,11 +49,16 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
if (target != null) {
Block block = Block.getBlockFromItem(target.getItem());
if (block instanceof BlockDrawersCustom) {
ItemStack result = ItemCustomDrawers.makeItemStack(block, 1, tileTable.getStackInSlot(1), tileTable.getStackInSlot(2), tileTable.getStackInSlot(3));
ItemStack result = ItemCustomDrawers.makeItemStack(
block,
1,
tileTable.getStackInSlot(1),
tileTable.getStackInSlot(2),
tileTable.getStackInSlot(3));
renderSlot(tileTable, x, y, z, result, 2f, 0f, .25f, 0f);
}
else if (block instanceof BlockTrimCustom) {
ItemStack result = ItemCustomTrim.makeItemStack(block, 1, tileTable.getStackInSlot(1), tileTable.getStackInSlot(2));
} else if (block instanceof BlockTrimCustom) {
ItemStack result = ItemCustomTrim.makeItemStack(
block, 1, tileTable.getStackInSlot(1), tileTable.getStackInSlot(2));
renderSlot(tileTable, x, y, z, result, 2f, 0f, .25f, 0f);
}
}
@@ -66,13 +68,20 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
renderSlot(tileTable, x, y, z, tileTable.getStackInSlot(3), 1.15f, .225f, .15f, .65f);
}
private void renderSlot (TileEntityFramingTable tileTable, double x, double y, double z, ItemStack item, float scale, float tx, float ty, float tz) {
if (item == null)
return;
private void renderSlot(
TileEntityFramingTable tileTable,
double x,
double y,
double z,
ItemStack item,
float scale,
float tx,
float ty,
float tz) {
if (item == null) return;
Block itemBlock = Block.getBlockFromItem(item.getItem());
if (itemBlock == null)
return;
if (itemBlock == null) return;
int meta = tileTable.getBlockMetadata();
int side = meta & 0x07;
@@ -84,12 +93,9 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
GL11.glTranslated(x + .5, y + 1, z + .5);
if (side == 2)
GL11.glRotatef(90, 0, 1, 0);
if (side == 3)
GL11.glRotatef(270, 0, 1, 0);
if (side == 4)
GL11.glRotatef(180, 0, 1, 0);
if (side == 2) GL11.glRotatef(90, 0, 1, 0);
if (side == 3) GL11.glRotatef(270, 0, 1, 0);
if (side == 4) GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(0, 0f, .5f);
GL11.glTranslatef(tx, ty, tz);
@@ -102,8 +108,8 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
EntityItem itemEnt = new EntityItem(null, 0, 0, 0, item);
itemEnt.hoverStart = 0;
itemRenderer.doRender(itemEnt, 0, 0, 0, 0, 0);
} catch (Exception e) {
}
catch (Exception e) { }
GL11.glPopMatrix();
}
@@ -11,43 +11,36 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class TrimCustomRenderer implements ISimpleBlockRenderingHandler
{
public class TrimCustomRenderer implements ISimpleBlockRenderingHandler {
private CommonTrimRenderer commonRender = new CommonTrimRenderer();
@Override
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
}
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {}
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockTrimCustom))
return false;
public boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (!(block instanceof BlockTrimCustom)) return false;
return renderWorldBlock(world, x, y, z, (BlockTrimCustom) block, modelId, renderer);
}
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockTrimCustom block, int modelId, RenderBlocks renderer) {
private boolean renderWorldBlock(
IBlockAccess world, int x, int y, int z, BlockTrimCustom block, int modelId, RenderBlocks renderer) {
TileEntityTrim tile = block.getTileEntity(world, x, y, z);
if (tile == null)
return false;
if (tile == null) return false;
ItemStack materialSide = tile.getMaterialSide();
if (materialSide == null)
materialSide = new ItemStack(block);
if (materialSide == null) materialSide = new ItemStack(block);
ItemStack materialTrim = tile.getMaterialTrim();
if (materialTrim == null)
materialTrim = materialSide;
if (materialTrim == null) materialTrim = materialSide;
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
if (trimIcon == null)
trimIcon = block.getDefaultTrimIcon();
if (panelIcon == null)
panelIcon = block.getDefaultFaceIcon();
if (trimIcon == null) trimIcon = block.getDefaultTrimIcon();
if (panelIcon == null) panelIcon = block.getDefaultFaceIcon();
commonRender.render(world, x, y, z, block, panelIcon, trimIcon);
@@ -55,12 +48,12 @@ public class TrimCustomRenderer implements ISimpleBlockRenderingHandler
}
@Override
public boolean shouldRender3DInInventory (int modelId) {
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId () {
public int getRenderId() {
return StorageDrawers.proxy.trimCustomRenderID;
}
}
@@ -10,38 +10,33 @@ import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
public class TrimItemRender implements IItemRenderer
{
public class TrimItemRender implements IItemRenderer {
private CommonTrimRenderer commonRender = new CommonTrimRenderer();
@Override
public boolean handleRenderType (ItemStack item, ItemRenderType type) {
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem (ItemRenderType type, ItemStack item, Object... data) {
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
RenderBlocks renderer = getRenderer(data);
if (renderer == null)
return;
if (renderer == null) return;
Block block = Block.getBlockFromItem(item.getItem());
if (!(block instanceof BlockTrimCustom))
return;
if (!(block instanceof BlockTrimCustom)) return;
renderTrim((BlockTrimCustom) block, item, renderer, type);
}
private void renderTrim (BlockTrimCustom block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
if (renderType == ItemRenderType.INVENTORY)
GL11.glRotatef(90, 0, 1, 0);
if (renderType == ItemRenderType.ENTITY)
GL11.glRotatef(180, 0, 1, 0);
private void renderTrim(BlockTrimCustom block, ItemStack item, RenderBlocks renderer, ItemRenderType renderType) {
if (renderType == ItemRenderType.INVENTORY) GL11.glRotatef(90, 0, 1, 0);
if (renderType == ItemRenderType.ENTITY) GL11.glRotatef(180, 0, 1, 0);
if (renderType == ItemRenderType.INVENTORY || renderType == ItemRenderType.ENTITY)
GL11.glTranslatef(-.5f, -.5f, -.5f);
@@ -51,24 +46,18 @@ public class TrimItemRender implements IItemRenderer
if (item.hasTagCompound()) {
NBTTagCompound tag = item.getTagCompound();
if (tag.hasKey("MatS"))
materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
if (tag.hasKey("MatT"))
materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
if (tag.hasKey("MatS")) materialSide = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatS"));
if (tag.hasKey("MatT")) materialTrim = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("MatT"));
}
if (materialSide == null)
materialSide = new ItemStack(block);
if (materialTrim == null)
materialTrim = materialSide;
if (materialSide == null) materialSide = new ItemStack(block);
if (materialTrim == null) materialTrim = materialSide;
IIcon trimIcon = Block.getBlockFromItem(materialTrim.getItem()).getIcon(4, materialTrim.getItemDamage());
IIcon panelIcon = Block.getBlockFromItem(materialSide.getItem()).getIcon(4, materialSide.getItemDamage());
if (trimIcon == null)
trimIcon = block.getDefaultTrimIcon();
if (panelIcon == null)
panelIcon = block.getDefaultFaceIcon();
if (trimIcon == null) trimIcon = block.getDefaultTrimIcon();
if (panelIcon == null) panelIcon = block.getDefaultFaceIcon();
commonRender.render(null, 0, 0, 0, block, panelIcon, trimIcon);
@@ -76,10 +65,9 @@ public class TrimItemRender implements IItemRenderer
GL11.glTranslatef(.5f, .5f, .5f);
}
private RenderBlocks getRenderer (Object[] data) {
private RenderBlocks getRenderer(Object[] data) {
for (Object obj : data) {
if (obj instanceof RenderBlocks)
return (RenderBlocks)obj;
if (obj instanceof RenderBlocks) return (RenderBlocks) obj;
}
return null;
@@ -1,7 +1,6 @@
package com.jaquadro.minecraft.storagedrawers.client.renderer.common;
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawersCustom;
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
import com.jaquadro.minecraft.storagedrawers.client.renderer.ModularBoxRenderer;
import com.jaquadro.minecraft.storagedrawers.client.renderer.PanelBoxRenderer;
import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
@@ -9,8 +8,7 @@ import com.jaquadro.minecraft.storagedrawers.util.RenderHelperState;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class CommonDrawerRenderer
{
public class CommonDrawerRenderer {
private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
private double depth;
@@ -20,7 +18,7 @@ public class CommonDrawerRenderer
private static double unit7 = 0.4375;
private static double unit9 = 0.5625;
private RenderHelper start (IBlockAccess world, int x, int y, int z, BlockDrawersCustom block, int direction) {
private RenderHelper start(IBlockAccess world, int x, int y, int z, BlockDrawersCustom block, int direction) {
depth = block.halfDepth ? .5 : 0;
trimWidth = block.getTrimWidth();
trimDepth = block.getTrimDepth();
@@ -33,31 +31,39 @@ public class CommonDrawerRenderer
panelRenderer.setPanelColor(ModularBoxRenderer.COLOR_WHITE);
RenderHelper renderHelper = RenderHelper.instance;
if (world != null)
renderHelper.setColorAndBrightness(world, block, x, y, z);
if (world != null) renderHelper.setColorAndBrightness(world, block, x, y, z);
renderHelper.state.setRotateTransform(RenderHelper.ZNEG, direction);
renderHelper.state.setUVRotation(RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][direction]);
renderHelper.state.setUVRotation(
RenderHelper.YPOS, RenderHelperState.ROTATION_BY_FACE_FACE[RenderHelper.ZNEG][direction]);
return renderHelper;
}
private void end () {
private void end() {
RenderHelper renderHelper = RenderHelper.instance;
renderHelper.state.clearRotateTransform();
renderHelper.state.clearUVRotation(RenderHelper.YPOS);
}
public void renderBasePass (IBlockAccess world, int x, int y, int z, BlockDrawersCustom block, int direction, IIcon iconSide, IIcon iconTrim, IIcon iconFront) {
public void renderBasePass(
IBlockAccess world,
int x,
int y,
int z,
BlockDrawersCustom block,
int direction,
IIcon iconSide,
IIcon iconTrim,
IIcon iconFront) {
RenderHelper renderHelper = start(world, x, y, z, block, direction);
panelRenderer.setTrimIcon(iconTrim);
panelRenderer.setPanelIcon(iconSide);
for (int i = 0; i < 6; i++) {
if (i != RenderHelper.ZNEG)
panelRenderer.renderFacePanel(i, world, block, x, y, z, 0, 0, depth, 1, 1, 1);
if (i != RenderHelper.ZNEG) panelRenderer.renderFacePanel(i, world, block, x, y, z, 0, 0, depth, 1, 1, 1);
panelRenderer.renderFaceTrim(i, world, block, x, y, z, 0, 0, depth, 1, 1, 1);
}
@@ -67,8 +73,7 @@ public class CommonDrawerRenderer
if (block.drawerCount == 1) {
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, 1 - trimWidth, 1 - trimWidth, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, iconFront);
}
else if (block.drawerCount == 2) {
} else if (block.drawerCount == 2) {
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, 1 - trimWidth, unit7, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, iconFront);
renderHelper.setRenderBounds(trimWidth, unit9, depth + trimDepth, 1 - trimWidth, 1 - trimWidth, 1);
@@ -76,8 +81,7 @@ public class CommonDrawerRenderer
renderHelper.setRenderBounds(trimWidth, unit7, depth + trimDepth, 1 - trimWidth, unit9, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, iconTrim);
}
else if (block.drawerCount == 4) {
} else if (block.drawerCount == 4) {
renderHelper.state.flipTexture = true;
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, unit7, unit7, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, iconFront);
@@ -104,7 +108,15 @@ public class CommonDrawerRenderer
end();
}
public void renderOverlayPass (IBlockAccess world, int x, int y, int z, BlockDrawersCustom block, int direction, IIcon iconTrim, IIcon iconFront) {
public void renderOverlayPass(
IBlockAccess world,
int x,
int y,
int z,
BlockDrawersCustom block,
int direction,
IIcon iconTrim,
IIcon iconFront) {
RenderHelper renderHelper = start(world, x, y, z, block, direction);
IIcon trimShadow = block.getTrimShadowOverlay(iconTrim == iconFront);
@@ -116,8 +128,7 @@ public class CommonDrawerRenderer
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, 1 - trimWidth, 1 - trimWidth, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getHandleOverlay());
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getFaceShadowOverlay());
}
else if (block.drawerCount == 2) {
} else if (block.drawerCount == 2) {
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, 1 - trimWidth, unit7, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getHandleOverlay());
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getFaceShadowOverlay());
@@ -128,8 +139,7 @@ public class CommonDrawerRenderer
renderHelper.setRenderBounds(trimWidth, unit7, depth + trimDepth, 1 - trimWidth, unit9, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, trimShadow);
}
else if (block.drawerCount == 4) {
} else if (block.drawerCount == 4) {
renderHelper.setRenderBounds(trimWidth, trimWidth, depth + trimDepth, unit7, unit7, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getHandleOverlay());
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getFaceShadowOverlay());
@@ -156,9 +166,7 @@ public class CommonDrawerRenderer
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, trimShadow);
renderHelper.setRenderBounds(unit7, unit7, depth + trimDepth, unit9, unit9, 1);
renderHelper.renderFace(RenderHelper.ZNEG, world, block, x, y, z, trimShadow);
}
else
RenderHelper.instance.renderEmptyPlane(x, y, z);
} else RenderHelper.instance.renderEmptyPlane(x, y, z);
end();
}
@@ -6,78 +6,91 @@ import com.jaquadro.minecraft.storagedrawers.util.RenderHelperState;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class CommonFramingRenderer
{
public class CommonFramingRenderer {
private static double unit = .0625;
private static double unit2 = unit * 2;
private static double unit4 = unit * 4;
private static double unit14 = unit * 14;
private static double[][] baseBoundsLeftY = new double[][] {
{ unit, 1 - unit2, unit, 1, 1, 1 - unit }
};
private static double[][] baseBoundsLeftY = new double[][] {{unit, 1 - unit2, unit, 1, 1, 1 - unit}};
private static double[][] trimBoundsLeftY = new double[][] {
{ 0, 1 - unit2, unit, unit, 1, 1 - unit },
{ 0, 1 - unit2, 0, unit, 1, unit },
{ 0, 1 - unit2, 1 - unit, unit, 1, 1 },
{ unit, 1 - unit2, 0, 1, 1, unit },
{ unit, 1 - unit2, 1 - unit, 1, 1, 1 },
{0, 1 - unit2, unit, unit, 1, 1 - unit},
{0, 1 - unit2, 0, unit, 1, unit},
{0, 1 - unit2, 1 - unit, unit, 1, 1},
{unit, 1 - unit2, 0, 1, 1, unit},
{unit, 1 - unit2, 1 - unit, 1, 1, 1},
};
private static double[][] trimBoundsLeftZ = new double[][] {
{ 0, 1 - unit2, 0, unit, 1, 1 },
{ unit, 1 - unit2, 0, 1, 1, 1 },
{0, 1 - unit2, 0, unit, 1, 1},
{unit, 1 - unit2, 0, 1, 1, 1},
};
private static double[][] trimBoundsLeftX = new double[][] {
{ 0, 1 - unit2, 0, 1, 1, unit },
{ 0, 1 - unit2, unit, 1, 1, 1 - unit },
{ 0, 1 - unit2, 1 - unit, 1, 1, 1 },
{0, 1 - unit2, 0, 1, 1, unit},
{0, 1 - unit2, unit, 1, 1, 1 - unit},
{0, 1 - unit2, 1 - unit, 1, 1, 1},
};
private static double[][] baseBoundsRightY = new double[][] {
{ 0, 1 - unit2, unit, 1 - unit, 1, 1 - unit }
};
private static double[][] baseBoundsRightY = new double[][] {{0, 1 - unit2, unit, 1 - unit, 1, 1 - unit}};
private static double[][] trimBoundsRightY = new double[][] {
{ 1 - unit, 1 - unit2, unit, 1, 1, 1 - unit },
{ 1 - unit, 1 - unit2, 0, 1, 1, unit },
{ 1 - unit, 1 - unit2, 1 - unit, 1, 1, 1 },
{ 0, 1 - unit2, 0, 1 - unit, 1, unit },
{ 0, 1 - unit2, 1 - unit, 1 - unit, 1, 1 },
{1 - unit, 1 - unit2, unit, 1, 1, 1 - unit},
{1 - unit, 1 - unit2, 0, 1, 1, unit},
{1 - unit, 1 - unit2, 1 - unit, 1, 1, 1},
{0, 1 - unit2, 0, 1 - unit, 1, unit},
{0, 1 - unit2, 1 - unit, 1 - unit, 1, 1},
};
private static double[][] trimBoundsRightZ = new double[][] {
{ 1 - unit, 1 - unit2, 0, 1, 1, 1 },
{ 0, 1 - unit2, 0, 1 - unit, 1, 1 },
{1 - unit, 1 - unit2, 0, 1, 1, 1},
{0, 1 - unit2, 0, 1 - unit, 1, 1},
};
private static double[][] trimBoundsRightX = new double[][] {
{ 0, 1 - unit2, 0, 1, 1, unit },
{ 0, 1 - unit2, unit, 1, 1, 1 - unit },
{ 0, 1 - unit2, 1 - unit, 1, 1, 1 },
{0, 1 - unit2, 0, 1, 1, unit},
{0, 1 - unit2, unit, 1, 1, 1 - unit},
{0, 1 - unit2, 1 - unit, 1, 1, 1},
};
public void renderLeft (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderTableBox(blockAccess, x, y, z, block, baseBoundsLeftY, trimBoundsLeftY, trimBoundsLeftZ, trimBoundsLeftX, true);
public void renderLeft(IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderTableBox(
blockAccess, x, y, z, block, baseBoundsLeftY, trimBoundsLeftY, trimBoundsLeftZ, trimBoundsLeftX, true);
renderStructure(blockAccess, x, y, z, block, true);
}
public void renderRight (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderTableBox(blockAccess, x, y, z, block, baseBoundsRightY, trimBoundsRightY, trimBoundsRightZ, trimBoundsRightX, false);
public void renderRight(IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderTableBox(
blockAccess,
x,
y,
z,
block,
baseBoundsRightY,
trimBoundsRightY,
trimBoundsRightZ,
trimBoundsRightX,
false);
renderStructure(blockAccess, x, y, z, block, false);
}
public void renderOverlayLeft (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
public void renderOverlayLeft(IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderOverlay(blockAccess, x, y, z, block, baseBoundsLeftY, true);
}
public void renderOverlayRight (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
public void renderOverlayRight(IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block) {
renderOverlay(blockAccess, x, y, z, block, baseBoundsRightY, false);
}
public void renderOverlay (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, double[][] baseBoundsY, boolean left) {
public void renderOverlay(
IBlockAccess blockAccess,
int x,
int y,
int z,
BlockFramingTable block,
double[][] baseBoundsY,
boolean left) {
IIcon iconOverlay = block.getIconOverlay(left);
RenderHelper renderer = RenderHelper.instance;
@@ -88,7 +101,7 @@ public class CommonFramingRenderer
}
}
private void renderStructure (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, boolean left) {
private void renderStructure(IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, boolean left) {
IIcon iconSurface = block.getIconBase();
renderFoot(blockAccess, x, y, z, block, iconSurface, left);
@@ -96,7 +109,17 @@ public class CommonFramingRenderer
renderBraces(blockAccess, x, y, z, block, iconSurface, left);
}
private void renderTableBox (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, double[][] baseBoundsY, double[][] trimBoundsY, double[][] trimBoundsZ, double[][] trimBoundsX, boolean left) {
private void renderTableBox(
IBlockAccess blockAccess,
int x,
int y,
int z,
BlockFramingTable block,
double[][] baseBoundsY,
double[][] trimBoundsY,
double[][] trimBoundsZ,
double[][] trimBoundsX,
boolean left) {
RenderHelper renderer = RenderHelper.instance;
IIcon iconSurface = block.getIconBase();
@@ -128,7 +151,8 @@ public class CommonFramingRenderer
}
}
private void renderFoot (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
private void renderFoot(
IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
RenderHelper renderer = RenderHelper.instance;
float oldColor = renderer.state.colorMultYPos;
@@ -140,57 +164,49 @@ public class CommonFramingRenderer
double xStart = left ? unit2 : 1 - unit2 - unit2;
renderer.setRenderBounds(xStart, 0, 0, xStart + unit2, unit2, 1);
for (int i = 0; i < 6; i++)
renderer.renderFace(i, blockAccess, block, x,y , z, icon);
for (int i = 0; i < 6; i++) renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 0; i < 2; i++)
renderer.state.clearUVRotation(i);
for (int i = 0; i < 2; i++) renderer.state.clearUVRotation(i);
renderer.state.colorMultYPos = oldColor;
}
private void renderLegs (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
private void renderLegs(
IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
RenderHelper renderer = RenderHelper.instance;
for (int i = 2; i < 6; i++)
renderer.state.setUVRotation(i, RenderHelperState.ROTATE90);
for (int i = 2; i < 6; i++) renderer.state.setUVRotation(i, RenderHelperState.ROTATE90);
double xStart = left ? unit2 : 1 - unit2 - unit2;
renderer.setRenderBounds(xStart, unit2, unit2, xStart + unit2, 1 - unit2, unit2 + unit2);
for (int i = 2; i < 6; i++)
renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 2; i < 6; i++) renderer.renderFace(i, blockAccess, block, x, y, z, icon);
renderer.setRenderBounds(xStart, unit2, 1 - unit2 - unit2, xStart + unit2, 1 - unit2, 1 - unit2);
for (int i = 2; i < 6; i++)
renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 2; i < 6; i++) renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 2; i < 6; i++)
renderer.state.clearUVRotation(i);
for (int i = 2; i < 6; i++) renderer.state.clearUVRotation(i);
}
private void renderBraces (IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
private void renderBraces(
IBlockAccess blockAccess, int x, int y, int z, BlockFramingTable block, IIcon icon, boolean left) {
RenderHelper renderer = RenderHelper.instance;
float oldColor = renderer.state.colorMultYPos;
renderer.state.colorMultYPos = .85f;
for (int i = 0; i < 2; i++)
renderer.state.setUVRotation(i, renderer.state.rotateTransform);
for (int i = 0; i < 2; i++) renderer.state.setUVRotation(i, renderer.state.rotateTransform);
double xStart = left ? unit2 + unit2 : 0;
double xStop = left ? 1 : 1 - unit2 - unit2;
renderer.setRenderBounds(xStart, unit4, unit2, xStop, unit4 + unit2, unit2 + unit2);
for (int i = 0; i < 4; i++)
renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 0; i < 4; i++) renderer.renderFace(i, blockAccess, block, x, y, z, icon);
renderer.setRenderBounds(xStart, unit4, 1 - unit2 - unit2, xStop, unit4 + unit2, 1 - unit2);
for (int i = 0; i < 4; i++)
renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 0; i < 4; i++) renderer.renderFace(i, blockAccess, block, x, y, z, icon);
for (int i = 0; i < 2; i++)
renderer.state.clearUVRotation(i);
for (int i = 0; i < 2; i++) renderer.state.clearUVRotation(i);
renderer.state.colorMultYPos = oldColor;
}
@@ -7,13 +7,12 @@ import com.jaquadro.minecraft.storagedrawers.util.RenderHelper;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class CommonTrimRenderer
{
public class CommonTrimRenderer {
private PanelBoxRenderer panelRenderer = new PanelBoxRenderer();
private double trimWidth;
private RenderHelper start (IBlockAccess world, int x, int y, int z, BlockTrimCustom block) {
private RenderHelper start(IBlockAccess world, int x, int y, int z, BlockTrimCustom block) {
trimWidth = .0625f;
panelRenderer.setTrimWidth(trimWidth);
@@ -22,13 +21,12 @@ public class CommonTrimRenderer
panelRenderer.setPanelColor(ModularBoxRenderer.COLOR_WHITE);
RenderHelper renderHelper = RenderHelper.instance;
if (world != null)
renderHelper.setColorAndBrightness(world, block, x, y, z);
if (world != null) renderHelper.setColorAndBrightness(world, block, x, y, z);
return renderHelper;
}
public void render (IBlockAccess world, int x, int y, int z, BlockTrimCustom block, IIcon iconSide, IIcon iconTrim) {
public void render(IBlockAccess world, int x, int y, int z, BlockTrimCustom block, IIcon iconSide, IIcon iconTrim) {
RenderHelper renderHelper = start(world, x, y, z, block);
panelRenderer.setTrimIcon(iconTrim);
@@ -1,15 +1,13 @@
package com.jaquadro.minecraft.storagedrawers.config;
import cpw.mods.fml.common.Loader;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class CompTierRegistry
{
public class CompTierRegistry {
public class Record {
public ItemStack upper;
public ItemStack lower;
@@ -18,7 +16,7 @@ public class CompTierRegistry
private List<Record> records = new ArrayList<Record>();
public CompTierRegistry () {
public CompTierRegistry() {
register(new ItemStack(Blocks.clay), new ItemStack(Items.clay_ball), 4);
register(new ItemStack(Blocks.snow), new ItemStack(Items.snowball), 4);
register(new ItemStack(Blocks.glowstone), new ItemStack(Items.glowstone_dust), 4);
@@ -31,9 +29,8 @@ public class CompTierRegistry
register(new ItemStack(Blocks.sandstone), new ItemStack(Blocks.sand), 4);
}
public boolean register (ItemStack upper, ItemStack lower, int convRate) {
if (upper == null || lower == null)
return false;
public boolean register(ItemStack upper, ItemStack lower, int convRate) {
if (upper == null || lower == null) return false;
unregisterUpperTarget(upper);
unregisterLowerTarget(lower);
@@ -51,7 +48,7 @@ public class CompTierRegistry
return true;
}
public boolean unregisterUpperTarget (ItemStack stack) {
public boolean unregisterUpperTarget(ItemStack stack) {
for (Record r : records) {
if (ItemStack.areItemStacksEqual(stack, r.upper)) {
records.remove(r);
@@ -62,7 +59,7 @@ public class CompTierRegistry
return false;
}
public boolean unregisterLowerTarget (ItemStack stack) {
public boolean unregisterLowerTarget(ItemStack stack) {
for (Record r : records) {
if (ItemStack.areItemStacksEqual(stack, r.lower)) {
records.remove(r);
@@ -73,27 +70,23 @@ public class CompTierRegistry
return false;
}
public Record findHigherTier (ItemStack stack) {
if (stack == null || stack.getItem() == null)
return null;
public Record findHigherTier(ItemStack stack) {
if (stack == null || stack.getItem() == null) return null;
for (int i = 0, n = records.size(); i < n; i++) {
Record r = records.get(i);
if (stack.isItemEqual(r.lower) && ItemStack.areItemStackTagsEqual(stack, r.lower))
return r;
if (stack.isItemEqual(r.lower) && ItemStack.areItemStackTagsEqual(stack, r.lower)) return r;
}
return null;
}
public Record findLowerTier (ItemStack stack) {
if (stack == null || stack.getItem() == null)
return null;
public Record findLowerTier(ItemStack stack) {
if (stack == null || stack.getItem() == null) return null;
for (int i = 0, n = records.size(); i < n; i++) {
Record r = records.get(i);
if (stack.isItemEqual(r.upper) && ItemStack.areItemStackTagsEqual(stack, r.upper))
return r;
if (stack.isItemEqual(r.upper) && ItemStack.areItemStackTagsEqual(stack, r.upper)) return r;
}
return null;
@@ -5,17 +5,15 @@ import com.jaquadro.minecraft.storagedrawers.api.config.IBlockConfig;
import com.jaquadro.minecraft.storagedrawers.api.config.IIntegrationConfig;
import com.jaquadro.minecraft.storagedrawers.api.config.IUserConfig;
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
public class ConfigManager
{
public class ConfigManager {
public class ConfigSection {
public final ConfigSection parent;
public final String name;
@@ -23,7 +21,7 @@ public class ConfigManager
private ConfigCategory category;
public ConfigSection (List<ConfigSection> list, ConfigSection parent, String name, String lang) {
public ConfigSection(List<ConfigSection> list, ConfigSection parent, String name, String lang) {
this.parent = parent;
this.name = name;
this.lang = lang;
@@ -31,24 +29,22 @@ public class ConfigManager
list.add(this);
}
public ConfigSection (List<ConfigSection> list, String name, String lang) {
public ConfigSection(List<ConfigSection> list, String name, String lang) {
this(list, null, name, lang);
}
public ConfigCategory getCategory () {
if (category != null)
return category;
public ConfigCategory getCategory() {
if (category != null) return category;
if (parent != null)
category = config.getCategory(parent.getCategory().getQualifiedName() + "." + name.toLowerCase());
else
category = config.getCategory(name.toLowerCase());
else category = config.getCategory(name.toLowerCase());
category.setLanguageKey(LANG_PREFIX + lang);
return category;
}
public String getQualifiedName () {
public String getQualifiedName() {
return getCategory().getQualifiedName();
}
}
@@ -99,24 +95,24 @@ public class ConfigManager
private class AddonConfig implements IAddonConfig {
@Override
public boolean showAddonItemsNEI () {
public boolean showAddonItemsNEI() {
return cache.addonShowNEI;
}
@Override
public boolean showAddonItemsVanilla () {
public boolean showAddonItemsVanilla() {
return cache.addonShowVanilla;
}
@Override
public boolean addonItemsUseSeparateTab () {
public boolean addonItemsUseSeparateTab() {
return cache.addonSeparateVanilla;
}
}
private class BlockConfig implements IBlockConfig {
@Override
public String getBlockConfigName (BlockConfiguration blockConfig) {
public String getBlockConfigName(BlockConfiguration blockConfig) {
switch (blockConfig) {
case BasicFull1:
case SortingFull1:
@@ -142,52 +138,51 @@ public class ConfigManager
}
@Override
public boolean isBlockEnabled (String blockConfigName) {
public boolean isBlockEnabled(String blockConfigName) {
return ConfigManager.this.isBlockEnabled(blockConfigName);
}
@Override
public int getBlockRecipeOutput (String blockConfigName) {
public int getBlockRecipeOutput(String blockConfigName) {
return ConfigManager.this.getBlockRecipeOutput(blockConfigName);
}
@Override
public int getBaseCapacity (String blockConfigName) {
public int getBaseCapacity(String blockConfigName) {
return ConfigManager.this.getBlockBaseStorage(blockConfigName);
}
}
private class IntegrationConfig implements IIntegrationConfig {
@Override
public boolean isRefinedRelocationEnabled () {
public boolean isRefinedRelocationEnabled() {
return cache.enableRefinedRelocationIntegration;
}
@Override
public boolean isChiselEnabled () {
public boolean isChiselEnabled() {
return cache.enableChiselIntegration;
}
@Override
public boolean isGTNHEnabled () {
public boolean isGTNHEnabled() {
return cache.enableGTNHIntegration;
}
}
private class UserConfig implements IUserConfig {
@Override
public IAddonConfig addonConfig () {
public IAddonConfig addonConfig() {
return addonConfig;
}
@Override
public IBlockConfig blockConfig () {
public IBlockConfig blockConfig() {
return blockConfig;
}
@Override
public IIntegrationConfig integrationConfig () {
public IIntegrationConfig integrationConfig() {
return integrationConfig;
}
}
@@ -205,15 +200,24 @@ public class ConfigManager
public final ConfigSection sectionAddons = new ConfigSection(sections, "addons", "addons");
public final List<ConfigSection> blockSections = new ArrayList<ConfigSection>();
public final ConfigSection sectionBlocksFullDrawers1x1 = new ConfigSection(blockSections, sectionBlocks, "fulldrawers1", "blocks.fullDrawers1");
public final ConfigSection sectionBlocksFullDrawers1x2 = new ConfigSection(blockSections, sectionBlocks, "fulldrawers2", "blocks.fullDrawers2");
public final ConfigSection sectionBlocksFullDrawers2x2 = new ConfigSection(blockSections, sectionBlocks, "fulldrawers4", "blocks.fullDrawers4");
public final ConfigSection sectionBlocksHalfDrawers1x2 = new ConfigSection(blockSections, sectionBlocks, "halfdrawers2", "blocks.halfDrawers2");
public final ConfigSection sectionBlocksHalfDrawers2x2 = new ConfigSection(blockSections, sectionBlocks, "halfdrawers4", "blocks.halfDrawers4");
public final ConfigSection sectionBlocksCompDrawers = new ConfigSection(blockSections, sectionBlocks, "compdrawers", "blocks.compDrawers");
public final ConfigSection sectionBlocksController = new ConfigSection(blockSections, sectionBlocks, "controller", "blocks.controller");
public final ConfigSection sectionBlocksTrim = new ConfigSection(blockSections, sectionBlocks, "trim", "blocks.trim");
public final ConfigSection sectionBlocksSlave = new ConfigSection(blockSections, sectionBlocks, "controllerSlave", "blocks.controllerSlave");
public final ConfigSection sectionBlocksFullDrawers1x1 =
new ConfigSection(blockSections, sectionBlocks, "fulldrawers1", "blocks.fullDrawers1");
public final ConfigSection sectionBlocksFullDrawers1x2 =
new ConfigSection(blockSections, sectionBlocks, "fulldrawers2", "blocks.fullDrawers2");
public final ConfigSection sectionBlocksFullDrawers2x2 =
new ConfigSection(blockSections, sectionBlocks, "fulldrawers4", "blocks.fullDrawers4");
public final ConfigSection sectionBlocksHalfDrawers1x2 =
new ConfigSection(blockSections, sectionBlocks, "halfdrawers2", "blocks.halfDrawers2");
public final ConfigSection sectionBlocksHalfDrawers2x2 =
new ConfigSection(blockSections, sectionBlocks, "halfdrawers4", "blocks.halfDrawers4");
public final ConfigSection sectionBlocksCompDrawers =
new ConfigSection(blockSections, sectionBlocks, "compdrawers", "blocks.compDrawers");
public final ConfigSection sectionBlocksController =
new ConfigSection(blockSections, sectionBlocks, "controller", "blocks.controller");
public final ConfigSection sectionBlocksTrim =
new ConfigSection(blockSections, sectionBlocks, "trim", "blocks.trim");
public final ConfigSection sectionBlocksSlave =
new ConfigSection(blockSections, sectionBlocks, "controllerSlave", "blocks.controllerSlave");
public Map<String, ConfigSection> blockSectionsMap = new HashMap<String, ConfigSection>();
@@ -222,14 +226,13 @@ public class ConfigManager
public IIntegrationConfig integrationConfig = new IntegrationConfig();
public IUserConfig userConfig = new UserConfig();
//private Property itemRenderType;
// private Property itemRenderType;
public ConfigManager (File file) {
public ConfigManager(File file) {
config = new Configuration(file);
cache = new ConfigCache();
for (ConfigSection section : sections)
section.getCategory();
for (ConfigSection section : sections) section.getCategory();
for (ConfigSection section : blockSections) {
section.getCategory();
@@ -239,144 +242,312 @@ public class ConfigManager
syncConfig();
}
public void syncConfig () {
cache.enableIndicatorUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableIndicatorUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableIndicatorUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableStorageUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableStorageUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableLockUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableLockUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableLockUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableVoidUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableVoidUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableVoidUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableCreativeUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableCreativeUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableCreativeUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableShroudUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableShroudUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableShroudUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enablePersonalUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enablePersonalUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enablePersonalUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableSortingUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableRedstoneUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableRedstoneUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableRedstoneUpgrades").setRequiresMcRestart(true).getBoolean();
cache.enableTape = config.get(Configuration.CATEGORY_GENERAL, "enableTape", true).setLanguageKey(LANG_PREFIX + "prop.enableTape").setRequiresMcRestart(true).getBoolean();
cache.itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "itemRenderType", "fast", null, new String[]{"fancy", "fast"}).setLanguageKey(LANG_PREFIX + "prop.itemRenderType").getString();
cache.renderStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "renderStorageUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.renderStorageUpgrades").getBoolean();
cache.creativeTabVanillaWoods = config.get(Configuration.CATEGORY_GENERAL, "creativeTabVanillaWoods", true).setLanguageKey(LANG_PREFIX + "prop.creativeTabVanillaWoods").getBoolean();
cache.enableDrawerUI = config.get(Configuration.CATEGORY_GENERAL, "enableDrawerUI", true).setLanguageKey(LANG_PREFIX + "prop.enableDrawerUI").getBoolean();
cache.enableSidedInput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedInput", true).setLanguageKey(LANG_PREFIX + "prop.enableSidedInput").getBoolean();
cache.enableSidedOutput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedOutput", true).setLanguageKey(LANG_PREFIX + "prop.enableSidedOutput").getBoolean();
cache.enableItemConversion = config.get(Configuration.CATEGORY_GENERAL, "enableItemConversion", true).setLanguageKey(LANG_PREFIX + "prop.enableItemConversion").getBoolean();
cache.enableFallbackRecipes = config.get(Configuration.CATEGORY_GENERAL, "enableFallbackRecipes", true).setLanguageKey(LANG_PREFIX + "prop.enableFallbackRecipes").setRequiresMcRestart(true).getBoolean();
cache.enableFramedDrawers = config.get(Configuration.CATEGORY_GENERAL, "enableFramedDrawers", true).setLanguageKey(LANG_PREFIX + "prop.enableFramedDrawers").setRequiresMcRestart(true).getBoolean();
cache.stackRemainderWaila = !config.get(Configuration.CATEGORY_GENERAL, "wailaStackRemainder", "stack + remainder", null, new String[]{"exact", "stack + remainder"}).setLanguageKey(LANG_PREFIX + "prop.wailaStackRemainder").getString().equals("exact");
cache.invertShift = config.get(Configuration.CATEGORY_GENERAL, "invertShift", false,
"Inverts how shift works with drawers. If this is true, shifting will only give one item, where regular clicks will give a full stack. Leave false for default behavior.")
.setLanguageKey(LANG_PREFIX + "prop.invertShift").getBoolean();
cache.debugTrace = config.get(Configuration.CATEGORY_GENERAL, "enableDebugLogging", false,
"Writes additional log messages while using the mod. Mainly for debug purposes. Should be kept disabled unless instructed otherwise.")
.setLanguageKey(LANG_PREFIX + "prop.enableDebugLogging").getBoolean();
public void syncConfig() {
cache.enableIndicatorUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableIndicatorUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableIndicatorUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableStorageUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableStorageUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableLockUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableLockUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableLockUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableVoidUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableVoidUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableVoidUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableCreativeUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableCreativeUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableCreativeUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableShroudUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableShroudUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableShroudUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enablePersonalUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enablePersonalUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enablePersonalUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableSortingUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableRedstoneUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableRedstoneUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.enableRedstoneUpgrades")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableTape = config.get(Configuration.CATEGORY_GENERAL, "enableTape", true)
.setLanguageKey(LANG_PREFIX + "prop.enableTape")
.setRequiresMcRestart(true)
.getBoolean();
cache.itemRenderType = config.get(
Configuration.CATEGORY_GENERAL, "itemRenderType", "fast", null, new String[] {"fancy", "fast"})
.setLanguageKey(LANG_PREFIX + "prop.itemRenderType")
.getString();
cache.renderStorageUpgrades = config.get(Configuration.CATEGORY_GENERAL, "renderStorageUpgrades", true)
.setLanguageKey(LANG_PREFIX + "prop.renderStorageUpgrades")
.getBoolean();
cache.creativeTabVanillaWoods = config.get(Configuration.CATEGORY_GENERAL, "creativeTabVanillaWoods", true)
.setLanguageKey(LANG_PREFIX + "prop.creativeTabVanillaWoods")
.getBoolean();
cache.enableDrawerUI = config.get(Configuration.CATEGORY_GENERAL, "enableDrawerUI", true)
.setLanguageKey(LANG_PREFIX + "prop.enableDrawerUI")
.getBoolean();
cache.enableSidedInput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedInput", true)
.setLanguageKey(LANG_PREFIX + "prop.enableSidedInput")
.getBoolean();
cache.enableSidedOutput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedOutput", true)
.setLanguageKey(LANG_PREFIX + "prop.enableSidedOutput")
.getBoolean();
cache.enableItemConversion = config.get(Configuration.CATEGORY_GENERAL, "enableItemConversion", true)
.setLanguageKey(LANG_PREFIX + "prop.enableItemConversion")
.getBoolean();
cache.enableFallbackRecipes = config.get(Configuration.CATEGORY_GENERAL, "enableFallbackRecipes", true)
.setLanguageKey(LANG_PREFIX + "prop.enableFallbackRecipes")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableFramedDrawers = config.get(Configuration.CATEGORY_GENERAL, "enableFramedDrawers", true)
.setLanguageKey(LANG_PREFIX + "prop.enableFramedDrawers")
.setRequiresMcRestart(true)
.getBoolean();
cache.stackRemainderWaila = !config.get(
Configuration.CATEGORY_GENERAL, "wailaStackRemainder", "stack + remainder", null, new String[] {
"exact", "stack + remainder"
})
.setLanguageKey(LANG_PREFIX + "prop.wailaStackRemainder")
.getString()
.equals("exact");
cache.invertShift = config.get(
Configuration.CATEGORY_GENERAL,
"invertShift",
false,
"Inverts how shift works with drawers. If this is true, shifting will only give one item, where regular clicks will give a full stack. Leave false for default behavior.")
.setLanguageKey(LANG_PREFIX + "prop.invertShift")
.getBoolean();
cache.debugTrace = config.get(
Configuration.CATEGORY_GENERAL,
"enableDebugLogging",
false,
"Writes additional log messages while using the mod. Mainly for debug purposes. Should be kept disabled unless instructed otherwise.")
.setLanguageKey(LANG_PREFIX + "prop.enableDebugLogging")
.getBoolean();
cache.enableAE2Integration = config.get(sectionIntegration.getQualifiedName(), "enableAE2", true).setLanguageKey(LANG_PREFIX + "integration.enableAE2").setRequiresMcRestart(true).getBoolean();
cache.enableWailaIntegration = config.get(sectionIntegration.getQualifiedName(), "enableWaila", true).setLanguageKey(LANG_PREFIX + "integration.enableWaila").setRequiresMcRestart(true).getBoolean();
cache.enableThaumcraftIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThaumcraft", true).setLanguageKey(LANG_PREFIX + "integration.enableThaumcraft").setRequiresMcRestart(true).getBoolean();
cache.enableMineTweakerIntegration = config.get(sectionIntegration.getQualifiedName(), "enableMineTweaker", true).setLanguageKey(LANG_PREFIX + "integration.enableMineTweaker").setRequiresMcRestart(true).getBoolean();
cache.enableRefinedRelocationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableRefinedRelocation", true).setLanguageKey(LANG_PREFIX + "integration.enableRefinedRelocation").setRequiresMcRestart(true).getBoolean();
cache.enableThermalExpansionIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalExpansion", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalExpansion").setRequiresMcRestart(true).getBoolean();
cache.enableThermalFoundationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalFoundation", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalFoundation").setRequiresMcRestart(true).getBoolean();
cache.enableChiselIntegration = config.get(sectionIntegration.getQualifiedName(), "enableChisel", true).setLanguageKey(LANG_PREFIX + "integration.enableChisel").setRequiresMcRestart(true).getBoolean();
cache.enableGTNHIntegration = config.get(sectionIntegration.getQualifiedName(), "enableGTNH", true).setLanguageKey(LANG_PREFIX + "integration.enableGTNH").setRequiresMcRestart(true).getBoolean();
cache.enableAE2Integration = config.get(sectionIntegration.getQualifiedName(), "enableAE2", true)
.setLanguageKey(LANG_PREFIX + "integration.enableAE2")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableWailaIntegration = config.get(sectionIntegration.getQualifiedName(), "enableWaila", true)
.setLanguageKey(LANG_PREFIX + "integration.enableWaila")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableThaumcraftIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThaumcraft", true)
.setLanguageKey(LANG_PREFIX + "integration.enableThaumcraft")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableMineTweakerIntegration = config.get(
sectionIntegration.getQualifiedName(), "enableMineTweaker", true)
.setLanguageKey(LANG_PREFIX + "integration.enableMineTweaker")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableRefinedRelocationIntegration = config.get(
sectionIntegration.getQualifiedName(), "enableRefinedRelocation", true)
.setLanguageKey(LANG_PREFIX + "integration.enableRefinedRelocation")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableThermalExpansionIntegration = config.get(
sectionIntegration.getQualifiedName(), "enableThermalExpansion", true)
.setLanguageKey(LANG_PREFIX + "integration.enableThermalExpansion")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableThermalFoundationIntegration = config.get(
sectionIntegration.getQualifiedName(), "enableThermalFoundation", true)
.setLanguageKey(LANG_PREFIX + "integration.enableThermalFoundation")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableChiselIntegration = config.get(sectionIntegration.getQualifiedName(), "enableChisel", true)
.setLanguageKey(LANG_PREFIX + "integration.enableChisel")
.setRequiresMcRestart(true)
.getBoolean();
cache.enableGTNHIntegration = config.get(sectionIntegration.getQualifiedName(), "enableGTNH", true)
.setLanguageKey(LANG_PREFIX + "integration.enableGTNH")
.setRequiresMcRestart(true)
.getBoolean();
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "baseStorage", 32).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "recipeOutput", 1).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "baseStorage", 32)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "recipeOutput", 1)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "baseStorage", 16).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "recipeOutput", 2).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "baseStorage", 16)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers1x2.getQualifiedName(), "recipeOutput", 2)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "baseStorage", 8).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "recipeOutput", 4).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "baseStorage", 8)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksFullDrawers2x2.getQualifiedName(), "recipeOutput", 4)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "baseStorage", 8).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "recipeOutput", 2).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "baseStorage", 8)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers1x2.getQualifiedName(), "recipeOutput", 2)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "baseStorage", 4).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "recipeOutput", 4).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "baseStorage", 4)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksHalfDrawers2x2.getQualifiedName(), "recipeOutput", 4)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "baseStorage", 16).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "recipeOutput", 1).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "baseStorage", 16)
.setLanguageKey(LANG_PREFIX + "prop.baseStorage")
.setRequiresWorldRestart(true);
config.get(sectionBlocksCompDrawers.getQualifiedName(), "recipeOutput", 1)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksController.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksController.getQualifiedName(), "range", 12).setLanguageKey(LANG_PREFIX + "prop.controllerRange");
config.get(sectionBlocksController.getQualifiedName(), "maxDrawers", 2048).setLanguageKey(LANG_PREFIX + "prop.controllerMaxDrawers");
config.get(sectionBlocksController.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksController.getQualifiedName(), "range", 12)
.setLanguageKey(LANG_PREFIX + "prop.controllerRange");
config.get(sectionBlocksController.getQualifiedName(), "maxDrawers", 2048)
.setLanguageKey(LANG_PREFIX + "prop.controllerMaxDrawers");
config.get(sectionBlocksTrim.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksTrim.getQualifiedName(), "recipeOutput", 4).setLanguageKey(LANG_PREFIX + "prop.recipeOutput").setRequiresMcRestart(true);
config.get(sectionBlocksTrim.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
config.get(sectionBlocksTrim.getQualifiedName(), "recipeOutput", 4)
.setLanguageKey(LANG_PREFIX + "prop.recipeOutput")
.setRequiresMcRestart(true);
config.get(sectionBlocksSlave.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
config.get(sectionBlocksSlave.getQualifiedName(), "enabled", true)
.setLanguageKey(LANG_PREFIX + "prop.enabled")
.setRequiresMcRestart(true);
cache.level2Mult = config.get(sectionUpgrades.getQualifiedName(), "level2Mult", 2).setLanguageKey(LANG_PREFIX + "upgrades.level2Mult").setRequiresWorldRestart(true).getInt();
cache.level3Mult = config.get(sectionUpgrades.getQualifiedName(), "level3Mult", 3).setLanguageKey(LANG_PREFIX + "upgrades.level3Mult").setRequiresWorldRestart(true).getInt();
cache.level4Mult = config.get(sectionUpgrades.getQualifiedName(), "level4Mult", 5).setLanguageKey(LANG_PREFIX + "upgrades.level4Mult").setRequiresWorldRestart(true).getInt();
cache.level5Mult = config.get(sectionUpgrades.getQualifiedName(), "level5Mult", 8).setLanguageKey(LANG_PREFIX + "upgrades.level5Mult").setRequiresWorldRestart(true).getInt();
cache.level6Mult = config.get(sectionUpgrades.getQualifiedName(), "level6Mult", 13).setLanguageKey(LANG_PREFIX + "upgrades.level6Mult").setRequiresWorldRestart(true).getInt();
cache.level2Mult = config.get(sectionUpgrades.getQualifiedName(), "level2Mult", 2)
.setLanguageKey(LANG_PREFIX + "upgrades.level2Mult")
.setRequiresWorldRestart(true)
.getInt();
cache.level3Mult = config.get(sectionUpgrades.getQualifiedName(), "level3Mult", 3)
.setLanguageKey(LANG_PREFIX + "upgrades.level3Mult")
.setRequiresWorldRestart(true)
.getInt();
cache.level4Mult = config.get(sectionUpgrades.getQualifiedName(), "level4Mult", 5)
.setLanguageKey(LANG_PREFIX + "upgrades.level4Mult")
.setRequiresWorldRestart(true)
.getInt();
cache.level5Mult = config.get(sectionUpgrades.getQualifiedName(), "level5Mult", 8)
.setLanguageKey(LANG_PREFIX + "upgrades.level5Mult")
.setRequiresWorldRestart(true)
.getInt();
cache.level6Mult = config.get(sectionUpgrades.getQualifiedName(), "level6Mult", 13)
.setLanguageKey(LANG_PREFIX + "upgrades.level6Mult")
.setRequiresWorldRestart(true)
.getInt();
cache.addonShowNEI = config.get(sectionAddons.getQualifiedName(), "showBlocksInNEI", true).setLanguageKey(LANG_PREFIX + "addons.showNEI").setRequiresWorldRestart(true).getBoolean();
cache.addonShowVanilla = config.get(sectionAddons.getQualifiedName(), "showBlocksInCreative", true).setLanguageKey(LANG_PREFIX + "addons.showCreative").setRequiresWorldRestart(true).getBoolean();
cache.addonSeparateVanilla = config.get(sectionAddons.getQualifiedName(), "useSeparateCreativeTabs", true).setLanguageKey(LANG_PREFIX + "addons.separateTabs").setRequiresMcRestart(true).getBoolean();
cache.addonShowNEI = config.get(sectionAddons.getQualifiedName(), "showBlocksInNEI", true)
.setLanguageKey(LANG_PREFIX + "addons.showNEI")
.setRequiresWorldRestart(true)
.getBoolean();
cache.addonShowVanilla = config.get(sectionAddons.getQualifiedName(), "showBlocksInCreative", true)
.setLanguageKey(LANG_PREFIX + "addons.showCreative")
.setRequiresWorldRestart(true)
.getBoolean();
cache.addonSeparateVanilla = config.get(sectionAddons.getQualifiedName(), "useSeparateCreativeTabs", true)
.setLanguageKey(LANG_PREFIX + "addons.separateTabs")
.setRequiresMcRestart(true)
.getBoolean();
getControllerRange();
getControllerMaxDrawers();
if (config.hasChanged())
config.save();
if (config.hasChanged()) config.save();
}
public boolean isFancyItemRenderEnabled () {
public boolean isFancyItemRenderEnabled() {
return cache.itemRenderType.equals("fancy");
}
public String getPath () {
public String getPath() {
return config.toString();
}
public boolean isBlockEnabled (String blockName) {
if (!blockSectionsMap.containsKey(blockName))
return false;
public boolean isBlockEnabled(String blockName) {
if (!blockSectionsMap.containsKey(blockName)) return false;
ConfigSection section = blockSectionsMap.get(blockName);
return section.getCategory().get("enabled").getBoolean();
}
public int getBlockBaseStorage (String blockName) {
if (!blockSectionsMap.containsKey(blockName))
return 0;
public int getBlockBaseStorage(String blockName) {
if (!blockSectionsMap.containsKey(blockName)) return 0;
ConfigSection section = blockSectionsMap.get(blockName);
return section.getCategory().get("baseStorage").getInt();
}
public int getBlockRecipeOutput (String blockName) {
if (!blockSectionsMap.containsKey(blockName))
return 0;
public int getBlockRecipeOutput(String blockName) {
if (!blockSectionsMap.containsKey(blockName)) return 0;
ConfigSection section = blockSectionsMap.get(blockName);
return section.getCategory().get("recipeOutput").getInt();
}
public int getControllerRange () {
public int getControllerRange() {
ConfigSection section = blockSectionsMap.get("controller");
return section.getCategory().get("range").getInt();
}
public int getControllerMaxDrawers () {
public int getControllerMaxDrawers() {
ConfigSection section = blockSectionsMap.get("controller");
return section.getCategory().get("maxDrawers").getInt();
}
public int getStorageUpgradeMultiplier (int level) {
public int getStorageUpgradeMultiplier(int level) {
switch (level) {
case 2: return cache.level2Mult;
case 3: return cache.level3Mult;
case 4: return cache.level4Mult;
case 5: return cache.level5Mult;
case 6: return cache.level6Mult;
default: return 1;
case 2:
return cache.level2Mult;
case 3:
return cache.level3Mult;
case 4:
return cache.level4Mult;
case 5:
return cache.level5Mult;
case 6:
return cache.level6Mult;
default:
return 1;
}
}
}
@@ -3,19 +3,17 @@ package com.jaquadro.minecraft.storagedrawers.config;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.IConfigElement;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import java.util.ArrayList;
import java.util.List;
public class ModConfigGui extends GuiConfig
{
public ModConfigGui (GuiScreen parent) {
public class ModConfigGui extends GuiConfig {
public ModConfigGui(GuiScreen parent) {
super(parent, getConfigElements(), StorageDrawers.MOD_ID, false, false, "Storage Drawers Configuration");
}
private static List<IConfigElement> getConfigElements () {
private static List<IConfigElement> getConfigElements() {
List<IConfigElement> list = new ArrayList<IConfigElement>();
for (ConfigManager.ConfigSection section : StorageDrawers.config.sections)
@@ -23,5 +21,4 @@ public class ModConfigGui extends GuiConfig
return list;
}
}
@@ -2,17 +2,15 @@ package com.jaquadro.minecraft.storagedrawers.config;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class OreDictRegistry
{
public class OreDictRegistry {
private Set<String> blacklist = new HashSet<String>();
private Set<String> whitelist = new HashSet<String>();
private List<String> blacklistPrefix = new ArrayList<String>();
@@ -20,7 +18,7 @@ public class OreDictRegistry
private Set<String> blacklistCache = new HashSet<String>();
private Set<String> graylistCache = new HashSet<String>();
public OreDictRegistry () {
public OreDictRegistry() {
addBlacklist("logWood");
addBlacklist("plankWood");
addBlacklist("slabWood");
@@ -55,19 +53,34 @@ public class OreDictRegistry
addBlacklistPrefix("list");
addBlacklistPrefix("dye");
String[] oreTypes = { "ore", "block", "ingot", "nugget" };
String[] oreMaterials = { "Iron", "Gold", "Diamond", "Emerald", "Aluminum", "Aluminium", "Tin", "Copper", "Lead",
"Silver", "Platinum", "Nickel", "Osmium", "Invar", "Bronze", "Electrum", "Enderium" };
String[] oreTypes = {"ore", "block", "ingot", "nugget"};
String[] oreMaterials = {
"Iron",
"Gold",
"Diamond",
"Emerald",
"Aluminum",
"Aluminium",
"Tin",
"Copper",
"Lead",
"Silver",
"Platinum",
"Nickel",
"Osmium",
"Invar",
"Bronze",
"Electrum",
"Enderium"
};
for (String ore : oreMaterials) {
for (String type : oreTypes)
addWhitelist(type + ore);
for (String type : oreTypes) addWhitelist(type + ore);
}
}
public boolean addBlacklist (String entry) {
if (entry == null)
return false;
public boolean addBlacklist(String entry) {
if (entry == null) return false;
blacklistCache.add(entry);
graylistCache.remove(entry);
@@ -75,42 +88,38 @@ public class OreDictRegistry
return blacklist.add(entry);
}
public boolean addBlacklistPrefix (String entry) {
if (entry == null)
return false;
public boolean addBlacklistPrefix(String entry) {
if (entry == null) return false;
if (blacklistPrefix.contains(entry))
return false;
if (blacklistPrefix.contains(entry)) return false;
graylistCache.clear();
return blacklistPrefix.add(entry);
}
public boolean addWhitelist (String entry) {
if (entry == null)
return false;
public boolean addWhitelist(String entry) {
if (entry == null) return false;
return whitelist.add(entry);
}
public boolean removeBlacklist (String entry) {
public boolean removeBlacklist(String entry) {
blacklistCache.remove(entry);
return blacklist.remove(entry);
}
public boolean removeBlacklistPrefix (String entry) {
public boolean removeBlacklistPrefix(String entry) {
return blacklistPrefix.remove(entry);
}
public boolean removeWhitelist (String entry) {
public boolean removeWhitelist(String entry) {
return whitelist.remove(entry);
}
public boolean isEntryBlacklisted (String entry) {
if (blacklistCache.contains(entry))
return true;
public boolean isEntryBlacklisted(String entry) {
if (blacklistCache.contains(entry)) return true;
for (int i = 0, n = blacklistPrefix.size(); i < n; i++) {
if (entry.startsWith(blacklistPrefix.get(i))) {
@@ -122,17 +131,15 @@ public class OreDictRegistry
return false;
}
public boolean isEntryWhitelisted (String entry) {
public boolean isEntryWhitelisted(String entry) {
return whitelist.contains(entry);
}
public boolean isEntryValid (String entry) {
if (graylistCache.contains(entry))
return true;
public boolean isEntryValid(String entry) {
if (graylistCache.contains(entry)) return true;
if (!whitelist.contains(entry)) {
if (isEntryBlacklisted(entry))
return false;
if (isEntryBlacklisted(entry)) return false;
if (!isValidForEquiv(entry)) {
blacklistCache.add(entry);
@@ -145,37 +152,32 @@ public class OreDictRegistry
return true;
}
private String getModId (Item item) {
private String getModId(Item item) {
String itemId = GameData.getItemRegistry().getNameForObject(item);
if (itemId == null)
return null;
if (itemId == null) return null;
GameRegistry.UniqueIdentifier uid = new GameRegistry.UniqueIdentifier(itemId);
return uid.modId;
}
private boolean isValidForEquiv (String oreName) {
private boolean isValidForEquiv(String oreName) {
List<ItemStack> oreList = OreDictionary.getOres(oreName);
if (oreList.size() == 0)
return false;
if (oreList.size() == 0) return false;
// Fail entries that have any wildcard items registered to them.
HashSet<String> modIds = new HashSet<String>();
for (int i = 0, n = oreList.size(); i < n; i++) {
if (oreList.get(i).getItemDamage() == OreDictionary.WILDCARD_VALUE)
return false;
if (oreList.get(i).getItemDamage() == OreDictionary.WILDCARD_VALUE) return false;
String modId = getModId(oreList.get(i).getItem());
if (modId != null)
modIds.add(modId);
if (modId != null) modIds.add(modId);
}
// Fail entries that have multiple instances of an item registered, differing by metadata or other
// criteria.
if (modIds.size() < oreList.size())
return false;
if (modIds.size() < oreList.size()) return false;
// Fail entries where the keys in at least one stack are not the super-set of all other stacks.
// Can be determined by merging all keys and testing cardinality.
@@ -187,12 +189,10 @@ public class OreDictRegistry
int[] ids = OreDictionary.getOreIDs(oreList.get(i));
maxKeyCount = Math.max(maxKeyCount, ids.length);
for (int id : ids)
mergedIds.add(id);
for (int id : ids) mergedIds.add(id);
}
if (maxKeyCount < mergedIds.size())
return false;
if (maxKeyCount < mergedIds.size()) return false;
return true;
}
@@ -3,22 +3,20 @@ package com.jaquadro.minecraft.storagedrawers.config;
import com.jaquadro.minecraft.storagedrawers.api.registry.IIngredientHandler;
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandler;
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
{
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry {
private Map<Class, IRecipeHandler> recipeRegistry = new HashMap<Class, IRecipeHandler>();
private Map<Class, IIngredientHandler> ingredientRegistry = new HashMap<Class, IIngredientHandler>();
public RecipeHandlerRegistry () {
public RecipeHandlerRegistry() {
registerRecipeHandler(ShapedOreRecipe.class, new ShapedOreRecipeHandler());
registerRecipeHandler(ShapedRecipes.class, new ShapedRecipeHandler());
registerRecipeHandler(ShapelessOreRecipe.class, new ShapelessOreRecipeHandler());
@@ -26,22 +24,19 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
}
@Override
public void registerRecipeHandler (Class clazz, IRecipeHandler handler) {
if (!recipeRegistry.containsKey(clazz))
recipeRegistry.put(clazz, handler);
public void registerRecipeHandler(Class clazz, IRecipeHandler handler) {
if (!recipeRegistry.containsKey(clazz)) recipeRegistry.put(clazz, handler);
}
@Override
public void registerIngredientHandler (Class clazz, IIngredientHandler handler) {
if (!ingredientRegistry.containsKey(clazz))
ingredientRegistry.put(clazz, handler);
public void registerIngredientHandler(Class clazz, IIngredientHandler handler) {
if (!ingredientRegistry.containsKey(clazz)) ingredientRegistry.put(clazz, handler);
}
@Override
public IRecipeHandler getRecipeHandler (Class clazz) {
public IRecipeHandler getRecipeHandler(Class clazz) {
while (clazz != null) {
if (recipeRegistry.containsKey(clazz))
return recipeRegistry.get(clazz);
if (recipeRegistry.containsKey(clazz)) return recipeRegistry.get(clazz);
clazz = clazz.getSuperclass();
}
@@ -50,14 +45,12 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
}
@Override
public IIngredientHandler getIngredientHandler (Class clazz) {
public IIngredientHandler getIngredientHandler(Class clazz) {
while (clazz != null) {
if (ingredientRegistry.containsKey(clazz))
return ingredientRegistry.get(clazz);
if (ingredientRegistry.containsKey(clazz)) return ingredientRegistry.get(clazz);
for (Class inter : clazz.getInterfaces()) {
if (ingredientRegistry.containsKey(inter))
return ingredientRegistry.get(inter);
if (ingredientRegistry.containsKey(inter)) return ingredientRegistry.get(inter);
}
clazz = clazz.getSuperclass();
@@ -66,54 +59,50 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
return null;
}
private static class ShapedOreRecipeHandler implements IRecipeHandler
{
private static class ShapedOreRecipeHandler implements IRecipeHandler {
@Override
public Object[] getInputAsArray (IRecipe recipe) {
public Object[] getInputAsArray(IRecipe recipe) {
return ((ShapedOreRecipe) recipe).getInput();
}
@Override
public List getInputAsList (IRecipe recipe) {
public List getInputAsList(IRecipe recipe) {
return null;
}
}
private static class ShapedRecipeHandler implements IRecipeHandler
{
private static class ShapedRecipeHandler implements IRecipeHandler {
@Override
public Object[] getInputAsArray (IRecipe recipe) {
public Object[] getInputAsArray(IRecipe recipe) {
return ((ShapedRecipes) recipe).recipeItems;
}
@Override
public List getInputAsList (IRecipe recipe) {
public List getInputAsList(IRecipe recipe) {
return null;
}
}
private static class ShapelessOreRecipeHandler implements IRecipeHandler
{
private static class ShapelessOreRecipeHandler implements IRecipeHandler {
@Override
public Object[] getInputAsArray (IRecipe recipe) {
public Object[] getInputAsArray(IRecipe recipe) {
return null;
}
@Override
public List getInputAsList (IRecipe recipe) {
public List getInputAsList(IRecipe recipe) {
return ((ShapelessOreRecipe) recipe).getInput();
}
}
private static class ShapelessRecipeHandler implements IRecipeHandler
{
private static class ShapelessRecipeHandler implements IRecipeHandler {
@Override
public Object[] getInputAsArray (IRecipe recipe) {
public Object[] getInputAsArray(IRecipe recipe) {
return null;
}
@Override
public List getInputAsList (IRecipe recipe) {
public List getInputAsList(IRecipe recipe) {
return ((ShapelessRecipes) recipe).recipeItems;
}
}
@@ -2,20 +2,18 @@ package com.jaquadro.minecraft.storagedrawers.config;
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
import java.util.ArrayList;
import java.util.List;
public class RenderRegistry implements IRenderRegistry
{
public class RenderRegistry implements IRenderRegistry {
private List<IRenderLabel> registry = new ArrayList<IRenderLabel>();
@Override
public void registerPreLabelRenderHandler (IRenderLabel renderHandler) {
public void registerPreLabelRenderHandler(IRenderLabel renderHandler) {
registry.add(renderHandler);
}
public List<IRenderLabel> getRenderHandlers () {
public List<IRenderLabel> getRenderHandlers() {
return registry;
}
}
@@ -2,20 +2,18 @@ package com.jaquadro.minecraft.storagedrawers.config;
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
import java.util.ArrayList;
import java.util.List;
public class WailaRegistry implements IWailaRegistry
{
public class WailaRegistry implements IWailaRegistry {
private List<IWailaTooltipHandler> registry = new ArrayList<IWailaTooltipHandler>();
@Override
public void registerTooltipHandler (IWailaTooltipHandler handler) {
public void registerTooltipHandler(IWailaTooltipHandler handler) {
registry.add(handler);
}
public List<IWailaTooltipHandler> getTooltipHandlers () {
public List<IWailaTooltipHandler> getTooltipHandlers() {
return registry;
}
}
Loaded 100 of 210 files, more files were not shown because too many files have changed in this diff. Show more