Massive improvement to parts, should work a lot better now
@gigabit101 you asked for it, now you just need to place covers on ic2 cables, and you can place covers in the conecting bit. Also fixes, slow responsiveness when placing/breaking cables Also fixes cables rendering incorectally when a cover is placed between two cables.
This commit is contained in:
parent
1723410d17
commit
20a57d298f
12 changed files with 144 additions and 51 deletions
|
@ -25,8 +25,8 @@ public class IconSupplier {
|
||||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||||
TextureMap reg = event.map;
|
TextureMap reg = event.map;
|
||||||
if (reg.getTextureType() == 0) {
|
if (reg.getTextureType() == 0) {
|
||||||
insulatedCopperCable = reg.registerIcon("ic2" + ":wiring/cable/blockCableO");
|
insulatedCopperCable = reg.registerIcon("ic2" + ":wiring/cable/blockCable");
|
||||||
copperCable = reg.registerIcon("ic2" + ":wiring/cable/blockCable");
|
copperCable = reg.registerIcon("ic2" + ":wiring/cable/blockCableO");
|
||||||
goldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCable");
|
goldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCable");
|
||||||
insulatedGoldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCableI");
|
insulatedGoldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCableI");
|
||||||
doubleInsulatedGoldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCableII");
|
doubleInsulatedGoldCable = reg.registerIcon("ic2" + ":wiring/cable/blockGoldCableII");
|
||||||
|
|
|
@ -127,7 +127,6 @@ public class CasingConnectedTextureGenerator extends TextureAtlasSprite {
|
||||||
if (iconRegister instanceof TextureMap) {
|
if (iconRegister instanceof TextureMap) {
|
||||||
TextureMap map = (TextureMap) iconRegister;
|
TextureMap map = (TextureMap) iconRegister;
|
||||||
String name = CasingConnectedTextureGenerator.getDerivedName(types[meta] + "." + texNum);
|
String name = CasingConnectedTextureGenerator.getDerivedName(types[meta] + "." + texNum);
|
||||||
System.out.println(name);
|
|
||||||
TextureAtlasSprite texture = map.getTextureExtry(name);
|
TextureAtlasSprite texture = map.getTextureExtry(name);
|
||||||
if (texture == null) {
|
if (texture == null) {
|
||||||
texture = new CasingConnectedTextureGenerator(name, types[meta], connectedTexture);
|
texture = new CasingConnectedTextureGenerator(name, types[meta], connectedTexture);
|
||||||
|
|
|
@ -129,7 +129,6 @@ public class LesuConnectedTextureGenerator extends TextureAtlasSprite {
|
||||||
if (iconRegister instanceof TextureMap) {
|
if (iconRegister instanceof TextureMap) {
|
||||||
TextureMap map = (TextureMap) iconRegister;
|
TextureMap map = (TextureMap) iconRegister;
|
||||||
String name = LesuConnectedTextureGenerator.getDerivedName("lesu." + texNum);
|
String name = LesuConnectedTextureGenerator.getDerivedName("lesu." + texNum);
|
||||||
System.out.println(name);
|
|
||||||
TextureAtlasSprite texture = map.getTextureExtry(name);
|
TextureAtlasSprite texture = map.getTextureExtry(name);
|
||||||
if (texture == null) {
|
if (texture == null) {
|
||||||
texture = new LesuConnectedTextureGenerator(name, "lesu", connectedTexture);
|
texture = new LesuConnectedTextureGenerator(name, "lesu", connectedTexture);
|
||||||
|
|
|
@ -115,4 +115,6 @@ public interface IModPart {
|
||||||
public void onRemoved();
|
public void onRemoved();
|
||||||
|
|
||||||
public IModPart copy();
|
public IModPart copy();
|
||||||
|
|
||||||
|
public boolean needsItem();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,6 @@ public interface IPartProvider {
|
||||||
public boolean isTileFromProvider(TileEntity tileEntity);
|
public boolean isTileFromProvider(TileEntity tileEntity);
|
||||||
|
|
||||||
public IModPart getPartFromWorld(World world, Location location, String name);
|
public IModPart getPartFromWorld(World world, Location location, String name);
|
||||||
|
|
||||||
|
public void init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,4 +95,9 @@ public abstract class ModPart extends TileEntity implements IModPart {
|
||||||
public String getItemTextureName() {
|
public String getItemTextureName() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needsItem() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,19 +33,25 @@ public class ModPartRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAllPartsToSystems() {
|
public static void addAllPartsToSystems() {
|
||||||
|
for (IPartProvider iPartProvider : providers) {
|
||||||
|
iPartProvider.init();
|
||||||
|
}
|
||||||
|
|
||||||
LogHelper.info("Started to load all parts");
|
LogHelper.info("Started to load all parts");
|
||||||
|
|
||||||
for (ModPart modPart : ModPartRegistry.parts) {
|
for (ModPart modPart : ModPartRegistry.parts) {
|
||||||
Item part = new ModPartItem(modPart)
|
if(modPart.needsItem()){
|
||||||
.setUnlocalizedName(modPart.getName())
|
Item part = new ModPartItem(modPart)
|
||||||
.setCreativeTab(TechRebornCreativeTab.instance)
|
.setUnlocalizedName(modPart.getName())
|
||||||
.setTextureName(modPart.getItemTextureName());
|
.setCreativeTab(TechRebornCreativeTab.instance)
|
||||||
GameRegistry.registerItem(part, modPart.getName());
|
.setTextureName(modPart.getItemTextureName());
|
||||||
itemParts.put(modPart.getName(), part);
|
GameRegistry.registerItem(part, modPart.getName());
|
||||||
if (modPart instanceof CablePart) {
|
itemParts.put(modPart.getName(), part);
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(part), IC2Items.getItem(CablePart.getTextureNameFromType(((CablePart) modPart).type)));
|
if (modPart instanceof CablePart) {
|
||||||
((CablePart) modPart).stack = new ItemStack(part);
|
GameRegistry.addShapelessRecipe(new ItemStack(part), IC2Items.getItem(CablePart.getTextureNameFromType(((CablePart) modPart).type)));
|
||||||
ModParts.stackCable.put(((CablePart) modPart).type, new ItemStack(part));
|
((CablePart) modPart).stack = new ItemStack(part);
|
||||||
|
ModParts.stackCable.put(((CablePart) modPart).type, new ItemStack(part));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class QModPartFactory implements IPartFactory, IPartProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public String getCreatedPartType(ItemStack item, EntityPlayer player,
|
public String getCreatedPartType(ItemStack item, EntityPlayer player,
|
||||||
World world, MovingObjectPosition mop, ModPart modPart) {
|
World world, MovingObjectPosition mop, ModPart modPart) {
|
||||||
return modPart.getName();
|
return modPart.getName();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package techreborn.partSystem.fmp;
|
package techreborn.partSystem.fmp;
|
||||||
|
|
||||||
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.lib.vec.Cuboid6;
|
import codechicken.lib.vec.Cuboid6;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
|
@ -12,6 +13,7 @@ import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import techreborn.lib.Location;
|
import techreborn.lib.Location;
|
||||||
|
@ -20,15 +22,14 @@ import techreborn.partSystem.IModPart;
|
||||||
import techreborn.partSystem.IPartProvider;
|
import techreborn.partSystem.IPartProvider;
|
||||||
import techreborn.partSystem.ModPart;
|
import techreborn.partSystem.ModPart;
|
||||||
import techreborn.partSystem.ModPartRegistry;
|
import techreborn.partSystem.ModPartRegistry;
|
||||||
|
import techreborn.partSystem.parts.CableConverter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
public class FMPFactory implements MultiPartRegistry.IPartFactory2,
|
||||||
* Created by mark on 09/12/14.
|
|
||||||
*/
|
|
||||||
public class FMPFactory implements MultiPartRegistry.IPartFactory,
|
|
||||||
IPartProvider {
|
IPartProvider {
|
||||||
@Override
|
|
||||||
|
|
||||||
public TMultiPart createPart(String type, boolean client) {
|
public TMultiPart createPart(String type, boolean client) {
|
||||||
for (ModPart modPart : ModPartRegistry.parts) {
|
for (ModPart modPart : ModPartRegistry.parts) {
|
||||||
if (modPart.getName().equals(type)) {
|
if (modPart.getName().equals(type)) {
|
||||||
|
@ -50,12 +51,34 @@ public class FMPFactory implements MultiPartRegistry.IPartFactory,
|
||||||
return tileEntity instanceof TileMultipart;
|
return tileEntity instanceof TileMultipart;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
|
||||||
@Override
|
@Override
|
||||||
public IModPart getPartFromWorld(World world, Location location, String name) {
|
public IModPart getPartFromWorld(World world, Location location, String name) {
|
||||||
|
TileEntity tileEntity = world.getTileEntity(location.getX(),
|
||||||
|
location.getY(), location.getZ());
|
||||||
|
if (tileEntity instanceof TileMultipart) {
|
||||||
|
TileMultipart mp = (TileMultipart) tileEntity;
|
||||||
|
boolean ret = false;
|
||||||
|
List<TMultiPart> t = mp.jPartList();
|
||||||
|
for (TMultiPart p : t) {
|
||||||
|
if (ret == false) {
|
||||||
|
if (p.getType().equals(name)) {
|
||||||
|
if(p instanceof FMPModPart){
|
||||||
|
return ((FMPModPart) p).iModPart;
|
||||||
|
}
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
MultiPartRegistry.registerConverter(new CableConverter());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String modID() {
|
public String modID() {
|
||||||
return "ForgeMultipart";
|
return "ForgeMultipart";
|
||||||
|
@ -100,4 +123,14 @@ public class FMPFactory implements MultiPartRegistry.IPartFactory,
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart createPart(String s, NBTTagCompound nbtTagCompound) {
|
||||||
|
return createPart(s, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart createPart(String s, MCDataInput mcDataInput) {
|
||||||
|
return createPart(s, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,23 +59,6 @@ public class FMPModPart extends TMultiPart implements TSlottedPart,
|
||||||
return NormalOcclusionTest.apply(this, npart);
|
return NormalOcclusionTest.apply(this, npart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCollisionBoxesToList(List<Vecs3dCube> l,
|
|
||||||
AxisAlignedBB bounds, Entity entity) {
|
|
||||||
List<Vecs3dCube> boxes = new ArrayList<Vecs3dCube>();
|
|
||||||
List<Vecs3dCube> boxes_ = new ArrayList<Vecs3dCube>();
|
|
||||||
iModPart.addCollisionBoxesToList(boxes_, entity);
|
|
||||||
for (Vecs3dCube c : boxes_) {
|
|
||||||
Vecs3dCube cube = c.clone();
|
|
||||||
cube.add(getX(), getY(), getZ());
|
|
||||||
boxes.add(cube);
|
|
||||||
}
|
|
||||||
boxes_.clear();
|
|
||||||
|
|
||||||
for (Vecs3dCube c : boxes) {
|
|
||||||
if (c.toAABB().intersectsWith(bounds))
|
|
||||||
l.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<Cuboid6> getCollisionBoxes() {
|
public Iterable<Cuboid6> getCollisionBoxes() {
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package techreborn.partSystem.parts;
|
||||||
|
|
||||||
|
import codechicken.lib.vec.BlockCoord;
|
||||||
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
|
import codechicken.multipart.TMultiPart;
|
||||||
|
import ic2.api.item.IC2Items;
|
||||||
|
import ic2.core.block.wiring.BlockCable;
|
||||||
|
import ic2.core.block.wiring.TileEntityCable;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import techreborn.partSystem.fmp.FMPModPart;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class CableConverter implements MultiPartRegistry.IPartConverter {
|
||||||
|
@Override
|
||||||
|
public Iterable<Block> blockTypes() {
|
||||||
|
return Arrays.asList(Block.getBlockFromItem(IC2Items.getItem("copperCableBlock").getItem()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart convert(World world, BlockCoord blockCoord) {
|
||||||
|
Block block = world.getBlock(blockCoord.x, blockCoord.y, blockCoord.z);
|
||||||
|
if (block instanceof BlockCable) {
|
||||||
|
TileEntity tileEntity = world.getTileEntity(blockCoord.x, blockCoord.y, blockCoord.z);
|
||||||
|
if (tileEntity instanceof TileEntityCable) {
|
||||||
|
TileEntityCable cable = (TileEntityCable) tileEntity;
|
||||||
|
int type = cable.cableType;
|
||||||
|
CablePart newPart = new CablePart();
|
||||||
|
newPart.setType(type);
|
||||||
|
return new FMPModPart(newPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import techreborn.client.render.RenderCablePart;
|
import techreborn.client.render.RenderCablePart;
|
||||||
import techreborn.init.ModParts;
|
import techreborn.init.ModParts;
|
||||||
import techreborn.lib.Functions;
|
import techreborn.lib.Functions;
|
||||||
|
import techreborn.lib.Location;
|
||||||
import techreborn.lib.vecmath.Vecs3d;
|
import techreborn.lib.vecmath.Vecs3d;
|
||||||
import techreborn.lib.vecmath.Vecs3dCube;
|
import techreborn.lib.vecmath.Vecs3dCube;
|
||||||
import techreborn.partSystem.IModPart;
|
import techreborn.partSystem.IModPart;
|
||||||
|
@ -114,12 +115,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
@Override
|
@Override
|
||||||
public List<Vecs3dCube> getOcclusionBoxes() {
|
public List<Vecs3dCube> getOcclusionBoxes() {
|
||||||
List<Vecs3dCube> vecs3dCubesList = new ArrayList<Vecs3dCube>();
|
List<Vecs3dCube> vecs3dCubesList = new ArrayList<Vecs3dCube>();
|
||||||
|
vecs3dCubesList.add(boundingBoxes[6]);
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
|
||||||
if (connectedSides.containsKey(dir))
|
|
||||||
vecs3dCubesList.add(boundingBoxes[Functions
|
|
||||||
.getIntDirFromDirection(dir)]);
|
|
||||||
}
|
|
||||||
return vecs3dCubesList;
|
return vecs3dCubesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +172,14 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
@Override
|
@Override
|
||||||
public void nearByChange() {
|
public void nearByChange() {
|
||||||
checkConnectedSides();
|
checkConnectedSides();
|
||||||
|
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
|
||||||
|
worldObj.markBlockForUpdate(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||||
|
IModPart part = ModPartUtils.getPartFromWorld(world, new Location(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ) , this.getName());
|
||||||
|
if(part != null){
|
||||||
|
CablePart cablePart = (CablePart) part;
|
||||||
|
cablePart.checkConnectedSides();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,7 +190,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
this.addedToEnergyNet = true;
|
this.addedToEnergyNet = true;
|
||||||
nearByChange();
|
nearByChange();
|
||||||
}
|
}
|
||||||
checkConnectedSides();
|
nearByChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -206,7 +210,7 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return ModParts.stackCable.get(type);
|
return new ItemStack(IC2Items.getItem("copperCableItem").getItem(), 1, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) {
|
public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) {
|
||||||
|
@ -215,8 +219,21 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
} else if (entity instanceof IEnergyTile) {
|
} else if (entity instanceof IEnergyTile) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord,
|
if(ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, this.getName())){
|
||||||
entity.yCoord, entity.zCoord, this.getName());
|
CablePart otherCable = (CablePart) ModPartUtils.getPartFromWorld(entity.getWorldObj(), new Location(entity.xCoord, entity.yCoord, entity.zCoord), this.getName());
|
||||||
|
int thisDir = Functions.getIntDirFromDirection(dir);
|
||||||
|
int thereDir = Functions.getIntDirFromDirection(dir.getOpposite());
|
||||||
|
boolean hasconnection = otherCable.connections[thereDir];
|
||||||
|
|
||||||
|
otherCable.connections[thereDir] = false;
|
||||||
|
|
||||||
|
if(ModPartUtils.checkOcclusion(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, boundingBoxes[thereDir])){
|
||||||
|
otherCable.connections[thereDir] = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
otherCable.connections[thereDir] = hasconnection;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,10 +403,10 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
String p = null;
|
String p = null;
|
||||||
switch (cableType) {
|
switch (cableType) {
|
||||||
case 0:
|
case 0:
|
||||||
p = "copperCable";
|
p = "insulatedCopperCable";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
p = "insulatedCopperCable";
|
p = "copperCable";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
p = "goldCable";
|
p = "goldCable";
|
||||||
|
@ -438,10 +455,10 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
String p = null;
|
String p = null;
|
||||||
switch (cableType) {
|
switch (cableType) {
|
||||||
case 0:
|
case 0:
|
||||||
p = "copperCableItem";
|
p = "insulatedCopperCableItem";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
p = "insulatedCopperCableItem";
|
p = "copperCableItem";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
p = "goldCableItem";
|
p = "goldCableItem";
|
||||||
|
@ -567,4 +584,9 @@ public class CablePart extends ModPart implements IEnergyConductor, INetworkTile
|
||||||
public void writeDesc(NBTTagCompound tagCompound) {
|
public void writeDesc(NBTTagCompound tagCompound) {
|
||||||
writeConnectedSidesToNBT(tagCompound);
|
writeConnectedSidesToNBT(tagCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean needsItem() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue