Added fluid pipe types
This commit is contained in:
parent
fd95cf7141
commit
62fd8f53f6
8 changed files with 152 additions and 223 deletions
|
@ -8,6 +8,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
|||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
|
@ -26,9 +27,12 @@ public class ClientPartModelBakery
|
|||
new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()),
|
||||
new RenderCablePart(type));
|
||||
}
|
||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||
event.getModelRegistry().putObject(
|
||||
new ModelResourceLocation("techreborn:fluidpipe#multipart"),
|
||||
new RenderFluidPipePart());
|
||||
new ModelResourceLocation("techreborn:fluidpipe#type=" + type.getName().toLowerCase()),
|
||||
new RenderFluidPipePart(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -38,7 +42,9 @@ public class ClientPartModelBakery
|
|||
{
|
||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||
}
|
||||
event.getMap().registerSprite(new ResourceLocation("techreborn:blocks/fluidPipes/fluidpipe"));
|
||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import reborncore.client.models.BakedModelUtils;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
@ -28,43 +29,6 @@ public class RenderCablePart implements IBakedModel
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir)
|
||||
{
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[] { (float) cube.getMinX(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxX(), (float) cube.getMaxY() }, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
if(dir == EnumFacing.NORTH || dir == EnumFacing.SOUTH){
|
||||
uv = new BlockFaceUV(new float[] { (float) cube.getMinZ(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxZ(), (float) cube.getMaxY() }, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
}
|
||||
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> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
||||
{
|
||||
|
@ -78,39 +42,39 @@ public class RenderCablePart implements IBakedModel
|
|||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
if (state != null)
|
||||
{
|
||||
if (state.getValue(CableMultipart.UP))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.DOWN))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.NORTH))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, thickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, thickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.SOUTH))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.EAST))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.WEST))
|
||||
{
|
||||
addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -6,11 +6,12 @@ import net.minecraft.client.renderer.block.model.*;
|
|||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import reborncore.client.models.BakedModelUtils;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
||||
import techreborn.parts.fluidPipes.MultipartFluidPipe;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -22,131 +23,11 @@ public class RenderFluidPipePart implements IBakedModel {
|
|||
|
||||
private FaceBakery faceBakery = new FaceBakery();
|
||||
private TextureAtlasSprite texture;
|
||||
EnumFluidPipeTypes type;
|
||||
|
||||
public RenderFluidPipePart() {
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("techreborn:blocks/fluidPipes/fluidpipe");
|
||||
}
|
||||
|
||||
public void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir) {
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[]{(float) cube.getMinX(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxX(), (float) cube.getMaxY()}, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
if (dir == EnumFacing.NORTH || dir == EnumFacing.SOUTH) {
|
||||
uv = new BlockFaceUV(new float[]{(float) cube.getMinZ(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxZ(), (float) cube.getMaxY()}, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
}
|
||||
if (dir == null) {
|
||||
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
|
||||
} else {
|
||||
if (dir != EnumFacing.DOWN) {
|
||||
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
|
||||
}
|
||||
if (dir != EnumFacing.UP) {
|
||||
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
|
||||
}
|
||||
if (dir != EnumFacing.NORTH) {
|
||||
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
|
||||
}
|
||||
if (dir != EnumFacing.SOUTH) {
|
||||
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
|
||||
}
|
||||
if (dir != EnumFacing.EAST) {
|
||||
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
|
||||
}
|
||||
if (dir != EnumFacing.WEST) {
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addCulledCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, List<EnumFacing> dirs) {
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[]{(float) cube.getMinX(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxX(), (float) cube.getMaxY()}, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
|
||||
if (dirs.contains(EnumFacing.DOWN)) {
|
||||
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
|
||||
}
|
||||
if (dirs.contains(EnumFacing.UP)) {
|
||||
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
|
||||
}
|
||||
if (dirs.contains(EnumFacing.NORTH)) {
|
||||
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
|
||||
}
|
||||
if (dirs.contains(EnumFacing.SOUTH)) {
|
||||
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
|
||||
}
|
||||
if (dirs.contains(EnumFacing.EAST)) {
|
||||
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
|
||||
}
|
||||
if (dirs.contains(EnumFacing.WEST)) {
|
||||
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
|
||||
}
|
||||
|
||||
public RenderFluidPipePart(EnumFluidPipeTypes type) {
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,53 +41,32 @@ public class RenderFluidPipePart implements IBakedModel {
|
|||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//TODO recode the fuck out of this
|
||||
ArrayList<EnumFacing> dirs = new ArrayList<>();
|
||||
if(!state.getValue(MultipartFluidPipe.DOWN)){
|
||||
dirs.add(EnumFacing.DOWN);
|
||||
}
|
||||
if(!state.getValue(MultipartFluidPipe.UP)){
|
||||
dirs.add(EnumFacing.UP);
|
||||
}
|
||||
if(!state.getValue(MultipartFluidPipe.NORTH)){
|
||||
dirs.add(EnumFacing.NORTH);
|
||||
}
|
||||
if(!state.getValue(MultipartFluidPipe.SOUTH)){
|
||||
dirs.add(EnumFacing.SOUTH);
|
||||
}
|
||||
if(!state.getValue(MultipartFluidPipe.EAST)){
|
||||
dirs.add(EnumFacing.EAST);
|
||||
}
|
||||
if(!state.getValue(MultipartFluidPipe.WEST)){
|
||||
dirs.add(EnumFacing.WEST);
|
||||
}
|
||||
|
||||
addCulledCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, dirs);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
if (state != null) {
|
||||
if (state.getValue(MultipartFluidPipe.UP)) {
|
||||
addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.DOWN)) {
|
||||
addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.NORTH)) {
|
||||
addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, thickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, thickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.SOUTH)) {
|
||||
addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, lastThickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.EAST)) {
|
||||
addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.WEST)) {
|
||||
addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST);
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package techreborn.parts.fluidPipes;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 09/05/2016.
|
||||
*/
|
||||
public enum EnumFluidPipeTypes implements IStringSerializable {
|
||||
|
||||
EMPTY("empty","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
INSERT("insert","techreborn:blocks/fluidPipes/fluidpipe_insert", false, true),
|
||||
EXTRACT("extract","techreborn:blocks/fluidPipes/fluidpipe_extract", true, false),
|
||||
FLV1("flv1","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV2("flv2","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV3("flv3","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV4("flv4","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV5("flv5","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV6("flv6","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV7("flv7","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV8("flv8","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV9("flv9","techreborn:blocks/fluidPipes/fluidpipe", false, false),
|
||||
FLV10("flv10","techreborn:blocks/fluidPipes/fluidpipe", false, false);
|
||||
|
||||
|
||||
private String name;
|
||||
public String textureName = "minecraft:blocks/iron_block";
|
||||
public boolean extract = false;
|
||||
public boolean insert = false;
|
||||
|
||||
EnumFluidPipeTypes(String name, String textureName, boolean extract, boolean insert) {
|
||||
this.name = name;
|
||||
this.textureName = textureName;
|
||||
this.extract = extract;
|
||||
this.insert = insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package techreborn.parts.fluidPipes;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import mcmultipart.MCMultiPartMod;
|
||||
import mcmultipart.microblock.IMicroblock;
|
||||
import mcmultipart.multipart.*;
|
||||
|
@ -8,28 +9,33 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ChatLine;
|
||||
import net.minecraft.client.gui.GuiNewChat;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import reborncore.api.power.IEnergyInterfaceTile;
|
||||
import reborncore.common.misc.Functions;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.parts.TechRebornParts;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +49,9 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
|||
public static final IUnlistedProperty<Boolean> EAST = Properties.toUnlisted(PropertyBool.create("east"));
|
||||
public static final IUnlistedProperty<Boolean> SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
|
||||
public static final IUnlistedProperty<Boolean> WEST = Properties.toUnlisted(PropertyBool.create("west"));
|
||||
public static final IProperty<EnumFluidPipeTypes> TYPE = PropertyEnum.create("type", EnumFluidPipeTypes.class);
|
||||
EnumFluidPipeTypes currentType = EnumFluidPipeTypes.EMPTY;
|
||||
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
|
@ -184,7 +193,7 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
|||
} else {
|
||||
TileEntity tile = getNeighbourTile(dir);
|
||||
|
||||
if (tile instanceof IEnergyInterfaceTile) {
|
||||
if (tile instanceof IFluidHandler && (currentType == EnumFluidPipeTypes.EXTRACT || currentType == EnumFluidPipeTypes.INSERT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -240,12 +249,12 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
|||
.withProperty(UP, shouldConnectTo(EnumFacing.UP)).withProperty(NORTH, shouldConnectTo(EnumFacing.NORTH))
|
||||
.withProperty(SOUTH, shouldConnectTo(EnumFacing.SOUTH))
|
||||
.withProperty(WEST, shouldConnectTo(EnumFacing.WEST))
|
||||
.withProperty(EAST, shouldConnectTo(EnumFacing.EAST));
|
||||
.withProperty(EAST, shouldConnectTo(EnumFacing.EAST)).withProperty(TYPE, currentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[]{},
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[]{TYPE},
|
||||
new IUnlistedProperty[]{DOWN, UP, NORTH, SOUTH, WEST, EAST});
|
||||
}
|
||||
|
||||
|
@ -279,4 +288,53 @@ public class MultipartFluidPipe extends Multipart implements INormallyOccludingP
|
|||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand, ItemStack heldItem, PartMOP hit) {
|
||||
//TODO move to client side only class
|
||||
if(getWorld().isRemote){
|
||||
try {
|
||||
GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
|
||||
Field field = chat.getClass().getDeclaredField("chatLines");
|
||||
field.setAccessible(true);
|
||||
List<ChatLine> lines = (List<ChatLine>) field.get(chat);
|
||||
List<Integer> linesToRemove = new ArrayList<>();
|
||||
for(ChatLine line : lines){
|
||||
if(line.getChatComponent() instanceof TextComponetValue){
|
||||
linesToRemove.add(line.getChatLineID());
|
||||
}
|
||||
}
|
||||
for(Integer integer : linesToRemove){
|
||||
chat.deleteChatLine(integer);
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(currentType == EnumFluidPipeTypes.EMPTY){
|
||||
currentType = EnumFluidPipeTypes.EXTRACT;
|
||||
if(getWorld().isRemote)
|
||||
player.addChatMessage(new TextComponetValue("Mode set to: " + ChatFormatting.YELLOW + "Extract"));
|
||||
} else if(currentType == EnumFluidPipeTypes.EXTRACT){
|
||||
currentType = EnumFluidPipeTypes.INSERT;
|
||||
if(getWorld().isRemote)
|
||||
player.addChatMessage(new TextComponetValue("Mode set to: " + ChatFormatting.BLUE + "Insert"));
|
||||
} else if(currentType == EnumFluidPipeTypes.INSERT){
|
||||
currentType = EnumFluidPipeTypes.EMPTY;
|
||||
if(getWorld().isRemote)
|
||||
player.addChatMessage(new TextComponetValue("Mode set to: " + ChatFormatting.WHITE + "Normal"));
|
||||
}
|
||||
markRenderUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class TextComponetValue extends TextComponentString{
|
||||
|
||||
public TextComponetValue(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Add table
Reference in a new issue