mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Updates:
- Added warning message for non-preloaded textures. - Documentation - Ladder fix for SMP. - Obsoleted IBlockSecondaryProperties - Added hooks for place-by-side. - Fixed texture 3 and piston texture bug. - Added new tool system.
This commit is contained in:
1 parent
fb5f9373c5
commit
12b64fa287
6 files changed
+1823
-273
No files matched your search
@@ -79,6 +79,7 @@ public class ForgeHooksClient {
|
||||
|
||||
public static void beforeRenderPass(int pass) {
|
||||
Tessellator.instance=Tessellator.firstInstance;
|
||||
Tessellator.renderingWorldRenderer=true;
|
||||
GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, ModLoader
|
||||
.getMinecraftInstance().renderEngine
|
||||
.getTexture("/terrain.png"));
|
||||
@@ -100,6 +101,7 @@ public class ForgeHooksClient {
|
||||
.getMinecraftInstance().renderEngine
|
||||
.getTexture("/terrain.png"));
|
||||
Tessellator.instance=Tessellator.firstInstance;
|
||||
Tessellator.renderingWorldRenderer=false;
|
||||
}
|
||||
|
||||
public static void beforeBlockRender(Block block,
|
||||
@@ -115,7 +117,7 @@ public class ForgeHooksClient {
|
||||
RenderBlocks renderblocks) {
|
||||
if (block instanceof ITextureProvider
|
||||
&& renderblocks.overrideBlockTexture == -1) {
|
||||
Tessellator.instance=Tessellator.firstInstance;
|
||||
unbindTexture();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,20 +12,43 @@ import net.minecraft.src.Tessellator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class MinecraftForgeClient {
|
||||
/** Bind a texture. This is used to bind a texture file when
|
||||
* performing your own rendering, rather than using ITextureProvider.
|
||||
*
|
||||
* This variation is reserved for future expansion.
|
||||
*/
|
||||
public static void bindTexture(String name, int sub) {
|
||||
ForgeHooksClient.bindTexture(name,sub);
|
||||
}
|
||||
|
||||
/** Bind a texture. This is used to bind a texture file when
|
||||
* performing your own rendering, rather than using ITextureProvider.
|
||||
*/
|
||||
public static void bindTexture(String name) {
|
||||
ForgeHooksClient.bindTexture(name,0);
|
||||
}
|
||||
|
||||
/** Unbind a texture. This binds the default texture, when you are
|
||||
* finished performing custom rendering.
|
||||
*/
|
||||
public static void unbindTexture() {
|
||||
ForgeHooksClient.unbindTexture();
|
||||
}
|
||||
|
||||
/** Preload a texture. Textures must be preloaded before the first
|
||||
* use, or they will cause visual anomalies.
|
||||
*/
|
||||
public static void preloadTexture(String texture) {
|
||||
ModLoader.getMinecraftInstance().renderEngine
|
||||
.getTexture(texture);
|
||||
}
|
||||
|
||||
/** Render a block. Render a block which may have a custom texture.
|
||||
*/
|
||||
public static void renderBlock(RenderBlocks rb, Block bl, int i, int
|
||||
j, int k) {
|
||||
ForgeHooksClient.beforeBlockRender(bl,rb);
|
||||
rb.renderBlockByRenderType(bl,i,j,k);
|
||||
ForgeHooksClient.afterBlockRender(bl,rb);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import net.minecraft.src.World;
|
||||
/**
|
||||
* This interface provides access to a number of secondary block properties through providing
|
||||
* overrides to methods within world.class.
|
||||
*
|
||||
* This interface is DEPRECATED. The functions are now provided directly by
|
||||
* Block.
|
||||
*/
|
||||
|
||||
public interface IBlockSecondaryProperties
|
||||
|
||||
@@ -1,23 +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.ItemTool;
|
||||
|
||||
public interface IHarvestHandler {
|
||||
|
||||
/**
|
||||
* Return true if the tool in parameter is known to be able to harvest
|
||||
* the given block, false if this handler does not know of any particular
|
||||
* harvesting. Other rules may activate the harvesting outside of this
|
||||
* handler. This is typically used to add e.g. blocks only extracted by
|
||||
* diamond pickaxe
|
||||
*
|
||||
* @see MinecraftForge#registerHarvestHandler(IHarvestHandler)
|
||||
*/
|
||||
public boolean canHarvestBlock(ItemTool item, Block block);
|
||||
}
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraft.src.forge;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
@@ -14,10 +12,11 @@ import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.ItemTool;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MinecraftForge {
|
||||
|
||||
private static LinkedList<IBucketHandler> bucketHandlers = new LinkedList<IBucketHandler>();
|
||||
private static LinkedList<IHarvestHandler> harvestHandlers = new LinkedList<IHarvestHandler>();
|
||||
|
||||
/**
|
||||
* Registers a new custom bucket handler.
|
||||
@@ -25,13 +24,6 @@ public class MinecraftForge {
|
||||
public static void registerCustomBucketHander(IBucketHandler handler) {
|
||||
bucketHandlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new harvest handler.
|
||||
*/
|
||||
public static void registerHarvestHandler(IHarvestHandler handler) {
|
||||
harvestHandlers.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not supposed to be called outside of Minecraft internals.
|
||||
@@ -48,28 +40,100 @@ public class MinecraftForge {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not supposed to be called outside of Minecraft internals.
|
||||
/** Register a tool as a tool class with a given harvest level.
|
||||
*
|
||||
* @param tool The custom tool to register.
|
||||
* @param tclass The tool class to register as. The predefined tool
|
||||
* clases are "pickaxe", "shovel", "axe". You can add others for custom
|
||||
* tools.
|
||||
* @param hlevel The harvest level of the tool.
|
||||
*/
|
||||
public static boolean canHarvestBlock(ItemTool item, Block block) {
|
||||
for (IHarvestHandler handler : harvestHandlers) {
|
||||
if (handler.canHarvestBlock(item, block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
public static void setToolClass(Item tool, String tclass, int hlevel) {
|
||||
ForgeHooks.initTools();
|
||||
ForgeHooks.toolClasses.put(tool.shiftedIndex,
|
||||
Arrays.asList(tclass,hlevel));
|
||||
}
|
||||
|
||||
/** 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 bl The block to register.
|
||||
* @param md The metadata for the block subtype.
|
||||
* @param tclass 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 hlevel The minimum tool harvest level required to successfully
|
||||
* harvest the block.
|
||||
* @see setToolClass for details on tool classes.
|
||||
*/
|
||||
public static void setBlockHarvestLevel(Block bl, int md, String tclass,
|
||||
int hlevel) {
|
||||
ForgeHooks.initTools();
|
||||
List key=Arrays.asList(bl.blockID,md,tclass);
|
||||
ForgeHooks.toolHarvestLevels.put(key,hlevel);
|
||||
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 bl The block to remove effectiveness from.
|
||||
* @param md The metadata for the block subtype.
|
||||
* @param tclass The tool class to remove the effectiveness mapping from.
|
||||
* @see setToolClass for details on tool classes.
|
||||
*/
|
||||
public static void removeBlockEffectiveness(Block bl, int md,
|
||||
String tclass) {
|
||||
ForgeHooks.initTools();
|
||||
List key=Arrays.asList(bl.blockID,md,tclass);
|
||||
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 bl The block to register.
|
||||
* @param tclass 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 hlevel The minimum tool harvest level required to successfully
|
||||
* harvest the block.
|
||||
* @see setToolClass for details on tool classes.
|
||||
*/
|
||||
public static void setBlockHarvestLevel(Block bl, String tclass,
|
||||
int hlevel) {
|
||||
ForgeHooks.initTools();
|
||||
for(int md=0; md<16; md++) {
|
||||
List key=Arrays.asList(bl.blockID,md,tclass);
|
||||
ForgeHooks.toolHarvestLevels.put(key,hlevel);
|
||||
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 bl The block to remove effectiveness from.
|
||||
* @param tclass The tool class to remove the effectiveness mapping from.
|
||||
* @see setToolClass for details on tool classes.
|
||||
*/
|
||||
public static void removeBlockEffectiveness(Block bl, String tclass) {
|
||||
ForgeHooks.initTools();
|
||||
for(int md=0; md<16; md++) {
|
||||
List key=Arrays.asList(bl.blockID,md,tclass);
|
||||
ForgeHooks.toolEffectiveness.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a block to the list of blocks to which the pickaxe is know to be
|
||||
* effective.
|
||||
* This function is deprecated and will be removed eventually.
|
||||
*/
|
||||
public static void addPickaxeBlockEffectiveAgainst (Block block) {
|
||||
((ItemTool) Item.pickaxeWood).addBlockEffectiveAgainst(block);
|
||||
((ItemTool) Item.pickaxeStone).addBlockEffectiveAgainst(block);
|
||||
((ItemTool) Item.pickaxeSteel).addBlockEffectiveAgainst(block);
|
||||
((ItemTool) Item.pickaxeGold).addBlockEffectiveAgainst(block);
|
||||
((ItemTool) Item.pickaxeDiamond).addBlockEffectiveAgainst(block);
|
||||
setBlockHarvestLevel(block,"pickaxe",0);
|
||||
}
|
||||
}
|
||||
+1703
-222
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user