Added proper damage sources
This commit is contained in:
parent
1cae38e464
commit
f35fc9dce4
6 changed files with 43 additions and 33 deletions
13
src/main/java/cr0s/warpdrive/DamageAsphyxia.java
Normal file
13
src/main/java/cr0s/warpdrive/DamageAsphyxia.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package cr0s.warpdrive;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class DamageAsphyxia extends DamageSource {
|
||||
|
||||
public DamageAsphyxia() {
|
||||
super("warpdrive.asphyxia");
|
||||
setDamageBypassesArmor();
|
||||
setDamageIsAbsolute();
|
||||
}
|
||||
|
||||
}
|
10
src/main/java/cr0s/warpdrive/DamageTeleportation.java
Normal file
10
src/main/java/cr0s/warpdrive/DamageTeleportation.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package cr0s.warpdrive;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class DamageTeleportation extends DamageSource {
|
||||
public DamageTeleportation() {
|
||||
super("warpdrive.teleportation");
|
||||
setDamageBypassesArmor();
|
||||
}
|
||||
}
|
|
@ -177,6 +177,9 @@ public class WarpDrive implements LoadingCallback {
|
|||
public static ItemHelmet itemHelmet;
|
||||
public static ItemAirCanisterFull itemAirCanisterFull;
|
||||
|
||||
public static DamageAsphyxia damageAxphyxia;
|
||||
public static DamageTeleportation damageTeleportation;
|
||||
|
||||
public static BiomeGenBase spaceBiome;
|
||||
public SpaceWorldGenerator spaceWorldGenerator;
|
||||
public HyperSpaceWorldGenerator hyperSpaceWorldGenerator;
|
||||
|
@ -424,6 +427,9 @@ public class WarpDrive implements LoadingCallback {
|
|||
GameRegistry.registerItem(itemTuningRod, "itemTuningRod");
|
||||
|
||||
|
||||
damageAxphyxia = new DamageAsphyxia();
|
||||
damageTeleportation = new DamageTeleportation();
|
||||
|
||||
proxy.registerEntities();
|
||||
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance);
|
||||
|
|
|
@ -10,14 +10,11 @@ import li.cil.oc.api.machine.Context;
|
|||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cr0s.warpdrive.DamageTeleportation;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IUpgradable;
|
||||
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
|
||||
|
@ -42,7 +39,7 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I
|
|||
private Vector3 sourceVec = new Vector3();
|
||||
private Vector3 destVec = new Vector3();
|
||||
|
||||
private TeleporterDamage teleDam = new TeleporterDamage("teleporter");
|
||||
private DamageTeleportation damageTeleportation = new DamageTeleportation();
|
||||
|
||||
public TileEntityTransporter() {
|
||||
super();
|
||||
|
@ -347,15 +344,15 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I
|
|||
}
|
||||
|
||||
if (value < 0.1) {
|
||||
ent.attackEntityFrom(teleDam, 1000);
|
||||
ent.attackEntityFrom(damageTeleportation, 1000);
|
||||
}
|
||||
|
||||
if (value < 0.2) {
|
||||
ent.attackEntityFrom(teleDam, 10);
|
||||
ent.attackEntityFrom(damageTeleportation, 10);
|
||||
}
|
||||
|
||||
if (value < 0.5) {
|
||||
ent.attackEntityFrom(teleDam, 1);
|
||||
ent.attackEntityFrom(damageTeleportation, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,27 +528,6 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I
|
|||
powerBoost = tag.getDouble("powerBoost");
|
||||
}
|
||||
|
||||
class TeleporterDamage extends DamageSource {
|
||||
protected TeleporterDamage(String par1Str) {
|
||||
super(par1Str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatComponentText func_151519_b(EntityLivingBase entity) {
|
||||
String message = "";
|
||||
if (entity instanceof EntityPlayer || entity instanceof EntityPlayerMP) {
|
||||
message = ((EntityPlayer) entity).getDisplayName() + " was killed by a teleporter malfunction";
|
||||
} else {
|
||||
message = entity.toString() + " was killed by a teleporter malfunction";
|
||||
}
|
||||
|
||||
if (WarpDriveConfig.LOGGING_TRANSPORTER) {
|
||||
WarpDrive.logger.info(message);
|
||||
}
|
||||
return new ChatComponentText(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeUpgrade(UpgradeType upgradeType, boolean simulate) {
|
||||
int max = 0;
|
||||
|
|
|
@ -131,7 +131,7 @@ public class LivingHandler {
|
|||
player_airTank.put(playerName, airTicks);
|
||||
} else {
|
||||
player_airTank.put(playerName, AIR_DROWN_TICKS);
|
||||
player.attackEntityFrom(DamageSource.drown, 2.0F);
|
||||
player.attackEntityFrom(WarpDrive.damageAxphyxia, 2.0F);
|
||||
}
|
||||
} else {
|
||||
player_airTank.put(playerName, air - 1);
|
||||
|
@ -146,7 +146,7 @@ public class LivingHandler {
|
|||
player_airTank.put(playerName, AIR_TANK_TICKS);
|
||||
} else {
|
||||
player_airTank.put(playerName, AIR_DROWN_TICKS);
|
||||
entity.attackEntityFrom(DamageSource.drown, 2.0F);
|
||||
entity.attackEntityFrom(WarpDrive.damageAxphyxia, 2.0F);
|
||||
}
|
||||
} else {
|
||||
player_airTank.put(playerName, air - 1);
|
||||
|
@ -159,7 +159,7 @@ public class LivingHandler {
|
|||
player_airTank.put(playerName, AIR_TANK_TICKS);
|
||||
} else if (air <= 1) {
|
||||
player_airTank.put(playerName, AIR_DROWN_TICKS);
|
||||
entity.attackEntityFrom(DamageSource.drown, 2.0F);
|
||||
entity.attackEntityFrom(WarpDrive.damageAxphyxia, 2.0F);
|
||||
} else {
|
||||
player_airTank.put(playerName, air - 1);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class LivingHandler {
|
|||
}
|
||||
} else {// (in space, no air block and not a player)
|
||||
entity_airBlock.put(entity.getEntityId(), 0);
|
||||
entity.attackEntityFrom(DamageSource.drown, 2.0F);
|
||||
entity.attackEntityFrom(WarpDrive.damageAxphyxia, 2.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
death.attack.warpdrive.asphyxia=%s died from asphyxia
|
||||
death.attack.warpdrive.asphyxia.player=%1$s was killed by %2$s using asphyxia
|
||||
death.attack.warpdrive.teleportation=%s didn't survive from rematerialization
|
||||
death.attack.warpdrive.teleportation.player=%1$s was teleporkilled by %2$s
|
||||
|
||||
item.warpdrive.crafting.Malformed.name=Bad Item
|
||||
item.warpdrive.crafting.EmeraldCrystal.name=Emerald Tuned Crystal
|
||||
item.warpdrive.crafting.EnderCrystal.name=Ender Tuned Crystal
|
||||
|
|
Loading…
Add table
Reference in a new issue