Small improvements to the multiblock renderer
This commit is contained in:
parent
fe11409b4e
commit
adf6c95331
1 changed files with 5 additions and 20 deletions
|
@ -37,41 +37,28 @@ public class MultiblockRenderEvent {
|
||||||
|
|
||||||
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
||||||
public MultiblockSet currentMultiblock;
|
public MultiblockSet currentMultiblock;
|
||||||
public ChunkCoordinates anchor;
|
|
||||||
public int angle;
|
|
||||||
|
|
||||||
public void setMultiblock(MultiblockSet set) {
|
public void setMultiblock(MultiblockSet set) {
|
||||||
currentMultiblock = set;
|
currentMultiblock = set;
|
||||||
anchor = null;
|
|
||||||
angle = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldRenderLast(RenderWorldLastEvent event) {
|
public void onWorldRenderLast(RenderWorldLastEvent event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
if(mc.thePlayer != null && mc.objectMouseOver != null && (!mc.thePlayer.isSneaking() || anchor != null)) {
|
if(mc.thePlayer != null && mc.objectMouseOver != null && !mc.thePlayer.isSneaking()) {
|
||||||
mc.thePlayer.getCurrentEquippedItem();
|
mc.thePlayer.getCurrentEquippedItem();
|
||||||
renderPlayerLook(mc.thePlayer, mc.objectMouseOver);
|
renderPlayerLook(mc.thePlayer, mc.objectMouseOver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
|
||||||
if(currentMultiblock != null && anchor == null && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR && event.entityPlayer == Minecraft.getMinecraft().thePlayer) {
|
|
||||||
anchor = new ChunkCoordinates(event.x, event.y, event.z);
|
|
||||||
angle = MathHelper.floor_double(event.entityPlayer.rotationYaw * 4.0 / 360.0 + 0.5) & 3;
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
||||||
if(currentMultiblock != null) {
|
if(currentMultiblock != null) {
|
||||||
int anchorX = anchor != null ? anchor.posX : src.blockX;
|
int anchorX = src.blockX;
|
||||||
int anchorY = anchor != null ? anchor.posY : src.blockY;
|
int anchorY = src.blockY + 1;
|
||||||
int anchorZ = anchor != null ? anchor.posZ : src.blockZ;
|
int anchorZ = src.blockZ;
|
||||||
|
|
||||||
rendering = true;
|
rendering = true;
|
||||||
Multiblock mb = anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player);
|
Multiblock mb =currentMultiblock.getForEntity(player);
|
||||||
boolean didAny = false;
|
boolean didAny = false;
|
||||||
for(MultiblockComponent comp : mb.getComponents())
|
for(MultiblockComponent comp : mb.getComponents())
|
||||||
if(renderComponent(player.worldObj, mb, comp, anchorX, anchorY, anchorZ))
|
if(renderComponent(player.worldObj, mb, comp, anchorX, anchorY, anchorZ))
|
||||||
|
@ -90,8 +77,6 @@ public class MultiblockRenderEvent {
|
||||||
int x = pos.posX + anchorX;
|
int x = pos.posX + anchorX;
|
||||||
int y = pos.posY + anchorY;
|
int y = pos.posY + anchorY;
|
||||||
int z = pos.posZ + anchorZ;
|
int z = pos.posZ + anchorZ;
|
||||||
if(anchor != null && comp.matches(world, x, y, z))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
|
Loading…
Reference in a new issue