Auto Format code
This commit is contained in:
parent
112b1657cf
commit
796df6c055
503 changed files with 12260 additions and 16291 deletions
|
@ -11,33 +11,28 @@ import techreborn.parts.powerCables.ItemStandaloneCables;
|
|||
/**
|
||||
* Created by modmuss50 on 06/03/2016.
|
||||
*/
|
||||
public class StandalonePartCompact implements ICompatModule
|
||||
{
|
||||
public class StandalonePartCompact implements ICompatModule {
|
||||
|
||||
public static ItemStandaloneCables itemStandaloneCable;
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
itemStandaloneCable = new ItemStandaloneCables();
|
||||
GameRegistry.registerItem(itemStandaloneCable, "cables");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package techreborn.parts;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import reborncore.mcmultipart.multipart.MultipartRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
|
@ -12,17 +7,19 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import reborncore.mcmultipart.multipart.MultipartRegistry;
|
||||
import techreborn.compat.ICompatModule;
|
||||
import techreborn.parts.fluidPipes.*;
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
import techreborn.parts.powerCables.ItemCables;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 02/03/2016.
|
||||
*/
|
||||
public class TechRebornParts implements ICompatModule
|
||||
{
|
||||
public class TechRebornParts implements ICompatModule {
|
||||
|
||||
@Nullable
|
||||
public static Item cables;
|
||||
|
@ -33,16 +30,13 @@ public class TechRebornParts implements ICompatModule
|
|||
public static HashMap<EnumCableType, Class<? extends CableMultipart>> multipartHashMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
for (EnumCableType cableType : EnumCableType.values())
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
for (EnumCableType cableType : EnumCableType.values()) {
|
||||
multipartHashMap.put(cableType, cableType.cableClass);
|
||||
MultipartRegistry.registerPart(cableType.cableClass, "techreborn:cable." + cableType.name());
|
||||
}
|
||||
|
@ -50,23 +44,21 @@ public class TechRebornParts implements ICompatModule
|
|||
cables.setRegistryName("cables");
|
||||
GameRegistry.register(cables);
|
||||
|
||||
// MultipartRegistry.registerPart(EmptyFluidPipe.class, "techreborn:fluidpipe.empty");
|
||||
// MultipartRegistry.registerPart(InsertingFluidPipe.class, "techreborn:fluidpipe.inserting");
|
||||
// MultipartRegistry.registerPart(ExtractingFluidPipe.class, "techreborn:fluidpipe.extracting");
|
||||
// fluidPipe = new ItemFluidPipe();
|
||||
// fluidPipe.setRegistryName("fluidPipe");
|
||||
// GameRegistry.register(fluidPipe);
|
||||
// MultipartRegistry.registerPart(EmptyFluidPipe.class, "techreborn:fluidpipe.empty");
|
||||
// MultipartRegistry.registerPart(InsertingFluidPipe.class, "techreborn:fluidpipe.inserting");
|
||||
// MultipartRegistry.registerPart(ExtractingFluidPipe.class, "techreborn:fluidpipe.extracting");
|
||||
// fluidPipe = new ItemFluidPipe();
|
||||
// fluidPipe.setRegistryName("fluidPipe");
|
||||
// GameRegistry.register(fluidPipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ package techreborn.parts.fluidPipes;
|
|||
* Created by modmuss50 on 12/05/2016.
|
||||
*/
|
||||
public class EmptyFluidPipe extends MultipartFluidPipe {
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.EMPTY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraft.util.text.TextFormatting;
|
|||
/**
|
||||
* Created by modmuss50 on 09/05/2016.
|
||||
*/
|
||||
public enum EnumFluidPipeTypes implements IStringSerializable
|
||||
{
|
||||
public enum EnumFluidPipeTypes implements IStringSerializable {
|
||||
|
||||
EMPTY("empty", "techreborn:blocks/fluidPipes/fluidpipe", false, false, TextFormatting.DARK_GRAY),
|
||||
INSERT("insert", "techreborn:blocks/fluidPipes/fluidpipe_insert", false, true, TextFormatting.BLUE),
|
||||
|
@ -19,8 +18,7 @@ public enum EnumFluidPipeTypes implements IStringSerializable
|
|||
public TextFormatting colour = TextFormatting.WHITE;
|
||||
private String name;
|
||||
|
||||
EnumFluidPipeTypes(String name, String textureName, boolean extract, boolean insert, TextFormatting colour)
|
||||
{
|
||||
EnumFluidPipeTypes(String name, String textureName, boolean extract, boolean insert, TextFormatting colour) {
|
||||
this.name = name;
|
||||
this.textureName = textureName;
|
||||
this.extract = extract;
|
||||
|
@ -28,8 +26,8 @@ public enum EnumFluidPipeTypes implements IStringSerializable
|
|||
this.colour = colour;
|
||||
}
|
||||
|
||||
@Override public String getName()
|
||||
{
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ package techreborn.parts.fluidPipes;
|
|||
* Created by modmuss50 on 12/05/2016.
|
||||
*/
|
||||
public class ExtractingFluidPipe extends MultipartFluidPipe {
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.EXTRACT;
|
||||
}
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.EXTRACT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ package techreborn.parts.fluidPipes;
|
|||
*/
|
||||
public interface IPartType {
|
||||
|
||||
EnumFluidPipeTypes getPipeType();
|
||||
EnumFluidPipeTypes getPipeType();
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ package techreborn.parts.fluidPipes;
|
|||
* Created by modmuss50 on 12/05/2016.
|
||||
*/
|
||||
public class InsertingFluidPipe extends MultipartFluidPipe {
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.INSERT;
|
||||
}
|
||||
@Override
|
||||
public EnumFluidPipeTypes getPipeType() {
|
||||
return EnumFluidPipeTypes.INSERT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package techreborn.parts.fluidPipes;
|
||||
|
||||
import reborncore.mcmultipart.item.ItemMultiPart;
|
||||
import reborncore.mcmultipart.multipart.IMultipart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -9,6 +7,8 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.mcmultipart.item.ItemMultiPart;
|
||||
import reborncore.mcmultipart.multipart.IMultipart;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
|
||||
/**
|
||||
|
@ -16,14 +16,14 @@ import techreborn.client.TechRebornCreativeTab;
|
|||
*/
|
||||
public class ItemFluidPipe extends ItemMultiPart {
|
||||
|
||||
public ItemFluidPipe() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setUnlocalizedName("techreborn.fluidpipe");
|
||||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
}
|
||||
public ItemFluidPipe() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setUnlocalizedName("techreborn.fluidpipe");
|
||||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack, EntityPlayer player) {
|
||||
return new EmptyFluidPipe();
|
||||
}
|
||||
@Override
|
||||
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack, EntityPlayer player) {
|
||||
return new EmptyFluidPipe();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package techreborn.parts.fluidPipes;
|
||||
|
||||
import reborncore.mcmultipart.MCMultiPartMod;
|
||||
import reborncore.mcmultipart.microblock.IMicroblock;
|
||||
import reborncore.mcmultipart.multipart.*;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -35,6 +31,10 @@ import reborncore.common.misc.vecmath.Vecs3dCube;
|
|||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.Tank;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import reborncore.mcmultipart.MCMultiPartMod;
|
||||
import reborncore.mcmultipart.microblock.IMicroblock;
|
||||
import reborncore.mcmultipart.multipart.*;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import techreborn.lib.MessageIDs;
|
||||
import techreborn.parts.TechRebornParts;
|
||||
|
||||
|
@ -45,386 +45,386 @@ import java.util.*;
|
|||
*/
|
||||
public abstract class MultipartFluidPipe extends Multipart implements INormallyOccludingPart, ISlottedPart, ITickable, IPartType {
|
||||
|
||||
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
|
||||
public static final IUnlistedProperty<Boolean> DOWN = Properties.toUnlisted(PropertyBool.create("down"));
|
||||
public static final IUnlistedProperty<Boolean> NORTH = Properties.toUnlisted(PropertyBool.create("north"));
|
||||
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);
|
||||
public static final double thickness = 11;
|
||||
public static int mbt = 20;
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<EnumFacing, BlockPos> connectedSides;
|
||||
Tank tank = new Tank("MultipartFluidPipe", 1000, null);
|
||||
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
|
||||
public static final IUnlistedProperty<Boolean> DOWN = Properties.toUnlisted(PropertyBool.create("down"));
|
||||
public static final IUnlistedProperty<Boolean> NORTH = Properties.toUnlisted(PropertyBool.create("north"));
|
||||
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);
|
||||
public static final double thickness = 11;
|
||||
public static int mbt = 20;
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<EnumFacing, BlockPos> connectedSides;
|
||||
Tank tank = new Tank("MultipartFluidPipe", 1000, null);
|
||||
|
||||
public MultipartFluidPipe() {
|
||||
connectedSides = new HashMap<>();
|
||||
refreshBounding();
|
||||
}
|
||||
public MultipartFluidPipe() {
|
||||
connectedSides = new HashMap<>();
|
||||
refreshBounding();
|
||||
}
|
||||
|
||||
public static MultipartFluidPipe getPartFromWorld(World world, BlockPos pos, EnumFacing side) {
|
||||
if (world == null || pos == null) {
|
||||
return null;
|
||||
}
|
||||
IMultipartContainer container = MultipartHelper.getPartContainer(world, pos);
|
||||
if (side != null && container != null) {
|
||||
ISlottedPart slottedPart = container.getPartInSlot(PartSlot.getFaceSlot(side));
|
||||
if (slottedPart instanceof IMicroblock.IFaceMicroblock && !((IMicroblock.IFaceMicroblock) slottedPart)
|
||||
.isFaceHollow()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static MultipartFluidPipe getPartFromWorld(World world, BlockPos pos, EnumFacing side) {
|
||||
if (world == null || pos == null) {
|
||||
return null;
|
||||
}
|
||||
IMultipartContainer container = MultipartHelper.getPartContainer(world, pos);
|
||||
if (side != null && container != null) {
|
||||
ISlottedPart slottedPart = container.getPartInSlot(PartSlot.getFaceSlot(side));
|
||||
if (slottedPart instanceof IMicroblock.IFaceMicroblock && !((IMicroblock.IFaceMicroblock) slottedPart)
|
||||
.isFaceHollow()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (container == null) {
|
||||
return null;
|
||||
}
|
||||
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
|
||||
if (part instanceof MultipartFluidPipe) {
|
||||
return (MultipartFluidPipe) part;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (container == null) {
|
||||
return null;
|
||||
}
|
||||
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
|
||||
if (part instanceof MultipartFluidPipe) {
|
||||
return (MultipartFluidPipe) part;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void refreshBounding() {
|
||||
float centerFirst = center - offset;
|
||||
double w = (thickness / 16) - 0.5;
|
||||
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, centerFirst - w, centerFirst + w,
|
||||
centerFirst + w, centerFirst + w);
|
||||
public void refreshBounding() {
|
||||
float centerFirst = center - offset;
|
||||
double w = (thickness / 16) - 0.5;
|
||||
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, centerFirst - w, centerFirst + w,
|
||||
centerFirst + w, centerFirst + w);
|
||||
|
||||
int i = 0;
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
double xMin1 = (dir.getFrontOffsetX() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetX() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double xMax1 = (dir.getFrontOffsetX() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetX() == 0 ? centerFirst + w : centerFirst - w));
|
||||
int i = 0;
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
double xMin1 = (dir.getFrontOffsetX() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetX() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double xMax1 = (dir.getFrontOffsetX() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetX() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double yMin1 = (dir.getFrontOffsetY() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetY() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double yMax1 = (dir.getFrontOffsetY() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetY() == 0 ? centerFirst + w : centerFirst - w));
|
||||
double yMin1 = (dir.getFrontOffsetY() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetY() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double yMax1 = (dir.getFrontOffsetY() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetY() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double zMin1 = (dir.getFrontOffsetZ() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetZ() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double zMax1 = (dir.getFrontOffsetZ() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetZ() == 0 ? centerFirst + w : centerFirst - w));
|
||||
double zMin1 = (dir.getFrontOffsetZ() < 0 ?
|
||||
0.0 :
|
||||
(dir.getFrontOffsetZ() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double zMax1 = (dir.getFrontOffsetZ() > 0 ?
|
||||
1.0 :
|
||||
(dir.getFrontOffsetZ() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, yMax1, zMax1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, yMax1, zMax1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
|
||||
@Override
|
||||
public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
|
||||
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir) && mask
|
||||
.intersectsWith(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB()))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
if (mask.intersectsWith(boundingBoxes[6].toAABB())) {
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
super.addCollisionBoxes(mask, list, collidingEntity);
|
||||
}
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir) && mask
|
||||
.intersectsWith(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB()))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
if (mask.intersectsWith(boundingBoxes[6].toAABB())) {
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
super.addCollisionBoxes(mask, list, collidingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionBoxes(List<AxisAlignedBB> list) {
|
||||
@Override
|
||||
public void addSelectionBoxes(List<AxisAlignedBB> list) {
|
||||
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
super.addSelectionBoxes(list);
|
||||
}
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
super.addSelectionBoxes(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
MultipartFluidPipe multipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipart != null) {
|
||||
multipart.nearByChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
MultipartFluidPipe multipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipart != null) {
|
||||
multipart.nearByChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOcclusionBoxes(List<AxisAlignedBB> list) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
@Override
|
||||
public void addOcclusionBoxes(List<AxisAlignedBB> list) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block block) {
|
||||
super.onNeighborBlockChange(block);
|
||||
nearByChange();
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block block) {
|
||||
super.onNeighborBlockChange(block);
|
||||
nearByChange();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void nearByChange() {
|
||||
checkConnectedSides();
|
||||
for (EnumFacing direction : EnumFacing.VALUES) {
|
||||
BlockPos blockPos = getPos().offset(direction);
|
||||
WorldUtils.updateBlock(getWorld(), blockPos);
|
||||
MultipartFluidPipe part = getPartFromWorld(getWorld(), blockPos, direction);
|
||||
if (part != null) {
|
||||
part.checkConnectedSides();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void nearByChange() {
|
||||
checkConnectedSides();
|
||||
for (EnumFacing direction : EnumFacing.VALUES) {
|
||||
BlockPos blockPos = getPos().offset(direction);
|
||||
WorldUtils.updateBlock(getWorld(), blockPos);
|
||||
MultipartFluidPipe part = getPartFromWorld(getWorld(), blockPos, direction);
|
||||
if (part != null) {
|
||||
part.checkConnectedSides();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
nearByChange();
|
||||
}
|
||||
@Override
|
||||
public void onAdded() {
|
||||
nearByChange();
|
||||
}
|
||||
|
||||
public boolean shouldConnectTo(EnumFacing dir) {
|
||||
if (dir != null) {
|
||||
if (internalShouldConnectTo(dir)) {
|
||||
MultipartFluidPipe multipartFluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipartFluidPipe != null && multipartFluidPipe.internalShouldConnectTo(dir.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TileEntity tile = getNeighbourTile(dir);
|
||||
public boolean shouldConnectTo(EnumFacing dir) {
|
||||
if (dir != null) {
|
||||
if (internalShouldConnectTo(dir)) {
|
||||
MultipartFluidPipe multipartFluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipartFluidPipe != null && multipartFluidPipe.internalShouldConnectTo(dir.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TileEntity tile = getNeighbourTile(dir);
|
||||
|
||||
if (tile instanceof IFluidHandler && (getPipeType() == EnumFluidPipeTypes.EXTRACT
|
||||
|| getPipeType() == EnumFluidPipeTypes.INSERT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (tile instanceof IFluidHandler && (getPipeType() == EnumFluidPipeTypes.EXTRACT
|
||||
|| getPipeType() == EnumFluidPipeTypes.INSERT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean internalShouldConnectTo(EnumFacing dir) {
|
||||
ISlottedPart part = getContainer().getPartInSlot(PartSlot.getFaceSlot(dir));
|
||||
if (part instanceof IMicroblock.IFaceMicroblock) {
|
||||
if (!((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean internalShouldConnectTo(EnumFacing dir) {
|
||||
ISlottedPart part = getContainer().getPartInSlot(PartSlot.getFaceSlot(dir));
|
||||
if (part instanceof IMicroblock.IFaceMicroblock) {
|
||||
if (!((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), p -> p == this,
|
||||
boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
|
||||
return false;
|
||||
}
|
||||
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), p -> p == this,
|
||||
boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultipartFluidPipe multipartFluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir.getOpposite());
|
||||
MultipartFluidPipe multipartFluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir.getOpposite());
|
||||
|
||||
return multipartFluidPipe != null;
|
||||
}
|
||||
return multipartFluidPipe != null;
|
||||
}
|
||||
|
||||
public TileEntity getNeighbourTile(EnumFacing side) {
|
||||
return side != null ? getWorld().getTileEntity(getPos().offset(side)) : null;
|
||||
}
|
||||
public TileEntity getNeighbourTile(EnumFacing side) {
|
||||
return side != null ? getWorld().getTileEntity(getPos().offset(side)) : null;
|
||||
}
|
||||
|
||||
public void checkConnectedSides() {
|
||||
refreshBounding();
|
||||
connectedSides = new HashMap<>();
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
int d = Functions.getIntDirFromDirection(dir);
|
||||
if (getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (shouldConnectTo(dir)) {
|
||||
connectedSides.put(dir, te.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void checkConnectedSides() {
|
||||
refreshBounding();
|
||||
connectedSides = new HashMap<>();
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
int d = Functions.getIntDirFromDirection(dir);
|
||||
if (getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (shouldConnectTo(dir)) {
|
||||
connectedSides.put(dir, te.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<PartSlot> getSlotMask() {
|
||||
return EnumSet.of(PartSlot.CENTER);
|
||||
}
|
||||
@Override
|
||||
public EnumSet<PartSlot> getSlotMask() {
|
||||
return EnumSet.of(PartSlot.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state) {
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
return extendedBlockState.withProperty(DOWN, shouldConnectTo(EnumFacing.DOWN))
|
||||
.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(TYPE, getPipeType());
|
||||
}
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state) {
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
return extendedBlockState.withProperty(DOWN, shouldConnectTo(EnumFacing.DOWN))
|
||||
.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(TYPE, getPipeType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[]{TYPE},
|
||||
new IUnlistedProperty[]{DOWN, UP, NORTH, SOUTH, WEST, EAST});
|
||||
}
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[] { TYPE },
|
||||
new IUnlistedProperty[] { DOWN, UP, NORTH, SOUTH, WEST, EAST });
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness(PartMOP hit) {
|
||||
return 0.5F;
|
||||
}
|
||||
@Override
|
||||
public float getHardness(PartMOP hit) {
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return Material.CLOTH;
|
||||
}
|
||||
public Material getMaterial() {
|
||||
return Material.CLOTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(TechRebornParts.fluidPipe, 1, 0));
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(TechRebornParts.fluidPipe, 1, 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelPath() {
|
||||
return new ResourceLocation("techreborn:fluidpipe");
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getModelPath() {
|
||||
return new ResourceLocation("techreborn:fluidpipe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!getWorld().isRemote) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
//if (connectedSides.containsKey(dir)) {
|
||||
MultipartFluidPipe fluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (fluidPipe != null) {
|
||||
if (!tank.isEmpty()) {
|
||||
if (fluidPipe.tank.isEmpty() || fluidPipe.tank.getFluid().getFluid() == tank.getFluid()
|
||||
.getFluid()) {
|
||||
if (fluidPipe.tank.getFluidAmount() < tank.getFluidAmount()) {
|
||||
int freeSpace = fluidPipe.tank.getCapacity();
|
||||
if (!fluidPipe.tank.isEmpty()) {
|
||||
freeSpace = fluidPipe.tank.getCapacity() - fluidPipe.tank.getFluidAmount();
|
||||
}
|
||||
int difference = tank.getFluidAmount() - freeSpace;
|
||||
int amountToChange = difference / 2;
|
||||
fluidPipe.tank.setFluid(tank.getFluid());
|
||||
fluidPipe.tank.setFluidAmount(fluidPipe.tank.getFluidAmount() + amountToChange);
|
||||
tank.setFluidAmount(tank.getFluidAmount() - amountToChange);
|
||||
}
|
||||
@Override
|
||||
public void update() {
|
||||
if (!getWorld().isRemote) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
//if (connectedSides.containsKey(dir)) {
|
||||
MultipartFluidPipe fluidPipe = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (fluidPipe != null) {
|
||||
if (!tank.isEmpty()) {
|
||||
if (fluidPipe.tank.isEmpty() || fluidPipe.tank.getFluid().getFluid() == tank.getFluid()
|
||||
.getFluid()) {
|
||||
if (fluidPipe.tank.getFluidAmount() < tank.getFluidAmount()) {
|
||||
int freeSpace = fluidPipe.tank.getCapacity();
|
||||
if (!fluidPipe.tank.isEmpty()) {
|
||||
freeSpace = fluidPipe.tank.getCapacity() - fluidPipe.tank.getFluidAmount();
|
||||
}
|
||||
int difference = tank.getFluidAmount() - freeSpace;
|
||||
int amountToChange = difference / 2;
|
||||
fluidPipe.tank.setFluid(tank.getFluid());
|
||||
fluidPipe.tank.setFluidAmount(fluidPipe.tank.getFluidAmount() + amountToChange);
|
||||
tank.setFluidAmount(tank.getFluidAmount() - amountToChange);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
TileEntity tileEntity = getNeighbourTile(dir);
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof IFluidHandler) {
|
||||
IFluidHandler handler = (IFluidHandler) tileEntity;
|
||||
if (getPipeType() == EnumFluidPipeTypes.EXTRACT) {
|
||||
if (!tank.isFull()) {
|
||||
FluidTankInfo[] fluidTankInfos = handler.getTankInfo(dir.getOpposite());
|
||||
if (fluidTankInfos.length != 0) {
|
||||
FluidTankInfo info = fluidTankInfos[0];
|
||||
if (info != null & info.fluid != null) {
|
||||
if (tank.isEmpty() || info.fluid.getFluid() == tank.getFluid().getFluid()) {
|
||||
if (handler.canDrain(dir.getOpposite(), info.fluid.getFluid())) {
|
||||
int amountToMove = Math
|
||||
.min(mbt, tank.getCapacity() - tank.getFluidAmount());
|
||||
int fluidAmount = tank.getFluidAmount();
|
||||
FluidStack fluidStack = handler
|
||||
.drain(dir.getOpposite(), amountToMove, true);
|
||||
tank.fill(fluidStack, true);
|
||||
tank.setFluid(fluidStack);
|
||||
tank.setFluidAmount(fluidAmount + amountToMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (getPipeType() == EnumFluidPipeTypes.INSERT) {
|
||||
if (!tank.isEmpty()) {
|
||||
FluidTankInfo[] fluidTankInfos = handler.getTankInfo(dir.getOpposite());
|
||||
if (fluidTankInfos.length != 0) {
|
||||
FluidTankInfo info = fluidTankInfos[0];
|
||||
if (info.fluid == null || info.fluid.getFluid() == null
|
||||
|| info.fluid.getFluid() == tank.getFluid().getFluid() && handler
|
||||
.canFill(dir.getOpposite(), tank.getFluid().getFluid())) {
|
||||
int infoSpace = info.capacity;
|
||||
if (info.fluid != null) {
|
||||
infoSpace = info.capacity - info.fluid.amount;
|
||||
}
|
||||
int amountToMove = Math.min(mbt, infoSpace);
|
||||
FluidStack fluidStack = tank.drain(amountToMove, true);
|
||||
handler.fill(dir.getOpposite(), fluidStack, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
TileEntity tileEntity = getNeighbourTile(dir);
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof IFluidHandler) {
|
||||
IFluidHandler handler = (IFluidHandler) tileEntity;
|
||||
if (getPipeType() == EnumFluidPipeTypes.EXTRACT) {
|
||||
if (!tank.isFull()) {
|
||||
FluidTankInfo[] fluidTankInfos = handler.getTankInfo(dir.getOpposite());
|
||||
if (fluidTankInfos.length != 0) {
|
||||
FluidTankInfo info = fluidTankInfos[0];
|
||||
if (info != null & info.fluid != null) {
|
||||
if (tank.isEmpty() || info.fluid.getFluid() == tank.getFluid().getFluid()) {
|
||||
if (handler.canDrain(dir.getOpposite(), info.fluid.getFluid())) {
|
||||
int amountToMove = Math
|
||||
.min(mbt, tank.getCapacity() - tank.getFluidAmount());
|
||||
int fluidAmount = tank.getFluidAmount();
|
||||
FluidStack fluidStack = handler
|
||||
.drain(dir.getOpposite(), amountToMove, true);
|
||||
tank.fill(fluidStack, true);
|
||||
tank.setFluid(fluidStack);
|
||||
tank.setFluidAmount(fluidAmount + amountToMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (getPipeType() == EnumFluidPipeTypes.INSERT) {
|
||||
if (!tank.isEmpty()) {
|
||||
FluidTankInfo[] fluidTankInfos = handler.getTankInfo(dir.getOpposite());
|
||||
if (fluidTankInfos.length != 0) {
|
||||
FluidTankInfo info = fluidTankInfos[0];
|
||||
if (info.fluid == null || info.fluid.getFluid() == null
|
||||
|| info.fluid.getFluid() == tank.getFluid().getFluid() && handler
|
||||
.canFill(dir.getOpposite(), tank.getFluid().getFluid())) {
|
||||
int infoSpace = info.capacity;
|
||||
if (info.fluid != null) {
|
||||
infoSpace = info.capacity - info.fluid.amount;
|
||||
}
|
||||
int amountToMove = Math.min(mbt, infoSpace);
|
||||
FluidStack fluidStack = tank.drain(amountToMove, true);
|
||||
handler.fill(dir.getOpposite(), fluidStack, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand, ItemStack heldItem, PartMOP hit) {
|
||||
//TODO make only wrench able to change mode, shift-click with wrench picks up pipe, and click with empty hand displays current mode in chat (doesn't change it)
|
||||
@Override
|
||||
public boolean onActivated(EntityPlayer player, EnumHand hand, ItemStack heldItem, PartMOP hit) {
|
||||
//TODO make only wrench able to change mode, shift-click with wrench picks up pipe, and click with empty hand displays current mode in chat (doesn't change it)
|
||||
|
||||
System.out.println(getWorld().isRemote);
|
||||
System.out.println(getWorld().isRemote);
|
||||
|
||||
if(!getWorld().isRemote){
|
||||
if (getPipeType() == EnumFluidPipeTypes.EMPTY) {
|
||||
setPartType(EnumFluidPipeTypes.EXTRACT, this);
|
||||
} else if (getPipeType() == EnumFluidPipeTypes.EXTRACT) {
|
||||
setPartType(EnumFluidPipeTypes.INSERT, this);
|
||||
} else if (getPipeType()== EnumFluidPipeTypes.INSERT) {
|
||||
setPartType(EnumFluidPipeTypes.EMPTY, this);
|
||||
}
|
||||
}
|
||||
if (!getWorld().isRemote) {
|
||||
if (getPipeType() == EnumFluidPipeTypes.EMPTY) {
|
||||
setPartType(EnumFluidPipeTypes.EXTRACT, this);
|
||||
} else if (getPipeType() == EnumFluidPipeTypes.EXTRACT) {
|
||||
setPartType(EnumFluidPipeTypes.INSERT, this);
|
||||
} else if (getPipeType() == EnumFluidPipeTypes.INSERT) {
|
||||
setPartType(EnumFluidPipeTypes.EMPTY, this);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setPartType(EnumFluidPipeTypes type, MultipartFluidPipe pipe){
|
||||
World world = pipe.getWorld();
|
||||
BlockPos pos = pipe.getPos();
|
||||
Tank tank = pipe.tank;
|
||||
pipe.getContainer().removePart(pipe);
|
||||
MultipartFluidPipe newPipe = null;
|
||||
switch (type){
|
||||
case EMPTY:
|
||||
newPipe = new EmptyFluidPipe();
|
||||
break;
|
||||
case INSERT:
|
||||
newPipe = new InsertingFluidPipe();
|
||||
break;
|
||||
case EXTRACT:
|
||||
newPipe = new ExtractingFluidPipe();
|
||||
break;
|
||||
}
|
||||
newPipe.tank = tank;
|
||||
MultipartHelper.addPart(world, pos, newPipe);
|
||||
public void setPartType(EnumFluidPipeTypes type, MultipartFluidPipe pipe) {
|
||||
World world = pipe.getWorld();
|
||||
BlockPos pos = pipe.getPos();
|
||||
Tank tank = pipe.tank;
|
||||
pipe.getContainer().removePart(pipe);
|
||||
MultipartFluidPipe newPipe = null;
|
||||
switch (type) {
|
||||
case EMPTY:
|
||||
newPipe = new EmptyFluidPipe();
|
||||
break;
|
||||
case INSERT:
|
||||
newPipe = new InsertingFluidPipe();
|
||||
break;
|
||||
case EXTRACT:
|
||||
newPipe = new ExtractingFluidPipe();
|
||||
break;
|
||||
}
|
||||
newPipe.tank = tank;
|
||||
MultipartHelper.addPart(world, pos, newPipe);
|
||||
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.fluidPipeID, new TextComponentString(
|
||||
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " " +
|
||||
type.colour + reborncore.common.util.StringUtils.toFirstCapital(type.getName())));
|
||||
}
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.fluidPipeID, new TextComponentString(
|
||||
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.setTo") + " " +
|
||||
type.colour + reborncore.common.util.StringUtils.toFirstCapital(type.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package techreborn.parts.powerCables;
|
||||
|
||||
import reborncore.mcmultipart.MCMultiPartMod;
|
||||
import reborncore.mcmultipart.microblock.IMicroblock;
|
||||
import reborncore.mcmultipart.multipart.*;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -29,6 +25,10 @@ import reborncore.api.power.IEnergyInterfaceTile;
|
|||
import reborncore.common.misc.Functions;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import reborncore.mcmultipart.MCMultiPartMod;
|
||||
import reborncore.mcmultipart.microblock.IMicroblock;
|
||||
import reborncore.mcmultipart.multipart.*;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.parts.TechRebornParts;
|
||||
|
@ -42,378 +42,378 @@ import java.util.*;
|
|||
* Created by modmuss50 on 02/03/2016.
|
||||
*/
|
||||
public abstract class CableMultipart extends Multipart
|
||||
implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType, IPartWaliaProvider {
|
||||
implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType, IPartWaliaProvider {
|
||||
|
||||
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
|
||||
public static final IUnlistedProperty<Boolean> DOWN = Properties.toUnlisted(PropertyBool.create("down"));
|
||||
public static final IUnlistedProperty<Boolean> NORTH = Properties.toUnlisted(PropertyBool.create("north"));
|
||||
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<EnumCableType> TYPE = PropertyEnum.create("type", EnumCableType.class);
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<EnumFacing, BlockPos> connectedSides;
|
||||
public int ticks = 0;
|
||||
public ItemStack stack;
|
||||
public TRPowerNet mergeWith = null;
|
||||
private TRPowerNet network;
|
||||
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
|
||||
public static final IUnlistedProperty<Boolean> DOWN = Properties.toUnlisted(PropertyBool.create("down"));
|
||||
public static final IUnlistedProperty<Boolean> NORTH = Properties.toUnlisted(PropertyBool.create("north"));
|
||||
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<EnumCableType> TYPE = PropertyEnum.create("type", EnumCableType.class);
|
||||
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
|
||||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<EnumFacing, BlockPos> connectedSides;
|
||||
public int ticks = 0;
|
||||
public ItemStack stack;
|
||||
public TRPowerNet mergeWith = null;
|
||||
private TRPowerNet network;
|
||||
|
||||
public CableMultipart() {
|
||||
connectedSides = new HashMap<>();
|
||||
refreshBounding();
|
||||
}
|
||||
public CableMultipart() {
|
||||
connectedSides = new HashMap<>();
|
||||
refreshBounding();
|
||||
}
|
||||
|
||||
public static CableMultipart getPartFromWorld(World world, BlockPos pos, EnumFacing side) {
|
||||
if (world == null || pos == null) {
|
||||
return null;
|
||||
}
|
||||
IMultipartContainer container = MultipartHelper.getPartContainer(world, pos);
|
||||
if (side != null && container != null) {
|
||||
ISlottedPart slottedPart = container.getPartInSlot(PartSlot.getFaceSlot(side));
|
||||
if (slottedPart instanceof IMicroblock.IFaceMicroblock
|
||||
&& !((IMicroblock.IFaceMicroblock) slottedPart).isFaceHollow()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static CableMultipart getPartFromWorld(World world, BlockPos pos, EnumFacing side) {
|
||||
if (world == null || pos == null) {
|
||||
return null;
|
||||
}
|
||||
IMultipartContainer container = MultipartHelper.getPartContainer(world, pos);
|
||||
if (side != null && container != null) {
|
||||
ISlottedPart slottedPart = container.getPartInSlot(PartSlot.getFaceSlot(side));
|
||||
if (slottedPart instanceof IMicroblock.IFaceMicroblock
|
||||
&& !((IMicroblock.IFaceMicroblock) slottedPart).isFaceHollow()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (container == null) {
|
||||
return null;
|
||||
}
|
||||
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
|
||||
if (part instanceof CableMultipart) {
|
||||
return (CableMultipart) part;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (container == null) {
|
||||
return null;
|
||||
}
|
||||
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
|
||||
if (part instanceof CableMultipart) {
|
||||
return (CableMultipart) part;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void refreshBounding() {
|
||||
float centerFirst = center - offset;
|
||||
double w = (getCableType().cableThickness / 16) - 0.5;
|
||||
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, centerFirst - w, centerFirst + w,
|
||||
centerFirst + w, centerFirst + w);
|
||||
public void refreshBounding() {
|
||||
float centerFirst = center - offset;
|
||||
double w = (getCableType().cableThickness / 16) - 0.5;
|
||||
boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, centerFirst - w, centerFirst + w,
|
||||
centerFirst + w, centerFirst + w);
|
||||
|
||||
int i = 0;
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
double xMin1 = (dir.getFrontOffsetX() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetX() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double xMax1 = (dir.getFrontOffsetX() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetX() == 0 ? centerFirst + w : centerFirst - w));
|
||||
int i = 0;
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
double xMin1 = (dir.getFrontOffsetX() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetX() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double xMax1 = (dir.getFrontOffsetX() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetX() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double yMin1 = (dir.getFrontOffsetY() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetY() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double yMax1 = (dir.getFrontOffsetY() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetY() == 0 ? centerFirst + w : centerFirst - w));
|
||||
double yMin1 = (dir.getFrontOffsetY() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetY() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double yMax1 = (dir.getFrontOffsetY() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetY() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
double zMin1 = (dir.getFrontOffsetZ() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetZ() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double zMax1 = (dir.getFrontOffsetZ() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetZ() == 0 ? centerFirst + w : centerFirst - w));
|
||||
double zMin1 = (dir.getFrontOffsetZ() < 0 ? 0.0
|
||||
: (dir.getFrontOffsetZ() == 0 ? centerFirst - w : centerFirst + w));
|
||||
double zMax1 = (dir.getFrontOffsetZ() > 0 ? 1.0
|
||||
: (dir.getFrontOffsetZ() == 0 ? centerFirst + w : centerFirst - w));
|
||||
|
||||
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, yMax1, zMax1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, yMax1, zMax1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
|
||||
@Override
|
||||
public void addCollisionBoxes(AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
|
||||
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir)
|
||||
&& mask.intersectsWith(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB()))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
if (mask.intersectsWith(boundingBoxes[6].toAABB())) {
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
super.addCollisionBoxes(mask, list, collidingEntity);
|
||||
}
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir)
|
||||
&& mask.intersectsWith(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB()))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
if (mask.intersectsWith(boundingBoxes[6].toAABB())) {
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
super.addCollisionBoxes(mask, list, collidingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionBoxes(List<AxisAlignedBB> list) {
|
||||
@Override
|
||||
public void addSelectionBoxes(List<AxisAlignedBB> list) {
|
||||
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
super.addSelectionBoxes(list);
|
||||
}
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
super.addSelectionBoxes(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
removeFromNetwork();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
CableMultipart multipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipart != null) {
|
||||
multipart.nearByChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
removeFromNetwork();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
CableMultipart multipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipart != null) {
|
||||
multipart.nearByChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnloaded() {
|
||||
super.onUnloaded();
|
||||
removeFromNetwork();
|
||||
}
|
||||
@Override
|
||||
public void onUnloaded() {
|
||||
super.onUnloaded();
|
||||
removeFromNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOcclusionBoxes(List<AxisAlignedBB> list) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
@Override
|
||||
public void addOcclusionBoxes(List<AxisAlignedBB> list) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
if (connectedSides.containsKey(dir))
|
||||
list.add(boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB());
|
||||
}
|
||||
list.add(boundingBoxes[6].toAABB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block block) {
|
||||
super.onNeighborBlockChange(block);
|
||||
nearByChange();
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block block) {
|
||||
super.onNeighborBlockChange(block);
|
||||
nearByChange();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void nearByChange() {
|
||||
if (network == null) {
|
||||
findAndJoinNetwork(getWorld(), getPos());
|
||||
}
|
||||
checkConnectedSides();
|
||||
for (EnumFacing direction : EnumFacing.VALUES) {
|
||||
BlockPos blockPos = getPos().offset(direction);
|
||||
WorldUtils.updateBlock(getWorld(), blockPos);
|
||||
CableMultipart part = getPartFromWorld(getWorld(), blockPos, direction);
|
||||
if (part != null) {
|
||||
part.checkConnectedSides();
|
||||
}
|
||||
}
|
||||
TRPowerNet.buildEndpoint(network);
|
||||
}
|
||||
public void nearByChange() {
|
||||
if (network == null) {
|
||||
findAndJoinNetwork(getWorld(), getPos());
|
||||
}
|
||||
checkConnectedSides();
|
||||
for (EnumFacing direction : EnumFacing.VALUES) {
|
||||
BlockPos blockPos = getPos().offset(direction);
|
||||
WorldUtils.updateBlock(getWorld(), blockPos);
|
||||
CableMultipart part = getPartFromWorld(getWorld(), blockPos, direction);
|
||||
if (part != null) {
|
||||
part.checkConnectedSides();
|
||||
}
|
||||
}
|
||||
TRPowerNet.buildEndpoint(network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
nearByChange();
|
||||
}
|
||||
@Override
|
||||
public void onAdded() {
|
||||
nearByChange();
|
||||
}
|
||||
|
||||
public boolean shouldConnectTo(EnumFacing dir) {
|
||||
if (dir != null) {
|
||||
if (internalShouldConnectTo(dir)) {
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (cableMultipart != null && cableMultipart.internalShouldConnectTo(dir.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TileEntity tile = getNeighbourTile(dir);
|
||||
public boolean shouldConnectTo(EnumFacing dir) {
|
||||
if (dir != null) {
|
||||
if (internalShouldConnectTo(dir)) {
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (cableMultipart != null && cableMultipart.internalShouldConnectTo(dir.getOpposite())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
TileEntity tile = getNeighbourTile(dir);
|
||||
|
||||
if (tile instanceof IEnergyInterfaceTile) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (tile instanceof IEnergyInterfaceTile) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean internalShouldConnectTo(EnumFacing dir) {
|
||||
ISlottedPart part = getContainer().getPartInSlot(PartSlot.getFaceSlot(dir));
|
||||
if (part instanceof IMicroblock.IFaceMicroblock) {
|
||||
if (!((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean internalShouldConnectTo(EnumFacing dir) {
|
||||
ISlottedPart part = getContainer().getPartInSlot(PartSlot.getFaceSlot(dir));
|
||||
if (part instanceof IMicroblock.IFaceMicroblock) {
|
||||
if (!((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), p -> p == this, boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
|
||||
return false;
|
||||
}
|
||||
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), p -> p == this, boundingBoxes[Functions.getIntDirFromDirection(dir)].toAABB())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir.getOpposite());
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir.getOpposite());
|
||||
|
||||
return cableMultipart != null && cableMultipart.getCableType() == getCableType();
|
||||
}
|
||||
return cableMultipart != null && cableMultipart.getCableType() == getCableType();
|
||||
}
|
||||
|
||||
public TileEntity getNeighbourTile(EnumFacing side) {
|
||||
return side != null ? getWorld().getTileEntity(getPos().offset(side)) : null;
|
||||
}
|
||||
public TileEntity getNeighbourTile(EnumFacing side) {
|
||||
return side != null ? getWorld().getTileEntity(getPos().offset(side)) : null;
|
||||
}
|
||||
|
||||
public void checkConnectedSides() {
|
||||
refreshBounding();
|
||||
connectedSides = new HashMap<>();
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
int d = Functions.getIntDirFromDirection(dir);
|
||||
if (getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (shouldConnectTo(dir)) {
|
||||
connectedSides.put(dir, te.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void checkConnectedSides() {
|
||||
refreshBounding();
|
||||
connectedSides = new HashMap<>();
|
||||
for (EnumFacing dir : EnumFacing.values()) {
|
||||
int d = Functions.getIntDirFromDirection(dir);
|
||||
if (getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (shouldConnectTo(dir)) {
|
||||
connectedSides.put(dir, te.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<PartSlot> getSlotMask() {
|
||||
return EnumSet.of(PartSlot.CENTER);
|
||||
}
|
||||
@Override
|
||||
public EnumSet<PartSlot> getSlotMask() {
|
||||
return EnumSet.of(PartSlot.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (getWorld() != null) {
|
||||
if (getWorld().getTotalWorldTime() % 80 == 0) {
|
||||
checkConnectedSides();
|
||||
}
|
||||
}
|
||||
if (network == null) {
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
} else {
|
||||
if (mergeWith != null) {
|
||||
getNetwork().merge(mergeWith);
|
||||
mergeWith = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void update() {
|
||||
if (getWorld() != null) {
|
||||
if (getWorld().getTotalWorldTime() % 80 == 0) {
|
||||
checkConnectedSides();
|
||||
}
|
||||
}
|
||||
if (network == null) {
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
} else {
|
||||
if (mergeWith != null) {
|
||||
getNetwork().merge(mergeWith);
|
||||
mergeWith = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state) {
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
return extendedBlockState.withProperty(DOWN, shouldConnectTo(EnumFacing.DOWN))
|
||||
.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(TYPE, getCableType());
|
||||
}
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state) {
|
||||
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
|
||||
return extendedBlockState.withProperty(DOWN, shouldConnectTo(EnumFacing.DOWN))
|
||||
.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(TYPE, getCableType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[]{TYPE},
|
||||
new IUnlistedProperty[]{DOWN, UP, NORTH, SOUTH, WEST, EAST});
|
||||
}
|
||||
@Override
|
||||
public BlockStateContainer createBlockState() {
|
||||
return new ExtendedBlockState(MCMultiPartMod.multipart, new IProperty[] { TYPE },
|
||||
new IUnlistedProperty[] { DOWN, UP, NORTH, SOUTH, WEST, EAST });
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness(PartMOP hit) {
|
||||
return 0.5F;
|
||||
}
|
||||
@Override
|
||||
public float getHardness(PartMOP hit) {
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return Material.CLOTH;
|
||||
}
|
||||
public Material getMaterial() {
|
||||
return Material.CLOTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(TechRebornParts.cables, 1, getCableType().ordinal()));
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public List<ItemStack> getDrops() {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(TechRebornParts.cables, 1, getCableType().ordinal()));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollided(Entity entity) {
|
||||
if (getCableType().canKill && entity instanceof EntityLivingBase) {
|
||||
if (network != null) {
|
||||
if (network.getEnergy() != 0) {
|
||||
if (ConfigTechReborn.UninsulatedElectocutionDamage) {
|
||||
if (getCableType() == EnumCableType.HV) {
|
||||
entity.setFire(1);
|
||||
}
|
||||
network.setEnergy(-1);
|
||||
entity.attackEntityFrom(new ElectrialShockSource(), 1F);
|
||||
}
|
||||
if (ConfigTechReborn.UninsulatedElectocutionSound) {
|
||||
getWorld().playSound(null, entity.posX, entity.posY,
|
||||
entity.posZ, ModSounds.shock,
|
||||
SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
}
|
||||
if (ConfigTechReborn.UninsulatedElectocutionParticle) {
|
||||
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onEntityCollided(Entity entity) {
|
||||
if (getCableType().canKill && entity instanceof EntityLivingBase) {
|
||||
if (network != null) {
|
||||
if (network.getEnergy() != 0) {
|
||||
if (ConfigTechReborn.UninsulatedElectocutionDamage) {
|
||||
if (getCableType() == EnumCableType.HV) {
|
||||
entity.setFire(1);
|
||||
}
|
||||
network.setEnergy(-1);
|
||||
entity.attackEntityFrom(new ElectrialShockSource(), 1F);
|
||||
}
|
||||
if (ConfigTechReborn.UninsulatedElectocutionSound) {
|
||||
getWorld().playSound(null, entity.posX, entity.posY,
|
||||
entity.posZ, ModSounds.shock,
|
||||
SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
}
|
||||
if (ConfigTechReborn.UninsulatedElectocutionParticle) {
|
||||
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityStanding(Entity entity) {
|
||||
@Override
|
||||
public void onEntityStanding(Entity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(EntityPlayer player, PartMOP hit) {
|
||||
return new ItemStack(TechRebornParts.cables, 1, getCableType().ordinal());
|
||||
}
|
||||
@Override
|
||||
public ItemStack getPickBlock(EntityPlayer player, PartMOP hit) {
|
||||
return new ItemStack(TechRebornParts.cables, 1, getCableType().ordinal());
|
||||
}
|
||||
|
||||
public final void findAndJoinNetwork(World world, BlockPos pos) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (cableMultipart != null && cableMultipart.getCableType() == getCableType()) {
|
||||
TRPowerNet net = cableMultipart.getNetwork();
|
||||
if (net != null) {
|
||||
network = net;
|
||||
network.addElement(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (network == null) {
|
||||
network = new TRPowerNet(getCableType());
|
||||
network.addElement(this);
|
||||
}
|
||||
network.endpoints.clear();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (te != null && te instanceof IEnergyInterfaceTile) {
|
||||
network.addConnection((IEnergyInterfaceTile) te, dir.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
public final void findAndJoinNetwork(World world, BlockPos pos) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
CableMultipart cableMultipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (cableMultipart != null && cableMultipart.getCableType() == getCableType()) {
|
||||
TRPowerNet net = cableMultipart.getNetwork();
|
||||
if (net != null) {
|
||||
network = net;
|
||||
network.addElement(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (network == null) {
|
||||
network = new TRPowerNet(getCableType());
|
||||
network.addElement(this);
|
||||
}
|
||||
network.endpoints.clear();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
TileEntity te = getNeighbourTile(dir);
|
||||
if (te != null && te instanceof IEnergyInterfaceTile) {
|
||||
network.addConnection((IEnergyInterfaceTile) te, dir.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final TRPowerNet getNetwork() {
|
||||
return network;
|
||||
}
|
||||
public final TRPowerNet getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
public final void setNetwork(TRPowerNet n) {
|
||||
if (n == null) {
|
||||
} else {
|
||||
network = n;
|
||||
network.addElement(this);
|
||||
}
|
||||
}
|
||||
public final void setNetwork(TRPowerNet n) {
|
||||
if (n == null) {
|
||||
} else {
|
||||
network = n;
|
||||
network.addElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void removeFromNetwork() {
|
||||
if (network == null) {
|
||||
} else
|
||||
network.removeElement(this);
|
||||
}
|
||||
public final void removeFromNetwork() {
|
||||
if (network == null) {
|
||||
} else
|
||||
network.removeElement(this);
|
||||
}
|
||||
|
||||
public final void rebuildNetwork() {
|
||||
this.removeFromNetwork();
|
||||
this.resetNetwork();
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
}
|
||||
public final void rebuildNetwork() {
|
||||
this.removeFromNetwork();
|
||||
this.resetNetwork();
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
}
|
||||
|
||||
public final void resetNetwork() {
|
||||
if (network != null) {
|
||||
network.removeElement(this);
|
||||
}
|
||||
public final void resetNetwork() {
|
||||
if (network != null) {
|
||||
network.removeElement(this);
|
||||
}
|
||||
|
||||
network = null;
|
||||
}
|
||||
network = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info) {
|
||||
info.add(TextFormatting.GREEN + "EU Transfer: " +
|
||||
TextFormatting.LIGHT_PURPLE + getCableType().transferRate);
|
||||
if (getCableType().canKill) {
|
||||
info.add(TextFormatting.RED + "Damages entity's!");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addInfo(List<String> info) {
|
||||
info.add(TextFormatting.GREEN + "EU Transfer: " +
|
||||
TextFormatting.LIGHT_PURPLE + getCableType().transferRate);
|
||||
if (getCableType().canKill) {
|
||||
info.add(TextFormatting.RED + "Damages entity's!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelPath() {
|
||||
return new ResourceLocation("techreborn:cable");
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getModelPath() {
|
||||
return new ResourceLocation("techreborn:cable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,9 @@ package techreborn.parts.powerCables;
|
|||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import techreborn.parts.powerCables.types.CopperCable;
|
||||
import techreborn.parts.powerCables.types.GlassFiberCable;
|
||||
import techreborn.parts.powerCables.types.GoldCable;
|
||||
import techreborn.parts.powerCables.types.HVCable;
|
||||
import techreborn.parts.powerCables.types.InsulatedCopperCable;
|
||||
import techreborn.parts.powerCables.types.InsulatedGoldCable;
|
||||
import techreborn.parts.powerCables.types.InsulatedHVCable;
|
||||
import techreborn.parts.powerCables.types.TinCable;
|
||||
import techreborn.parts.powerCables.types.*;
|
||||
|
||||
public enum EnumCableType implements IStringSerializable
|
||||
{
|
||||
public enum EnumCableType implements IStringSerializable {
|
||||
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, EnumPowerTier.LOW, CopperCable.class),
|
||||
TIN("tin", "techreborn:blocks/cables/tin_cable", 32, 12.0, true, EnumPowerTier.MEDIUM, TinCable.class),
|
||||
GOLD("gold", "techreborn:blocks/cables/gold_cable", 512, 12.0, true, EnumPowerTier.MEDIUM, GoldCable.class),
|
||||
|
@ -31,8 +23,7 @@ public enum EnumCableType implements IStringSerializable
|
|||
private String friendlyName;
|
||||
|
||||
EnumCableType(String friendlyName, String textureName, int transferRate, double cableThickness, boolean canKill,
|
||||
EnumPowerTier tier, Class<? extends CableMultipart> cableClass)
|
||||
{
|
||||
EnumPowerTier tier, Class<? extends CableMultipart> cableClass) {
|
||||
this.friendlyName = friendlyName;
|
||||
this.textureName = textureName;
|
||||
this.transferRate = transferRate;
|
||||
|
@ -43,8 +34,7 @@ public enum EnumCableType implements IStringSerializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return friendlyName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@ import reborncore.api.power.EnumPowerTier;
|
|||
|
||||
public enum EnumStandaloneCableType implements IStringSerializable {
|
||||
COPPER("copper", "techreborn:blocks/cables/copper_cable", 128, 12.0, true, EnumPowerTier.LOW), TIN("tin",
|
||||
"techreborn:blocks/cables/tin_cable", 32, 12.0, true, EnumPowerTier.MEDIUM), GOLD("gold",
|
||||
"techreborn:blocks/cables/gold_cable", 512, 12.0, true, EnumPowerTier.MEDIUM), HV("hv",
|
||||
"techreborn:blocks/cables/hv_cable", 2048, 12.0, true,
|
||||
EnumPowerTier.HIGH), GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable",
|
||||
8192, 12.0, false, EnumPowerTier.HIGH), ICOPPER("insulatedcopper",
|
||||
"techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false,
|
||||
EnumPowerTier.LOW), IGOLD("insulatedgold",
|
||||
"techreborn:blocks/cables/gold_insulated_cable", 512, 10.0, false,
|
||||
EnumPowerTier.MEDIUM), IHV("insulatedhv",
|
||||
"techreborn:blocks/cables/hv_insulated_cable", 2048, 10.0,
|
||||
false, EnumPowerTier.HIGH);
|
||||
"techreborn:blocks/cables/tin_cable", 32, 12.0, true, EnumPowerTier.MEDIUM), GOLD("gold",
|
||||
"techreborn:blocks/cables/gold_cable", 512, 12.0, true, EnumPowerTier.MEDIUM), HV("hv",
|
||||
"techreborn:blocks/cables/hv_cable", 2048, 12.0, true,
|
||||
EnumPowerTier.HIGH), GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable",
|
||||
8192, 12.0, false, EnumPowerTier.HIGH), ICOPPER("insulatedcopper",
|
||||
"techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false,
|
||||
EnumPowerTier.LOW), IGOLD("insulatedgold",
|
||||
"techreborn:blocks/cables/gold_insulated_cable", 512, 10.0, false,
|
||||
EnumPowerTier.MEDIUM), IHV("insulatedhv",
|
||||
"techreborn:blocks/cables/hv_insulated_cable", 2048, 10.0,
|
||||
false, EnumPowerTier.HIGH);
|
||||
|
||||
public String textureName = "minecraft:blocks/iron_block";
|
||||
public int transferRate = 128;
|
||||
|
@ -25,7 +25,7 @@ public enum EnumStandaloneCableType implements IStringSerializable {
|
|||
private String friendlyName;
|
||||
|
||||
EnumStandaloneCableType(String friendlyName, String textureName, int transferRate, double cableThickness,
|
||||
boolean canKill, EnumPowerTier tier) {
|
||||
boolean canKill, EnumPowerTier tier) {
|
||||
this.friendlyName = friendlyName;
|
||||
this.textureName = textureName;
|
||||
this.transferRate = transferRate;
|
||||
|
|
|
@ -3,8 +3,7 @@ package techreborn.parts.powerCables;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public interface ICableType
|
||||
{
|
||||
public interface ICableType {
|
||||
|
||||
EnumCableType getCableType();
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package techreborn.parts.powerCables;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import reborncore.mcmultipart.item.ItemMultiPart;
|
||||
import reborncore.mcmultipart.multipart.IMultipart;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -19,18 +15,20 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.mcmultipart.item.ItemMultiPart;
|
||||
import reborncore.mcmultipart.multipart.IMultipart;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.parts.TechRebornParts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 27/02/2016.
|
||||
*/
|
||||
public class ItemCables extends ItemMultiPart implements ITexturedItem
|
||||
{
|
||||
public class ItemCables extends ItemMultiPart implements ITexturedItem {
|
||||
|
||||
public ItemCables()
|
||||
{
|
||||
public ItemCables() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("techreborn.cable");
|
||||
|
@ -41,13 +39,10 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem
|
|||
|
||||
@Override
|
||||
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack,
|
||||
EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
EntityPlayer player) {
|
||||
try {
|
||||
return TechRebornParts.multipartHashMap.get(EnumCableType.values()[stack.getItemDamage()]).newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
@ -55,11 +50,9 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem
|
|||
|
||||
@Override
|
||||
// gets Unlocalized Name depending on meta data
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack itemStack) {
|
||||
int meta = itemStack.getItemDamage();
|
||||
if (meta < 0 || meta >= EnumCableType.values().length)
|
||||
{
|
||||
if (meta < 0 || meta >= EnumCableType.values().length) {
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
|
@ -67,40 +60,33 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem
|
|||
}
|
||||
|
||||
// Adds Dusts SubItems To Creative Tab
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < EnumCableType.values().length; ++meta)
|
||||
{
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int meta = 0; meta < EnumCableType.values().length; ++meta) {
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureName(int damage)
|
||||
{
|
||||
public String getTextureName(int damage) {
|
||||
return ModInfo.MOD_ID + ":items/cables/" + EnumCableType.values()[damage].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMeta()
|
||||
{
|
||||
public int getMaxMeta() {
|
||||
return EnumCableType.values().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
|
||||
{
|
||||
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
|
||||
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
|
||||
{
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
EnumCableType type = EnumCableType.values()[stack.getItemDamage()];
|
||||
tooltip.add(TextFormatting.GREEN + I18n.translateToLocal("desc.euTransfer") + TextFormatting.LIGHT_PURPLE + type.transferRate);
|
||||
if (type.canKill)
|
||||
{
|
||||
if (type.canKill) {
|
||||
tooltip.add(TextFormatting.RED + I18n.translateToLocal("desc.uninsulatedCable"));
|
||||
}
|
||||
tooltip.add(TextFormatting.GREEN + I18n.translateToLocal("desc.tier") + TextFormatting.LIGHT_PURPLE + type.tier);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package techreborn.parts.powerCables;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -14,16 +11,17 @@ import techreborn.items.ItemTextureBase;
|
|||
import techreborn.lib.ModInfo;
|
||||
import techreborn.parts.StandalonePartCompact;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 06/03/2016.
|
||||
*/
|
||||
public class ItemStandaloneCables extends ItemTextureBase
|
||||
{
|
||||
public class ItemStandaloneCables extends ItemTextureBase {
|
||||
|
||||
public static Item mcPartCable;
|
||||
|
||||
public ItemStandaloneCables()
|
||||
{
|
||||
public ItemStandaloneCables() {
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("techreborn.cable");
|
||||
|
@ -31,31 +29,25 @@ public class ItemStandaloneCables extends ItemTextureBase
|
|||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
}
|
||||
|
||||
public static ItemStack getCableByName(String name, int count)
|
||||
{
|
||||
for (int i = 0; i < EnumStandaloneCableType.values().length; i++)
|
||||
{
|
||||
if (EnumStandaloneCableType.values()[i].getName().equalsIgnoreCase(name))
|
||||
{
|
||||
public static ItemStack getCableByName(String name, int count) {
|
||||
for (int i = 0; i < EnumStandaloneCableType.values().length; i++) {
|
||||
if (EnumStandaloneCableType.values()[i].getName().equalsIgnoreCase(name)) {
|
||||
return new ItemStack(mcPartCable != null ? mcPartCable : StandalonePartCompact.itemStandaloneCable,
|
||||
count, i);
|
||||
count, i);
|
||||
}
|
||||
}
|
||||
throw new InvalidParameterException("The cable " + name + " could not be found.");
|
||||
}
|
||||
|
||||
public static ItemStack getCableByName(String name)
|
||||
{
|
||||
public static ItemStack getCableByName(String name) {
|
||||
return getCableByName(name, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
// gets Unlocalized Name depending on meta data
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack itemStack) {
|
||||
int meta = itemStack.getItemDamage();
|
||||
if (meta < 0 || meta >= EnumStandaloneCableType.values().length)
|
||||
{
|
||||
if (meta < 0 || meta >= EnumStandaloneCableType.values().length) {
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
|
@ -63,23 +55,19 @@ public class ItemStandaloneCables extends ItemTextureBase
|
|||
}
|
||||
|
||||
// Adds Dusts SubItems To Creative Tab
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
|
||||
{
|
||||
for (int meta = 0; meta < EnumStandaloneCableType.values().length; ++meta)
|
||||
{
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int meta = 0; meta < EnumStandaloneCableType.values().length; ++meta) {
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureName(int damage)
|
||||
{
|
||||
public String getTextureName(int damage) {
|
||||
return ModInfo.MOD_ID + ":items/cables/" + EnumStandaloneCableType.values()[damage].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMeta()
|
||||
{
|
||||
public int getMaxMeta() {
|
||||
return EnumStandaloneCableType.values().length;
|
||||
}
|
||||
|
||||
|
@ -91,12 +79,10 @@ public class ItemStandaloneCables extends ItemTextureBase
|
|||
// }
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
|
||||
{
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
EnumStandaloneCableType type = EnumStandaloneCableType.values()[stack.getItemDamage()];
|
||||
tooltip.add(TextFormatting.GREEN + "EU Transfer: " + TextFormatting.LIGHT_PURPLE + type.transferRate);
|
||||
if (type.canKill)
|
||||
{
|
||||
if (type.canKill) {
|
||||
tooltip.add(TextFormatting.RED + "Damages entity's!");
|
||||
}
|
||||
tooltip.add(TextFormatting.RED + "!!INSTALL MCMP TO PLACE CABLES!!");
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class CopperCable extends CableMultipart
|
||||
{
|
||||
public class CopperCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.COPPER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class GlassFiberCable extends CableMultipart
|
||||
{
|
||||
public class GlassFiberCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.GLASSFIBER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class GoldCable extends CableMultipart
|
||||
{
|
||||
public class GoldCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.GOLD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class HVCable extends CableMultipart
|
||||
{
|
||||
public class HVCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.HV;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedCopperCable extends CableMultipart
|
||||
{
|
||||
public class InsulatedCopperCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.ICOPPER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedGoldCable extends CableMultipart
|
||||
{
|
||||
public class InsulatedGoldCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.IGOLD;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedHVCable extends CableMultipart
|
||||
{
|
||||
public class InsulatedHVCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.IHV;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class TinCable extends CableMultipart
|
||||
{
|
||||
public class TinCable extends CableMultipart {
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
public EnumCableType getCableType() {
|
||||
return EnumCableType.TIN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by modmuss50 on 07/03/2016.
|
||||
*/
|
||||
public interface IPartWaliaProvider
|
||||
{
|
||||
public interface IPartWaliaProvider {
|
||||
|
||||
void addInfo(List<String> info);
|
||||
}
|
||||
|
|
|
@ -1,45 +1,35 @@
|
|||
package techreborn.parts.walia;
|
||||
|
||||
import reborncore.mcmultipart.block.TileMultipartContainer;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.event.*;
|
||||
import reborncore.mcmultipart.block.TileMultipartContainer;
|
||||
import techreborn.compat.ICompatModule;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 07/03/2016.
|
||||
*/
|
||||
public class WailaMcMultiPartCompact implements ICompatModule
|
||||
{
|
||||
public static void callbackRegister(IWailaRegistrar registrar)
|
||||
{
|
||||
public class WailaMcMultiPartCompact implements ICompatModule {
|
||||
public static void callbackRegister(IWailaRegistrar registrar) {
|
||||
registrar.registerBodyProvider(new WaliaPartProvider(), TileMultipartContainer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
FMLInterModComms.sendMessage("Waila", "register", getClass().getName() + ".callbackRegister");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package techreborn.parts.walia;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import reborncore.mcmultipart.block.TileMultipartContainer;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import reborncore.mcmultipart.raytrace.RayTraceUtils;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
|
@ -18,21 +12,23 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.mcmultipart.block.TileMultipartContainer;
|
||||
import reborncore.mcmultipart.raytrace.PartMOP;
|
||||
import reborncore.mcmultipart.raytrace.RayTraceUtils;
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 07/03/2016.
|
||||
*/
|
||||
public class WaliaPartProvider implements IWailaDataProvider
|
||||
{
|
||||
public class WaliaPartProvider implements IWailaDataProvider {
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
PartMOP mop = reTrace(accessor.getWorld(), accessor.getPosition(), accessor.getPlayer());
|
||||
if (mop != null)
|
||||
{
|
||||
if (mop.partHit instanceof CableMultipart)
|
||||
{
|
||||
if (mop != null) {
|
||||
if (mop.partHit instanceof CableMultipart) {
|
||||
return mop.partHit.getDrops().get(0);
|
||||
}
|
||||
}
|
||||
|
@ -41,21 +37,17 @@ public class WaliaPartProvider implements IWailaDataProvider
|
|||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config)
|
||||
{
|
||||
IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config)
|
||||
{
|
||||
IWailaConfigHandler config) {
|
||||
PartMOP mop = reTrace(accessor.getWorld(), accessor.getPosition(), accessor.getPlayer());
|
||||
List<String> data = new ArrayList<>();
|
||||
if (mop != null)
|
||||
{
|
||||
if (mop.partHit instanceof IPartWaliaProvider)
|
||||
{
|
||||
if (mop != null) {
|
||||
if (mop.partHit instanceof IPartWaliaProvider) {
|
||||
((IPartWaliaProvider) mop.partHit).addInfo(data);
|
||||
}
|
||||
}
|
||||
|
@ -64,33 +56,29 @@ public class WaliaPartProvider implements IWailaDataProvider
|
|||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config)
|
||||
{
|
||||
IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world,
|
||||
BlockPos pos)
|
||||
{
|
||||
BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Stolen from
|
||||
// https://github.com/amadornes/MCMultiPart/blob/master/src/main/java/mcmultipart/block/BlockMultipart.java
|
||||
private PartMOP reTrace(World world, BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
private PartMOP reTrace(World world, BlockPos pos, EntityPlayer player) {
|
||||
Vec3d start = RayTraceUtils.getStart(player);
|
||||
Vec3d end = RayTraceUtils.getEnd(player);
|
||||
RayTraceUtils.AdvancedRayTraceResultPart result = getMultipartTile(world, pos).getPartContainer()
|
||||
.collisionRayTrace(start, end);
|
||||
.collisionRayTrace(start, end);
|
||||
return result == null ? null : result.hit;
|
||||
}
|
||||
|
||||
// Stolen from
|
||||
// https://github.com/amadornes/MCMultiPart/blob/master/src/main/java/mcmultipart/block/BlockMultipart.java
|
||||
private TileMultipartContainer getMultipartTile(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
private TileMultipartContainer getMultipartTile(IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
return tile instanceof TileMultipartContainer ? (TileMultipartContainer) tile : null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue