Merge branch 'NextGen' of https://github.com/anti344/BuildCraft into anti344-NextGen
This commit is contained in:
commit
2a2aec3a79
5 changed files with 197 additions and 2 deletions
|
@ -244,6 +244,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
||||||
}
|
}
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
MinecraftForge.EVENT_BUS.register(new BlockHighlightHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
12
common/buildcraft/core/ICustomHighlight.java
Normal file
12
common/buildcraft/core/ICustomHighlight.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package buildcraft.core;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface ICustomHighlight{
|
||||||
|
|
||||||
|
public AxisAlignedBB[] getBoxes(World wrd, int x, int y, int z, EntityPlayer player);
|
||||||
|
|
||||||
|
public double getExpansion();
|
||||||
|
}
|
45
common/buildcraft/core/render/BlockHighlightHandler.java
Normal file
45
common/buildcraft/core/render/BlockHighlightHandler.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
package buildcraft.core.render;
|
||||||
|
|
||||||
|
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import buildcraft.core.ICustomHighlight;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class BlockHighlightHandler{
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void handleBlockHighlight(DrawBlockHighlightEvent e){
|
||||||
|
if (e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){
|
||||||
|
int x = e.target.blockX;
|
||||||
|
int y = e.target.blockY;
|
||||||
|
int z = e.target.blockZ;
|
||||||
|
Block block = e.player.worldObj.getBlock(x, y, z);
|
||||||
|
if (block instanceof ICustomHighlight) {
|
||||||
|
AxisAlignedBB[] aabbs = ((ICustomHighlight)block).getBoxes(e.player.worldObj, x, y, z, e.player);
|
||||||
|
Vec3 pos = e.player.getPosition(e.partialTicks);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||||
|
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
|
||||||
|
GL11.glLineWidth(2.0F);
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
double exp = ((ICustomHighlight)block).getExpansion();
|
||||||
|
for (AxisAlignedBB aabb : aabbs) {
|
||||||
|
RenderGlobal.drawOutlinedBoundingBox(aabb.copy().expand(exp, exp, exp)
|
||||||
|
.offset(x, y, z)
|
||||||
|
.offset(-pos.xCoord, -pos.yCoord, -pos.zCoord), -1);
|
||||||
|
}
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
e.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,24 @@ import buildcraft.core.CreativeTabBuildCraft;
|
||||||
import buildcraft.core.IItemPipe;
|
import buildcraft.core.IItemPipe;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import buildcraft.core.ICustomHighlight;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
public class BlockEngine extends BlockBuildCraft {
|
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||||
|
|
||||||
|
public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
||||||
|
|
||||||
|
private static final AxisAlignedBB[][] boxes = {
|
||||||
|
{getBoundingBox(0.0, 0.5, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)},// -Y
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.5, 1.0), getBoundingBox(0.25, 0.5, 0.25, 0.75, 1.0, 0.75)},// +Y
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.5, 1.0, 1.0, 1.0), getBoundingBox(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)},// -Z
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.5), getBoundingBox(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)},// +Z
|
||||||
|
{getBoundingBox(0.5, 0.0, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)},// -X
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 0.5, 1.0, 1.0), getBoundingBox(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)} // +X
|
||||||
|
};
|
||||||
|
|
||||||
private static IIcon woodTexture;
|
private static IIcon woodTexture;
|
||||||
private static IIcon stoneTexture;
|
private static IIcon stoneTexture;
|
||||||
|
@ -121,6 +137,65 @@ public class BlockEngine extends BlockBuildCraft {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void addCollisionBoxesToList(World wrd, int x, int y, int z, AxisAlignedBB mask, List list, Entity ent) {
|
||||||
|
TileEntity tile = wrd.getTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEngine){
|
||||||
|
AxisAlignedBB[] aabbs = boxes[((TileEngine)tile).orientation.ordinal()];
|
||||||
|
for (AxisAlignedBB aabb : aabbs) {
|
||||||
|
aabb = aabb.getOffsetBoundingBox(x, y, z);
|
||||||
|
if (mask.intersectsWith(aabb)){
|
||||||
|
list.add(aabb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.addCollisionBoxesToList(wrd, x, y, z, mask, list, ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB[] getBoxes(World wrd, int x, int y, int z, EntityPlayer player) {
|
||||||
|
TileEntity tile = wrd.getTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEngine) {
|
||||||
|
return boxes[((TileEngine)tile).orientation.ordinal()];
|
||||||
|
} else {
|
||||||
|
return new AxisAlignedBB[]{AxisAlignedBB.getAABBPool().getAABB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getExpansion() {
|
||||||
|
return 0.0075;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MovingObjectPosition collisionRayTrace(World wrd, int x, int y, int z, Vec3 origin, Vec3 direction) {
|
||||||
|
TileEntity tile = wrd.getTileEntity(x, y, z);
|
||||||
|
if (tile instanceof TileEngine){
|
||||||
|
AxisAlignedBB[] aabbs = boxes[((TileEngine)tile).orientation.ordinal()];
|
||||||
|
MovingObjectPosition closest = null;
|
||||||
|
for(AxisAlignedBB aabb : aabbs){
|
||||||
|
MovingObjectPosition mop = aabb.getOffsetBoundingBox(x, y, z).calculateIntercept(origin, direction);
|
||||||
|
if(mop != null){
|
||||||
|
if (closest != null && mop.hitVec.distanceTo(origin) < closest.hitVec.distanceTo(origin)) {
|
||||||
|
closest = mop;
|
||||||
|
} else {
|
||||||
|
closest = mop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (closest != null){
|
||||||
|
closest.blockX = x;
|
||||||
|
closest.blockY = y;
|
||||||
|
closest.blockZ = z;
|
||||||
|
}
|
||||||
|
return closest;
|
||||||
|
} else {
|
||||||
|
return super.collisionRayTrace(wrd, x, y, z, origin, direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
||||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
||||||
|
|
|
@ -18,8 +18,26 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import buildcraft.core.CreativeTabBuildCraft;
|
import buildcraft.core.CreativeTabBuildCraft;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import buildcraft.core.ICustomHighlight;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockLaser extends BlockContainer {
|
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||||
|
|
||||||
|
public class BlockLaser extends BlockContainer implements ICustomHighlight {
|
||||||
|
|
||||||
|
private static final AxisAlignedBB[][] boxes = {
|
||||||
|
{getBoundingBox(0.0, 0.75, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.3125, 0.1875, 0.3125, 0.6875, 0.75, 0.6875)},// -Y
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 1.0, 0.25, 1.0), getBoundingBox(0.3125, 0.25, 0.3125, 0.6875, 0.8125, 0.6875)},// +Y
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.75, 1.0, 1.0, 1.0), getBoundingBox(0.3125, 0.3125, 0.1875, 0.6875, 0.6875, 0.75)},// -Z
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 0.25), getBoundingBox(0.3125, 0.3125, 0.25, 0.6875, 0.6875, 0.8125)},// +Z
|
||||||
|
{getBoundingBox(0.75, 0.0, 0.0, 1.0, 1.0, 1.0), getBoundingBox(0.1875, 0.3125, 0.3125, 0.75, 0.6875, 0.6875)},// -X
|
||||||
|
{getBoundingBox(0.0, 0.0, 0.0, 0.25, 1.0, 1.0), getBoundingBox(0.25, 0.3125, 0.3125, 0.8125, 0.6875, 0.6875)} // +X
|
||||||
|
};
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
private IIcon textureTop, textureBottom, textureSide;
|
private IIcon textureTop, textureBottom, textureSide;
|
||||||
|
@ -30,6 +48,50 @@ public class BlockLaser extends BlockContainer {
|
||||||
setCreativeTab(CreativeTabBuildCraft.TIER_3.get());
|
setCreativeTab(CreativeTabBuildCraft.TIER_3.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB[] getBoxes(World wrd, int x, int y, int z, EntityPlayer player) {
|
||||||
|
return boxes[wrd.getBlockMetadata(x, y, z)];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getExpansion() {
|
||||||
|
return 0.0075;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MovingObjectPosition collisionRayTrace(World wrd, int x, int y, int z, Vec3 origin, Vec3 direction) {
|
||||||
|
AxisAlignedBB[] aabbs = boxes[wrd.getBlockMetadata(x, y, z)];
|
||||||
|
MovingObjectPosition closest = null;
|
||||||
|
for(AxisAlignedBB aabb : aabbs){
|
||||||
|
MovingObjectPosition mop = aabb.getOffsetBoundingBox(x, y, z).calculateIntercept(origin, direction);
|
||||||
|
if(mop != null){
|
||||||
|
if (closest != null && mop.hitVec.distanceTo(origin) < closest.hitVec.distanceTo(origin)) {
|
||||||
|
closest = mop;
|
||||||
|
} else {
|
||||||
|
closest = mop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (closest != null){
|
||||||
|
closest.blockX = x;
|
||||||
|
closest.blockY = y;
|
||||||
|
closest.blockZ = z;
|
||||||
|
}
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void addCollisionBoxesToList(World wrd, int x, int y, int z, AxisAlignedBB mask, List list, Entity ent) {
|
||||||
|
AxisAlignedBB[] aabbs = boxes[wrd.getBlockMetadata(x, y, z)];
|
||||||
|
for (AxisAlignedBB aabb : aabbs) {
|
||||||
|
aabb = aabb.getOffsetBoundingBox(x, y, z);
|
||||||
|
if (mask.intersectsWith(aabb)){
|
||||||
|
list.add(aabb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRenderType() {
|
public int getRenderType() {
|
||||||
return SiliconProxy.laserBlockModel;
|
return SiliconProxy.laserBlockModel;
|
||||||
|
|
Loading…
Reference in a new issue