More progress on converting patches from 1.2.5

This commit is contained in:
LexManos 2012-08-06 03:35:57 -07:00
parent 545b905f11
commit d286154997
47 changed files with 3170 additions and 197 deletions

View File

@ -0,0 +1,180 @@
package net.minecraftforge.client;
import java.util.HashMap;
import java.util.TreeSet;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.Block;
import net.minecraft.src.ModLoader;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.Tessellator;
public class ForgeHooksClient
{
private static class TesKey implements Comparable<TesKey>
{
public final int texture, subid;
public TesKey(int textureID, int subID)
{
texture = textureID;
subid = subID;
}
public int compareTo(TesKey key)
{
if (subid == key.subid)
{
return texture - key.texture;
}
return subid - key.subid;
}
public boolean equals(Object obj)
{
return compareTo((TesKey)obj) == 0;
}
public int hashCode()
{
return texture + 31 * subid;
}
}
public static HashMap<TesKey, Tessellator> tessellators = new HashMap<TesKey, Tessellator>();
public static HashMap<String, Integer> textures = new HashMap<String, Integer>();
public static TreeSet<TesKey> renderTextures = new TreeSet<TesKey>();
public static Tessellator defaultTessellator = null;
public static boolean inWorld = false;
public static void bindTexture(String texture, int subID)
{
Integer texID = textures.get(texture);
if (texID == null)
{
texID = ModLoader.getMinecraftInstance().renderEngine.getTexture(texture);
textures.put(texture, texID);
}
if (!inWorld)
{
/*if (unbindContext != null)
{
unbindContext.afterRenderContext();
unbindContext = null;
}*/
if (Tessellator.instance.isDrawing)
{
int mode = Tessellator.instance.drawMode;
Tessellator.instance.draw();
Tessellator.instance.startDrawing(mode);
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
/*unbindContext = renderHandlers.get(new TesKey(texID, subID));
if (unbindContext != null)
{
unbindContext.beforeRenderContext();
}*/
return;
}
bindTessellator(texID, subID);
}
public static void unbindTexture()
{
if (inWorld)
{
Tessellator.instance = defaultTessellator;
}
else
{
if (Tessellator.instance.isDrawing)
{
int mode = Tessellator.instance.drawMode;
Tessellator.instance.draw();
/*if (unbindContext != null)
{
unbindContext.afterRenderContext();
unbindContext = null;
}*/
Tessellator.instance.startDrawing(mode);
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
return;
}
}
protected static void bindTessellator(int texture, int subID)
{
TesKey key = new TesKey(texture, subID);
Tessellator tess = tessellators.get(key);
if (tess == null)
{
tess = new Tessellator();
tess.textureID = texture;
tessellators.put(key, tess);
}
if (inWorld && !renderTextures.contains(key))
{
renderTextures.add(key);
tess.startDrawingQuads();
tess.setTranslation(defaultTessellator.xOffset, defaultTessellator.yOffset, defaultTessellator.zOffset);
}
Tessellator.instance = tess;
}
static int renderPass = -1;
public static void beforeRenderPass(int pass)
{
renderPass = pass;
defaultTessellator = Tessellator.instance;
Tessellator.renderingWorldRenderer = true;
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
renderTextures.clear();
inWorld = true;
}
public static void afterRenderPass(int pass)
{
renderPass = -1;
inWorld = false;
for (TesKey info : renderTextures)
{
//IRenderContextHandler handler = renderHandlers.get(info);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, info.texture);
Tessellator tess = tessellators.get(info);
//if (handler == null)
//{
tess.draw();
/*}
else
{
Tessellator.instance = tess;
handler.beforeRenderContext();
tess.draw();
handler.afterRenderContext();
}*/
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
Tessellator.renderingWorldRenderer = false;
Tessellator.instance = defaultTessellator;
}
public static void beforeBlockRender(Block block, RenderBlocks render)
{
if (!block.isDefaultTexture && render.overrideBlockTexture == -1)
{
bindTexture(block.getTextureFile(), 0);
}
}
public static void afterBlockRender(Block block, RenderBlocks render)
{
if (!block.isDefaultTexture && render.overrideBlockTexture == -1)
{
unbindTexture();
}
}
}

View File

@ -8,3 +8,14 @@ public avd.w # yOffset
public avd.x # zOffset
public-f avd.a # instance remove final
public avd.z # isDrawing
#ItemPickaxe
public+f rp.c # blocksEffectiveAgainst
#ItemAxe
public+f re.c # blocksEffectiveAgainst
#ItemSpade
public+f sa.c # blocksEffectiveAgainst
#ItemTool
public gs.a # efficiencyOnProperMaterial
public gs.bY # damageVsEntity
#EntityEnderman
public no.d # EntityEnderman.carriableBlocks

View File

@ -50,12 +50,154 @@ public class ForgeHooks
return entry.seed.copy();
}
private static boolean toolInit = false;
static HashMap<Item, List> toolClasses = new HashMap<Item, List>();
static HashMap<List, Integer> toolHarvestLevels = new HashMap<List, Integer>();
static HashSet<List> toolEffectiveness = new HashSet<List>();
public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata)
{
if (block.blockMaterial.isHarvestable())
{
return true;
}
ItemStack stack = player.inventory.getCurrentItem();
if (stack == null)
{
return player.canHarvestBlock(block);
}
List info = (List)toolClasses.get(stack);
if (info == null)
{
return player.canHarvestBlock(block);
}
Object[] tmp = info.toArray();
String toolClass = (String)tmp[0];
int harvestLevel = (Integer)tmp[1];
Integer blockHarvestLevel = (Integer)toolHarvestLevels.get(Arrays.asList(block, metadata, toolClass));
if (blockHarvestLevel == null)
{
return player.canHarvestBlock(block);
}
if (blockHarvestLevel > harvestLevel)
{
return false;
}
return true;
}
public static float blockStrength(Block block, EntityPlayer player, World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
float hardness = block.getBlockHardness(world, x, y, z);
if (hardness < 0.0F)
{
return 0.0F;
}
if (!canHarvestBlock(block, player, metadata))
{
return 1.0F / hardness / 100F;
}
else
{
return player.getCurrentPlayerStrVsBlock(block, metadata) / hardness / 30F;
}
}
public static boolean isToolEffective(ItemStack stack, Block block, int metadata)
{
List toolClass = (List)toolClasses.get(stack.getItem());
if (toolClass == null)
{
return false;
}
return toolEffectiveness.contains(Arrays.asList(block, metadata, (String)toolClass.get(0)));
}
static void initTools()
{
if (toolInit)
{
return;
}
toolInit = true;
MinecraftForge.setToolClass(Item.pickaxeWood, "pickaxe", 0);
MinecraftForge.setToolClass(Item.pickaxeStone, "pickaxe", 1);
MinecraftForge.setToolClass(Item.pickaxeSteel, "pickaxe", 2);
MinecraftForge.setToolClass(Item.pickaxeGold, "pickaxe", 0);
MinecraftForge.setToolClass(Item.pickaxeDiamond, "pickaxe", 3);
MinecraftForge.setToolClass(Item.axeWood, "axe", 0);
MinecraftForge.setToolClass(Item.axeStone, "axe", 1);
MinecraftForge.setToolClass(Item.axeSteel, "axe", 2);
MinecraftForge.setToolClass(Item.axeGold, "axe", 0);
MinecraftForge.setToolClass(Item.axeDiamond, "axe", 3);
MinecraftForge.setToolClass(Item.shovelWood, "shovel", 0);
MinecraftForge.setToolClass(Item.shovelStone, "shovel", 1);
MinecraftForge.setToolClass(Item.shovelSteel, "shovel", 2);
MinecraftForge.setToolClass(Item.shovelGold, "shovel", 0);
MinecraftForge.setToolClass(Item.shovelDiamond, "shovel", 3);
MinecraftForge.setBlockHarvestLevel(Block.obsidian, "pickaxe", 3);
MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 1);
MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 2);
MinecraftForge.setBlockHarvestLevel(Block.oreRedstoneGlowing, "pickaxe", 2);
MinecraftForge.removeBlockEffectiveness(Block.oreRedstone, "pickaxe");
MinecraftForge.removeBlockEffectiveness(Block.obsidian, "pickaxe");
MinecraftForge.removeBlockEffectiveness(Block.oreRedstoneGlowing, "pickaxe");
for (Block block : ItemPickaxe.blocksEffectiveAgainst)
{
MinecraftForge.setBlockHarvestLevel(block, "pickaxe", 0);
}
for (Block block : ItemSpade.blocksEffectiveAgainst)
{
MinecraftForge.setBlockHarvestLevel(block, "shovel", 0);
}
for (Block block : ItemAxe.blocksEffectiveAgainst)
{
MinecraftForge.setBlockHarvestLevel(block, "axe", 0);
}
}
static
{
grassList.add(new GrassEntry(Block.plantYellow, 0, 20));
grassList.add(new GrassEntry(Block.plantRed, 0, 10));
seedList.add(new SeedEntry(new ItemStack(Item.seeds), 10));
initTools();
System.out.printf("MinecraftForge v%s Initialized\n", ForgeVersion.getVersion());
ModLoader.getLogger().info(String.format("MinecraftForge v%s Initialized", ForgeVersion.getVersion()));
}
public static String getTexture(String _default, Object obj)
{
if (obj instanceof Item)
{
return ((Item)obj).getTextureFile();
}
else if (obj instanceof Block)
{
return ((Block)obj).getTextureFile();
}
else
{
return _default;
}
}
}

View File

@ -1,5 +1,7 @@
package net.minecraftforge.common;
import java.util.*;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeHooks.GrassEntry;
import net.minecraftforge.common.ForgeHooks.SeedEntry;
@ -13,6 +15,7 @@ public class MinecraftForge
* This replaces every register*Handler() function in the old version of Forge.
*/
public static final EventBus EVENT_BUS = new EventBus();
public static boolean SPAWNER_ALLOW_ON_INVERTED = false;
/** Register a new plant to be planted when bonemeal is used on grass.
@ -37,4 +40,159 @@ public class MinecraftForge
{
ForgeHooks.seedList.add(new SeedEntry(seed, weight));
}
/**
*
* Register a tool as a tool class with a given harvest level.
*
* @param tool The custom tool to register.
* @param toolClass The tool class to register as. The predefined tool
* clases are "pickaxe", "shovel", "axe". You can add
* others for custom tools.
* @param harvestLevel The harvest level of the tool.
*/
public static void setToolClass(Item tool, String toolClass, int harvestLevel)
{
ForgeHooks.toolClasses.put(tool, Arrays.asList(toolClass, harvestLevel));
}
/**
* Register a block to be harvested by a tool class. This is the metadata
* sensitive version, use it if your blocks are using metadata variants.
* By default, this sets the block class as effective against that type.
*
* @param block The block to register.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to register as able to remove this block.
* You may register the same block multiple times with different tool
* classes, if multiple tool types can be used to harvest this block.
* @param harvestLevel The minimum tool harvest level required to successfully
* harvest the block.
* @see setToolClass for details on tool classes.
*/
public static void setBlockHarvestLevel(Block block, int metadata, String toolClass, int harvestLevel)
{
List key = Arrays.asList(block, metadata, toolClass);
ForgeHooks.toolHarvestLevels.put(key, harvestLevel);
ForgeHooks.toolEffectiveness.add(key);
}
/**
* Remove a block effectiveness mapping. Since setBlockHarvestLevel
* makes the tool class effective against the block by default, this can be
* used to remove that mapping. This will force a block to be harvested at
* the same speed regardless of tool quality, while still requiring a given
* harvesting level.
*
* @param block The block to remove effectiveness from.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to remove the effectiveness mapping from.
* @see setToolClass for details on tool classes.
*/
public static void removeBlockEffectiveness(Block block, int metadata, String toolClass)
{
List key = Arrays.asList(block, metadata, toolClass);
ForgeHooks.toolEffectiveness.remove(key);
}
/**
* Register a block to be harvested by a tool class.
* By default, this sets the block class as effective against that type.
*
* @param block The block to register.
* @param toolClass The tool class to register as able to remove this block.
* You may register the same block multiple times with different tool
* classes, if multiple tool types can be used to harvest this block.
* @param harvestLevel The minimum tool harvest level required to successfully
* harvest the block.
* @see setToolClass for details on tool classes.
*/
public static void setBlockHarvestLevel(Block block, String toolClass, int harvestLevel)
{
for (int metadata = 0; metadata < 16; metadata++)
{
List key = Arrays.asList(block, metadata, toolClass);
ForgeHooks.toolHarvestLevels.put(key, harvestLevel);
ForgeHooks.toolEffectiveness.add(key);
}
}
/**
* Returns the block harvest level for a particular tool class.
*
* @param block The block to check.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to check as able to remove this block.
* @see setToolClass for details on tool classes.
* @return The harvest level or -1 if no mapping exists.
*/
public static int getBlockHarvestLevel(Block block, int metadata, String toolClass)
{
ForgeHooks.initTools();
List key = Arrays.asList(block, metadata, toolClass);
Integer harvestLevel = (Integer)ForgeHooks.toolHarvestLevels.get(key);
if(harvestLevel == null)
{
return -1;
}
return harvestLevel;
}
/**
* Remove a block effectiveness mapping. Since setBlockHarvestLevel
* makes the tool class effective against the block by default, this can be
* used to remove that mapping. This will force a block to be harvested at
* the same speed regardless of tool quality, while still requiring a given
* harvesting level.
*
* @param block The block to remove effectiveness from.
* @param toolClass The tool class to remove the effectiveness mapping from.
* @see setToolClass for details on tool classes.
*/
public static void removeBlockEffectiveness(Block block, String toolClass)
{
for (int metadata = 0; metadata < 16; metadata++)
{
List key = Arrays.asList(block, metadata, toolClass);
ForgeHooks.toolEffectiveness.remove(key);
}
}
/**
* Method invoked by FML before any other mods are loaded.
*/
public static void initialize()
{
//Cause the classes to initialize if they already haven't
Block.stone.getTextureFile();
Item.appleGold.getTextureFile();
Block filler = null;
try
{
filler = Block.class.getConstructor(int.class, Material.class).newInstance(256, Material.air);
}catch (Exception e){}
if (filler == null)
{
throw new RuntimeException("Could not create Forge filler block");
}
for (int x = 256; x < 4096; x++)
{
if (Item.itemsList[x - 256] != null)
{
Block.blocksList[x] = filler;
}
}
boolean[] temp = new boolean[4096];
for (int x = 0; x < EntityEnderman.carriableBlocks.length; x++)
{
temp[x] = EntityEnderman.carriableBlocks[x];
}
EntityEnderman.carriableBlocks = temp;
}
}

View File

@ -0,0 +1,43 @@
package net.minecraftforge.event.entity;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
public class UseHoeEvent extends PlayerEvent
{
public final ItemStack current;
public final World world;
public final int x;
public final int y;
public final int z;
private boolean handeled = false;
public UseHoeEvent(EntityPlayer player, ItemStack current, World world, int x, int y, int z)
{
super(player);
this.current = current;
this.world = world;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public boolean isCancelable()
{
return true;
}
public boolean isHandeled()
{
return handeled;
}
public void setHandeled()
{
handeled = true;
}
}

View File

@ -10,3 +10,10 @@
/org.eclipse.team.cvs.core/
/org.eclipse.ui.workbench/
/org.eclipse.wb.discovery.core/
/org.eclipse.recommenders.rcp/
/org.eclipse.recommenders.completion.rcp.overrides/
/org.eclipse.recommenders.completion.rcp.calls/
/org.eclipse.mylyn.context.core/
/org.eclipse.search/
/org.eclipse.jdt.debug.ui/
/org.eclipse.ui.editors/

View File

@ -40,33 +40,6 @@ import java.util.logging.Level;
public class ForgeHooks
{
public static void plantGrassPlant(World world, int x, int y, int z)
{
int index = world.rand.nextInt(plantGrassWeight);
ProbableItem item = getRandomItem(plantGrassList, index);
if (item == null || Block.blocksList[item.ItemID] == null)
{
return;
}
if (mod_MinecraftForge.DISABLE_DARK_ROOMS && !Block.blocksList[item.ItemID].canBlockStay(world, x, y, z))
{
return;
}
world.setBlockAndMetadataWithNotify(x, y, z, item.ItemID, item.Metadata);
}
public static ItemStack getGrassSeed(World world)
{
int index = world.rand.nextInt(seedGrassWeight);
ProbableItem item = getRandomItem(seedGrassList, index);
if (item == null)
{
return null;
}
return new ItemStack(item.ItemID, item.Quantity, item.Metadata);
}
// Tool Path
// ------------------------------------------------------------
public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata)

View File

@ -1,26 +0,0 @@
/**
* This software is provided under the terms of the Minecraft Forge Public
* License v1.0.
*/
package net.minecraft.src.forge;
import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
/**
* This interface is to be implemented by Block classes. It will override
* standard algorithms controlling connection between two blocks by redstone
*
* @see Block
*/
public interface IConnectRedstone
{
/**
* When this returns false, the block at location i, j, k cannot make
* a redstone connection in the direction given in parameter, otherwise
* it can. Use to control which sides are inputs and outputs for redstone
* wires.
*/
public boolean canConnectRedstone(IBlockAccess world, int X, int Y, int Z, int direction);
}

View File

@ -28,144 +28,6 @@ import java.util.Map.Entry;
public class MinecraftForge
{
// ------------------------------------------------------------
/** Register a new plant to be planted when bonemeal is used on grass.
* @param bid The block ID to plant.
* @param metadata The metadata to plant.
* @param probability The relative probability of the plant, where red flowers are
* 10 and yellow flowers are 20.
*/
public static void addGrassPlant(int blockID, int metadata, int probability)
{
ForgeHooks.addPlantGrass(blockID, metadata, probability);
}
/** Register a new seed to be dropped when breaking tall grass.
* @param bid The item ID of the seeds.
* @param metadata The metadata of the seeds.
* @param quantity The quantity of seeds to drop.
* @param probability The relative probability of the seeds, where wheat seeds are
* 10.
*/
public static void addGrassSeed(int itemID, int metadata, int quantity, int probability)
{
ForgeHooks.addGrassSeed(itemID, metadata, quantity, probability);
}
/** Register a tool as a tool class with a given harvest level.
*
* @param tool The custom tool to register.
* @param toolClass The tool class to register as. The predefined tool
* clases are "pickaxe", "shovel", "axe". You can add others for custom
* tools.
* @param harvestLevel The harvest level of the tool.
*/
public static void setToolClass(Item tool, String toolClass, int harvestLevel)
{
ForgeHooks.initTools();
ForgeHooks.toolClasses.put(tool.shiftedIndex, Arrays.asList(toolClass, harvestLevel));
}
/** Register a block to be harvested by a tool class. This is the metadata
* sensitive version, use it if your blocks are using metadata variants.
* By default, this sets the block class as effective against that type.
*
* @param block The block to register.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to register as able to remove this block.
* You may register the same block multiple times with different tool
* classes, if multiple tool types can be used to harvest this block.
* @param harvestLevel The minimum tool harvest level required to successfully
* harvest the block.
* @see setToolClass for details on tool classes.
*/
public static void setBlockHarvestLevel(Block block, int metadata, String toolClass, int harvestLevel)
{
ForgeHooks.initTools();
List key = Arrays.asList(block.blockID, metadata, toolClass);
ForgeHooks.toolHarvestLevels.put(key, harvestLevel);
ForgeHooks.toolEffectiveness.add(key);
}
/** Remove a block effectiveness mapping. Since setBlockHarvestLevel
* makes the tool class effective against the block by default, this can be
* used to remove that mapping. This will force a block to be harvested at
* the same speed regardless of tool quality, while still requiring a given
* harvesting level.
* @param block The block to remove effectiveness from.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to remove the effectiveness mapping from.
* @see setToolClass for details on tool classes.
*/
public static void removeBlockEffectiveness(Block block, int metadata, String toolClass)
{
ForgeHooks.initTools();
List key = Arrays.asList(block.blockID, metadata, toolClass);
ForgeHooks.toolEffectiveness.remove(key);
}
/** Register a block to be harvested by a tool class.
* By default, this sets the block class as effective against that type.
*
* @param block The block to register.
* @param toolClass The tool class to register as able to remove this block.
* You may register the same block multiple times with different tool
* classes, if multiple tool types can be used to harvest this block.
* @param harvestLevel The minimum tool harvest level required to successfully
* harvest the block.
* @see setToolClass for details on tool classes.
*/
public static void setBlockHarvestLevel(Block block, String toolClass, int harvestLevel)
{
ForgeHooks.initTools();
for (int metadata = 0; metadata < 16; metadata++)
{
List key = Arrays.asList(block.blockID, metadata, toolClass);
ForgeHooks.toolHarvestLevels.put(key, harvestLevel);
ForgeHooks.toolEffectiveness.add(key);
}
}
/** Returns the block harvest level for a particular tool class.
*
* @param block The block to check.
* @param metadata The metadata for the block subtype.
* @param toolClass The tool class to check as able to remove this block.
* @see setToolClass for details on tool classes.
* @return The harvest level or -1 if no mapping exists.
*/
public static int getBlockHarvestLevel(Block block, int metadata, String toolClass)
{
ForgeHooks.initTools();
List key = Arrays.asList(block.blockID, metadata, toolClass);
Integer harvestLevel = (Integer)ForgeHooks.toolHarvestLevels.get(key);
if(harvestLevel == null)
{
return -1;
}
return harvestLevel;
}
/** Remove a block effectiveness mapping. Since setBlockHarvestLevel
* makes the tool class effective against the block by default, this can be
* used to remove that mapping. This will force a block to be harvested at
* the same speed regardless of tool quality, while still requiring a given
* harvesting level.
* @param block The block to remove effectiveness from.
* @param toolClass The tool class to remove the effectiveness mapping from.
* @see setToolClass for details on tool classes.
*/
public static void removeBlockEffectiveness(Block block, String toolClass)
{
ForgeHooks.initTools();
for (int metadata = 0; metadata < 16; metadata++)
{
List key = Arrays.asList(block.blockID, metadata, toolClass);
ForgeHooks.toolEffectiveness.remove(key);
}
}
/**
* Kill minecraft with an error message.
*/

View File

@ -0,0 +1,20 @@
--- ../src_base/common/net/minecraft/src/AnvilSaveHandler.java
+++ ../src_work/common/net/minecraft/src/AnvilSaveHandler.java
@@ -17,15 +17,9 @@
File var2 = this.getSaveDirectory();
File var3;
- if (par1WorldProvider instanceof WorldProviderHell)
+ if (par1WorldProvider.getSaveFolder() != null)
{
- var3 = new File(var2, "DIM-1");
- var3.mkdirs();
- return new AnvilChunkLoader(var3);
- }
- else if (par1WorldProvider instanceof WorldProviderEnd)
- {
- var3 = new File(var2, "DIM1");
+ var3 = new File(var2, par1WorldProvider.getSaveFolder());
var3.mkdirs();
return new AnvilChunkLoader(var3);
}

View File

@ -0,0 +1,24 @@
--- ../src_base/common/net/minecraft/src/BlockContainer.java
+++ ../src_work/common/net/minecraft/src/BlockContainer.java
@@ -20,7 +20,7 @@
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
super.onBlockAdded(par1World, par2, par3, par4);
- par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World));
+ par1World.setBlockTileEntity(par2, par3, par4, this.createNewTileEntity(par1World, par1World.getBlockMetadata(par2, par3, par4)));
}
/**
@@ -36,6 +36,12 @@
* each class overrdies this to return a new <className>
*/
public abstract TileEntity createNewTileEntity(World var1);
+
+
+ public TileEntity createNewTileEntity(World world, int metadata)
+ {
+ return createNewTileEntity(world);
+ }
/**
* Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on to the tile

View File

@ -0,0 +1,11 @@
--- ../src_base/common/net/minecraft/src/EnchantmentHelper.java
+++ ../src_work/common/net/minecraft/src/EnchantmentHelper.java
@@ -365,7 +365,7 @@
{
Enchantment var7 = var4[var6];
- if (var7 != null && var7.type.canEnchantItem(var2))
+ if (var7 != null && var7.canEnchantItem(par1ItemStack))
{
for (int var8 = var7.getMinLevel(); var8 <= var7.getMaxLevel(); ++var8)
{

View File

@ -0,0 +1,10 @@
--- ../src_base/common/net/minecraft/src/SlotCrafting.java
+++ ../src_work/common/net/minecraft/src/SlotCrafting.java
@@ -107,6 +107,7 @@
*/
public void onPickupFromSlot(ItemStack par1ItemStack)
{
+ ForgeHooks.onTakenFromCrafting(thePlayer, par1ItemStack, craftMatrix);
this.onCrafting(par1ItemStack);
for (int var2 = 0; var2 < this.craftMatrix.getSizeInventory(); ++var2)

View File

@ -0,0 +1,22 @@
--- ../src_base/common/net/minecraft/src/WorldGenDeadBush.java
+++ ../src_work/common/net/minecraft/src/WorldGenDeadBush.java
@@ -16,10 +16,16 @@
{
int var11;
- for (boolean var6 = false; ((var11 = par1World.getBlockId(par3, par4, par5)) == 0 || var11 == Block.leaves.blockID) && par4 > 0; --par4)
+ Block block = null;
+ do
{
- ;
- }
+ block = Block.blocksList[par1World.getBlockId(par3, par4, par5)];
+ if (block != null && !block.isLeaves(par1World, par3, par4, par5))
+ {
+ break;
+ }
+ par4--;
+ } while (par4 > 0);
for (int var7 = 0; var7 < 4; ++var7)
{

View File

@ -0,0 +1,22 @@
--- ../src_base/common/net/minecraft/src/WorldGenTallGrass.java
+++ ../src_work/common/net/minecraft/src/WorldGenTallGrass.java
@@ -18,10 +18,16 @@
{
int var11;
- for (boolean var6 = false; ((var11 = par1World.getBlockId(par3, par4, par5)) == 0 || var11 == Block.leaves.blockID) && par4 > 0; --par4)
+ Block block = null;
+ do
{
- ;
- }
+ block = Block.blocksList[par1World.getBlockId(par3, par4, par5)];
+ if (block != null && !block.isLeaves(par1World, par3, par4, par5))
+ {
+ break;
+ }
+ par4--;
+ } while (par4 > 0);
for (int var7 = 0; var7 < 128; ++var7)
{

View File

@ -0,0 +1,735 @@
--- ../src_base/minecraft/net/minecraft/src/Block.java
+++ ../src_work/minecraft/net/minecraft/src/Block.java
@@ -1,7 +1,13 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+
+import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class Block
{
@@ -277,6 +283,7 @@
lightOpacity[par1] = this.isOpaqueCube() ? 255 : 0;
canBlockGrass[par1] = !par2Material.getCanBlockGrass();
}
+ isDefaultTexture = (getTextureFile() != null && getTextureFile().equalsIgnoreCase("/terrain.png"));
}
/**
@@ -415,9 +422,10 @@
return this.needsRandomTick;
}
+ @Deprecated //Forge: New Metadata sensitive version.
public boolean hasTileEntity()
{
- return this.isBlockContainer;
+ return hasTileEntity(0);
}
/**
@@ -438,7 +446,7 @@
*/
public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
- return par1IBlockAccess.getBrightness(par2, par3, par4, lightValue[par1IBlockAccess.getBlockId(par2, par3, par4)]);
+ return par1IBlockAccess.getBrightness(par2, par3, par4, getLightValue(par1IBlockAccess, par2, par3, par4));
}
/**
@@ -446,7 +454,7 @@
*/
public int getMixedBrightnessForBlock(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
- return par1IBlockAccess.getLightBrightnessForSkyBlocks(par2, par3, par4, lightValue[par1IBlockAccess.getBlockId(par2, par3, par4)]);
+ return par1IBlockAccess.getLightBrightnessForSkyBlocks(par2, par3, par4, getLightValue(par1IBlockAccess, par2, par3, par4));
}
/**
@@ -607,8 +615,7 @@
*/
public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5)
{
- float var6 = this.getBlockHardness(par2World, par3, par4, par5);
- return var6 < 0.0F ? 0.0F : (!par1EntityPlayer.canHarvestBlock(this) ? 1.0F / var6 / 100.0F : par1EntityPlayer.getCurrentPlayerStrVsBlock(this) / var6 / 30.0F);
+ return ForgeHooks.blockStrength(this, par1EntityPlayer, par2World, par3, par4, par5);
}
/**
@@ -626,18 +633,13 @@
{
if (!par1World.isRemote)
{
- int var8 = this.quantityDroppedWithBonus(par7, par1World.rand);
-
- for (int var9 = 0; var9 < var8; ++var9)
+ ArrayList<ItemStack> items = getBlockDropped(par1World, par2, par3, par4, par5, par7);
+
+ for (ItemStack item : items)
{
if (par1World.rand.nextFloat() <= par6)
{
- int var10 = this.idDropped(par5, par1World.rand, par7);
-
- if (var10 > 0)
- {
- this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(var10, 1, this.damageDropped(par5)));
- }
+ this.dropBlockAsItem_do(par1World, par2, par3, par4, item);
}
}
}
@@ -964,7 +966,7 @@
par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
par2EntityPlayer.addExhaustion(0.025F);
- if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer.inventory))
+ if (this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer.inventory))
{
ItemStack var8 = this.createStackedBlock(par6);
@@ -1218,4 +1220,638 @@
canBlockGrass[0] = true;
StatList.initBreakableStats();
}
+
+ /* =================================================== 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
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return The light value
+ */
+ public int getLightValue(IBlockAccess world, int x, int y, int z)
+ {
+ return lightValue[blockID];
+ }
+
+ /**
+ * Checks if a player or entity can use this block to 'climb' like a ladder.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block should act like a ladder
+ */
+ public boolean isLadder(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Return true if the block is a normal, solid cube. This
+ * determines indirect power state, entity ejection from blocks, and a few
+ * others.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block is a full cube
+ */
+ public boolean isBlockNormalCube(World world, int x, int y, int z)
+ {
+ return blockMaterial.isOpaque() && renderAsNormalBlock();
+ }
+
+ /**
+ * Checks if the block is a solid face on the given side, used by placement logic.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @param size The side to check
+ * @return True if the block is solid on the specified side.
+ */
+ public boolean isBlockSolidOnSide(World world, int x, int y, int z, Orientation side)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ if (this instanceof BlockStep)
+ {
+ return (((meta & 8) == 8 && (side == UP)) || isOpaqueCube());
+ }
+ else if (this instanceof BlockFarmland)
+ {
+ return (side != DOWN && side != UP);
+ }
+ else if (this instanceof BlockStairs)
+ {
+ boolean flipped = ((meta & 4) != 0);
+ return ((meta & 3) + side.ordinal() == 5) || (side == UP && flipped);
+ }
+ return isBlockNormalCube(world, x, y, z);
+ }
+
+ /**
+ * Determines if a new block can be replace the space occupied by this one,
+ * Used in the player's placement code to make the block act like water, and lava.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block is replaceable by another block
+ */
+ public boolean isBlockReplaceable(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Determines if this block should set fire and deal fire damage
+ * to entities coming into contact with it.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block should deal damage
+ */
+ public boolean isBlockBurning(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Determines this block should be treated as an air block
+ * by the rest of the code. This method is primarily
+ * useful for creating pure logic-blocks that will be invisible
+ * to the player and otherwise interact as air would.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block considered air
+ */
+ public boolean isAirBlock(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.
+ *
+ * @param player The player damaging the block, may be null
+ * @param meta The block's current metadata
+ * @return True to spawn the drops
+ */
+ public boolean canHarvestBlock(EntityPlayer player, int meta)
+ {
+ return ForgeHooks.canHarvestBlock(this, player, meta);
+ }
+
+ /**
+ * Called when a player removes a block. This is responsible for
+ * actually destroying the block, and the block is intact at time of call.
+ * This is called regardless of whether the player can harvest the block or
+ * not.
+ *
+ * Return true if the block is actually destroyed.
+ *
+ * Note: When used in multiplayer, this is called on both client and
+ * server sides!
+ *
+ * @param world The current world
+ * @param player The player damaging the block, may be null
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @return True if the block is actually destroyed.
+ */
+ public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
+ {
+ return world.setBlockWithNotify(x, y, z, 0);
+ }
+
+ /**
+ * Called when a new CreativeContainer is opened, populate the list
+ * with all of the items for this block you want a player in creative mode
+ * to have access to.
+ *
+ * @param itemList The list of items to display on the creative inventory.
+ */
+ public void addCreativeItems(ArrayList itemList)
+ {
+ }
+
+ /**
+ * Chance that fire will spread and consume this block.
+ * 300 being a 100% chance, 0, being a 0% chance.
+ *
+ * @param world The current world
+ * @param x The blocks X position
+ * @param y The blocks Y position
+ * @param z The blocks Z position
+ * @param metadata The blocks current metadata
+ * @param face The face that the fire is coming from
+ * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire
+ */
+ public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, Orientation face)
+ {
+ return blockFlammability[blockID];
+ }
+
+ /**
+ * Called when fire is updating, checks if a block face can catch fire.
+ *
+ *
+ * @param world The current world
+ * @param x The blocks X position
+ * @param y The blocks Y position
+ * @param z The blocks Z position
+ * @param metadata The blocks current metadata
+ * @param face The face that the fire is coming from
+ * @return True if the face can be on fire, false otherwise.
+ */
+ public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, Orientation face)
+ {
+ return getFlammability(world, x, y, z, metadata, face) > 0;
+ }
+
+ /**
+ * Called when fire is updating on a neighbor block.
+ * The higher the number returned, the faster fire will spread around this block.
+ *
+ * @param world The current world
+ * @param x The blocks X position
+ * @param y The blocks Y position
+ * @param z The blocks Z position
+ * @param metadata The blocks current metadata
+ * @param face The face that the fire is coming from
+ * @return A number that is used to determine the speed of fire growth around the block
+ */
+ public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, Orientation face)
+ {
+ return blockFireSpreadSpeed[blockID];
+ }
+
+ /**
+ * Currently only called by fire when it is on top of this block.
+ * Returning true will prevent the fire from naturally dying during updating.
+ * Also prevents firing from dying from rain.
+ *
+ * @param world The current world
+ * @param x The blocks X position
+ * @param y The blocks Y position
+ * @param z The blocks Z position
+ * @param metadata The blocks current metadata
+ * @param side The face that the fire is coming from
+ * @return
+ */
+ public boolean isFireSource(World world, int x, int y, int z, int metadata, Orientation side)
+ {
+ if (blockID == Block.netherrack.blockID && side == UP)
+ {
+ return true;
+ }
+ if ((world.provider instanceof WorldProviderEnd) && blockID == Block.bedrock.blockID && side == UP)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Called by BlockFire to setup the burn values of vanilla blocks.
+ * @param id The block id
+ * @param encouragement How much the block encourages fire to spread
+ * @param flammability how easy a block is to catch fire
+ */
+ public static void setBurnProperties(int id, int encouragement, int flammability)
+ {
+ blockFireSpreadSpeed[id] = encouragement;
+ blockFlammability[id] = flammability;
+ }
+
+ /**
+ * Called throughout the code as a replacement for block instanceof BlockContainer
+ * Moving this to the Block base class allows for mods that wish to extend vinella
+ * blocks, and also want to have a tile entity on that block, may.
+ *
+ * Return true from this function to specify this block has a tile entity.
+ *
+ * @param metadata Metadata of the current block
+ * @return True if block has a tile entity, false otherwise
+ */
+ public boolean hasTileEntity(int metadata)
+ {
+ return isBlockContainer;
+ }
+
+ /**
+ * Called throughout the code as a replacement for BlockContainer.getBlockEntity
+ * Return the same thing you would from that function.
+ * This will fall back to BlockContainer.getBlockEntity if this block is a BlockContainer.
+ *
+ * @param metadata The Metadata of the current block
+ * @return A instance of a class extending TileEntity
+ */
+ public TileEntity createTileEntity(World world, int metadata)
+ {
+ if (this instanceof BlockContainer)
+ {
+ return ((BlockContainer)this).createNewTileEntity(world, metadata);
+ }
+ return null;
+ }
+
+ /**
+ * Metadata and fortune sensitive version, this replaces the old (int meta, Random rand)
+ * version in 1.1.
+ *
+ * @param meta Blocks Metadata
+ * @param fortune Current item fortune level
+ * @param random Random number generator
+ * @return The number of items to drop
+ */
+ public int quantityDropped(int meta, int fortune, Random random)
+ {
+ return quantityDroppedWithBonus(fortune, random);
+ }
+
+ /**
+ * This returns a complete list of items dropped from this block.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param Y Y Position
+ * @param Z Z Position
+ * @param metadata Current metadata
+ * @param fortune Breakers fortune level
+ * @return A ArrayList containing all items this block drops
+ */
+ public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+
+ int count = quantityDropped(metadata, fortune, world.rand);
+ for(int i = 0; i < count; i++)
+ {
+ int id = idDropped(metadata, world.rand, 0);
+ if (id > 0)
+ {
+ ret.add(new ItemStack(id, 1, damageDropped(metadata)));
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Return true from this function if the player with silk touch can harvest this block directly, and not it's normal drops.
+ *
+ * @param world The world
+ * @param player The player doing the harvesting
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param metadata The metadata
+ * @return True if the block can be directly harvested using silk touch
+ */
+ public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata)
+ {
+ if (this instanceof BlockGlass)
+ {
+ return true;
+ }
+ return renderAsNormalBlock() && !hasTileEntity(metadata);
+ }
+
+ /**
+ * Determines if a specified mob type can spawn on this block, returning false will
+ * prevent any mob from spawning on the block.
+ *
+ * @param type The Mob Category Type
+ * @param world The current world
+ * @param x The X Position
+ * @param y The Y Position
+ * @param z The Z Position
+ * @return True to allow a mob of the specified category to spawn, false to prevent it.
+ */
+ public boolean canCreatureSpawn(EnumCreatureType type, World world, int x, int y, int z)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ if (this instanceof BlockStep)
+ {
+ if (MinecraftForge.SPAWNER_ALLOW_ON_INVERTED)
+ {
+ return (((meta & 8) == 8) || isOpaqueCube());
+ }
+ else
+ {
+ return isNormalCube(this.blockID);
+ }
+ }
+ else if (this instanceof BlockStairs)
+ {
+ if (MinecraftForge.SPAWNER_ALLOW_ON_INVERTED)
+ {
+ return ((meta & 4) != 0);
+ }
+ else
+ {
+ return isNormalCube(this.blockID);
+ }
+ }
+ return isBlockSolidOnSide(world, x, y, z, UP);
+ }
+
+ /**
+ * Determines if this block is classified as a Bed, Allowing
+ * players to sleep in it, though the block has to specifically
+ * perform the sleeping functionality in it's activated event.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param player The player or camera entity, null in some cases.
+ * @return True to treat this as a bed
+ */
+ public boolean isBed(World world, int x, int y, int z, EntityLiving player)
+ {
+ return blockID == Block.bed.blockID;
+ }
+
+ /**
+ * Returns the position that the player is moved to upon
+ * waking up, or respawning at the bed.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param player The player or camera entity, null in some cases.
+ * @return The spawn position
+ */
+ public ChunkCoordinates getBedSpawnPosition(World world, int x, int y, int z, EntityPlayer player)
+ {
+ return BlockBed.getNearestEmptyChunkCoordinates(world, x, y, z, 0);
+ }
+
+ /**
+ * Called when a user either starts or stops sleeping in the bed.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param player The player or camera entity, null in some cases.
+ * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed
+ */
+ public void setBedOccupied(World world, int x, int y, int z, EntityPlayer player, boolean occupied)
+ {
+ BlockBed.setBedOccupied(world, x, y, z, occupied);
+ }
+
+ /**
+ * Returns the direction of the block. Same values that
+ * are returned by BlockDirectional
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return Bed direction
+ */
+ public int getBedDirection(IBlockAccess world, int x, int y, int z)
+ {
+ return BlockBed.getDirection(world.getBlockMetadata(x, y, z));
+ }
+
+ /**
+ * Determines if the current block is the foot half of the bed.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return True if the current block is the foot side of a bed.
+ */
+ public boolean isBedFoot(IBlockAccess world, int x, int y, int z)
+ {
+ return BlockBed.isBlockHeadOfBed(world.getBlockMetadata(x, y, z));
+ }
+
+ /**
+ * Called when a leaf should start its decay process.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ */
+ public void beginLeavesDecay(World world, int x, int y, int z){}
+
+ /**
+ * Determines if this block can prevent leaves connected to it from decaying.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return true if the presence this block can prevent leaves from decaying.
+ */
+ public boolean canSustainLeaves(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Determines if this block is considered a leaf block, used to apply the leaf decay and generation system.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return true if this block is considered leaves.
+ */
+ public boolean isLeaves(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Used during tree growth to determine if newly generated leaves can replace this block.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return true if this block can be replaced by growing leaves.
+ */
+ public boolean canBeReplacedByLeaves(World world, int x, int y, int z)
+ {
+ return !Block.opaqueCubeLookup[this.blockID];
+ }
+
+ /**
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return true if the block is wood (logs)
+ */
+ public boolean isWood(World world, int x, int y, int z)
+ {
+ return false;
+ }
+
+ /**
+ * Determines if the current block is replaceable by Ore veins during world generation.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return True to allow this block to be replaced by a ore
+ */
+ public boolean isGenMineableReplaceable(World world, int x, int y, int z)
+ {
+ return blockID == stone.blockID;
+ }
+
+ /**
+ * Grabs the current texture file used for this block
+ */
+ 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;
+ }
+
+
+ /**
+ * Location sensitive version of getExplosionRestance
+ *
+ * @param par1Entity
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param explosionX
+ * @param explosionY
+ * @param explosionZ
+ * @return
+ */
+ public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
+ {
+ return getExplosionResistance(par1Entity);
+ }
+
+ /**
+ * Determine if this block can make a redstone connection on the side provided,
+ * Useful to control which sides are inputs and outputs for redstone wires.
+ *
+ * Side:
+ * -1: UP
+ * 0: NORTH
+ * 1: EAST
+ * 2: SOUTH
+ * 3: WEST
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param side The side that is trying to make the connection
+ * @return True to make the connection
+ */
+ public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
+ {
+ return Block.blocksList[blockID].canProvidePower() && side != -1;
+ }
+
+ /**
+ * Determines if a torch can be placed on the top surface of this block.
+ * Useful for creating your own block that torches can be on, such as fences.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @return True to allow the torch to be placed
+ */
+ public boolean canPlaceTorchOnTop(World world, int x, int y, int z)
+ {
+ if (world.doesBlockHaveSolidTopSurface(x, y, z))
+ {
+ return true;
+ }
+ else
+ {
+ int id = world.getBlockId(x, y, z);
+ return id == Block.fence.blockID || id == Block.netherFence.blockID || id == Block.glass.blockID;
+ }
+ }
}

View File

@ -0,0 +1,53 @@
--- ../src_base/minecraft/net/minecraft/src/BlockChest.java
+++ ../src_work/minecraft/net/minecraft/src/BlockChest.java
@@ -2,6 +2,8 @@
import java.util.Iterator;
import java.util.Random;
+
+import static net.minecraftforge.common.Orientation.*;
public class BlockChest extends BlockContainer
{
@@ -379,7 +381,7 @@
{
return true;
}
- else if (par1World.isBlockNormalCube(par2, par3 + 1, par4))
+ else if (par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN))
{
return true;
}
@@ -387,19 +389,19 @@
{
return true;
}
- else if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 - 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 - 1, par3, par4)))
- {
- return true;
- }
- else if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID && (par1World.isBlockNormalCube(par2 + 1, par3 + 1, par4) || isOcelotBlockingChest(par1World, par2 + 1, par3, par4)))
- {
- return true;
- }
- else if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 - 1) || isOcelotBlockingChest(par1World, par2, par3, par4 - 1)))
- {
- return true;
- }
- else if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID && (par1World.isBlockNormalCube(par2, par3 + 1, par4 + 1) || isOcelotBlockingChest(par1World, par2, par3, par4 + 1)))
+ else if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID && (par1World.isBlockSolidOnSide(par2 - 1, par3 + 1, par4, DOWN) || isOcelotBlockingChest(par1World, par2 - 1, par3, par4)))
+ {
+ return true;
+ }
+ else if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID && (par1World.isBlockSolidOnSide(par2 + 1, par3 + 1, par4, DOWN) || isOcelotBlockingChest(par1World, par2 + 1, par3, par4)))
+ {
+ return true;
+ }
+ else if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID && (par1World.isBlockSolidOnSide(par2, par3 + 1, par4 - 1, DOWN) || isOcelotBlockingChest(par1World, par2, par3, par4 - 1)))
+ {
+ return true;
+ }
+ else if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID && (par1World.isBlockSolidOnSide(par2, par3 + 1, par4 + 1, DOWN) || isOcelotBlockingChest(par1World, par2, par3, par4 + 1)))
{
return true;
}

