Revert "Power system re-write, recipe fixes."
This reverts commit d982cc4028
.
# Conflicts:
# src/main/java/techreborn/init/ModRecipes.java
This commit is contained in:
parent
aa05d906f9
commit
d96149fc97
47 changed files with 937 additions and 1361 deletions
|
@ -30,6 +30,8 @@ public class TechRebornParts implements ICompatModule
|
|||
@Nullable
|
||||
public static Item fluidPipe;
|
||||
|
||||
public static HashMap<EnumCableType, Class<? extends CableMultipart>> multipartHashMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
|
@ -37,13 +39,17 @@ public class TechRebornParts implements ICompatModule
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
for (EnumCableType cableType : EnumCableType.values())
|
||||
{
|
||||
multipartHashMap.put(cableType, cableType.cableClass);
|
||||
MultipartRegistry.registerPart(cableType.cableClass, "techreborn:cable." + cableType.name());
|
||||
}
|
||||
cables = new ItemCables();
|
||||
cables.setRegistryName("cables");
|
||||
GameRegistry.register(cables);
|
||||
|
||||
MultipartRegistry.registerPart(CableMultipart.class, "techreborn:cable");
|
||||
MultipartRegistry.registerPart(EmptyFluidPipe.class, "techreborn:fluidpipe.empty");
|
||||
MultipartRegistry.registerPart(InsertingFluidPipe.class, "techreborn:fluidpipe.inserting");
|
||||
MultipartRegistry.registerPart(ExtractingFluidPipe.class, "techreborn:fluidpipe.extracting");
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
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;
|
||||
|
@ -11,13 +15,8 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -30,12 +29,11 @@ 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;
|
||||
import techreborn.parts.walia.IPartWaliaProvider;
|
||||
import techreborn.power.TRPowerNet;
|
||||
import techreborn.utils.damageSources.ElectrialShockSource;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -43,7 +41,7 @@ import java.util.*;
|
|||
/**
|
||||
* Created by modmuss50 on 02/03/2016.
|
||||
*/
|
||||
public class CableMultipart extends Multipart
|
||||
public abstract class CableMultipart extends Multipart
|
||||
implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType, IPartWaliaProvider {
|
||||
|
||||
public static final IUnlistedProperty<Boolean> UP = Properties.toUnlisted(PropertyBool.create("up"));
|
||||
|
@ -57,14 +55,10 @@ public class CableMultipart extends Multipart
|
|||
public float center = 0.6F;
|
||||
public float offset = 0.10F;
|
||||
public Map<EnumFacing, BlockPos> connectedSides;
|
||||
public double lastEnergyPacket;
|
||||
public EnumCableType cableType = EnumCableType.ICOPPER;
|
||||
|
||||
public CableMultipart(EnumCableType cableType) {
|
||||
this.cableType = cableType;
|
||||
connectedSides = new HashMap<>();
|
||||
refreshBounding();
|
||||
}
|
||||
public int ticks = 0;
|
||||
public ItemStack stack;
|
||||
public TRPowerNet mergeWith = null;
|
||||
private TRPowerNet network;
|
||||
|
||||
public CableMultipart() {
|
||||
connectedSides = new HashMap<>();
|
||||
|
@ -150,6 +144,7 @@ public class CableMultipart extends Multipart
|
|||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
removeFromNetwork();
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
CableMultipart multipart = getPartFromWorld(getWorld(), getPos().offset(dir), dir);
|
||||
if (multipart != null) {
|
||||
|
@ -158,6 +153,12 @@ public class CableMultipart extends Multipart
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnloaded() {
|
||||
super.onUnloaded();
|
||||
removeFromNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOcclusionBoxes(List<AxisAlignedBB> list) {
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
|
@ -171,9 +172,13 @@ public class CableMultipart extends Multipart
|
|||
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);
|
||||
|
@ -183,6 +188,7 @@ public class CableMultipart extends Multipart
|
|||
part.checkConnectedSides();
|
||||
}
|
||||
}
|
||||
TRPowerNet.buildEndpoint(network);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -252,14 +258,18 @@ public class CableMultipart extends Multipart
|
|||
@Override
|
||||
public void update() {
|
||||
if (getWorld() != null) {
|
||||
if(lastEnergyPacket > 0)
|
||||
--lastEnergyPacket;
|
||||
|
||||
if (getWorld().getTotalWorldTime() % 80 == 0) {
|
||||
checkConnectedSides();
|
||||
}
|
||||
}
|
||||
|
||||
if (network == null) {
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
} else {
|
||||
if (mergeWith != null) {
|
||||
getNetwork().merge(mergeWith);
|
||||
mergeWith = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,7 +294,7 @@ public class CableMultipart extends Multipart
|
|||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return getCableType().material;
|
||||
return Material.CLOTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -297,16 +307,97 @@ public class CableMultipart extends Multipart
|
|||
@Override
|
||||
public void onEntityCollided(Entity entity) {
|
||||
if (getCableType().canKill && entity instanceof EntityLivingBase) {
|
||||
entity.attackEntityFrom(new ElectrialShockSource(), (float) (lastEnergyPacket / 16F));
|
||||
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 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 TRPowerNet getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
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 rebuildNetwork() {
|
||||
this.removeFromNetwork();
|
||||
this.resetNetwork();
|
||||
this.findAndJoinNetwork(getWorld(), getPos());
|
||||
}
|
||||
|
||||
public final void resetNetwork() {
|
||||
if (network != null) {
|
||||
network.removeElement(this);
|
||||
}
|
||||
|
||||
network = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<String> info) {
|
||||
info.add(TextFormatting.GREEN + "EU Transfer: " +
|
||||
|
@ -325,35 +416,4 @@ public class CableMultipart extends Multipart
|
|||
public boolean canRenderInLayer(BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag.setString("CableType", cableType.name());
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
if(tag.hasKey("CableType")) {
|
||||
cableType = EnumCableType.valueOf(tag.getString("CableType"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUpdatePacket(PacketBuffer buf) {
|
||||
super.writeUpdatePacket(buf);
|
||||
buf.writeInt(cableType.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdatePacket(PacketBuffer buf) {
|
||||
super.readUpdatePacket(buf);
|
||||
cableType = EnumCableType.values()[buf.readInt()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumCableType getCableType() {
|
||||
return cableType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,37 +1,44 @@
|
|||
package techreborn.parts.powerCables;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
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;
|
||||
|
||||
public enum EnumCableType implements IStringSerializable
|
||||
{
|
||||
COPPER("copper", "techreborn:blocks/cables/copper_cable", Material.IRON, 128, 12.0, true, EnumPowerTier.LOW),
|
||||
TIN("tin", "techreborn:blocks/cables/tin_cable", Material.IRON, 32, 12.0, true, EnumPowerTier.MEDIUM),
|
||||
GOLD("gold", "techreborn:blocks/cables/gold_cable", Material.IRON, 512, 12.0, true, EnumPowerTier.MEDIUM),
|
||||
HV("hv", "techreborn:blocks/cables/hv_cable", Material.IRON, 2048, 12.0, true, EnumPowerTier.HIGH),
|
||||
GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable", Material.GLASS, 8192, 12.0, false, EnumPowerTier.HIGH),
|
||||
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", Material.CLOTH, 128, 10.0, false, EnumPowerTier.LOW),
|
||||
IGOLD("insulatedgold", "techreborn:blocks/cables/gold_insulated_cable", Material.CLOTH, 512, 10.0, false, EnumPowerTier.MEDIUM),
|
||||
IHV("insulatedhv", "techreborn:blocks/cables/hv_insulated_cable", Material.CLOTH, 2048, 10.0, false, EnumPowerTier.HIGH);
|
||||
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),
|
||||
HV("hv", "techreborn:blocks/cables/hv_cable", 2048, 12.0, true, EnumPowerTier.HIGH, HVCable.class),
|
||||
GLASSFIBER("glassfiber", "techreborn:blocks/cables/glass_fiber_cable", 8192, 12.0, false, EnumPowerTier.HIGH, GlassFiberCable.class),
|
||||
ICOPPER("insulatedcopper", "techreborn:blocks/cables/copper_insulated_cable", 128, 10.0, false, EnumPowerTier.LOW, InsulatedCopperCable.class),
|
||||
IGOLD("insulatedgold", "techreborn:blocks/cables/gold_insulated_cable", 512, 10.0, false, EnumPowerTier.MEDIUM, InsulatedGoldCable.class),
|
||||
IHV("insulatedhv", "techreborn:blocks/cables/hv_insulated_cable", 2048, 10.0, false, EnumPowerTier.HIGH, InsulatedHVCable.class);
|
||||
|
||||
public Material material;
|
||||
public String textureName = "minecraft:blocks/iron_block";
|
||||
public int transferRate = 128;
|
||||
public double cableThickness = 3.0;
|
||||
public boolean canKill = false;
|
||||
public Class<? extends CableMultipart> cableClass;
|
||||
public EnumPowerTier tier;
|
||||
private String friendlyName;
|
||||
|
||||
EnumCableType(String friendlyName, String textureName, Material material, int transferRate, double cableThickness, boolean canKill,
|
||||
EnumPowerTier tier)
|
||||
EnumCableType(String friendlyName, String textureName, int transferRate, double cableThickness, boolean canKill,
|
||||
EnumPowerTier tier, Class<? extends CableMultipart> cableClass)
|
||||
{
|
||||
this.friendlyName = friendlyName;
|
||||
this.textureName = textureName;
|
||||
this.material = material;
|
||||
this.transferRate = transferRate;
|
||||
this.cableThickness = cableThickness / 2;
|
||||
this.canKill = canKill;
|
||||
this.cableClass = cableClass;
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,17 @@ public class ItemCables extends ItemMultiPart implements ITexturedItem
|
|||
}
|
||||
|
||||
@Override
|
||||
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack, EntityPlayer player) {
|
||||
return new CableMultipart(EnumCableType.values()[stack.getItemDamage()]);
|
||||
public IMultipart createPart(World world, BlockPos pos, EnumFacing side, Vec3d hit, ItemStack stack,
|
||||
EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TechRebornParts.multipartHashMap.get(EnumCableType.values()[stack.getItemDamage()]).newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class CopperCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.COPPER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class GlassFiberCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.GLASSFIBER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class GoldCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.GOLD;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class HVCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.HV;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedCopperCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.ICOPPER;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedGoldCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.IGOLD;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class InsulatedHVCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.IHV;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package techreborn.parts.powerCables.types;
|
||||
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class TinCable extends CableMultipart
|
||||
{
|
||||
@Override
|
||||
public EnumCableType getCableType()
|
||||
{
|
||||
return EnumCableType.TIN;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue