Added uninsulated wire shock mechanism

This commit is contained in:
Calclavia 2013-12-23 11:26:39 +08:00
parent 18b3219a61
commit 6056a2215a
5 changed files with 27 additions and 12 deletions

View file

@ -12,6 +12,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.ShapedOreRecipe;
@ -20,7 +21,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import codechicken.lib.colour.ColourRGBA;
import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.contractor.ItemBlockContractor;
import resonantinduction.contractor.TileEntityEMContractor;
@ -36,13 +36,13 @@ import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.ItemWire;
import universalelectricity.api.item.IElectricalItem;
import universalelectricity.api.vector.Vector3;
import basiccomponents.api.BasicRegistry;
import calclavia.lib.UniversalRecipe;
import calclavia.lib.network.PacketHandler;
import calclavia.lib.network.PacketTile;
import calclavia.lib.prefab.CustomDamageSource;
import calclavia.lib.prefab.TranslationHelper;
import codechicken.lib.colour.ColourRGBA;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;

View file

@ -17,7 +17,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -26,6 +25,7 @@ import resonantinduction.api.ITesla;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender;
import calclavia.lib.prefab.CustomDamageSource;
import calclavia.lib.tile.EnergyStorage;
import calclavia.lib.tile.TileEntityElectrical;
@ -231,7 +231,7 @@ public class TileEntityTesla extends TileEntityElectrical implements ITesla, IPa
{
if (mop.entityHit instanceof EntityLivingBase)
{
mop.entityHit.attackEntityFrom(DamageSource.magic, 4);
mop.entityHit.attackEntityFrom(CustomDamageSource.electrocution, 4);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit));
}
}

View file

@ -4,14 +4,17 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import calclavia.lib.prefab.CustomDamageSource;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import resonantinduction.ResonantInduction;
import resonantinduction.wire.EnumWireMaterial;
import universalelectricity.api.CompatibilityModule;
import codechicken.lib.data.MCDataInput;
@ -58,6 +61,15 @@ public abstract class PartAdvancedWire extends PartConductor
return false;
}
@Override
public void onEntityCollision(Entity entity)
{
if (!this.isInsulated() && this.getNetwork().getLastBuffer() > 0)
{
entity.attackEntityFrom(CustomDamageSource.electrocution, this.getNetwork().getLastBuffer());
}
}
@Override
public long getEnergyLoss()
{

View file

@ -22,7 +22,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
*/
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
{System.out.println("RECEIVE");
return this.getNetwork().produce(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world()), from.getOpposite(), receive, doReceive);
}

View file

@ -104,9 +104,11 @@ public class TraitConductor extends TileMultipart implements IConductor
/**
* Try out different sides to try to inject energy into.
*/
if (this.partMap(from.ordinal()) == null)
{
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (dir != from.getOpposite() && dir != from)
if (dir != from.getOpposite())
{
TMultiPart part = this.partMap(dir.ordinal());
@ -116,6 +118,7 @@ public class TraitConductor extends TileMultipart implements IConductor
}
}
}
}
return 0;
}