View File

@ -0,0 +1,50 @@
--- ../src_base/minecraft/net/minecraft/src/BlockCrops.java
+++ ../src_work/minecraft/net/minecraft/src/BlockCrops.java
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.Random;
public class BlockCrops extends BlockFlower
@@ -136,25 +137,26 @@
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0);
+ }
+
+ @Override
+ public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+ if (metadata == 7)
+ {
+ ret.add(new ItemStack(Item.wheat));
+ }
- if (!par1World.isRemote)
+ for (int n = 0; n < 3 + fortune; n++)
{
- int var8 = 3 + par7;
-
- for (int var9 = 0; var9 < var8; ++var9)
+ if (world.rand.nextInt(15) <= metadata)
{
- if (par1World.rand.nextInt(15) <= par5)
- {
- float var10 = 0.7F;
- float var11 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
- float var12 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
- float var13 = par1World.rand.nextFloat() * var10 + (1.0F - var10) * 0.5F;
- EntityItem var14 = new EntityItem(par1World, (double)((float)par2 + var11), (double)((float)par3 + var12), (double)((float)par4 + var13), new ItemStack(Item.seeds));
- var14.delayBeforeCanPickup = 10;
- par1World.spawnEntityInWorld(var14);
- }
+ ret.add(new ItemStack(Item.seeds));
}
}
+
+ return ret;
}
/**

View File

@ -0,0 +1,38 @@
--- ../src_base/minecraft/net/minecraft/src/BlockDoor.java
+++ ../src_work/minecraft/net/minecraft/src/BlockDoor.java
@@ -1,6 +1,8 @@
package net.minecraft.src;
import java.util.Random;
+
+import static net.minecraftforge.common.Orientation.*;
public class BlockDoor extends Block
{
@@ -257,7 +259,7 @@
{
if (this.blockMaterial == Material.iron)
{
- return true;
+ return false; //Allow items to interact with the door
}
else
{
@@ -327,7 +329,7 @@
var7 = true;
}
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
+ if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP))
{
par1World.setBlockWithNotify(par2, par3, par4, 0);
var7 = true;
@@ -392,7 +394,7 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par3 >= 255 ? false : par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4);
+ return par3 >= 255 ? false : par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4);
}
/**

View File

@ -0,0 +1,257 @@
--- ../src_base/minecraft/net/minecraft/src/BlockFire.java
+++ ../src_work/minecraft/net/minecraft/src/BlockFire.java
@@ -1,6 +1,9 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockFire extends Block
{
@@ -25,6 +28,8 @@
*/
public void initializeBlock()
{
+ abilityToCatchFire = Block.blockFlammability;
+ chanceToEncourageFire = Block.blockFireSpreadSpeed;
this.setBurnRate(Block.planks.blockID, 5, 20);
this.setBurnRate(Block.woodDoubleSlab.blockID, 5, 20);
this.setBurnRate(Block.woodSingleSlab.blockID, 5, 20);
@@ -49,8 +54,7 @@
*/
private void setBurnRate(int par1, int par2, int par3)
{
- this.chanceToEncourageFire[par1] = par2;
- this.abilityToCatchFire[par1] = par3;
+ Block.setBurnProperties(par1, par2, par3);
}
/**
@@ -108,12 +112,8 @@
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
- boolean var6 = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;
-
- if (par1World.provider instanceof WorldProviderEnd && par1World.getBlockId(par2, par3 - 1, par4) == Block.bedrock.blockID)
- {
- var6 = true;
- }
+ Block base = Block.blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
+ boolean var6 = (base != null && base.isFireSource(par1World, par2, par3 - 1, par4, par1World.getBlockMetadata(par2, par3 - 1, par4), UP));
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
{
@@ -137,12 +137,12 @@
if (!var6 && !this.canNeighborBurn(par1World, par2, par3, par4))
{
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || var7 > 3)
+ if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) || var7 > 3)
{
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
- else if (!var6 && !this.canBlockCatchFire(par1World, par2, par3 - 1, par4) && var7 == 15 && par5Random.nextInt(4) == 0)
+ else if (!var6 && !this.canBlockCatchFire(par1World, par2, par3 - 1, par4, UP) && var7 == 15 && par5Random.nextInt(4) == 0)
{
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
@@ -156,12 +156,12 @@
var9 = -50;
}
- this.tryToCatchBlockOnFire(par1World, par2 + 1, par3, par4, 300 + var9, par5Random, var7);
- this.tryToCatchBlockOnFire(par1World, par2 - 1, par3, par4, 300 + var9, par5Random, var7);
- this.tryToCatchBlockOnFire(par1World, par2, par3 - 1, par4, 250 + var9, par5Random, var7);
- this.tryToCatchBlockOnFire(par1World, par2, par3 + 1, par4, 250 + var9, par5Random, var7);
- this.tryToCatchBlockOnFire(par1World, par2, par3, par4 - 1, 300 + var9, par5Random, var7);
- this.tryToCatchBlockOnFire(par1World, par2, par3, par4 + 1, 300 + var9, par5Random, var7);
+ this.tryToCatchBlockOnFire(par1World, par2 + 1, par3, par4, 300 + var9, par5Random, var7, WEST );
+ this.tryToCatchBlockOnFire(par1World, par2 - 1, par3, par4, 300 + var9, par5Random, var7, EAST );
+ this.tryToCatchBlockOnFire(par1World, par2, par3 - 1, par4, 250 + var9, par5Random, var7, UP );
+ this.tryToCatchBlockOnFire(par1World, par2, par3 + 1, par4, 250 + var9, par5Random, var7, DOWN);
+ this.tryToCatchBlockOnFire(par1World, par2, par3, par4 - 1, 300 + var9, par5Random, var7, SOUTH);
+ this.tryToCatchBlockOnFire(par1World, par2, par3, par4 + 1, 300 + var9, par5Random, var7, NORTH);
for (int var10 = par2 - 1; var10 <= par2 + 1; ++var10)
{
@@ -211,7 +211,16 @@
private void tryToCatchBlockOnFire(World par1World, int par2, int par3, int par4, int par5, Random par6Random, int par7)
{
- int var8 = this.abilityToCatchFire[par1World.getBlockId(par2, par3, par4)];
+ tryToCatchBlockOnFire(par1World, par2, par3, par4, par5, par6Random, par7, UP);
+ }
+ private void tryToCatchBlockOnFire(World par1World, int par2, int par3, int par4, int par5, Random par6Random, int par7, Orientation face)
+ {
+ int var8 = 0;
+ Block block = Block.blocksList[par1World.getBlockId(par2, par3, par4)];
+ if (block != null)
+ {
+ var8 = block.getFlammability(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), face);
+ }
if (par6Random.nextInt(par5) < var8)
{
@@ -245,7 +254,12 @@
*/
private boolean canNeighborBurn(World par1World, int par2, int par3, int par4)
{
- return this.canBlockCatchFire(par1World, par2 + 1, par3, par4) ? true : (this.canBlockCatchFire(par1World, par2 - 1, par3, par4) ? true : (this.canBlockCatchFire(par1World, par2, par3 - 1, par4) ? true : (this.canBlockCatchFire(par1World, par2, par3 + 1, par4) ? true : (this.canBlockCatchFire(par1World, par2, par3, par4 - 1) ? true : this.canBlockCatchFire(par1World, par2, par3, par4 + 1)))));
+ return canBlockCatchFire(par1World, par2 + 1, par3, par4, WEST ) ||
+ canBlockCatchFire(par1World, par2 - 1, par3, par4, EAST ) ||
+ canBlockCatchFire(par1World, par2, par3 - 1, par4, UP ) ||
+ canBlockCatchFire(par1World, par2, par3 + 1, par4, DOWN ) ||
+ canBlockCatchFire(par1World, par2, par3, par4 - 1, SOUTH) ||
+ canBlockCatchFire(par1World, par2, par3, par4 + 1, NORTH);
}
/**
@@ -261,12 +275,12 @@
}
else
{
- int var6 = this.getChanceToEncourageFire(par1World, par2 + 1, par3, par4, var5);
- var6 = this.getChanceToEncourageFire(par1World, par2 - 1, par3, par4, var6);
- var6 = this.getChanceToEncourageFire(par1World, par2, par3 - 1, par4, var6);
- var6 = this.getChanceToEncourageFire(par1World, par2, par3 + 1, par4, var6);
- var6 = this.getChanceToEncourageFire(par1World, par2, par3, par4 - 1, var6);
- var6 = this.getChanceToEncourageFire(par1World, par2, par3, par4 + 1, var6);
+ int var6 = this.getChanceToEncourageFire(par1World, par2 + 1, par3, par4, var5, WEST);
+ var6 = this.getChanceToEncourageFire(par1World, par2 - 1, par3, par4, var6, EAST );
+ var6 = this.getChanceToEncourageFire(par1World, par2, par3 - 1, par4, var6, UP );
+ var6 = this.getChanceToEncourageFire(par1World, par2, par3 + 1, par4, var6, DOWN );
+ var6 = this.getChanceToEncourageFire(par1World, par2, par3, par4 - 1, var6, SOUTH);
+ var6 = this.getChanceToEncourageFire(par1World, par2, par3, par4 + 1, var6, NORTH);
return var6;
}
}
@@ -281,21 +295,24 @@
/**
* Checks the specified block coordinate to see if it can catch fire. Args: blockAccess, x, y, z
- */
+ * Deprecated for a side-sensitive version
+ */
+ @Deprecated
public boolean canBlockCatchFire(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
- return this.chanceToEncourageFire[par1IBlockAccess.getBlockId(par2, par3, par4)] > 0;
+ return canBlockCatchFire(par1IBlockAccess, par2, par3, par4, UP);
}
/**
* Retrieves a specified block's chance to encourage their neighbors to burn and if the number is greater than the
* current number passed in it will return its number instead of the passed in one. Args: world, x, y, z,
* curChanceToEncourageFire
- */
+ * Deprecated for a side-sensitive version
+ */
+ @Deprecated
public int getChanceToEncourageFire(World par1World, int par2, int par3, int par4, int par5)
{
- int var6 = this.chanceToEncourageFire[par1World.getBlockId(par2, par3, par4)];
- return var6 > par5 ? var6 : par5;
+ return getChanceToEncourageFire(par1World, par2, par3, par4, par5, UP);
}
/**
@@ -351,9 +368,9 @@
float var8;
float var9;
- if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !Block.fire.canBlockCatchFire(par1World, par2, par3 - 1, par4))
- {
- if (Block.fire.canBlockCatchFire(par1World, par2 - 1, par3, par4))
+ if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !Block.fire.canBlockCatchFire(par1World, par2, par3 - 1, par4, UP))
+ {
+ if (Block.fire.canBlockCatchFire(par1World, par2 - 1, par3, par4, EAST))
{
for (var6 = 0; var6 < 2; ++var6)
{
@@ -364,7 +381,7 @@
}
}
- if (Block.fire.canBlockCatchFire(par1World, par2 + 1, par3, par4))
+ if (Block.fire.canBlockCatchFire(par1World, par2 + 1, par3, par4, WEST))
{
for (var6 = 0; var6 < 2; ++var6)
{
@@ -375,7 +392,7 @@
}
}
- if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 - 1))
+ if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 - 1, SOUTH))
{
for (var6 = 0; var6 < 2; ++var6)
{
@@ -386,7 +403,7 @@
}
}
- if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 + 1))
+ if (Block.fire.canBlockCatchFire(par1World, par2, par3, par4 + 1, NORTH))
{
for (var6 = 0; var6 < 2; ++var6)
{
@@ -397,7 +414,7 @@
}
}
- if (Block.fire.canBlockCatchFire(par1World, par2, par3 + 1, par4))
+ if (Block.fire.canBlockCatchFire(par1World, par2, par3 + 1, par4, DOWN))
{
for (var6 = 0; var6 < 2; ++var6)
{
@@ -419,4 +436,46 @@
}
}
}
+
+ /**
+ * Side sensitive version that calls the block function.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param face The side the fire is coming from
+ * @return True if the face can catch fire.
+ */
+ public boolean canBlockCatchFire(IBlockAccess world, int x, int y, int z, Orientation face)
+ {
+ Block block = Block.blocksList[world.getBlockId(x, y, z)];
+ if (block != null)
+ {
+ return block.isFlammable(world, x, y, z, world.getBlockMetadata(x, y, z), face);
+ }
+ return false;
+ }
+
+ /**
+ * Side sensitive version that calls the block function.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param oldChance The previous maximum chance.
+ * @param face The side the fire is coming from
+ * @return The chance of the block catching fire, or oldChance if it is higher
+ */
+ public int getChanceToEncourageFire(World world, int x, int y, int z, int oldChance, Orientation face)
+ {
+ int newChance = 0;
+ Block block = Block.blocksList[world.getBlockId(x, y, z)];
+ if (block != null)
+ {
+ newChance = block.getFireSpreadSpeed(world, x, y, z, world.getBlockMetadata(x, y, z), face);
+ }
+ return (newChance > oldChance ? newChance : oldChance);
+ }
}

