Working crystal chests

This commit is contained in:
Christian Weeks 2012-02-11 10:11:54 -05:00
parent e341f4d2f3
commit 879fa2a97a
11 changed files with 21 additions and 15 deletions

View File

@ -19,7 +19,7 @@ public class GUIChest extends GuiContainer {
DIAMOND(238,256,"/cpw/mods/ironchest/sprites/diamondcontainer.png",IronChestType.DIAMOND), DIAMOND(238,256,"/cpw/mods/ironchest/sprites/diamondcontainer.png",IronChestType.DIAMOND),
COPPER(184,184,"/cpw/mods/ironchest/sprites/coppercontainer.png",IronChestType.COPPER), COPPER(184,184,"/cpw/mods/ironchest/sprites/coppercontainer.png",IronChestType.COPPER),
SILVER(184,238,"/cpw/mods/ironchest/sprites/silvercontainer.png",IronChestType.SILVER), SILVER(184,238,"/cpw/mods/ironchest/sprites/silvercontainer.png",IronChestType.SILVER),
CRYSTAL(184,238,"/cpw/mods/ironchest/sprites/silvercontainer.png",IronChestType.CRYSTAL); CRYSTAL(238,256,"/cpw/mods/ironchest/sprites/diamondcontainer.png",IronChestType.CRYSTAL);
private int xSize; private int xSize;
private int ySize; private int ySize;

View File

@ -16,7 +16,6 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.ModelChest; import net.minecraft.src.ModelChest;
import net.minecraft.src.RenderBlocks; import net.minecraft.src.RenderBlocks;
import net.minecraft.src.RenderManager;
import net.minecraft.src.Tessellator; import net.minecraft.src.Tessellator;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer; import net.minecraft.src.TileEntitySpecialRenderer;
@ -30,7 +29,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
private RenderBlocks renderBlocks; private RenderBlocks renderBlocks;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F },
{ 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.35F, 0.5F }, }; { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
public TileEntityIronChestRenderer() { public TileEntityIronChestRenderer() {
model = new ModelChest(); model = new ModelChest();
@ -78,10 +77,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
if (tile.getType().isTransparent()) { if (tile.getType().isTransparent()) {
random.setSeed(254L); random.setSeed(254L);
glPushMatrix();
glDisable(2896 /* GL_LIGHTING */);
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
glTranslatef((float) x, (float) y, (float) z);
float shiftX; float shiftX;
float shiftY; float shiftY;
float shiftZ; float shiftZ;
@ -92,8 +87,12 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
if (tile.getTopItemStacks()[1] == null) { if (tile.getTopItemStacks()[1] == null) {
shift = 8; shift = 8;
blockScale = 0.2F; blockScale = 0.2F;
spread = 0.25F; spread = 0.22F;
} }
glPushMatrix();
glDisable(2896 /* GL_LIGHTING */);
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
glTranslatef((float) x, (float) y, (float) z);
for (ItemStack item : tile.getTopItemStacks()) { for (ItemStack item : tile.getTopItemStacks()) {
if (shift > shifts.length) { if (shift > shifts.length) {
break; break;
@ -109,8 +108,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
ICustomItemRenderer customRenderer = MinecraftForgeClient.getCustomItemRenderer(item.itemID); ICustomItemRenderer customRenderer = MinecraftForgeClient.getCustomItemRenderer(item.itemID);
float localScale = blockScale; float localScale = blockScale;
if (item.itemID < Block.blocksList.length) { if (item.itemID < Block.blocksList.length) {
bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]);
int j = Block.blocksList[item.itemID].getRenderType(); int j = Block.blocksList[item.itemID].getRenderType();
if (j == 1 || j == 19 || j == 12 || j == 2) { if (j == 1 || j == 19 || j == 12 || j == 2) {
localScale = 2 * blockScale; localScale = 2 * blockScale;
@ -124,20 +121,27 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
glRotatef(timeD, 0.0F, 1.0F, 0.0F); glRotatef(timeD, 0.0F, 1.0F, 0.0F);
if (miniBlocks > 0) { if (miniBlocks > 0) {
float minishiftX = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale; float minishiftX = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale;
float minishiftY = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale; float minishiftY = ((random.nextFloat() * 2.0F - 1.0F) * spread * 0.9F) / localScale;
float minishiftZ = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale; float minishiftZ = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale;
glTranslatef(minishiftX, minishiftY, minishiftZ); glTranslatef(minishiftX, minishiftY, minishiftZ);
} }
if (customRenderer != null) { if (customRenderer != null) {
bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(item.getItem());
ForgeHooksClient.renderCustomItem(customRenderer, renderBlocks, item.itemID, item.getItemDamage(), 1.0F); ForgeHooksClient.renderCustomItem(customRenderer, renderBlocks, item.itemID, item.getItemDamage(), 1.0F);
} else if (item.itemID < Block.blocksList.length && RenderBlocks.renderItemIn3d(Block.blocksList[item.itemID].getRenderType())) { } else if (item.itemID < Block.blocksList.length && RenderBlocks.renderItemIn3d(Block.blocksList[item.itemID].getRenderType())) {
bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]);
renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0F); renderBlocks.renderBlockAsItem(Block.blocksList[item.itemID], item.getItemDamage(), 1.0F);
} else { } else {
int i = item.getIconIndex(); int i = item.getIconIndex();
if (item.itemID >= Block.blocksList.length) { if (item.itemID >= Block.blocksList.length) {
bindTextureByName("/gui/items.png"); bindTextureByName("/gui/items.png");
ForgeHooksClient.overrideTexture(Item.itemsList[item.itemID]); ForgeHooksClient.overrideTexture(Item.itemsList[item.itemID]);
} else {
bindTextureByName("/terrain.png");
ForgeHooksClient.overrideTexture(Block.blocksList[item.itemID]);
} }
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
float f5 = (float) ((i % 16) * 16 + 0) / 256F; float f5 = (float) ((i % 16) * 16 + 0) / 256F;

View File

@ -5,6 +5,7 @@ import static cpw.mods.ironchest.IronChestType.DIAMOND;
import static cpw.mods.ironchest.IronChestType.GOLD; import static cpw.mods.ironchest.IronChestType.GOLD;
import static cpw.mods.ironchest.IronChestType.IRON; import static cpw.mods.ironchest.IronChestType.IRON;
import static cpw.mods.ironchest.IronChestType.SILVER; import static cpw.mods.ironchest.IronChestType.SILVER;
import static cpw.mods.ironchest.IronChestType.CRYSTAL;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
@ -15,7 +16,8 @@ public enum ChestChangerType {
GOLDDIAMOND(GOLD,DIAMOND,"goldDiamondUpgrade","Gold to Diamond Chest Upgrade","GGG","msm","GGG"), GOLDDIAMOND(GOLD,DIAMOND,"goldDiamondUpgrade","Gold to Diamond Chest Upgrade","GGG","msm","GGG"),
COPPERSILVER(COPPER,SILVER,"copperSilverUpgrade","Copper to Silver Chest Upgrade","mmm","msm","mmm"), COPPERSILVER(COPPER,SILVER,"copperSilverUpgrade","Copper to Silver Chest Upgrade","mmm","msm","mmm"),
SILVERGOLD(SILVER,GOLD,"silverGoldUpgrade","Silver to Gold Chest Upgrade","mGm","GsG","mGm"), SILVERGOLD(SILVER,GOLD,"silverGoldUpgrade","Silver to Gold Chest Upgrade","mGm","GsG","mGm"),
COPPERIRON(COPPER,IRON,"copperIronUpgrade","Copper to Iron Chest Upgrade","mGm","GsG","mGm"); COPPERIRON(COPPER,IRON,"copperIronUpgrade","Copper to Iron Chest Upgrade","mGm","GsG","mGm"),
DIAMONDCRYSTAL(DIAMOND,CRYSTAL,"diamondCrystalUpgrade", "Diamond to Crystal Chest Upgrade","GGG","GOG","GGG");
private IronChestType source; private IronChestType source;
private IronChestType target; private IronChestType target;
@ -47,7 +49,7 @@ public enum ChestChangerType {
} }
public void addRecipe() { public void addRecipe() {
IronChestType.addRecipe(new ItemStack(item), recipe, 'm', target.mat,'s',source.mat,'G',Block.glass); IronChestType.addRecipe(new ItemStack(item), recipe, 'm', target.mat,'s',source.mat,'G',Block.glass,'O',Block.obsidian);
} }
public static void buildItems(Configuration cfg, int defaultId) { public static void buildItems(Configuration cfg, int defaultId) {
@ -59,7 +61,7 @@ public enum ChestChangerType {
public static void generateRecipe(IronChestType type) { public static void generateRecipe(IronChestType type) {
for (ChestChangerType item: values()) { for (ChestChangerType item: values()) {
if (item.source==type || item.target==type) { if (item.source==type || item.target==type) {
for (Object[] recipe : MinecraftForge.generateRecipes(item.recipe[0],item.recipe[1],item.recipe[2],'s',item.source.getMatList(),'m',item.target.getMatList(),'G',Block.glass)) { for (Object[] recipe : MinecraftForge.generateRecipes(item.recipe[0],item.recipe[1],item.recipe[2],'s',item.source.getMatList(),'m',item.target.getMatList(),'G',Block.glass,'O',Block.obsidian)) {
if (recipe[4]==null || recipe[6]==null) { if (recipe[4]==null || recipe[6]==null) {
continue; continue;
} }

View File

@ -16,7 +16,7 @@ public enum IronChestType {
DIAMOND(108, 12, true, "Diamond Chest", "guiDiamondChest", "diamondchest.png", 2, Item.diamond, TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"), DIAMOND(108, 12, true, "Diamond Chest", "guiDiamondChest", "diamondchest.png", 2, Item.diamond, TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"),
COPPER(45, 9, false, "Copper Chest", "guiCopperChest", "copperchest.png", 3, null, TileEntityCopperChest.class, "mmmmCmmmm"), COPPER(45, 9, false, "Copper Chest", "guiCopperChest", "copperchest.png", 3, null, TileEntityCopperChest.class, "mmmmCmmmm"),
SILVER(72, 9, false, "Silver Chest", "guiSilverChest", "silverchest.png", 4, null, TileEntitySilverChest.class, "mmmm0mmmm", "mmmm3mmmm"), SILVER(72, 9, false, "Silver Chest", "guiSilverChest", "silverchest.png", 4, null, TileEntitySilverChest.class, "mmmm0mmmm", "mmmm3mmmm"),
CRYSTAL(72, 9, true, "Crystal Chest", "guiSilverChest", "crystalchest.png", 5, null, TileEntityCrystalChest.class, "GGGGCGGGG"); CRYSTAL(108, 12, true, "Crystal Chest", "guiDiamondChest", "crystalchest.png", 5, null, TileEntityCrystalChest.class, "GGGGPGGGG");
int size; int size;
private int rowLength; private int rowLength;
public String friendlyName; public String friendlyName;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB