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.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
@ -20,7 +21,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.modstats.ModstatInfo; import org.modstats.ModstatInfo;
import org.modstats.Modstats; import org.modstats.Modstats;
import codechicken.lib.colour.ColourRGBA;
import resonantinduction.contractor.BlockEMContractor; import resonantinduction.contractor.BlockEMContractor;
import resonantinduction.contractor.ItemBlockContractor; import resonantinduction.contractor.ItemBlockContractor;
import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.contractor.TileEntityEMContractor;
@ -36,13 +36,13 @@ import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.ItemWire; import resonantinduction.wire.ItemWire;
import universalelectricity.api.item.IElectricalItem;
import universalelectricity.api.vector.Vector3;
import basiccomponents.api.BasicRegistry; import basiccomponents.api.BasicRegistry;
import calclavia.lib.UniversalRecipe; import calclavia.lib.UniversalRecipe;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
import calclavia.lib.network.PacketTile; import calclavia.lib.network.PacketTile;
import calclavia.lib.prefab.CustomDamageSource;
import calclavia.lib.prefab.TranslationHelper; import calclavia.lib.prefab.TranslationHelper;
import codechicken.lib.colour.ColourRGBA;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod; 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.network.packet.Packet;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -26,6 +25,7 @@ import resonantinduction.api.ITesla;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;
import calclavia.lib.prefab.CustomDamageSource;
import calclavia.lib.tile.EnergyStorage; import calclavia.lib.tile.EnergyStorage;
import calclavia.lib.tile.TileEntityElectrical; import calclavia.lib.tile.TileEntityElectrical;
@ -231,7 +231,7 @@ public class TileEntityTesla extends TileEntityElectrical implements ITesla, IPa
{ {
if (mop.entityHit instanceof EntityLivingBase) 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)); 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.Collections;
import java.util.List; import java.util.List;
import calclavia.lib.prefab.CustomDamageSource;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockColored; import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemShears; import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import resonantinduction.ResonantInduction;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.CompatibilityModule;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
@ -58,6 +61,15 @@ public abstract class PartAdvancedWire extends PartConductor
return false; return false;
} }
@Override
public void onEntityCollision(Entity entity)
{
if (!this.isInsulated() && this.getNetwork().getLastBuffer() > 0)
{
entity.attackEntityFrom(CustomDamageSource.electrocution, this.getNetwork().getLastBuffer());
}
}
@Override @Override
public long getEnergyLoss() public long getEnergyLoss()
{ {

View file

@ -22,7 +22,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
*/ */
@Override @Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) 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); return this.getNetwork().produce(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world()), from.getOpposite(), receive, doReceive);
} }

View file

@ -104,15 +104,18 @@ public class TraitConductor extends TileMultipart implements IConductor
/** /**
* Try out different sides to try to inject energy into. * Try out different sides to try to inject energy into.
*/ */
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) if (this.partMap(from.ordinal()) == null)
{ {
if (dir != from.getOpposite() && dir != from) for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{ {
TMultiPart part = this.partMap(dir.ordinal()); if (dir != from.getOpposite())
if (this.interfaces.contains(part))
{ {
return ((IConductor) part).onReceiveEnergy(from, receive, doReceive); TMultiPart part = this.partMap(dir.ordinal());
if (this.interfaces.contains(part))
{
return ((IConductor) part).onReceiveEnergy(from, receive, doReceive);
}
} }
} }
} }