From 7ce7dbb374a16fc2d8e010e71b2c57c5260f76e1 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 6 Jun 2012 10:08:35 -0700 Subject: [PATCH] Server side of ITextureProvider for Block/Item for compilations sake. --- .../net/minecraft/src/Block.java.patch | 52 +++++++++++++++---- .../net/minecraft/src/Item.java.patch | 44 +++++++++++++--- 2 files changed, 80 insertions(+), 16 deletions(-) diff --git a/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch b/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch index 6180b72aa0..07badad70a 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch @@ -1,15 +1,26 @@ --- ../src_base/minecraft_server/net/minecraft/src/Block.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/src/Block.java 0000-00-00 00:00:00.000000000 -0000 -@@ -3,6 +3,8 @@ +@@ -3,7 +3,10 @@ import java.util.ArrayList; import java.util.Random; +-public class Block +import net.minecraft.src.forge.ForgeHooks; ++import net.minecraft.src.forge.ITextureProvider; + - public class Block ++public class Block implements ITextureProvider { public static final StepSound soundPowderFootstep = new StepSound("stone", 1.0F, 1.0F); -@@ -397,7 +399,7 @@ + public static final StepSound soundWoodFootstep = new StepSound("wood", 1.0F, 1.0F); +@@ -257,6 +260,7 @@ + lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0; + canBlockGrass[par1] = !par2Material.getCanBlockGrass(); + } ++ isDefaultTexture = getTextureFile().equalsIgnoreCase("/terrain.png"); + } + + /** +@@ -397,7 +401,7 @@ public boolean hasTileEntity() { @@ -18,7 +29,7 @@ } /** -@@ -536,12 +538,16 @@ +@@ -536,12 +540,16 @@ return this.blockID; } @@ -37,7 +48,7 @@ } /** -@@ -560,17 +566,13 @@ +@@ -560,17 +568,13 @@ if (!par1World.isRemote) { int var8 = this.quantityDroppedWithBonus(par7, par1World.rand); @@ -59,7 +70,7 @@ } } } -@@ -853,7 +855,7 @@ +@@ -853,7 +857,7 @@ par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); par2EntityPlayer.addExhaustion(0.025F); @@ -68,11 +79,15 @@ { ItemStack var8 = this.createStackedBlock(par6); -@@ -974,6 +976,592 @@ +@@ -974,6 +978,613 @@ */ public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6) {} + /* =================================================== FORGE START =====================================*/ ++ protected static int blockFireSpreadSpeed[] = new int[blocksList.length]; ++ protected static int blockFlammability[] = new int[blocksList.length]; ++ protected String currentTexture = "/terrain.png"; ++ public boolean isDefaultTexture = true; + /** + * Get a light value for this block, normal ranges are between 0 and 15 + * @@ -277,9 +292,6 @@ + { + } + -+ protected static int blockFireSpreadSpeed[] = new int[256]; -+ protected static int blockFlammability[] = new int[256]; -+ + /** + * Chance that fire will spread and consume this block. + * 300 being a 100% chance, 0, being a 0% chance. @@ -656,7 +668,27 @@ + { + return blockID == stone.blockID; + } ++ ++ /** ++ * Grabs the current texture file used for this block ++ */ ++ @Override ++ public String getTextureFile() ++ { ++ return currentTexture; ++ } + ++ /** ++ * Sets the current texture file for this block, used when rendering. ++ * Default is "/terrain.png" ++ * ++ * @param texture The texture file ++ */ ++ public void setTextureFile(String texture) ++ { ++ currentTexture = texture; ++ isDefaultTexture = false; ++ } + static { diff --git a/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch b/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch index 869edccb17..73af47ba79 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/Item.java.patch @@ -1,13 +1,19 @@ --- ../src_base/minecraft_server/net/minecraft/src/Item.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/src/Item.java 0000-00-00 00:00:00.000000000 -0000 -@@ -1,5 +1,6 @@ +@@ -1,8 +1,11 @@ package net.minecraft.src; +import java.util.ArrayList; import java.util.Random; - public class Item -@@ -191,6 +192,9 @@ +-public class Item ++import net.minecraft.src.forge.ITextureProvider; ++ ++public class Item implements ITextureProvider + { + /** The RNG used by the Item subclasses. */ + protected static Random itemRand = new Random(); +@@ -191,6 +194,9 @@ /** full name of item from language file */ private String itemName; @@ -17,7 +23,7 @@ protected Item(int par1) { -@@ -492,6 +496,10 @@ +@@ -492,6 +498,10 @@ float var18 = var15 * var16; float var20 = var14 * var16; double var21 = 5.0D; @@ -28,13 +34,14 @@ Vec3D var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21); MovingObjectPosition var24 = par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3); return var24; -@@ -509,4 +517,164 @@ +@@ -509,4 +519,190 @@ { StatList.initStats(); } + + /* =========================================================== FORGE START ===============================================================*/ -+ ++ public boolean isDefaultTexture = true; ++ private String currentTexture = "/gui/items.png"; + /** + * Called when a new CreativeContainer is opened, populate the list + * with all of the items for this item you want a player in creative mode @@ -191,5 +198,30 @@ + public int getRenderPasses(int metadata) + { + return 1; //return func_46058_c() ? 2 : 1; ++ } ++ ++ /** ++ * Grabs the current texture file used for this block ++ */ ++ @Override ++ public String getTextureFile() ++ { ++ if (this instanceof ItemBlock) ++ { ++ return Block.blocksList[((ItemBlock)this).getBlockID()].getTextureFile(); ++ } ++ return currentTexture; ++ } ++ ++ /** ++ * Sets the current texture file for this item, used when rendering. ++ * Default is "/gui/items.png" ++ * ++ * @param texture The texture file ++ */ ++ public void setTextureFile(String texture) ++ { ++ currentTexture = texture; ++ isDefaultTexture = false; + } }