View File

@ -0,0 +1,89 @@
--- ../src_base/minecraft/net/minecraft/src/BlockLadder.java
+++ ../src_work/minecraft/net/minecraft/src/BlockLadder.java
@@ -1,6 +1,9 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockLadder extends Block
{
@@ -103,7 +106,10 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCube(par2 - 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2 + 1, par3, par4) ? true : (par1World.isBlockNormalCube(par2, par3, par4 - 1) ? true : par1World.isBlockNormalCube(par2, par3, par4 + 1)));
+ return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST ) ||
+ par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST ) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH);
}
/**
@@ -113,22 +119,22 @@
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
- if ((var9 == 0 || par5 == 2) && par1World.isBlockNormalCube(par2, par3, par4 + 1))
+ if ((var9 == 0 || par5 == 2) && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH))
{
var9 = 2;
}
- if ((var9 == 0 || par5 == 3) && par1World.isBlockNormalCube(par2, par3, par4 - 1))
+ if ((var9 == 0 || par5 == 3) && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
{
var9 = 3;
}
- if ((var9 == 0 || par5 == 4) && par1World.isBlockNormalCube(par2 + 1, par3, par4))
+ if ((var9 == 0 || par5 == 4) && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST))
{
var9 = 4;
}
- if ((var9 == 0 || par5 == 5) && par1World.isBlockNormalCube(par2 - 1, par3, par4))
+ if ((var9 == 0 || par5 == 5) && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST))
{
var9 = 5;
}
@@ -145,22 +151,22 @@
int var6 = par1World.getBlockMetadata(par2, par3, par4);
boolean var7 = false;
- if (var6 == 2 && par1World.isBlockNormalCube(par2, par3, par4 + 1))
+ if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH))
{
var7 = true;
}
- if (var6 == 3 && par1World.isBlockNormalCube(par2, par3, par4 - 1))
+ if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
{
var7 = true;
}
- if (var6 == 4 && par1World.isBlockNormalCube(par2 + 1, par3, par4))
+ if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST))
{
var7 = true;
}
- if (var6 == 5 && par1World.isBlockNormalCube(par2 - 1, par3, par4))
+ if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST))
{
var7 = true;
}
@@ -181,4 +187,10 @@
{
return 1;
}
+
+ @Override
+ public boolean isLadder(World world, int x, int y, int z)
+ {
+ return true;
+ }
}

View File

@ -0,0 +1,93 @@
--- ../src_base/minecraft/net/minecraft/src/BlockLeaves.java
+++ ../src_work/minecraft/net/minecraft/src/BlockLeaves.java
@@ -1,9 +1,12 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.List;
import java.util.Random;
-public class BlockLeaves extends BlockLeavesBase
+import net.minecraftforge.common.IShearable;
+
+public class BlockLeaves extends BlockLeavesBase implements IShearable
{
/**
* The base index in terrain.png corresponding to the fancy version of the leaf texture. This is stored so we can
@@ -91,10 +94,9 @@
{
int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11);
- if (var12 == Block.leaves.blockID)
+ if (Block.blocksList[var12] != null)
{
- int var13 = par1World.getBlockMetadata(par2 + var9, par3 + var10, par4 + var11);
- par1World.setBlockMetadata(par2 + var9, par3 + var10, par4 + var11, var13 | 8);
+ Block.blocksList[var10].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
}
}
}
@@ -140,11 +142,13 @@
{
var15 = par1World.getBlockId(par2 + var12, par3 + var13, par4 + var14);
- if (var15 == Block.wood.blockID)
+ Block block = Block.blocksList[var15];
+
+ if (block != null && block.canSustainLeaves(par1World, par2 + var12, par3 + var13, par4 + var14))
{
this.adjacentTreeBlocks[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = 0;
}
- else if (var15 == Block.leaves.blockID)
+ else if (block != null && block.isLeaves(par1World, par2 + var12, par3 + var13, par4 + var14))
{
this.adjacentTreeBlocks[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = -2;
}
@@ -285,15 +289,7 @@
*/
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
- if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
- {
- par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
- this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.leaves.blockID, 1, par6 & 3));
- }
- else
- {
- super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
- }
+ super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
/**
@@ -340,4 +336,30 @@
par3List.add(new ItemStack(par1, 1, 2));
par3List.add(new ItemStack(par1, 1, 3));
}
+
+ @Override
+ public boolean isShearable(ItemStack item, World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ @Override
+ public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+ ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3));
+ return ret;
+ }
+
+ @Override
+ public void beginLeavesDecay(World world, int x, int y, int z)
+ {
+ world.setBlockMetadata(x, y, z, world.getBlockMetadata(x, y, z) | 8);
+ }
+
+ @Override
+ public boolean isLeaves(World world, int x, int y, int z)
+ {
+ return true;
+ }
}

View File

@ -0,0 +1,36 @@
--- ../src_base/minecraft/net/minecraft/src/BlockLog.java
+++ ../src_work/minecraft/net/minecraft/src/BlockLog.java
@@ -57,14 +57,9 @@
{
int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11);
- if (var12 == Block.leaves.blockID)
+ if (Block.blocksList[var12] != null)
{
- int var13 = par1World.getBlockMetadata(par2 + var9, par3 + var10, par4 + var11);
-
- if ((var13 & 8) == 0)
- {
- par1World.setBlockMetadata(par2 + var9, par3 + var10, par4 + var11, var13 | 8);
- }
+ Block.blocksList[var10].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11);
}
}
}
@@ -144,4 +139,16 @@
{
return new ItemStack(this.blockID, 1, limitToValidMetadata(par1));
}
+
+ @Override
+ public boolean canSustainLeaves(World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isWood(World world, int x, int y, int z)
+ {
+ return true;
+ }
}

View File

@ -0,0 +1,60 @@
--- ../src_base/minecraft/net/minecraft/src/BlockNetherStalk.java
+++ ../src_work/minecraft/net/minecraft/src/BlockNetherStalk.java
@@ -1,5 +1,6 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.Random;
public class BlockNetherStalk extends BlockFlower
@@ -67,25 +68,7 @@
*/
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
{
- if (!par1World.isRemote)
- {
- int var8 = 1;
-
- if (par5 >= 3)
- {
- var8 = 2 + par1World.rand.nextInt(3);
-
- if (par7 > 0)
- {
- var8 += par1World.rand.nextInt(par7 + 1);
- }
- }
-
- for (int var9 = 0; var9 < var8; ++var9)
- {
- this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.netherStalkSeeds));
- }
- }
+ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7);
}
/**
@@ -111,4 +94,23 @@
{
return Item.netherStalkSeeds.shiftedIndex;
}
+
+ @Override
+ public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+ int count = 1;
+
+ if (metadata >= 3)
+ {
+ count = 2 + world.rand.nextInt(3) + (fortune > 0 ? world.rand.nextInt(fortune + 1) : 0);
+ }
+
+ for (int i = 0; i < count; i++)
+ {
+ ret.add(new ItemStack(Item.netherStalkSeeds));
+ }
+
+ return ret;
+ }
}

View File

@ -0,0 +1,11 @@
--- ../src_base/minecraft/net/minecraft/src/BlockPistonBase.java
+++ ../src_work/minecraft/net/minecraft/src/BlockPistonBase.java
@@ -364,7 +364,7 @@
return false;
}
- return !(Block.blocksList[par0] instanceof BlockContainer);
+ return !par1World.blockHasTileEntity(par2, par3, par4);
}
}

View File

@ -0,0 +1,11 @@
--- ../src_base/minecraft/net/minecraft/src/BlockRedstoneWire.java
+++ ../src_work/minecraft/net/minecraft/src/BlockRedstoneWire.java
@@ -550,7 +550,7 @@
}
else if (var5 != Block.redstoneRepeaterIdle.blockID && var5 != Block.redstoneRepeaterActive.blockID)
{
- return Block.blocksList[var5].canProvidePower() && par4 != -1;
+ return (Block.blocksList[var5] != null && Block.blocksList[var5].canConnectRedstone(par0IBlockAccess, par1, par2, par3, par4));
}
else
{

View File

@ -0,0 +1,54 @@
--- ../src_base/minecraft/net/minecraft/src/BlockSnow.java
+++ ../src_work/minecraft/net/minecraft/src/BlockSnow.java
@@ -55,7 +55,8 @@
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3 - 1, par4);
- return var5 != 0 && (var5 == Block.leaves.blockID || Block.blocksList[var5].isOpaqueCube()) ? par1World.getBlockMaterial(par2, par3 - 1, par4).blocksMovement() : false;
+ Block block = Block.blocksList[var5];
+ return block != null && (block.isLeaves(par1World, par2, par3 - 1, par4) || Block.blocksList[var5].isOpaqueCube()) ? par1World.getBlockMaterial(par2, par3 - 1, par4).blocksMovement() : false;
}
/**
@@ -74,7 +75,6 @@
{
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
{
- this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
return false;
}
@@ -90,15 +90,7 @@
*/
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
- int var7 = Item.snowball.shiftedIndex;
- float var8 = 0.7F;
- double var9 = (double)(par1World.rand.nextFloat() * var8) + (double)(1.0F - var8) * 0.5D;
- double var11 = (double)(par1World.rand.nextFloat() * var8) + (double)(1.0F - var8) * 0.5D;
- double var13 = (double)(par1World.rand.nextFloat() * var8) + (double)(1.0F - var8) * 0.5D;
- EntityItem var15 = new EntityItem(par1World, (double)par3 + var9, (double)par4 + var11, (double)par5 + var13, new ItemStack(var7, 1, 0));
- var15.delayBeforeCanPickup = 10;
- par1World.spawnEntityInWorld(var15);
- par1World.setBlockWithNotify(par3, par4, par5, 0);
+ dropBlockAsItem(par1World, par3, par4, par5, par6, 0);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
}
@@ -115,7 +107,7 @@
*/
public int quantityDropped(Random par1Random)
{
- return 0;
+ return 1;
}
/**
@@ -125,7 +117,6 @@
{
if (par1World.getSavedLightValue(EnumSkyBlock.Block, par2, par3, par4) > 11)
{
- this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}

View File

@ -0,0 +1,133 @@
--- ../src_base/minecraft/net/minecraft/src/BlockTorch.java
+++ ../src_work/minecraft/net/minecraft/src/BlockTorch.java
@@ -1,6 +1,9 @@
package net.minecraft.src;
import java.util.Random;
+
+import net.minecraftforge.common.Orientation;
+import static net.minecraftforge.common.Orientation.*;
public class BlockTorch extends Block
{
@@ -50,15 +53,8 @@
*/
private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
- if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4))
- {
- return true;
- }
- else
- {
- int var5 = par1World.getBlockId(par2, par3, par4);
- return var5 == Block.fence.blockID || var5 == Block.netherFence.blockID || var5 == Block.glass.blockID;
- }
+ int id = par1World.getBlockId(par2, par3, par4);
+ return (Block.blocksList[id] != null && Block.blocksList[id].canPlaceTorchOnTop(par1World, par2, par3, par4));
}
/**
@@ -66,7 +62,11 @@
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
- return par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true) ? true : (par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true) ? true : (par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true) ? true : (par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true) ? true : this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))));
+ return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) ||
+ par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) ||
+ par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true) ||
+ canPlaceTorchOn(par1World, par2, par3 - 1, par4);
}
/**
@@ -81,22 +81,22 @@
var9 = 5;
}
- if (par5 == 2 && par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
+ if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
{
var9 = 4;
}
- if (par5 == 3 && par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
+ if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
{
var9 = 3;
}
- if (par5 == 4 && par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
+ if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, NORTH, true))
{
var9 = 2;
}
- if (par5 == 5 && par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
+ if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, SOUTH, true))
{
var9 = 1;
}
@@ -122,19 +122,19 @@
*/
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
- if (par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
+ if (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1);
}
- else if (par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
+ else if (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
- else if (par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
+ else if (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
- else if (par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
+ else if (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
@@ -157,22 +157,22 @@
int var6 = par1World.getBlockMetadata(par2, par3, par4);
boolean var7 = false;
- if (!par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true) && var6 == 1)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true) && var6 == 2)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true) && var6 == 3)
- {
- var7 = true;
- }
-
- if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true) && var6 == 4)
+ if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) && var6 == 1)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) && var6 == 2)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) && var6 == 3)
+ {
+ var7 = true;
+ }
+
+ if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true) && var6 == 4)
{
var7 = true;
}

