Handler for custom block highlight.

This commit is contained in:
Eloraam 2011-08-20 10:35:14 +00:00
parent 651af86795
commit 4cdb1cb3d0
4 changed files with 85 additions and 1 deletions

View file

@ -9,11 +9,29 @@ import net.minecraft.src.Block;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
import net.minecraft.src.RenderBlocks; import net.minecraft.src.RenderBlocks;
import net.minecraft.src.Tessellator; import net.minecraft.src.Tessellator;
import net.minecraft.src.RenderGlobal;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.MovingObjectPosition;
import net.minecraft.src.ItemStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.util.*; import java.util.*;
public class ForgeHooksClient { public class ForgeHooksClient {
public static boolean onBlockHighlight(RenderGlobal renderglobal,
EntityPlayer player, MovingObjectPosition mop, int i,
ItemStack itemstack, float f) {
for (IHighlightHandler handler : highlightHandlers) {
if(handler.onBlockHighlight(renderglobal,player,mop,
i,itemstack,f))
return true;
}
return false;
}
static LinkedList<IHighlightHandler> highlightHandlers = new LinkedList<IHighlightHandler>();
public static boolean canRenderInPass(Block block, int pass) { public static boolean canRenderInPass(Block block, int pass) {
if(block instanceof IMultipassRender) { if(block instanceof IMultipassRender) {
IMultipassRender impr = (IMultipassRender) block; IMultipassRender impr = (IMultipassRender) block;
@ -23,7 +41,6 @@ public class ForgeHooksClient {
return false; return false;
} }
static HashMap tessellators=new HashMap(); static HashMap tessellators=new HashMap();
static HashMap textures=new HashMap(); static HashMap textures=new HashMap();
static boolean inWorld=false; static boolean inWorld=false;

View file

@ -0,0 +1,23 @@
/*
* This software is provided under the terms of the Minecraft Forge Public
* License v1.0.
*/
package net.minecraft.src.forge;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumStatus;
import net.minecraft.src.RenderGlobal;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.MovingObjectPosition;
import net.minecraft.src.ItemStack;
public interface IHighlightHandler {
/**
* Allow custom handling of highlights. Return true if the hilight has
* been handled.
*/
public boolean onBlockHighlight(RenderGlobal renderglobal,
EntityPlayer player, MovingObjectPosition mop, int i,
ItemStack itemstack, float f);
}

View file

@ -12,6 +12,13 @@ import net.minecraft.src.Tessellator;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class MinecraftForgeClient { public class MinecraftForgeClient {
/**
* Registers a new block highlight handler.
*/
public static void registerHighlightHandler(IHighlightHandler handler) {
ForgeHooksClient.highlightHandlers.add(handler);
}
/** Bind a texture. This is used to bind a texture file when /** Bind a texture. This is used to bind a texture file when
* performing your own rendering, rather than using ITextureProvider. * performing your own rendering, rather than using ITextureProvider.
* *

View file

@ -1044,6 +1044,43 @@ diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EntityPla
if(!worldObj.multiplayerWorld) if(!worldObj.multiplayerWorld)
{ {
if(isPlayerSleeping() || !isEntityAlive()) if(isPlayerSleeping() || !isEntityAlive())
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/EntityRenderer.java ../src_work/minecraft/net/minecraft/src/EntityRenderer.java
--- ../src_base/minecraft/net/minecraft/src/EntityRenderer.java 2011-08-11 17:02:11.000000000 -0400
+++ ../src_work/minecraft/net/minecraft/src/EntityRenderer.java 2011-08-20 06:25:56.000000000 -0400
@@ -3,6 +3,7 @@
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
+import net.minecraft.src.forge.ForgeHooksClient;
import java.nio.FloatBuffer;
import java.util.List;
@@ -573,8 +574,12 @@
{
EntityPlayer entityplayer = (EntityPlayer)entityliving;
GL11.glDisable(3008 /*GL_ALPHA_TEST*/);
+ if(!ForgeHooksClient.onBlockHighlight(renderglobal,entityplayer,
+ mc.objectMouseOver,0,
+ entityplayer.inventory.getCurrentItem(),f)) {
renderglobal.drawBlockBreaking(entityplayer, mc.objectMouseOver, 0, entityplayer.inventory.getCurrentItem(), f);
renderglobal.drawSelectionBox(entityplayer, mc.objectMouseOver, 0, entityplayer.inventory.getCurrentItem(), f);
+ }
GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
}
GL11.glBlendFunc(770, 771);
@@ -619,8 +624,12 @@
{
EntityPlayer entityplayer1 = (EntityPlayer)entityliving;
GL11.glDisable(3008 /*GL_ALPHA_TEST*/);
+ if(!ForgeHooksClient.onBlockHighlight(renderglobal,entityplayer1,
+ mc.objectMouseOver,0,
+ entityplayer1.inventory.getCurrentItem(),f)) {
renderglobal.drawBlockBreaking(entityplayer1, mc.objectMouseOver, 0, entityplayer1.inventory.getCurrentItem(), f);
renderglobal.drawSelectionBox(entityplayer1, mc.objectMouseOver, 0, entityplayer1.inventory.getCurrentItem(), f);
+ }
GL11.glEnable(3008 /*GL_ALPHA_TEST*/);
}
renderRainSnow(f);
diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Explosion.java ../src_work/minecraft/net/minecraft/src/Explosion.java diff -u -r --strip-trailing-cr ../src_base/minecraft/net/minecraft/src/Explosion.java ../src_work/minecraft/net/minecraft/src/Explosion.java
--- ../src_base/minecraft/net/minecraft/src/Explosion.java 2011-08-11 17:02:11.000000000 -0400 --- ../src_base/minecraft/net/minecraft/src/Explosion.java 2011-08-11 17:02:11.000000000 -0400
+++ ../src_work/minecraft/net/minecraft/src/Explosion.java 2011-08-11 17:02:12.000000000 -0400 +++ ../src_work/minecraft/net/minecraft/src/Explosion.java 2011-08-11 17:02:12.000000000 -0400