2016-03-04 20:47:08 +01:00
|
|
|
package techreborn.client.render.parts;
|
2015-04-28 21:37:46 +02:00
|
|
|
|
2016-03-02 17:45:49 +01:00
|
|
|
import mcmultipart.client.multipart.ISmartMultipartModel;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-03-04 20:47:08 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2016-03-13 16:37:55 +01:00
|
|
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
|
|
|
import net.minecraft.client.renderer.block.model.BlockFaceUV;
|
|
|
|
import net.minecraft.client.renderer.block.model.BlockPartFace;
|
|
|
|
import net.minecraft.client.renderer.block.model.FaceBakery;
|
|
|
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
2016-03-02 17:45:49 +01:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
|
|
import net.minecraft.client.resources.model.IBakedModel;
|
|
|
|
import net.minecraft.client.resources.model.ModelRotation;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-05 12:19:33 +01:00
|
|
|
import net.minecraftforge.common.property.IExtendedBlockState;
|
2016-03-02 17:45:49 +01:00
|
|
|
import org.lwjgl.util.vector.Vector3f;
|
|
|
|
import reborncore.common.misc.vecmath.Vecs3dCube;
|
2016-03-05 12:19:33 +01:00
|
|
|
import techreborn.parts.CableMultipart;
|
|
|
|
import techreborn.parts.EnumCableType;
|
2016-03-02 17:45:49 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2016-03-04 20:47:08 +01:00
|
|
|
import java.util.Collections;
|
2016-03-02 17:45:49 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class RenderCablePart implements ISmartMultipartModel {
|
|
|
|
|
|
|
|
private FaceBakery faceBakery = new FaceBakery();
|
|
|
|
|
2016-03-04 20:47:08 +01:00
|
|
|
private TextureAtlasSprite texture;
|
|
|
|
|
2016-03-05 12:19:33 +01:00
|
|
|
EnumCableType type;
|
|
|
|
|
|
|
|
IExtendedBlockState state;
|
|
|
|
|
|
|
|
public RenderCablePart(IExtendedBlockState state, EnumCableType type) {
|
|
|
|
this(type);
|
|
|
|
this.state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RenderCablePart(EnumCableType type) {
|
2016-03-05 15:24:31 +01:00
|
|
|
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
2016-03-05 12:19:33 +01:00
|
|
|
this.type = type;
|
2016-03-04 20:47:08 +01:00
|
|
|
}
|
|
|
|
|
2016-03-02 17:45:49 +01:00
|
|
|
@Override
|
|
|
|
public IBakedModel handlePartState(IBlockState state) {
|
2016-03-05 12:19:33 +01:00
|
|
|
return new RenderCablePart((IExtendedBlockState) state, type);
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face, ModelRotation modelRotation, TextureAtlasSprite cubeTexture) {
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.DOWN, modelRotation, null, true, true));//down
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.UP, modelRotation, null, true, true));//up
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.NORTH, modelRotation, null, true, true));//north
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMaxZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.SOUTH, modelRotation, null, true, true));//south
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.EAST, modelRotation, null, true, true));//east
|
|
|
|
list.add(faceBakery.makeBakedQuad(new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()), new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture, EnumFacing.WEST, modelRotation, null, true, true));//west
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_) {
|
2016-03-04 20:47:08 +01:00
|
|
|
return Collections.emptyList();
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<BakedQuad> getGeneralQuads() {
|
2016-03-04 20:47:08 +01:00
|
|
|
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);
|
2016-03-05 19:10:36 +01:00
|
|
|
double thickness = type.cableThickness;
|
|
|
|
double lastThickness = 16 - thickness;
|
2016-03-04 20:47:08 +01:00
|
|
|
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
2016-03-05 12:19:33 +01:00
|
|
|
if (state != null) {
|
|
|
|
if (state.getValue(CableMultipart.UP)) {
|
|
|
|
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
if (state.getValue(CableMultipart.DOWN)) {
|
|
|
|
addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
if (state.getValue(CableMultipart.NORTH)) {
|
|
|
|
addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
if (state.getValue(CableMultipart.SOUTH)) {
|
|
|
|
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, 16.0), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
if (state.getValue(CableMultipart.EAST)) {
|
|
|
|
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, 16.0, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
if (state.getValue(CableMultipart.WEST)) {
|
|
|
|
addCubeToList(new Vecs3dCube(0.0, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture);
|
|
|
|
}
|
|
|
|
}
|
2016-03-04 20:47:08 +01:00
|
|
|
return list;
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAmbientOcclusion() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGui3d() {
|
2016-03-04 20:47:08 +01:00
|
|
|
return true;
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBuiltInRenderer() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TextureAtlasSprite getParticleTexture() {
|
2016-03-05 11:48:13 +01:00
|
|
|
return texture;
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemCameraTransforms getItemCameraTransforms() {
|
2016-03-04 20:47:08 +01:00
|
|
|
return ItemCameraTransforms.DEFAULT;
|
2016-03-02 17:45:49 +01:00
|
|
|
}
|
2015-04-28 21:37:46 +02:00
|
|
|
}
|