View File

@ -0,0 +1,56 @@
--- ../src_base/minecraft/net/minecraft/src/BlockTrapDoor.java
+++ ../src_work/minecraft/net/minecraft/src/BlockTrapDoor.java
@@ -1,7 +1,13 @@
package net.minecraft.src;
+
+import net.minecraftforge.common.Orientation;
public class BlockTrapDoor extends Block
{
+
+ /** Set this to allow trapdoors to remain free-floating */
+ public static boolean disableValidation = false;
+
protected BlockTrapDoor(int par1, Material par2Material)
{
super(par1, par2Material);
@@ -183,7 +189,7 @@
--var7;
}
- if (!isValidSupportBlock(par1World.getBlockId(var7, par3, var8)))
+ if (!(isValidSupportBlock(par1World.getBlockId(var7, par3, var8)) || par1World.isBlockSolidOnSide(var7, par3, var8, Orientation.getOrientation((var6 & 3) + 2))))
{
par1World.setBlockWithNotify(par2, par3, par4, 0);
this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
@@ -243,6 +249,10 @@
*/
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
+ if (disableValidation)
+ {
+ return true;
+ }
if (par5 == 0)
{
return false;
@@ -273,7 +283,7 @@
--par2;
}
- return isValidSupportBlock(par1World.getBlockId(par2, par3, par4));
+ return isValidSupportBlock(par1World.getBlockId(par2, par3, par4)) || par1World.isBlockSolidOnSide(par2, par3, par4, Orientation.UP);
}
}
@@ -288,6 +298,10 @@
*/
private static boolean isValidSupportBlock(int par0)
{
+ if (disableValidation)
+ {
+ return true;
+ }
if (par0 <= 0)
{
return false;

View File

@ -0,0 +1,50 @@
--- ../src_base/minecraft/net/minecraft/src/BlockVine.java
+++ ../src_work/minecraft/net/minecraft/src/BlockVine.java
@@ -2,7 +2,10 @@
import java.util.Random;
-public class BlockVine extends Block
+import java.util.ArrayList;
+import net.minecraftforge.common.IShearable;
+
+public class BlockVine extends Block implements IShearable
{
public BlockVine(int par1)
{
@@ -424,14 +427,26 @@
*/
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
- if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
- {
- par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
- this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(Block.vine, 1, 0));
- }
- else
- {
- super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
- }
+ super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
+ }
+
+ @Override
+ public boolean isShearable(ItemStack item, World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ @Override
+ public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+ ret.add(new ItemStack(this, 1, 0));
+ return ret;
+ }
+
+ @Override
+ public boolean isLadder(World world, int x, int y, int z)
+ {
+ return true;
}
}

View File

@ -121,7 +121,7 @@
if (var14 == null)
{
- var14 = ((BlockContainer)Block.blocksList[par4]).createNewTileEntity(this.worldObj);
+ var14 = Block.blocksList[par4].getTileEntity(this.worldObj, par5);
+ var14 = Block.blocksList[par4].createTileEntity(this.worldObj, par5);
this.worldObj.setBlockTileEntity(var12, par2, var13, var14);
}
@ -215,7 +215,7 @@
if (var5 == null)
{
- var5 = ((BlockContainer)Block.blocksList[var6]).createNewTileEntity(this.worldObj);
+ var5 = Block.blocksList[var6].createNewTileEntity(this.worldObj, meta);
+ var5 = Block.blocksList[var6].createTileEntity(this.worldObj, meta);
this.worldObj.setBlockTileEntity(this.xPosition * 16 + par1, par2, this.zPosition * 16 + par3, var5);
}

View File

@ -0,0 +1,11 @@
--- ../src_base/minecraft/net/minecraft/src/ContainerFurnace.java
+++ ../src_work/minecraft/net/minecraft/src/ContainerFurnace.java
@@ -119,7 +119,7 @@
}
else if (par1 != 1 && par1 != 0)
{
- if (FurnaceRecipes.smelting().getSmeltingResult(var4.getItem().shiftedIndex) != null)
+ if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null)
{
if (!this.mergeItemStack(var4, 0, 1, false))
{

View File

@ -0,0 +1,148 @@
--- ../src_base/minecraft/net/minecraft/src/EffectRenderer.java
+++ ../src_work/minecraft/net/minecraft/src/EffectRenderer.java
@@ -1,9 +1,19 @@
package net.minecraft.src;
import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Random;
+
+import net.minecraftforge.client.ForgeHooksClient;
+import net.minecraftforge.common.ForgeHooks;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
import org.lwjgl.opengl.GL11;
+
public class EffectRenderer
{
@@ -15,6 +25,8 @@
/** RNG. */
private Random rand = new Random();
+ private Multimap<String, EntityFX> effectList = ArrayListMultimap.create();
+
public EffectRenderer(World par1World, RenderEngine par2RenderEngine)
{
if (par1World != null)
@@ -55,6 +67,17 @@
{
this.fxLayers[var1].remove(var2--);
}
+ }
+ }
+
+ Iterator<Entry<String, EntityFX>> itr = effectList.entries().iterator();
+ while (itr.hasNext())
+ {
+ EntityFX fx = itr.next().getValue();
+ fx.onUpdate();
+ if (fx.isDead)
+ {
+ itr.remove();
}
}
}
@@ -109,6 +132,26 @@
var10.draw();
}
}
+
+ for (String key : effectList.keySet())
+ {
+ ForgeHooksClient.bindTexture(key, 0);
+ for (EntityFX entry : effectList.get(key))
+ {
+ Tessellator tessallator = Tessellator.instance;
+ //GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderer.getTexture(key));
+ tessallator.startDrawingQuads();
+
+ if (entry.getFXLayer() != 3)
+ {
+ tessallator.setBrightness(entry.getBrightnessForRender(par2));
+ entry.renderParticle(tessallator, par2, var3, var7, var4, var5, var6);
+ }
+
+ tessallator.draw();
+ }
+ ForgeHooksClient.unbindTexture();
+ }
}
public void func_78872_b(Entity par1Entity, float par2)
@@ -141,6 +184,8 @@
{
this.fxLayers[var2].clear();
}
+
+ effectList.clear();
}
public void addBlockDestroyEffects(int par1, int par2, int par3, int par4, int par5)
@@ -160,7 +205,7 @@
double var13 = (double)par2 + ((double)var9 + 0.5D) / (double)var7;
double var15 = (double)par3 + ((double)var10 + 0.5D) / (double)var7;
int var17 = this.rand.nextInt(6);
- this.addEffect((new EntityDiggingFX(this.worldObj, var11, var13, var15, var11 - (double)par1 - 0.5D, var13 - (double)par2 - 0.5D, var15 - (double)par3 - 0.5D, var6, var17, par5)).func_70596_a(par1, par2, par3));
+ this.addEffect((new EntityDiggingFX(this.worldObj, var11, var13, var15, var11 - (double)par1 - 0.5D, var13 - (double)par2 - 0.5D, var15 - (double)par3 - 0.5D, var6, var17, par5)).func_70596_a(par1, par2, par3), var6);
}
}
}
@@ -212,12 +257,51 @@
var8 = (double)par1 + var6.maxX + (double)var7;
}
- this.addEffect((new EntityDiggingFX(this.worldObj, var8, var10, var12, 0.0D, 0.0D, 0.0D, var6, par4, this.worldObj.getBlockMetadata(par1, par2, par3))).func_70596_a(par1, par2, par3).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
+ this.addEffect((new EntityDiggingFX(this.worldObj, var8, var10, var12, 0.0D, 0.0D, 0.0D, var6, par4, this.worldObj.getBlockMetadata(par1, par2, par3))).func_70596_a(par1, par2, par3).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F), var6);
}
}
public String getStatistics()
{
- return "" + (this.fxLayers[0].size() + this.fxLayers[1].size() + this.fxLayers[2].size());
+ int size = 0;
+ for (List x : fxLayers)
+ {
+ size += x.size();
+ }
+ size += effectList.size();
+ return Integer.toString(size);
+ }
+
+ public void addEffect(EntityFX effect, Object obj)
+ {
+ if (obj == null || !(obj instanceof Block || obj instanceof Item))
+ {
+ addEffect(effect);
+ return;
+ }
+
+ if (obj instanceof Item && ((Item)obj).isDefaultTexture)
+ {
+ addEffect(effect);
+ return;
+ }
+
+ if (obj instanceof Block && ((Block)obj).isDefaultTexture)
+ {
+ addEffect(effect);
+ return;
+ }
+
+ String texture = "/terrain.png";
+ if (effect.getFXLayer() == 0)
+ {
+ texture = "/particles.png";
+ }
+ else if (effect.getFXLayer() == 2)
+ {
+ texture = "/gui/items.png";
+ }
+ texture = ForgeHooks.getTexture(texture, obj);
+ effectList.put(texture, effect);
}
}

View File

@ -0,0 +1,17 @@
--- ../src_base/minecraft/net/minecraft/src/Enchantment.java
+++ ../src_work/minecraft/net/minecraft/src/Enchantment.java
@@ -191,4 +191,14 @@
String var2 = StatCollector.translateToLocal(this.getName());
return var2 + " " + StatCollector.translateToLocal("enchantment.level." + par1);
}
+
+ /**
+ * Called to determine if this enchantment can be applied to a ItemStack
+ * @param item The ItemStack that the enchantment might be put on
+ * @return True if the item is valid, false otherwise
+ */
+ public boolean canEnchantItem(ItemStack item)
+ {
+ return type.canEnchantItem(item.getItem());
+ }
}

View File

@ -0,0 +1,13 @@
--- ../src_base/minecraft/net/minecraft/src/EntityOcelot.java
+++ ../src_work/minecraft/net/minecraft/src/EntityOcelot.java
@@ -321,7 +321,9 @@
int var4 = this.worldObj.getBlockId(var1, var2 - 1, var3);
- if (var4 == Block.grass.blockID || var4 == Block.leaves.blockID)
+ Block block = Block.blocksList[var4];
+
+ if (var4 == Block.grass.blockID || (block != null && block.isLeaves(worldObj, var1, var2 - 1, var3)))
{
return true;
}

