added mineable block configuration, for #6

This commit is contained in:
Space Toad 2011-07-29 17:55:34 +00:00
parent 5af89543d3
commit 14b6dbe4f5
3 changed files with 139 additions and 21 deletions

View file

@ -8,13 +8,17 @@ package net.minecraft.src.forge;
import java.util.LinkedList; import java.util.LinkedList;
import net.minecraft.src.BiomeGenBase; import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.ItemTool;
import net.minecraft.src.World; import net.minecraft.src.World;
public class MinecraftForge { public class MinecraftForge {
private static LinkedList<IBucketHandler> bucketHandlers = new LinkedList<IBucketHandler>(); private static LinkedList<IBucketHandler> bucketHandlers = new LinkedList<IBucketHandler>();
private static LinkedList<IBiomePopulator> biomePopulators = new LinkedList<IBiomePopulator>(); private static LinkedList<IBiomePopulator> biomePopulators = new LinkedList<IBiomePopulator>();
private static LinkedList<IHarvestHandler> harvestHandlers = new LinkedList<IHarvestHandler>();
public static void registerCustomBucketHander(IBucketHandler handler) { public static void registerCustomBucketHander(IBucketHandler handler) {
bucketHandlers.add(handler); bucketHandlers.add(handler);
@ -23,6 +27,10 @@ public class MinecraftForge {
public static void registerBiomePopulate(IBiomePopulator populator) { public static void registerBiomePopulate(IBiomePopulator populator) {
biomePopulators.add(populator); biomePopulators.add(populator);
} }
public static void registerHarvestHandler(IHarvestHandler handler) {
harvestHandlers.add(handler);
}
public static ItemStack fillCustomBucket(World w, int i, int j, int k) { public static ItemStack fillCustomBucket(World w, int i, int j, int k) {
for (IBucketHandler handler : bucketHandlers) { for (IBucketHandler handler : bucketHandlers) {
@ -43,4 +51,21 @@ public class MinecraftForge {
} }
} }
public static boolean canHarvestBlock(ItemTool item, Block block) {
for (IHarvestHandler handler : harvestHandlers) {
if (handler.canHarvestBlock(item, block)) {
return true;
}
}
return false;
}
public void addPixaxeBlockEffectiveAgainst (Block block) {
((ItemTool) Item.pickaxeWood).addBlockEffectiveAgainst(block);
((ItemTool) Item.pickaxeStone).addBlockEffectiveAgainst(block);
((ItemTool) Item.pickaxeSteel).addBlockEffectiveAgainst(block);
((ItemTool) Item.pickaxeGold).addBlockEffectiveAgainst(block);
((ItemTool) Item.pickaxeDiamond).addBlockEffectiveAgainst(block);
}
} }

View file

@ -1,6 +1,6 @@
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/client/Minecraft.java ../src_work/minecraft/net/minecraft/client/Minecraft.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/client/Minecraft.java ../src_work/minecraft/net/minecraft/client/Minecraft.java
--- ../src_base/minecraft/net/minecraft/client/Minecraft.java 2011-07-19 20:32:54.429858500 +0200 --- ../src_base/minecraft/net/minecraft/client/Minecraft.java 2011-07-19 22:35:38.532061000 +0200
+++ ../src_work/minecraft/net/minecraft/client/Minecraft.java 2011-07-19 20:33:40.515494400 +0200 +++ ../src_work/minecraft/net/minecraft/client/Minecraft.java 2011-07-19 22:36:21.976545900 +0200
@@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
@ -19,8 +19,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/client/Minecr
{ {
downloadResourcesThread = new ThreadDownloadResources(mcDataDir, this); downloadResourcesThread = new ThreadDownloadResources(mcDataDir, this);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ChunkProviderGenerate.java ../src_work/minecraft/net/minecraft/src/ChunkProviderGenerate.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ChunkProviderGenerate.java ../src_work/minecraft/net/minecraft/src/ChunkProviderGenerate.java
--- ../src_base/minecraft/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 20:32:54.820880000 +0200 --- ../src_base/minecraft/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 22:35:38.968086000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 20:33:40.519494600 +0200 +++ ../src_work/minecraft/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 22:36:21.998547200 +0200
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
import java.util.Random; import java.util.Random;
@ -40,8 +40,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ChunkProv
generatedTemperatures = worldObj.getWorldChunkManager().getTemperatures(generatedTemperatures, k + 8, l + 8, 16, 16); generatedTemperatures = worldObj.getWorldChunkManager().getTemperatures(generatedTemperatures, k + 8, l + 8, 16, 16);
for(int j19 = k + 8; j19 < k + 8 + 16; j19++) for(int j19 = k + 8; j19 < k + 8 + 16; j19++)
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EffectRenderer.java ../src_work/minecraft/net/minecraft/src/EffectRenderer.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EffectRenderer.java ../src_work/minecraft/net/minecraft/src/EffectRenderer.java
--- ../src_base/minecraft/net/minecraft/src/EffectRenderer.java 2011-07-19 20:32:54.895885100 +0200 --- ../src_base/minecraft/net/minecraft/src/EffectRenderer.java 2011-07-19 22:35:39.064091500 +0200
+++ ../src_work/minecraft/net/minecraft/src/EffectRenderer.java 2011-07-19 20:40:47.501916600 +0200 +++ ../src_work/minecraft/net/minecraft/src/EffectRenderer.java 2011-07-19 22:36:22.004547500 +0200
@@ -7,6 +7,9 @@ @@ -7,6 +7,9 @@
import java.util.*; import java.util.*;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -185,8 +185,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EffectRen
private Random rand; private Random rand;
} }
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemBucket.java ../src_work/minecraft/net/minecraft/src/ItemBucket.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemBucket.java ../src_work/minecraft/net/minecraft/src/ItemBucket.java
--- ../src_base/minecraft/net/minecraft/src/ItemBucket.java 2011-07-19 20:32:55.620926000 +0200 --- ../src_base/minecraft/net/minecraft/src/ItemBucket.java 2011-07-19 22:35:39.911139000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemBucket.java 2011-07-19 20:33:40.524494900 +0200 +++ ../src_work/minecraft/net/minecraft/src/ItemBucket.java 2011-07-19 22:36:22.008547700 +0200
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
import java.util.Random; import java.util.Random;
@ -210,9 +210,31 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemBucke
if(world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0) if(world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
{ {
world.setBlockWithNotify(i, j, k, 0); world.setBlockWithNotify(i, j, k, 0);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemPickaxe.java ../src_work/minecraft/net/minecraft/src/ItemPickaxe.java
--- ../src_base/minecraft/net/minecraft/src/ItemPickaxe.java 2011-07-19 22:35:39.959142000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemPickaxe.java 2011-07-29 19:44:18.990445200 +0200
@@ -4,6 +4,8 @@
package net.minecraft.src;
+import net.minecraft.src.forge.MinecraftForge;
+
// Referenced classes of package net.minecraft.src:
// ItemTool, Block, EnumToolMaterial, Material
@@ -42,6 +44,9 @@
{
return toolMaterial.getHarvestLevel() >= 2;
}
+ if (MinecraftForge.canHarvestBlock(this, block)) {
+ return true;
+ }
if(block.blockMaterial == Material.rock)
{
return true;
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemRenderer.java ../src_work/minecraft/net/minecraft/src/ItemRenderer.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemRenderer.java ../src_work/minecraft/net/minecraft/src/ItemRenderer.java
--- ../src_base/minecraft/net/minecraft/src/ItemRenderer.java 2011-07-19 20:32:55.684930300 +0200 --- ../src_base/minecraft/net/minecraft/src/ItemRenderer.java 2011-07-19 22:35:39.984144100 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemRenderer.java 2011-07-19 20:33:40.528495200 +0200 +++ ../src_work/minecraft/net/minecraft/src/ItemRenderer.java 2011-07-19 22:36:22.013548000 +0200
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
package net.minecraft.src; package net.minecraft.src;
@ -241,9 +263,34 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemRende
} }
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.instance;
int i = entityliving.getItemIcon(itemstack); int i = entityliving.getItemIcon(itemstack);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/ItemTool.java ../src_work/minecraft/net/minecraft/src/ItemTool.java
--- ../src_base/minecraft/net/minecraft/src/ItemTool.java 2011-07-19 22:35:40.017146000 +0200
+++ ../src_work/minecraft/net/minecraft/src/ItemTool.java 2011-07-29 19:48:15.271959800 +0200
@@ -4,6 +4,9 @@
package net.minecraft.src;
+import java.util.Arrays;
+import java.util.concurrent.ArrayBlockingQueue;
+
// Referenced classes of package net.minecraft.src:
// Item, EnumToolMaterial, ItemStack, Block,
@@ -63,4 +66,11 @@
private float efficiencyOnProperMaterial;
private int damageVsEntity;
protected EnumToolMaterial toolMaterial;
+
+ public void addBlockEffectiveAgainst (Block block) {
+ blocksEffectiveAgainst = Arrays.copyOf(blocksEffectiveAgainst,
+ blocksEffectiveAgainst.length + 1);
+
+ blocksEffectiveAgainst [blocksEffectiveAgainst.length + 1] = block;
+ }
}
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderBlocks.java ../src_work/minecraft/net/minecraft/src/RenderBlocks.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderBlocks.java ../src_work/minecraft/net/minecraft/src/RenderBlocks.java
--- ../src_base/minecraft/net/minecraft/src/RenderBlocks.java 2011-07-19 20:32:57.062009000 +0200 --- ../src_base/minecraft/net/minecraft/src/RenderBlocks.java 2011-07-19 22:35:40.986201400 +0200
+++ ../src_work/minecraft/net/minecraft/src/RenderBlocks.java 2011-07-19 20:33:40.533495400 +0200 +++ ../src_work/minecraft/net/minecraft/src/RenderBlocks.java 2011-07-19 22:36:22.019548400 +0200
@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
package net.minecraft.src; package net.minecraft.src;
@ -254,8 +301,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderBlo
// Referenced classes of package net.minecraft.src: // Referenced classes of package net.minecraft.src:
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderItem.java ../src_work/minecraft/net/minecraft/src/RenderItem.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderItem.java ../src_work/minecraft/net/minecraft/src/RenderItem.java
--- ../src_base/minecraft/net/minecraft/src/RenderItem.java 2011-07-19 20:32:57.183015900 +0200 --- ../src_base/minecraft/net/minecraft/src/RenderItem.java 2011-07-19 22:35:41.100207900 +0200
+++ ../src_work/minecraft/net/minecraft/src/RenderItem.java 2011-07-19 20:33:40.568497500 +0200 +++ ../src_work/minecraft/net/minecraft/src/RenderItem.java 2011-07-19 22:36:22.037549400 +0200
@@ -5,6 +5,9 @@ @@ -5,6 +5,9 @@
package net.minecraft.src; package net.minecraft.src;
@ -317,8 +364,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/RenderIte
int k1 = Item.itemsList[i].getColorFromDamage(j); int k1 = Item.itemsList[i].getColorFromDamage(j);
float f = (float)(k1 >> 16 & 0xff) / 255F; float f = (float)(k1 >> 16 & 0xff) / 255F;
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/WorldRenderer.java ../src_work/minecraft/net/minecraft/src/WorldRenderer.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/WorldRenderer.java ../src_work/minecraft/net/minecraft/src/WorldRenderer.java
--- ../src_base/minecraft/net/minecraft/src/WorldRenderer.java 2011-07-19 20:32:57.777049900 +0200 --- ../src_base/minecraft/net/minecraft/src/WorldRenderer.java 2011-07-19 22:35:41.644239000 +0200
+++ ../src_work/minecraft/net/minecraft/src/WorldRenderer.java 2011-07-19 20:33:40.579498100 +0200 +++ ../src_work/minecraft/net/minecraft/src/WorldRenderer.java 2011-07-19 22:36:22.041549600 +0200
@@ -5,6 +5,9 @@ @@ -5,6 +5,9 @@
package net.minecraft.src; package net.minecraft.src;
@ -342,8 +389,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/WorldRend
} }
diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java ../src_work/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java ../src_work/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java
--- ../src_base/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 20:33:10.318767000 +0200 --- ../src_base/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 22:35:53.094893000 +0200
+++ ../src_work/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 20:33:40.583498300 +0200 +++ ../src_work/minecraft_server/net/minecraft/src/ChunkProviderGenerate.java 2011-07-19 22:36:22.046549900 +0200
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
import java.util.Random; import java.util.Random;
@ -363,8 +410,8 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/Ch
generatedTemperatures = worldObj.getWorldChunkManager().getTemperatures(generatedTemperatures, k + 8, l + 8, 16, 16); generatedTemperatures = worldObj.getWorldChunkManager().getTemperatures(generatedTemperatures, k + 8, l + 8, 16, 16);
for(int j19 = k + 8; j19 < k + 8 + 16; j19++) for(int j19 = k + 8; j19 < k + 8 + 16; j19++)
diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemBucket.java ../src_work/minecraft_server/net/minecraft/src/ItemBucket.java diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemBucket.java ../src_work/minecraft_server/net/minecraft/src/ItemBucket.java
--- ../src_base/minecraft_server/net/minecraft/src/ItemBucket.java 2011-07-19 20:33:10.742791000 +0200 --- ../src_base/minecraft_server/net/minecraft/src/ItemBucket.java 2011-07-19 22:35:53.568921000 +0200
+++ ../src_work/minecraft_server/net/minecraft/src/ItemBucket.java 2011-07-19 20:33:40.617500300 +0200 +++ ../src_work/minecraft_server/net/minecraft/src/ItemBucket.java 2011-07-19 22:36:22.050550100 +0200
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
import java.util.Random; import java.util.Random;
@ -388,3 +435,49 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/It
if(world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0) if(world.getBlockMaterial(i, j, k) == Material.water && world.getBlockMetadata(i, j, k) == 0)
{ {
world.setBlockWithNotify(i, j, k, 0); world.setBlockWithNotify(i, j, k, 0);
diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemPickaxe.java ../src_work/minecraft_server/net/minecraft/src/ItemPickaxe.java
--- ../src_base/minecraft_server/net/minecraft/src/ItemPickaxe.java 2011-07-19 22:35:53.647925000 +0200
+++ ../src_work/minecraft_server/net/minecraft/src/ItemPickaxe.java 2011-07-29 19:52:41.066162300 +0200
@@ -4,6 +4,8 @@
package net.minecraft.src;
+import net.minecraft.src.forge.MinecraftForge;
+
// Referenced classes of package net.minecraft.src:
// ItemTool, Block, EnumToolMaterial, Material
@@ -42,6 +44,9 @@
{
return toolMaterial.getHarvestLevel() >= 2;
}
+ if (MinecraftForge.canHarvestBlock(this, block)) {
+ return true;
+ }
if(block.blockMaterial == Material.rock)
{
return true;
diff -u -r --strip-trailing-cr ../src_base/minecraft_server/net/minecraft/src/ItemTool.java ../src_work/minecraft_server/net/minecraft/src/ItemTool.java
--- ../src_base/minecraft_server/net/minecraft/src/ItemTool.java 2011-07-19 22:35:53.708929000 +0200
+++ ../src_work/minecraft_server/net/minecraft/src/ItemTool.java 2011-07-29 19:51:37.558529900 +0200
@@ -4,6 +4,8 @@
package net.minecraft.src;
+import java.util.Arrays;
+
// Referenced classes of package net.minecraft.src:
// Item, EnumToolMaterial, ItemStack, Block,
@@ -58,4 +60,11 @@
private float efficiencyOnProperMaterial;
private int damageVsEntity;
protected EnumToolMaterial toolMaterial;
+
+ public void addBlockEffectiveAgainst (Block block) {
+ blocksEffectiveAgainst = Arrays.copyOf(blocksEffectiveAgainst,
+ blocksEffectiveAgainst.length + 1);
+
+ blocksEffectiveAgainst [blocksEffectiveAgainst.length + 1] = block;
+ }
}

View file

@ -8,6 +8,6 @@ set PATH=E:\cygwin\bin;%PATH%
cd forge cd forge
sh package.sh 1.0 sh package.sh 1.0.0.200110729
pause pause