mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +00:00
Merge all telepad models into one, add (very very basic) animation
This commit is contained in:
1 parent
88341fc5c3
commit
e024666a4f
12 files changed
+105
-64
No files matched your search
@@ -1,7 +1,5 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import crazypants.enderio.conduit.ConnectionMode;
|
||||
import crazypants.util.Lang;
|
||||
@@ -85,5 +83,4 @@ public enum IoMode {
|
||||
}
|
||||
return values()[index];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import crazypants.enderio.teleport.ContainerTravelAccessable;
|
||||
import crazypants.enderio.teleport.ContainerTravelAuth;
|
||||
import crazypants.enderio.teleport.GuiTravelAuth;
|
||||
import crazypants.enderio.teleport.anchor.BlockTravelAnchor;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class BlockTelePad extends BlockTravelAnchor {
|
||||
|
||||
@@ -79,20 +78,7 @@ public class BlockTelePad extends BlockTravelAnchor {
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean canRenderInPass(int pass) {
|
||||
RenderUtil.theRenderPass = pass;
|
||||
return pass <= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block changedTo) {
|
||||
super.onNeighborBlockChange(world, x, y, z, changedTo);
|
||||
|
||||
@@ -1,23 +1,36 @@
|
||||
package crazypants.enderio.teleport.telepad;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.render.TechneModelRenderer;
|
||||
import crazypants.render.TechneUtil;
|
||||
|
||||
public class TelePadRenderer extends TechneModelRenderer {
|
||||
|
||||
private List<GroupObject> glass = TechneUtil.getModel("models/telePadGlass");
|
||||
public static final Map<String, GroupObject> all = TechneUtil.getModel("models/telePad");
|
||||
|
||||
public TelePadRenderer() {
|
||||
super("models/telePad", BlockTelePad.renderId);
|
||||
super(getModel(), BlockTelePad.renderId);
|
||||
}
|
||||
|
||||
private static Collection<GroupObject> getModel() {
|
||||
Collection<GroupObject> model = Lists.newArrayList();
|
||||
for (String s : all.keySet()) {
|
||||
if(!s.equals("glass") && !s.contains("blade")) {
|
||||
model.add(all.get(s));
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,11 +41,7 @@ public class TelePadRenderer extends TechneModelRenderer {
|
||||
if(te.inNetwork()) {
|
||||
renderer.overrideBlockTexture = null;
|
||||
if(te.isMaster()) {
|
||||
if(RenderUtil.theRenderPass == 0) {
|
||||
super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
} else {
|
||||
TechneUtil.renderWorldBlock(glass, world, x, y, z, block, renderer);
|
||||
}
|
||||
super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,54 @@ package crazypants.enderio.teleport.telepad;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.model.obj.GroupObject;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import crazypants.render.TechneUtil;
|
||||
|
||||
public class TelePadSpecialRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
// This will probably need to be a Map<String, GroupObject>
|
||||
private List<GroupObject> model = TechneUtil.getModel("models/telePadAnimation");
|
||||
private static List<GroupObject> blades = Lists.newArrayList();
|
||||
private static List<GroupObject> glass = Lists.newArrayList(TelePadRenderer.all.get("glass"));
|
||||
|
||||
static {
|
||||
for (String s : TelePadRenderer.all.keySet()) {
|
||||
if(s.contains("blade")) {
|
||||
blades.add(TelePadRenderer.all.get(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_147500_8_) {
|
||||
// TODO spin the spinny thingies
|
||||
if(((TileTelePad) te).isMaster()) {
|
||||
TileTelePad tp = (TileTelePad) te;
|
||||
if(tp.isMaster() && tp.inNetwork()) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
// not working
|
||||
TechneUtil.renderWithIcon(model, ((BlockTelePad) te.getBlockType()).animationIcon, null, Tessellator.instance, te.getWorldObj(), 0, 0, 0);
|
||||
GL11.glTranslated(x + 0.5, y + 0.01, z + 0.5);
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.setBrightness(0xF000F0);
|
||||
// TODO spin the spinny thingies properly
|
||||
float rot = te.getWorldObj().getTotalWorldTime() + p_147500_8_;
|
||||
GL11.glRotatef(rot, 0, 1, 0);
|
||||
render(blades, te, tes);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glRotatef(-rot, 0, 1, 0);
|
||||
render(glass, te, tes);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void render(List<GroupObject> model, TileEntity te, Tessellator tes) {
|
||||
tes.startDrawingQuads();
|
||||
TechneUtil.renderWithIcon(model, te.getBlockType().getIcon(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, 0), null, Tessellator.instance,
|
||||
te.getWorldObj(), 0, 0, 0, null, false);
|
||||
tes.draw();
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ import crazypants.enderio.machine.PacketPowerStorage;
|
||||
import crazypants.enderio.machine.PacketProgress;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.IInternalPowerReceiver;
|
||||
import crazypants.enderio.rail.PacketTeleportEffects;
|
||||
import crazypants.enderio.rail.TeleporterEIO;
|
||||
import crazypants.enderio.teleport.TravelController;
|
||||
import crazypants.enderio.teleport.anchor.TileTravelAnchor;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package crazypants.render;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -10,7 +10,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class TechneModelRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private List<GroupObject> model;
|
||||
private Collection<GroupObject> model;
|
||||
private int renderId;
|
||||
|
||||
protected VertexTransform vt;
|
||||
@@ -20,7 +20,15 @@ public class TechneModelRenderer implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
public TechneModelRenderer(String modelPath, int renderId, VertexTransform vt) {
|
||||
model = TechneUtil.getModel(modelPath);
|
||||
this(TechneUtil.getModelAll(modelPath), renderId, vt);
|
||||
}
|
||||
|
||||
public TechneModelRenderer(Collection<GroupObject> model, int renderId) {
|
||||
this(model, renderId, null);
|
||||
}
|
||||
|
||||
public TechneModelRenderer(Collection<GroupObject> model, int renderId, VertexTransform vt) {
|
||||
this.model = model;
|
||||
this.renderId = renderId;
|
||||
this.vt = vt;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package crazypants.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -61,7 +62,7 @@ import org.lwjgl.util.vector.Matrix4f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import org.lwjgl.util.vector.Vector4f;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -168,15 +169,15 @@ public class TechneUtil {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<GroupObject> bakeModel(TechneModel model) {
|
||||
public static Map<String, GroupObject> bakeModel(TechneModel model) {
|
||||
return bakeModel(model, 1);
|
||||
}
|
||||
|
||||
public static List<GroupObject> bakeModel(TechneModel model, float scale) {
|
||||
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale) {
|
||||
return bakeModel(model, scale, new Matrix4f());
|
||||
}
|
||||
|
||||
public static List<GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m) {
|
||||
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m) {
|
||||
return bakeModel(model, scale, m, false);
|
||||
}
|
||||
|
||||
@@ -187,18 +188,18 @@ public class TechneUtil {
|
||||
* Use this to convert TechneModel to it's static representation
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m, boolean rotateYFirst) {
|
||||
public static Map<String, GroupObject> bakeModel(TechneModel model, float scale, Matrix4f m, boolean rotateYFirst) {
|
||||
Map<String, ModelRenderer> parts = (Map<String, ModelRenderer>) ObfuscationReflectionHelper.getPrivateValue(TechneModel.class, model, "parts");
|
||||
List<GroupObject> res = Lists.newArrayList();
|
||||
Map<String, GroupObject> res = Maps.newHashMap();
|
||||
|
||||
for (Map.Entry<String, ModelRenderer> e : parts.entrySet()) {
|
||||
GroupObject obj = bakeModel(e.getValue(), scale, m, rotateYFirst).get(0);
|
||||
res.add(obj);
|
||||
res.put(e.getKey(), obj);
|
||||
}
|
||||
|
||||
// Second pass, adjust the UVs to be on a 0-1 interpolation scale
|
||||
if(uMult + vMult != 2) {
|
||||
for (GroupObject go : res) {
|
||||
for (GroupObject go : res.values()) {
|
||||
for (Face f : go.faces) {
|
||||
for (TextureCoordinate tc : f.textureCoordinates) {
|
||||
tc.u /= uMult;
|
||||
@@ -213,25 +214,36 @@ public class TechneUtil {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static List<GroupObject> getModel(String modelPath) {
|
||||
public static Map<String, GroupObject> getModel(String modelPath) {
|
||||
TechneModel tm = (TechneModel) modelLoader.loadInstance(new ResourceLocation(EnderIO.MODID.toLowerCase(), modelPath + ".tcn"));
|
||||
return TechneUtil.bakeModel(tm, 1f / 16, new Matrix4f().scale(new Vector3f(-1, -1, 1)));
|
||||
}
|
||||
|
||||
public static Collection<GroupObject> getModelAll(String modelPath) {
|
||||
TechneModel tm = (TechneModel) modelLoader.loadInstance(new ResourceLocation(EnderIO.MODID.toLowerCase(), modelPath + ".tcn"));
|
||||
return TechneUtil.bakeModel(tm, 1f / 16, new Matrix4f().scale(new Vector3f(-1, -1, 1))).values();
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes) {
|
||||
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes) {
|
||||
renderWithIcon(model, icon, override, tes, null);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, VertexTransform vt) {
|
||||
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, VertexTransform vt) {
|
||||
renderWithIcon(model, icon, override, tes, null, 0, 0, 0, vt);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z) {
|
||||
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z) {
|
||||
renderWithIcon(model, icon, override, tes, world, x, y, z, null);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(List<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z,
|
||||
|
||||
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z,
|
||||
VertexTransform vt) {
|
||||
renderWithIcon(model, icon, override, tes, world, x, y, z, vt, true);
|
||||
}
|
||||
|
||||
public static void renderWithIcon(Collection<GroupObject> model, IIcon icon, IIcon override, Tessellator tes, IBlockAccess world, int x, int y, int z,
|
||||
VertexTransform vt, boolean isbrh) {
|
||||
for (GroupObject go : model) {
|
||||
for (Face f : go.faces) {
|
||||
Vertex n = f.faceNormal;
|
||||
@@ -243,7 +255,7 @@ public class TechneUtil {
|
||||
}
|
||||
ForgeDirection down = normal.getRotation(right.getOpposite());
|
||||
|
||||
if(world != null && world.getBlock(x, y, z).getLightOpacity() > 0) {
|
||||
if(isbrh && world != null && world.getBlock(x, y, z).getLightOpacity() > 0) {
|
||||
int bx = x + normal.offsetX;
|
||||
int by = y + normal.offsetY;
|
||||
int bz = z + normal.offsetZ;
|
||||
@@ -259,13 +271,15 @@ public class TechneUtil {
|
||||
vt.apply(v);
|
||||
}
|
||||
|
||||
float factor = normal.offsetX != 0 ? 0.6f : normal.offsetZ != 0 ? 0.8f : normal.offsetY < 0 ? 0.5f : 1;
|
||||
int c = (int) (0xFF * factor);
|
||||
|
||||
tes.setColorOpaque(c, c, c);
|
||||
if(isbrh) {
|
||||
float factor = normal.offsetX != 0 ? 0.6f : normal.offsetZ != 0 ? 0.8f : normal.offsetY < 0 ? 0.5f : 1;
|
||||
int c = (int) (0xFF * factor);
|
||||
|
||||
tes.setColorOpaque(c, c, c);
|
||||
}
|
||||
|
||||
if(override != null) {
|
||||
|
||||
|
||||
double interpX = Math.abs(tv.x * right.offsetX + tv.y * right.offsetY + tv.z * right.offsetZ);
|
||||
double interpY = Math.abs(tv.x * down.offsetX + tv.y * down.offsetY + tv.z * down.offsetZ);
|
||||
|
||||
@@ -303,11 +317,11 @@ public class TechneUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderInventoryBlock(List<GroupObject> model, Block block, int metadata, RenderBlocks rb) {
|
||||
public static void renderInventoryBlock(Collection<GroupObject> model, Block block, int metadata, RenderBlocks rb) {
|
||||
renderInventoryBlock(model, getIconFor(block, metadata), block, metadata, rb);
|
||||
}
|
||||
|
||||
public static void renderInventoryBlock(List<GroupObject> model, IIcon icon, Block block, int metadata, RenderBlocks rb) {
|
||||
public static void renderInventoryBlock(Collection<GroupObject> model, IIcon icon, Block block, int metadata, RenderBlocks rb) {
|
||||
tes.startDrawingQuads();
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(0, -0.47f, 0);
|
||||
@@ -317,12 +331,12 @@ public class TechneUtil {
|
||||
resetVT();
|
||||
}
|
||||
|
||||
public static boolean renderWorldBlock(List<GroupObject> model, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) {
|
||||
public static boolean renderWorldBlock(Collection<GroupObject> model, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) {
|
||||
IIcon icon = getIconFor(block, world, x, y, z);
|
||||
return renderWorldBlock(model, icon, world, x, y, z, block, rb);
|
||||
}
|
||||
|
||||
public static boolean renderWorldBlock(List<GroupObject> model, IIcon icon, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) {
|
||||
public static boolean renderWorldBlock(Collection<GroupObject> model, IIcon icon, IBlockAccess world, int x, int y, int z, Block block, RenderBlocks rb) {
|
||||
tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
tes.addTranslation(x + .5F, y + 0.0375f, z + .5F);
|
||||
|
||||
Reference in new issue
Block a user