Added fluid pipe types
This commit is contained in:
parent
fd95cf7141
commit
62fd8f53f6
8 changed files with 152 additions and 223 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue