Moved to RebornCore
This commit is contained in:
parent
50a830a101
commit
8abf6e5282
313 changed files with 3987 additions and 16508 deletions
|
@ -2,10 +2,9 @@
|
|||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* <p/>
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
*/
|
||||
package techreborn.client.render;
|
||||
|
||||
|
@ -16,97 +15,91 @@ import net.minecraft.client.renderer.RenderBlocks;
|
|||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import techreborn.client.multiblock.IMultiblockRenderHook;
|
||||
import techreborn.client.multiblock.Multiblock;
|
||||
import techreborn.client.multiblock.MultiblockSet;
|
||||
import techreborn.client.multiblock.component.MultiblockComponent;
|
||||
import reborncore.client.multiblock.IMultiblockRenderHook;
|
||||
import reborncore.client.multiblock.Multiblock;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import reborncore.client.multiblock.component.MultiblockComponent;
|
||||
|
||||
public class MultiblockRenderEvent {
|
||||
public static boolean rendering = false;
|
||||
public static boolean rendering = false;
|
||||
|
||||
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
||||
public MultiblockSet currentMultiblock;
|
||||
public static ChunkCoordinates anchor;
|
||||
public static int angle;
|
||||
private static RenderBlocks blockRender = RenderBlocks.getInstance();
|
||||
public MultiblockSet currentMultiblock;
|
||||
public static ChunkCoordinates anchor;
|
||||
public static int angle;
|
||||
|
||||
public void setMultiblock(MultiblockSet set) {
|
||||
currentMultiblock = set;
|
||||
anchor = null;
|
||||
angle = 0;
|
||||
}
|
||||
public void setMultiblock(MultiblockSet set) {
|
||||
currentMultiblock = set;
|
||||
anchor = null;
|
||||
angle = 0;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRenderLast(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(mc.thePlayer != null && mc.objectMouseOver != null && !mc.thePlayer.isSneaking()) {
|
||||
mc.thePlayer.getCurrentEquippedItem();
|
||||
renderPlayerLook(mc.thePlayer, mc.objectMouseOver);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if(currentMultiblock != null && anchor == null && event.action == Action.RIGHT_CLICK_BLOCK && 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);
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onWorldRenderLast(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.thePlayer != null && mc.objectMouseOver != null && !mc.thePlayer.isSneaking()) {
|
||||
mc.thePlayer.getCurrentEquippedItem();
|
||||
renderPlayerLook(mc.thePlayer, mc.objectMouseOver);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
||||
if(currentMultiblock != null) {
|
||||
int anchorX = anchor != null ? anchor.posX : src.blockX;
|
||||
int anchorY = anchor != null ? anchor.posY +1 : src.blockY + 1;
|
||||
int anchorZ = anchor != null ? anchor.posZ : src.blockZ;
|
||||
@SubscribeEvent
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (currentMultiblock != null && anchor == null && event.action == Action.RIGHT_CLICK_BLOCK && 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);
|
||||
}
|
||||
}
|
||||
|
||||
rendering = true;
|
||||
Multiblock mb =currentMultiblock.getForEntity(player);
|
||||
boolean didAny = false;
|
||||
for(MultiblockComponent comp : mb.getComponents())
|
||||
if(renderComponent(player.worldObj, mb, comp, anchorX, anchorY, anchorZ))
|
||||
didAny = true;
|
||||
rendering = false;
|
||||
private void renderPlayerLook(EntityPlayer player, MovingObjectPosition src) {
|
||||
if (currentMultiblock != null) {
|
||||
int anchorX = anchor != null ? anchor.posX : src.blockX;
|
||||
int anchorY = anchor != null ? anchor.posY + 1 : src.blockY + 1;
|
||||
int anchorZ = anchor != null ? anchor.posZ : src.blockZ;
|
||||
|
||||
if(!didAny) {
|
||||
setMultiblock(null);
|
||||
player.addChatComponentMessage(new ChatComponentText("Structure Complete!").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
|
||||
}
|
||||
}
|
||||
}
|
||||
rendering = true;
|
||||
Multiblock mb = currentMultiblock.getForEntity(player);
|
||||
boolean didAny = false;
|
||||
for (MultiblockComponent comp : mb.getComponents())
|
||||
if (renderComponent(player.worldObj, mb, comp, anchorX, anchorY, anchorZ))
|
||||
didAny = true;
|
||||
rendering = false;
|
||||
|
||||
private boolean renderComponent(World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) {
|
||||
ChunkCoordinates pos = comp.getRelativePosition();
|
||||
int x = pos.posX + anchorX;
|
||||
int y = pos.posY + anchorY;
|
||||
int z = pos.posZ + anchorZ;
|
||||
if (!didAny) {
|
||||
setMultiblock(null);
|
||||
player.addChatComponentMessage(new ChatComponentText("Structure Complete!").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.4F);
|
||||
GL11.glTranslated(x + 0.5 - RenderManager.renderPosX, y + 0.5 - RenderManager.renderPosY, z + 0.5 - RenderManager.renderPosZ);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
private boolean renderComponent(World world, Multiblock mb, MultiblockComponent comp, int anchorX, int anchorY, int anchorZ) {
|
||||
ChunkCoordinates pos = comp.getRelativePosition();
|
||||
int x = pos.posX + anchorX;
|
||||
int y = pos.posY + anchorY;
|
||||
int z = pos.posZ + anchorZ;
|
||||
|
||||
blockRender.useInventoryTint = false;
|
||||
Block block = comp.getBlock();
|
||||
if(IMultiblockRenderHook.renderHooks.containsKey(block))
|
||||
IMultiblockRenderHook.renderHooks.get(block).renderBlockForMultiblock(world, mb, block, comp.getMeta(), blockRender);
|
||||
else blockRender.renderBlockAsItem(comp.getBlock(), comp.getMeta(), 1F);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.4F);
|
||||
GL11.glTranslated(x + 0.5 - RenderManager.renderPosX, y + 0.5 - RenderManager.renderPosY, z + 0.5 - RenderManager.renderPosZ);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
blockRender.useInventoryTint = false;
|
||||
Block block = comp.getBlock();
|
||||
if (IMultiblockRenderHook.renderHooks.containsKey(block))
|
||||
IMultiblockRenderHook.renderHooks.get(block).renderBlockForMultiblock(world, mb, block, comp.getMeta(), blockRender);
|
||||
else blockRender.renderBlockAsItem(comp.getBlock(), comp.getMeta(), 1F);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,13 +7,12 @@ import ic2.api.item.IC2Items;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import reborncore.common.misc.Functions;
|
||||
import reborncore.common.misc.vecmath.Vecs3d;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import techreborn.client.IconSupplier;
|
||||
import techreborn.lib.Functions;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.parts.CablePart;
|
||||
|
||||
|
||||
|
@ -59,7 +58,7 @@ public class RenderCablePart {
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IIcon getIconFromType(int cableType) {
|
||||
if(IC2Classic.getLoadedIC2Type() == IC2Classic.IC2Type.SpeigersClassic){
|
||||
if (IC2Classic.getLoadedIC2Type() == IC2Classic.IC2Type.SpeigersClassic) {
|
||||
return Block.getBlockFromItem(IC2Items.getItem("copperCableBlock").getItem()).getIcon(0, cableType * 16);
|
||||
}
|
||||
IIcon p = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue