Some improvements to things
This commit is contained in:
parent
fee31761b1
commit
5fde39ebcd
5 changed files with 74 additions and 13 deletions
|
@ -106,6 +106,8 @@ public class Core {
|
|||
ModLoot.init();
|
||||
// Multiparts
|
||||
ModParts.init();
|
||||
//Sounds
|
||||
ModSounds.init();
|
||||
// Compat
|
||||
for (ICompatModule compatModule : CompatManager.INSTANCE.compatModules) {
|
||||
compatModule.init(event);
|
||||
|
|
24
src/main/java/techreborn/init/ModSounds.java
Normal file
24
src/main/java/techreborn/init/ModSounds.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -28,6 +28,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -40,6 +41,7 @@ import reborncore.common.misc.Functions;
|
|||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.power.TRPowerNet;
|
||||
import techreborn.utils.damageSources.ElectrialShockSource;
|
||||
|
||||
|
@ -339,16 +341,23 @@ public abstract class CableMultipart extends Multipart implements INormallyOcclu
|
|||
@Override
|
||||
public void onEntityCollided(Entity entity) {
|
||||
if (getCableType().canKill && entity instanceof EntityLivingBase) {
|
||||
if(ConfigTechReborn.UninsulatedElectocutionDamage){
|
||||
entity.attackEntityFrom(new ElectrialShockSource(), 1F);
|
||||
}
|
||||
if(ConfigTechReborn.UninsulatedElectocutionSound){
|
||||
//TODO 1.9 nope
|
||||
// getWorld().playSoundAtEntity(entity, "techreborn:cable_shock", 0.6F, 1F);
|
||||
}
|
||||
if(ConfigTechReborn.UninsulatedElectocutionParticle){
|
||||
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0, 0, 0);
|
||||
}
|
||||
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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ public class TRPowerNet {
|
|||
}
|
||||
cables.removeAll(oldCables);
|
||||
}
|
||||
if(tick % 20 == 0){
|
||||
checkAndRemoveOldEndpoints();
|
||||
}
|
||||
if (!cables.isEmpty()) {
|
||||
ArrayList<EnergyHandler> collectibles = new ArrayList();
|
||||
ArrayList<EnergyHandler> insertibles = new ArrayList();
|
||||
|
@ -108,6 +111,18 @@ public class TRPowerNet {
|
|||
for(CableMultipart cableMultipart : partsToMerge){
|
||||
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() {
|
||||
|
@ -120,6 +135,17 @@ public class TRPowerNet {
|
|||
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) {
|
||||
if (ih instanceof CableMultipart)
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"sap_extract": { "category": "block", "sounds":["sap_extract"] },
|
||||
"block_dismantle": { "category": "block", "sounds":["block_dismantle"] },
|
||||
"cable_shock": { "category": "block", "sounds":["cable_shock"] }
|
||||
"sap_extract": { "category": "block", "sounds":["techreborn:sap_extract"] },
|
||||
"block_dismantle": { "category": "block", "sounds":["techreborn:block_dismantle"] },
|
||||
"cable_shock": { "category": "block", "sounds":["techreborn:cable_shock"] }
|
||||
}
|
Loading…
Reference in a new issue