View File

@ -0,0 +1,36 @@
--- ../src_base/minecraft/net/minecraft/src/EntityPlayer.java
+++ ../src_work/minecraft/net/minecraft/src/EntityPlayer.java
@@ -2,6 +2,8 @@
import java.util.Iterator;
import java.util.List;
+
+import net.minecraftforge.common.ForgeHooks;
public abstract class EntityPlayer extends EntityLiving implements ICommandSender
{
@@ -673,13 +675,21 @@
/**
* Returns how strong the player is against the specified block at this moment
- */
+ * Deprecated in favor of the moresensitive version
+ */
+ @Deprecated
public float getCurrentPlayerStrVsBlock(Block par1Block)
{
- float var2 = this.inventory.getStrVsBlock(par1Block);
+ return getCurrentPlayerStrVsBlock(par1Block, 0);
+ }
+
+ public float getCurrentPlayerStrVsBlock(Block par1Block, int meta)
+ {
+ ItemStack stack = inventory.getCurrentItem();
+ float var2 = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta));
int var3 = EnchantmentHelper.getEfficiencyModifier(this.inventory);
- if (var3 > 0 && this.inventory.canHarvestBlock(par1Block))
+ if (var3 > 0 && ForgeHooks.canHarvestBlock(par1Block, this, meta))
{
var2 += (float)(var3 * var3 + 1);
}

View File

@ -0,0 +1,12 @@
--- ../src_base/minecraft/net/minecraft/src/ItemBlock.java
+++ ../src_work/minecraft/net/minecraft/src/ItemBlock.java
@@ -30,7 +30,8 @@
{
par7 = 1;
}
- else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID)
+ else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID
+ && (Block.blocksList[var11] != null && !Block.blocksList[var11].isBlockReplaceable(par3World, par4, par5, par6)))
{
if (par7 == 0)
{

View File

@ -0,0 +1,29 @@
--- ../src_base/minecraft/net/minecraft/src/ItemHoe.java
+++ ../src_work/minecraft/net/minecraft/src/ItemHoe.java
@@ -1,4 +1,7 @@
package net.minecraft.src;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.UseHoeEvent;
public class ItemHoe extends Item
{
@@ -21,6 +24,18 @@
}
else
{
+ UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (event.isCanceled())
+ {
+ return false;
+ }
+ if (event.isHandeled())
+ {
+ par1ItemStack.damageItem(1, par2EntityPlayer);
+ return true;
+ }
+
int var11 = par3World.getBlockId(par4, par5, par6);
int var12 = par3World.getBlockId(par4, par5 + 1, par6);

View File

@ -0,0 +1,25 @@
--- ../src_base/minecraft/net/minecraft/src/ItemTool.java
+++ ../src_work/minecraft/net/minecraft/src/ItemTool.java
@@ -1,4 +1,6 @@
package net.minecraft.src;
+
+import net.minecraftforge.common.ForgeHooks;
public class ItemTool extends Item
{
@@ -94,4 +96,15 @@
{
return this.toolMaterial.toString();
}
+
+ /** FORGE: Overridden to allow custom tool effectiveness */
+ @Override
+ public float getStrVsBlock(ItemStack stack, Block block, int meta)
+ {
+ if (ForgeHooks.isToolEffective(stack, block, meta))
+ {
+ return efficiencyOnProperMaterial;
+ }
+ return getStrVsBlock(stack, block);
+ }
}

View File

@ -0,0 +1,15 @@
--- ../src_base/minecraft/net/minecraft/src/StatList.java
+++ ../src_work/minecraft/net/minecraft/src/StatList.java
@@ -166,9 +166,9 @@
*/
private static StatBase[] initMinableStats(String par0Str, int par1)
{
- StatBase[] var2 = new StatBase[256];
-
- for (int var3 = 0; var3 < 256; ++var3)
+ StatBase[] var2 = new StatBase[Block.blocksList.length];
+
+ for (int var3 = 0; var3 < Block.blocksList.length; ++var3)
{
if (Block.blocksList[var3] != null && Block.blocksList[var3].getEnableStats())
{

View File

@ -0,0 +1,187 @@
--- ../src_base/minecraft/net/minecraft/src/Tessellator.java
+++ ../src_work/minecraft/net/minecraft/src/Tessellator.java
@@ -5,12 +5,20 @@
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
+import java.util.Arrays;
+
import org.lwjgl.opengl.ARBVertexBufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GLContext;
public class Tessellator
{
+ private static int nativeBufferSize = 0x200000;
+ private static int trivertsInBuffer = (nativeBufferSize / 48) * 6;
+ public static boolean renderingWorldRenderer = false;
+ public boolean defaultTexture = false;
+ private int rawBufferSize = 0;
+ public int textureID = 0;
/**
* Boolean used to check whether quads should be drawn as four triangles. Initialized to true and never changed.
*/
@@ -22,16 +30,16 @@
private static boolean tryVBO = false;
/** The byte buffer used for GL allocation. */
- private ByteBuffer byteBuffer;
+ private static ByteBuffer byteBuffer = GLAllocation.createDirectByteBuffer(nativeBufferSize * 4);
/** The same memory as byteBuffer, but referenced as an integer buffer. */
- private IntBuffer intBuffer;
+ private static IntBuffer intBuffer = byteBuffer.asIntBuffer();
/** The same memory as byteBuffer, but referenced as an float buffer. */
- private FloatBuffer floatBuffer;
+ private static FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();
/** Short buffer */
- private ShortBuffer shortBuffer;
+ private static ShortBuffer shortBuffer = byteBuffer.asShortBuffer();
/** Raw integer array. */
private int[] rawBuffer;
@@ -107,10 +115,10 @@
public boolean isDrawing = false;
/** Whether we are currently using VBO or not. */
- private boolean useVBO = false;
+ private static boolean useVBO = false;
/** An IntBuffer used to store the indices of vertex buffer objects. */
- private IntBuffer vertexBuffers;
+ private static IntBuffer vertexBuffers;
/**
* The index of the last VBO used. This is used in round-robin fashion, sequentially, through the vboCount vertex
@@ -119,25 +127,28 @@
private int vboIndex = 0;
/** Number of vertex buffer objects allocated for use. */
- private int vboCount = 10;
+ private static int vboCount = 10;
/** The size of the buffers used (in integers). */
private int bufferSize;
private Tessellator(int par1)
{
- this.bufferSize = par1;
- this.byteBuffer = GLAllocation.createDirectByteBuffer(par1 * 4);
- this.intBuffer = this.byteBuffer.asIntBuffer();
- this.floatBuffer = this.byteBuffer.asFloatBuffer();
- this.shortBuffer = this.byteBuffer.asShortBuffer();
- this.rawBuffer = new int[par1];
- this.useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
-
- if (this.useVBO)
- {
- this.vertexBuffers = GLAllocation.createDirectIntBuffer(this.vboCount);
- ARBVertexBufferObject.glGenBuffersARB(this.vertexBuffers);
+ }
+
+ public Tessellator()
+ {
+ }
+
+ static
+ {
+ instance.defaultTexture = true;
+ useVBO = tryVBO && GLContext.getCapabilities().GL_ARB_vertex_buffer_object;
+
+ if (useVBO)
+ {
+ vertexBuffers = GLAllocation.createDirectIntBuffer(vboCount);
+ ARBVertexBufferObject.glGenBuffersARB(vertexBuffers);
}
}
@@ -154,12 +165,23 @@
{
this.isDrawing = false;
- if (this.vertexCount > 0)
- {
+ int offs = 0;
+ while (offs < vertexCount)
+ {
+ int vtc = 0;
+ if (drawMode == 7 && convertQuadsToTriangles)
+ {
+ vtc = Math.min(vertexCount - offs, trivertsInBuffer);
+ }
+ else
+ {
+ vtc = Math.min(vertexCount - offs, nativeBufferSize >> 5);
+ }
this.intBuffer.clear();
- this.intBuffer.put(this.rawBuffer, 0, this.rawBufferIndex);
+ this.intBuffer.put(this.rawBuffer, offs * 8, vtc * 8);
this.byteBuffer.position(0);
- this.byteBuffer.limit(this.rawBufferIndex * 4);
+ this.byteBuffer.limit(vtc * 32);
+ offs += vtc;
if (this.useVBO)
{
@@ -245,11 +267,11 @@
if (this.drawMode == 7 && convertQuadsToTriangles)
{
- GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.vertexCount);
+ GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vtc);
}
else
{
- GL11.glDrawArrays(this.drawMode, 0, this.vertexCount);
+ GL11.glDrawArrays(this.drawMode, 0, vtc);
}
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
@@ -275,6 +297,12 @@
{
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
}
+ }
+
+ if (rawBufferSize > 0x20000 && rawBufferIndex < (rawBufferSize << 3))
+ {
+ rawBufferSize = 0;
+ rawBuffer = null;
}
int var1 = this.rawBufferIndex * 4;
@@ -439,6 +467,19 @@
*/
public void addVertex(double par1, double par3, double par5)
{
+ if (rawBufferIndex >= rawBufferSize - 32)
+ {
+ if (rawBufferSize == 0)
+ {
+ rawBufferSize = 0x10000;
+ rawBuffer = new int[rawBufferSize];
+ }
+ else
+ {
+ rawBufferSize *= 2;
+ rawBuffer = Arrays.copyOf(rawBuffer, rawBufferSize);
+ }
+ }
++this.addedVertices;
if (this.drawMode == 7 && convertQuadsToTriangles && this.addedVertices % 4 == 0)
@@ -497,12 +538,6 @@
this.rawBuffer[this.rawBufferIndex + 2] = Float.floatToRawIntBits((float)(par5 + this.zOffset));
this.rawBufferIndex += 8;
++this.vertexCount;
-
- if (this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32)
- {
- this.draw();
- this.isDrawing = true;
- }
}
/**

View File

@ -0,0 +1,32 @@
--- ../src_base/minecraft/net/minecraft/src/TileEntity.java
+++ ../src_work/minecraft/net/minecraft/src/TileEntity.java
@@ -243,4 +243,29 @@
addMapping(TileEntityEnchantmentTable.class, "EnchantTable");
addMapping(TileEntityEndPortal.class, "Airportal");
}
+
+ /**
+ * Determines if this TileEntity requires update calls.
+ * @return True if you want updateEntity() to be called, false if not
+ */
+ public boolean canUpdate()
+ {
+ return true;
+ }
+
+ /**
+ * Called when you receive a TileEntityData packet for the location this
+ * TileEntity is currently in. On the client, the NetworkManager will always
+ * be the remote server. On the server, it will be whomever is responsible for
+ * sending the packet.
+ *
+ * @param net The NetworkManager the packet originated from
+ * @param pkt The data packet
+ */
+ public void onDataPacket(NetworkManager net, Packet132TileEntityData pkt){}
+
+ /**
+ * Called when the chunk this TileEntity is on is Unloaded.
+ */
+ public void onChunkUnload(){}
}

View File

@ -1,6 +1,24 @@
--- ../src_base/minecraft/net/minecraft/src/World.java
+++ ../src_work/minecraft/net/minecraft/src/World.java
@@ -273,7 +273,8 @@
@@ -8,8 +8,17 @@
import java.util.Random;
import java.util.Set;
+import net.minecraftforge.common.Orientation;
+
public abstract class World implements IBlockAccess
{
+ /**
+ * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
+ * Modders should change this variable to a higher value if it is less then the radius
+ * of one of there entities.
+ */
+ public static double MAX_ENTITY_RADIUS = 2.0D;
+
/**
* boolean; if true updates scheduled by scheduleBlockUpdate happen immediately
*/
@@ -273,7 +282,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3)
{
int var4 = this.getBlockId(par1, par2, par3);
@ -10,3 +28,79 @@
}
/**
@@ -2562,8 +2572,7 @@
*/
public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3)
{
- Block var4 = Block.blocksList[this.getBlockId(par1, par2, par3)];
- return var4 == null ? false : (var4.blockMaterial.isOpaque() && var4.renderAsNormalBlock() ? true : (var4 instanceof BlockStairs ? (this.getBlockMetadata(par1, par2, par3) & 4) == 4 : (var4 instanceof BlockHalfSlab ? (this.getBlockMetadata(par1, par2, par3) & 8) == 8 : false)));
+ return isBlockSolidOnSide(par1, par2, par3, Orientation.UP);
}
/**
@@ -3917,4 +3926,65 @@
var7.destroyBlockPartially(par1, par2, par3, par4, par5);
}
}
+
+ /**
+ * Adds a single TileEntity to the world.
+ * @param entity The TileEntity to be added.
+ */
+ public void addTileEntity(TileEntity entity)
+ {
+ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList;
+ if(entity.canUpdate())
+ {
+ dest.add(entity);
+ }
+ }
+
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param X Block X Position
+ * @param Y Block Y Position
+ * @param Z Block Z Position
+ * @param side The Side in question
+ * @return True if the side is solid
+ */
+ public boolean isBlockSolidOnSide(int X, int Y, int Z, Orientation side)
+ {
+ return isBlockSolidOnSide(X, Y, Z, side, false);
+ }
+
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param X Block X Position
+ * @param Y Block Y Position
+ * @param Z Block Z Position
+ * @param side The Side in question
+ * @param _default The defult to return if the block doesn't exist.
+ * @return True if the side is solid
+ */
+ public boolean isBlockSolidOnSide(int X, int Y, int Z, Orientation side, boolean _default)
+ {
+ if (X < -30000000 || Z < -30000000 || X >= 30000000 || Z >= 30000000)
+ {
+ return _default;
+ }
+
+ Chunk var5 = this.chunkProvider.provideChunk(X >> 4, Z >> 4);
+ if (var5 == null || var5.isEmpty())
+ {
+ return _default;
+ }
+
+ Block block = Block.blocksList[getBlockId(X, Y, Z)];
+ if(block == null)
+ {
+ return false;
+ }
+
+ return block.isBlockSolidOnSide(this, X, Y, Z, side);
+ }
}

View File

@ -0,0 +1,85 @@
--- ../src_base/minecraft/net/minecraft/src/WorldProvider.java
+++ ../src_work/minecraft/net/minecraft/src/WorldProvider.java
@@ -177,7 +177,7 @@
public static WorldProvider getProviderForDimension(int par0)
{
- return (WorldProvider)(par0 == -1 ? new WorldProviderHell() : (par0 == 0 ? new WorldProviderSurface() : (par0 == 1 ? new WorldProviderEnd() : null)));
+ return DimensionManager.createProviderFor(par0);
}
/**
@@ -232,4 +232,73 @@
{
return false;
}
+
+ /**
+ * Returns the sub-folder of the world folder that this WorldProvider saves to.
+ * EXA: DIM1, DIM-1
+ * @return The sub-folder name to save this world's chunks to.
+ */
+ public String getSaveFolder()
+ {
+ if (this instanceof WorldProviderEnd)
+ {
+ return "DIM1";
+ }
+ else if (this instanceof WorldProviderHell)
+ {
+ return "DIM-1";
+ }
+ return null;
+ }
+
+ /**
+ * A message to display to the user when they transfer to this dimension.
+ *
+ * @return The message to be displayed
+ */
+ public String getWelcomeMessage()
+ {
+ if (this instanceof WorldProviderEnd)
+ {
+ return "Entering the End";
+ }
+ else if (this instanceof WorldProviderHell)
+ {
+ return "Entering the Nether";
+ }
+ return null;
+ }
+
+ /**
+ * A Message to display to the user when they transfer out of this dismension.
+ *
+ * @return The message to be displayed
+ */
+ public String getDepartMessage()
+ {
+ if (this instanceof WorldProviderEnd)
+ {
+ return "Leaving the End";
+ }
+ else if (this instanceof WorldProviderHell)
+ {
+ return "Leaving the Nether";
+ }
+ return null;
+ }
+
+ /**
+ * The dimensions movement factor. Relative to normal overworld.
+ * It is applied to the players position when they transfer dimensions.
+ * Exa: Nether movement is 8.0
+ * @return The movement factor
+ */
+ public double getMovementFactor()
+ {
+ if (this instanceof WorldProviderHell)
+ {
+ return 8.0;
+ }
+ return 1.0;
+ }
}

View File

@ -265,7 +265,7 @@
List var4 = var1[var3];
this.worldObj.addLoadedEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Load(this));
+ MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
}
/**
@ -273,7 +273,7 @@
List var4 = var5[var3];
this.worldObj.unloadEntities(var4);
}
+ MinecraftForge.eventBus.post(new ChunkEvent.Unload(this));
+ MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this));
}
/**

View File

@ -1,6 +1,24 @@
--- ../src_base/minecraft_server/net/minecraft/src/World.java
+++ ../src_work/minecraft_server/net/minecraft/src/World.java
@@ -248,7 +248,8 @@
@@ -8,8 +8,17 @@
import java.util.Random;
import java.util.Set;
+import net.minecraftforge.common.Orientation;
+
public abstract class World implements IBlockAccess
{
+ /**
+ * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
+ * Modders should change this variable to a higher value if it is less then the radius
+ * of one of there entities.
+ */
+ public static double MAX_ENTITY_RADIUS = 2.0D;
+
/**
* boolean; if true updates scheduled by scheduleBlockUpdate happen immediately
*/
@@ -248,7 +257,8 @@
public boolean blockHasTileEntity(int par1, int par2, int par3)
{
int var4 = this.getBlockId(par1, par2, par3);
@ -10,3 +28,69 @@
}
/**
@@ -3515,4 +3525,65 @@
var7.destroyBlockPartially(par1, par2, par3, par4, par5);
}
}
+
+ /**
+ * Adds a single TileEntity to the world.
+ * @param entity The TileEntity to be added.
+ */
+ public void addTileEntity(TileEntity entity)
+ {
+ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList;
+ if(entity.canUpdate())
+ {
+ dest.add(entity);
+ }
+ }
+
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param X Block X Position
+ * @param Y Block Y Position
+ * @param Z Block Z Position
+ * @param side The Side in question
+ * @return True if the side is solid
+ */
+ public boolean isBlockSolidOnSide(int X, int Y, int Z, Orientation side)
+ {
+ return isBlockSolidOnSide(X, Y, Z, side, false);
+ }
+
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param X Block X Position
+ * @param Y Block Y Position
+ * @param Z Block Z Position
+ * @param side The Side in question
+ * @param _default The defult to return if the block doesn't exist.
+ * @return True if the side is solid
+ */
+ public boolean isBlockSolidOnSide(int X, int Y, int Z, Orientation side, boolean _default)
+ {
+ if (X < -30000000 || Z < -30000000 || X >= 30000000 || Z >= 30000000)
+ {
+ return _default;
+ }
+
+ Chunk var5 = this.chunkProvider.provideChunk(X >> 4, Z >> 4);
+ if (var5 == null || var5.isEmpty())
+ {
+ return _default;
+ }
+
+ Block block = Block.blocksList[getBlockId(X, Y, Z)];
+ if(block == null)
+ {
+ return false;
+ }
+
+ return block.isBlockSolidOnSide(this, X, Y, Z, side);
+ }
}