Texture Rendering for cables

This commit is contained in:
modmuss50 2016-03-05 18:10:36 +00:00
parent 4000dbcc55
commit 1e24d1f116
4 changed files with 24 additions and 14 deletions

View file

@ -1,7 +1,9 @@
package techreborn.client.render.parts;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
@ -20,7 +22,15 @@ public class ClientPartModelBakery {
for(EnumCableType type : EnumCableType.values()){
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()), new RenderCablePart(type));
}
}
@SubscribeEvent
public void textureStichEvent(TextureStitchEvent event){
for(EnumCableType type : EnumCableType.values()){
event.map.registerSprite(new ResourceLocation(type.textureName));
}
}
}

View file

@ -63,8 +63,8 @@ public class RenderCablePart implements ISmartMultipartModel {
ArrayList<BakedQuad> list = new ArrayList<BakedQuad>();
BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0);
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
int thickness = 16 - (int) type.cableThickness * 2;
int lastThickness = 16 - thickness;
double thickness = type.cableThickness;
double lastThickness = 16 - thickness;
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
if (state != null) {
if (state.getValue(CableMultipart.UP)) {

View file

@ -57,7 +57,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
public void refreshBounding() {
float centerFirst = center - offset;
double w = getCableType().cableThickness / 16;
double w = (getCableType().cableThickness / 16) - 0.5;
boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst
- w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08,
centerFirst + w + 0.04, centerFirst + w + 0.08);

View file

@ -4,23 +4,23 @@ import net.minecraft.util.IStringSerializable;
import techreborn.parts.types.*;
public enum EnumCableType implements IStringSerializable {
COPPER("copper", "minecraft:blocks/iron_block", 128, 4.0F, true, CopperCable.class),
TIN("tin", "minecraft:blocks/iron_block", 32, 4.0F, true, TinCable.class),
GOLD("gold", "minecraft:blocks/iron_block", 512, 3.0F, true, GoldCable.class),
HV("hv", "minecraft:blocks/iron_block", 2048, 6.0F, true, HVCable.class),
GLASSFIBER("glassfiber", "minecraft:blocks/iron_block", 8192, 4.0F, false, GlassFiberCable.class),
ICOPPER("insulatedcopper", "minecraft:blocks/iron_block", 128, 6.0F, false, InsulatedCopperCable.class),
IGOLD("insulatedgold", "minecraft:blocks/iron_block", 512, 6.0F, false, InsulatedGoldCable.class),
IHV("insulatedhv", "minecraft:blocks/iron_block", 2048, 10.0F, false, InsulatedHVCable.class);
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, CopperCable.class),
TIN("tin", "minecraft:blocks/iron_block", 32, 4.0, true, TinCable.class),
GOLD("gold", "minecraft:blocks/iron_block", 512, 3.0, true, GoldCable.class),
HV("hv", "minecraft:blocks/iron_block", 2048, 6.0, true, HVCable.class),
GLASSFIBER("glassfiber", "minecraft:blocks/iron_block", 8192, 4.0, false, GlassFiberCable.class),
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false, InsulatedCopperCable.class),
IGOLD("insulatedgold", "minecraft:blocks/iron_block", 512, 6.0, false, InsulatedGoldCable.class),
IHV("insulatedhv", "minecraft:blocks/iron_block", 2048, 10.0, false, InsulatedHVCable.class);
private String friendlyName;
public String textureName = "minecraft:blocks/iron_block";
public int transferRate= 128;
public float cableThickness = 3.0F;
public double cableThickness = 3.0;
public boolean canKill = false;
public Class<? extends CableMultipart> cableClass;
EnumCableType(String friendlyName, String textureName, int transferRate, float cableThickness, boolean canKill, Class<? extends CableMultipart> cableClass) {
EnumCableType(String friendlyName, String textureName, int transferRate, double cableThickness, boolean canKill, Class<? extends CableMultipart> cableClass) {
this.friendlyName = friendlyName;
this.textureName = textureName;
this.transferRate = transferRate;