Some improvements to things

This commit is contained in:
modmuss50 2016-03-20 21:23:12 +00:00
parent fee31761b1
commit 5fde39ebcd
5 changed files with 74 additions and 13 deletions

View file

@ -106,6 +106,8 @@ public class Core {
ModLoot.init(); ModLoot.init();
// Multiparts // Multiparts
ModParts.init(); ModParts.init();
//Sounds
ModSounds.init();
// Compat // Compat
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) { for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
compatModule.init(event); compatModule.init(event);

View file

@ -0,0 +1,24 @@
package techreborn.init;
import net.minecraft.client.audio.Sound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
/**
* Created by Mark on 20/03/2016.
*/
public class ModSounds {
public static SoundEvent shock;
public static void init() {
shock = getSound("cable_shock");
}
private static SoundEvent getSound(String str){
SoundEvent soundEvent = SoundEvent.soundEventRegistry.getObject(new ResourceLocation("techreborn" + str));
return soundEvent;
}
}

View file

@ -28,6 +28,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ITickable; import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -40,6 +41,7 @@ import reborncore.common.misc.Functions;
import reborncore.common.misc.vecmath.Vecs3dCube; import reborncore.common.misc.vecmath.Vecs3dCube;
import reborncore.common.util.WorldUtils; import reborncore.common.util.WorldUtils;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModSounds;
import techreborn.power.TRPowerNet; import techreborn.power.TRPowerNet;
import techreborn.utils.damageSources.ElectrialShockSource; import techreborn.utils.damageSources.ElectrialShockSource;
@ -339,16 +341,23 @@ public abstract class CableMultipart extends Multipart implements INormallyOcclu
@Override @Override
public void onEntityCollided(Entity entity) { public void onEntityCollided(Entity entity) {
if (getCableType().canKill && entity instanceof EntityLivingBase) { if (getCableType().canKill && entity instanceof EntityLivingBase) {
if(ConfigTechReborn.UninsulatedElectocutionDamage){ if(network != null){
entity.attackEntityFrom(new ElectrialShockSource(), 1F); if(network.getEnergy() != 0){
} if(ConfigTechReborn.UninsulatedElectocutionDamage){
if(ConfigTechReborn.UninsulatedElectocutionSound){ if(getCableType() == EnumCableType.HV){
//TODO 1.9 nope entity.setFire(1);
// getWorld().playSoundAtEntity(entity, "techreborn:cable_shock", 0.6F, 1F); }
} network.setEnergy(-1);
if(ConfigTechReborn.UninsulatedElectocutionParticle){ entity.attackEntityFrom(new ElectrialShockSource(), 1F);
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0, 0, 0); }
} if(ConfigTechReborn.UninsulatedElectocutionSound){
getWorld().playSound(entity.posX, entity.posY, entity.posZ, ModSounds.shock, SoundCategory.BLOCKS, 0.6F, 1F, false);
}
if(ConfigTechReborn.UninsulatedElectocutionParticle){
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0, 0, 0);
}
}
}
} }
} }

View file

@ -48,6 +48,9 @@ public class TRPowerNet {
} }
cables.removeAll(oldCables); cables.removeAll(oldCables);
} }
if(tick % 20 == 0){
checkAndRemoveOldEndpoints();
}
if (!cables.isEmpty()) { if (!cables.isEmpty()) {
ArrayList<EnergyHandler> collectibles = new ArrayList(); ArrayList<EnergyHandler> collectibles = new ArrayList();
ArrayList<EnergyHandler> insertibles = new ArrayList(); ArrayList<EnergyHandler> insertibles = new ArrayList();
@ -108,6 +111,18 @@ public class TRPowerNet {
for(CableMultipart cableMultipart : partsToMerge){ for(CableMultipart cableMultipart : partsToMerge){
cableMultipart.mergeWith = net; cableMultipart.mergeWith = net;
} }
net.checkAndRemoveOldEndpoints();
}
public void checkAndRemoveOldEndpoints(){
List<EnergyHandler> deadHandlers = new ArrayList<>();
for(EnergyHandler energyHandler : endpoints){
TileEntity tile = (TileEntity) energyHandler.tile;
if(tile.getWorld().getTileEntity(tile.getPos()) == null){
deadHandlers.add(energyHandler);
}
}
endpoints.removeAll(deadHandlers);
} }
public void rebuild() { public void rebuild() {
@ -120,6 +135,17 @@ public class TRPowerNet {
MinecraftForge.EVENT_BUS.unregister(this); MinecraftForge.EVENT_BUS.unregister(this);
} }
public int getEnergy() {
return energy;
}
public void setEnergy(int energy){
energy += energy;
if(energy < 0){
energy = 0;
}
}
public void addConnection(IEnergyInterfaceTile ih, EnumFacing dir) { public void addConnection(IEnergyInterfaceTile ih, EnumFacing dir) {
if (ih instanceof CableMultipart) if (ih instanceof CableMultipart)
return; return;

View file

@ -1,5 +1,5 @@
{ {
"sap_extract": { "category": "block", "sounds":["sap_extract"] }, "sap_extract": { "category": "block", "sounds":["techreborn:sap_extract"] },
"block_dismantle": { "category": "block", "sounds":["block_dismantle"] }, "block_dismantle": { "category": "block", "sounds":["techreborn:block_dismantle"] },
"cable_shock": { "category": "block", "sounds":["cable_shock"] } "cable_shock": { "category": "block", "sounds":["techreborn:cable_shock"] }
} }