mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-22 13:09:44 +00:00
Made hollow covers more hollow.
This commit is contained in:
1 parent
1721ef0720
commit
fc68989c6f
6 files changed
+98
-20
No files matched your search
@@ -18,12 +18,16 @@ import codechicken.lib.render.CCRenderState
|
||||
import scala.collection.JavaConversions._
|
||||
import Rotation._
|
||||
import Vector3._
|
||||
import codechicken.lib.raytracer.IndexedCuboid6
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object HollowPlacement extends PlacementProperties
|
||||
{
|
||||
object HollowPlacementGrid extends FaceEdgeGrid(3/8D)
|
||||
|
||||
def microClass = HollowMicroClass
|
||||
|
||||
def placementGrid = FacePlacementGrid
|
||||
def placementGrid = HollowPlacementGrid
|
||||
|
||||
def opposite(slot:Int, side:Int) = slot^1
|
||||
|
||||
@@ -166,6 +170,34 @@ class HollowMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends HollowM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def drawHighlight(hit:MovingObjectPosition, player:EntityPlayer, frame:Float):Boolean =
|
||||
{
|
||||
val size = getHollowSize
|
||||
val d1 = 0.5-size/32D
|
||||
val d2 = 0.5+size/32D
|
||||
val t = (shape>>4)/8D
|
||||
|
||||
import GL11._
|
||||
glEnable(GL_BLEND)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||
glDisable(GL_TEXTURE_2D)
|
||||
glColor4f(0, 0, 0, 0.4F)
|
||||
glLineWidth(2)
|
||||
glDepthMask(false)
|
||||
glPushMatrix()
|
||||
RenderUtils.translateToWorldCoords(player, frame)
|
||||
glTranslated(x, y, z)
|
||||
sideRotations(shape&0xF).at(center).glApply()
|
||||
|
||||
RenderUtils.drawCuboidOutline(new Cuboid6(0, 0, 0, 1, t, 1).expand(0.001))
|
||||
RenderUtils.drawCuboidOutline(new Cuboid6(d1, 0, d1, d2, t, d2).expand(-0.001))
|
||||
glPopMatrix()
|
||||
glDepthMask(true)
|
||||
glEnable(GL_TEXTURE_2D)
|
||||
glDisable(GL_BLEND)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class HollowMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$) with TFacePart with TNormalOcclusion
|
||||
@@ -227,6 +259,23 @@ class HollowMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicrobl
|
||||
}
|
||||
}
|
||||
|
||||
override def getCollisionBoxes =
|
||||
{
|
||||
val size = getHollowSize
|
||||
val d1 = 0.5-size/32D
|
||||
val d2 = 0.5+size/32D
|
||||
val t = (shape>>4)/8D
|
||||
|
||||
val tr = sideRotations(shape&0xF).at(center)
|
||||
Seq(new Cuboid6(0, 0, 0, 1, t, d1),
|
||||
new Cuboid6(0, 0, d2, 1, t, 1),
|
||||
new Cuboid6(0, 0, d1, d1, t, d2),
|
||||
new Cuboid6(d2, 0, d1, 1, t, d2))
|
||||
.map(c => c.transform(tr))
|
||||
}
|
||||
|
||||
override def getSubParts = getCollisionBoxes.map(c => new IndexedCuboid6(0, c))
|
||||
|
||||
override def allowCompleteOcclusion = true
|
||||
|
||||
override def solid(side:Int) = false
|
||||
|
||||
@@ -23,7 +23,7 @@ trait PlacementGrid
|
||||
}
|
||||
}
|
||||
|
||||
object FacePlacementGrid extends PlacementGrid
|
||||
class FaceEdgeGrid(size:Double) extends PlacementGrid
|
||||
{
|
||||
def render(hit:Vector3, side:Int)
|
||||
{
|
||||
@@ -45,28 +45,28 @@ object FacePlacementGrid extends PlacementGrid
|
||||
GL11.glVertex3d(-0.5, 0,-0.5)
|
||||
|
||||
GL11.glVertex3d(0.5, 0, 0.5)
|
||||
GL11.glVertex3d(0.25, 0, 0.25)
|
||||
GL11.glVertex3d(size, 0, size)
|
||||
|
||||
GL11.glVertex3d(-0.5, 0, 0.5)
|
||||
GL11.glVertex3d(-0.25, 0, 0.25)
|
||||
GL11.glVertex3d(-size, 0, size)
|
||||
|
||||
GL11.glVertex3d(0.5, 0, -0.5)
|
||||
GL11.glVertex3d(0.25, 0, -0.25)
|
||||
GL11.glVertex3d(size, 0, -size)
|
||||
|
||||
GL11.glVertex3d(-0.5, 0, -0.5)
|
||||
GL11.glVertex3d(-0.25, 0, -0.25)
|
||||
GL11.glVertex3d(-size, 0, -size)
|
||||
|
||||
GL11.glVertex3d(-0.25, 0,-0.25)
|
||||
GL11.glVertex3d(-0.25, 0, 0.25)
|
||||
GL11.glVertex3d(-size, 0,-size)
|
||||
GL11.glVertex3d(-size, 0, size)
|
||||
|
||||
GL11.glVertex3d(-0.25, 0, 0.25)
|
||||
GL11.glVertex3d( 0.25, 0, 0.25)
|
||||
GL11.glVertex3d(-size, 0, size)
|
||||
GL11.glVertex3d( size, 0, size)
|
||||
|
||||
GL11.glVertex3d( 0.25, 0, 0.25)
|
||||
GL11.glVertex3d( 0.25, 0,-0.25)
|
||||
GL11.glVertex3d( size, 0, size)
|
||||
GL11.glVertex3d( size, 0,-size)
|
||||
|
||||
GL11.glVertex3d( 0.25, 0,-0.25)
|
||||
GL11.glVertex3d(-0.25, 0,-0.25)
|
||||
GL11.glVertex3d( size, 0,-size)
|
||||
GL11.glVertex3d(-size, 0,-size)
|
||||
GL11.glEnd();
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
@@ -78,7 +78,7 @@ object FacePlacementGrid extends PlacementGrid
|
||||
val u = vhit.copy().add(-0.5, -0.5, -0.5).scalarProject(Rotation.axes(s1))
|
||||
val v = vhit.copy().add(-0.5, -0.5, -0.5).scalarProject(Rotation.axes(s2))
|
||||
|
||||
if(Math.abs(u) < 4/16D && Math.abs(v) < 4/16D)
|
||||
if(Math.abs(u) < size && Math.abs(v) < size)
|
||||
return side^1
|
||||
if(Math.abs(u) > Math.abs(v))
|
||||
return if(u > 0) s1 else s1^1
|
||||
@@ -87,6 +87,8 @@ object FacePlacementGrid extends PlacementGrid
|
||||
}
|
||||
}
|
||||
|
||||
object FacePlacementGrid extends FaceEdgeGrid(1/4D)
|
||||
|
||||
object CornerPlacementGrid extends PlacementGrid
|
||||
{
|
||||
def render(hit:Vector3, side:Int)
|
||||
@@ -136,11 +138,9 @@ object CornerPlacementGrid extends PlacementGrid
|
||||
}
|
||||
}
|
||||
|
||||
object EdgePlacementGrid extends PlacementGrid
|
||||
object EdgePlacementGrid extends FaceEdgeGrid(1/4D)
|
||||
{
|
||||
def render(hit:Vector3, side:Int) = FacePlacementGrid.render(hit, side)
|
||||
|
||||
def getHitSlot(vhit:Vector3, side:Int):Int =
|
||||
override def getHitSlot(vhit:Vector3, side:Int):Int =
|
||||
{
|
||||
val s1 = (side+2)%6
|
||||
val s2 = (side+4)%6
|
||||
|
||||
@@ -48,6 +48,16 @@ object BlockMultipart
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
def drawHighlight(world:World, player:EntityPlayer, hit:MovingObjectPosition, frame:Float):Boolean =
|
||||
{
|
||||
val tile = getTile(world, hit.blockX, hit.blockY, hit.blockZ)
|
||||
if(tile == null)
|
||||
return false
|
||||
|
||||
val hitInfo:(Int, _) = ExtendedMOP.getData(hit)
|
||||
return tile.partList(hitInfo._1).drawHighlight(hit, player, frame)
|
||||
}
|
||||
}
|
||||
|
||||
trait BlockMultipart extends Block
|
||||
|
||||
@@ -59,6 +59,8 @@ abstract class TMultiPart
|
||||
def renderDynamic(pos:Vector3, frame:Float, pass:Int){}
|
||||
@SideOnly(Side.CLIENT)
|
||||
def drawBreaking(renderBlocks:RenderBlocks){}
|
||||
@SideOnly(Side.CLIENT)
|
||||
def drawHighlight(hit:MovingObjectPosition, player:EntityPlayer, frame:Float) = false
|
||||
|
||||
def read(packet:MCDataInput)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,11 @@ import scala.collection.JavaConverters._
|
||||
import java.util.List
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraftforge.event.EventPriority
|
||||
import cpw.mods.fml.relauncher.SideOnly
|
||||
import cpw.mods.fml.relauncher.Side
|
||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent
|
||||
import net.minecraft.util.EnumMovingObjectType
|
||||
import codechicken.multipart.BlockMultipart
|
||||
|
||||
object MultipartEventHandler extends IConnectionHandler with ITickHandler
|
||||
{
|
||||
@@ -48,6 +53,18 @@ object MultipartEventHandler extends IConnectionHandler with ITickHandler
|
||||
MultipartSPH.onChunkWatch(event.player, event.player.worldObj.getChunkFromChunkCoords(cc.chunkXPos, cc.chunkZPos))
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
@SideOnly(Side.CLIENT)
|
||||
def drawBlockHighlight(event:DrawBlockHighlightEvent)
|
||||
{
|
||||
if(event.target != null && event.target.typeOfHit == EnumMovingObjectType.TILE &&
|
||||
event.player.worldObj.getBlockTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ).isInstanceOf[TileMultipart])
|
||||
{
|
||||
if(BlockMultipart.drawHighlight(event.player.worldObj, event.player, event.target, event.partialTicks))
|
||||
event.setCanceled(true)
|
||||
}
|
||||
}
|
||||
|
||||
def connectionReceived(loginHandler:NetLoginHandler, netManager:INetworkManager):String =
|
||||
{
|
||||
val packet = new PacketCustom(MultipartSPH.registryChannel, 1)
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@
|
||||
"file": "CodeChickenLib-universal-@MCVERSION@-@[email protected]",
|
||||
"dev": "CodeChickenLib-dev-@MCVERSION@-@[email protected]",
|
||||
"class": "codechicken.lib.asm.ASMHelper",
|
||||
"version": "1.0.0.10"
|
||||
"version": "1.0.0.11"
|
||||
}
|
||||
Reference in new issue
Block a user