Added laser damage event catch
Creeps will explode if killed by lasers. Though this would be a nice addion. As well made an attempt at having diamond armor reflect laser damage. Though this didn't work as well
This commit is contained in:
parent
603874d94c
commit
ca71a5cca1
3 changed files with 79 additions and 1 deletions
|
@ -3,16 +3,19 @@ package dark.core.common.items;
|
|||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.core.item.ItemElectric;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.interfaces.IExtraInfo.IExtraItemInfo;
|
||||
import dark.core.prefab.ModPrefab;
|
||||
|
||||
/** Simple battery to store energy
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class ItemBattery extends ItemElectric
|
||||
public class ItemBattery extends ItemElectric implements IExtraItemInfo
|
||||
{
|
||||
public ItemBattery()
|
||||
{
|
||||
|
@ -45,4 +48,23 @@ public class ItemBattery extends ItemElectric
|
|||
{
|
||||
return 5000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasExtraConfigs()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadOreNames()
|
||||
{
|
||||
OreDictionary.registerOre("Battery", this);
|
||||
}
|
||||
}
|
||||
|
|
55
src/dark/core/prefab/LaserEntityDamageSource.java
Normal file
55
src/dark/core/prefab/LaserEntityDamageSource.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package dark.core.prefab;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
|
||||
public class LaserEntityDamageSource extends EntityDamageSource
|
||||
{
|
||||
public LaserEntityDamageSource(Entity par2Entity)
|
||||
{
|
||||
super("Laser", par2Entity);
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void LivingDeathEvent(LivingDeathEvent event)
|
||||
{
|
||||
if (event.entity instanceof EntityCreeper)
|
||||
{
|
||||
if (!event.entity.worldObj.isRemote && event.source instanceof LaserEntityDamageSource)
|
||||
{
|
||||
boolean flag = event.entity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");
|
||||
|
||||
if (((EntityCreeper) event.entity).getPowered())
|
||||
{
|
||||
event.entity.worldObj.createExplosion(event.entity, event.entity.posX, event.entity.posY, event.entity.posZ, 3 * 2, flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.entity.worldObj.createExplosion(event.entity, event.entity.posX, event.entity.posY, event.entity.posZ, 3, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void LivingAttackEvent(LivingAttackEvent event)
|
||||
{
|
||||
if (event.entity instanceof EntityPlayer)
|
||||
{
|
||||
if (((EntityPlayer) event.entity).inventory.armorItemInSlot(3) == new ItemStack(Item.plateDiamond, 1))
|
||||
{
|
||||
if(event.isCancelable())
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,6 +105,7 @@ public abstract class ModPrefab
|
|||
{
|
||||
MinecraftForge.EVENT_BUS.register(new FluidHelper());
|
||||
MinecraftForge.EVENT_BUS.register(SaveManager.instance());
|
||||
MinecraftForge.EVENT_BUS.register(new LaserEntityDamageSource(null));
|
||||
TickRegistry.registerTickHandler(NetworkUpdateHandler.instance(), Side.SERVER);
|
||||
TickRegistry.registerScheduledTickHandler(new PlayerKeyHandler(), Side.CLIENT);
|
||||
UniversalElectricity.initiate();
|
||||
|
|
Loading…
Reference in a new issue