Texture Rendering for cables
This commit is contained in:
parent
4000dbcc55
commit
1e24d1f116
4 changed files with 24 additions and 14 deletions
|
@ -1,7 +1,9 @@
|
||||||
package techreborn.client.render.parts;
|
package techreborn.client.render.parts;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
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.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
@ -20,7 +22,15 @@ public class ClientPartModelBakery {
|
||||||
for(EnumCableType type : EnumCableType.values()){
|
for(EnumCableType type : EnumCableType.values()){
|
||||||
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()), new RenderCablePart(type));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class RenderCablePart implements ISmartMultipartModel {
|
||||||
ArrayList<BakedQuad> list = new ArrayList<BakedQuad>();
|
ArrayList<BakedQuad> list = new ArrayList<BakedQuad>();
|
||||||
BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0);
|
BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0);
|
||||||
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
||||||
int thickness = 16 - (int) type.cableThickness * 2;
|
double thickness = type.cableThickness;
|
||||||
int lastThickness = 16 - thickness;
|
double lastThickness = 16 - thickness;
|
||||||
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
if (state.getValue(CableMultipart.UP)) {
|
if (state.getValue(CableMultipart.UP)) {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public abstract class CableMultipart extends Multipart implements IOccludingPart
|
||||||
|
|
||||||
public void refreshBounding() {
|
public void refreshBounding() {
|
||||||
float centerFirst = center - offset;
|
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
|
boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst
|
||||||
- w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08,
|
- w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08,
|
||||||
centerFirst + w + 0.04, centerFirst + w + 0.08);
|
centerFirst + w + 0.04, centerFirst + w + 0.08);
|
||||||
|
|
|
@ -4,23 +4,23 @@ import net.minecraft.util.IStringSerializable;
|
||||||
import techreborn.parts.types.*;
|
import techreborn.parts.types.*;
|
||||||
|
|
||||||
public enum EnumCableType implements IStringSerializable {
|
public enum EnumCableType implements IStringSerializable {
|
||||||
COPPER("copper", "minecraft:blocks/iron_block", 128, 4.0F, true, CopperCable.class),
|
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, CopperCable.class),
|
||||||
TIN("tin", "minecraft:blocks/iron_block", 32, 4.0F, true, TinCable.class),
|
TIN("tin", "minecraft:blocks/iron_block", 32, 4.0, true, TinCable.class),
|
||||||
GOLD("gold", "minecraft:blocks/iron_block", 512, 3.0F, true, GoldCable.class),
|
GOLD("gold", "minecraft:blocks/iron_block", 512, 3.0, true, GoldCable.class),
|
||||||
HV("hv", "minecraft:blocks/iron_block", 2048, 6.0F, true, HVCable.class),
|
HV("hv", "minecraft:blocks/iron_block", 2048, 6.0, true, HVCable.class),
|
||||||
GLASSFIBER("glassfiber", "minecraft:blocks/iron_block", 8192, 4.0F, false, GlassFiberCable.class),
|
GLASSFIBER("glassfiber", "minecraft:blocks/iron_block", 8192, 4.0, false, GlassFiberCable.class),
|
||||||
ICOPPER("insulatedcopper", "minecraft:blocks/iron_block", 128, 6.0F, false, InsulatedCopperCable.class),
|
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false, InsulatedCopperCable.class),
|
||||||
IGOLD("insulatedgold", "minecraft:blocks/iron_block", 512, 6.0F, false, InsulatedGoldCable.class),
|
IGOLD("insulatedgold", "minecraft:blocks/iron_block", 512, 6.0, false, InsulatedGoldCable.class),
|
||||||
IHV("insulatedhv", "minecraft:blocks/iron_block", 2048, 10.0F, false, InsulatedHVCable.class);
|
IHV("insulatedhv", "minecraft:blocks/iron_block", 2048, 10.0, false, InsulatedHVCable.class);
|
||||||
|
|
||||||
private String friendlyName;
|
private String friendlyName;
|
||||||
public String textureName = "minecraft:blocks/iron_block";
|
public String textureName = "minecraft:blocks/iron_block";
|
||||||
public int transferRate= 128;
|
public int transferRate= 128;
|
||||||
public float cableThickness = 3.0F;
|
public double cableThickness = 3.0;
|
||||||
public boolean canKill = false;
|
public boolean canKill = false;
|
||||||
public Class<? extends CableMultipart> cableClass;
|
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.friendlyName = friendlyName;
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
this.transferRate = transferRate;
|
this.transferRate = transferRate;
|
||||||
|
|
Loading…
Reference in a new issue