This commit is contained in:
Aidan Brady 2013-08-04 22:05:50 -04:00
commit 54b8800ff5
8 changed files with 30 additions and 28 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,018 B

After

Width:  |  Height:  |  Size: 752 B

View file

@ -15,11 +15,12 @@ import resonantinduction.TabRI;
*/ */
public class BlockBase extends Block public class BlockBase extends Block
{ {
public BlockBase(String name, int id, Material material) public BlockBase(String name, int id)
{ {
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), material); super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), Material.piston);
this.setCreativeTab(TabRI.INSTANCE); this.setCreativeTab(TabRI.INSTANCE);
this.setUnlocalizedName(ResonantInduction.PREFIX + name); this.setUnlocalizedName(ResonantInduction.PREFIX + name);
this.func_111022_d(ResonantInduction.PREFIX + name); this.func_111022_d(ResonantInduction.PREFIX + name);
this.setHardness(1f);
} }
} }

View file

@ -244,20 +244,21 @@ public class Vector3
return world.getBlockTileEntity((int) this.x, (int) this.y, (int) this.z); return world.getBlockTileEntity((int) this.x, (int) this.y, (int) this.z);
} }
public MovingObjectPosition rayTraceEntities(World world, double rotationYaw, double rotationPitch, double reachDistance) public MovingObjectPosition rayTraceEntities(World world, Vector3 target)
{ {
MovingObjectPosition pickedEntity = null; MovingObjectPosition pickedEntity = null;
Vec3 startingPosition = this.toVec3(); Vec3 startingPosition = this.toVec3();
Vec3 look = getDeltaPositionFromRotation(rotationYaw, rotationPitch).toVec3(); Vec3 look = target.normalize().toVec3();
double reachDistance = this.distance(target);
Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance); Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);
double checkBorder = 1.1 * reachDistance; double checkBorder = 1.1 * reachDistance;
AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z); AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);
;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan); List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
double closestEntity = reachDistance; double closestEntity = reachDistance;
if (entitiesHit == null || entitiesHit.isEmpty()) if (entitiesHit == null || entitiesHit.isEmpty())
{ {
return null; return null;

View file

@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -26,7 +27,8 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
{ {
public BlockBattery(int id) public BlockBattery(int id)
{ {
super("battery", id, Material.iron); super("battery", id);
this.func_111022_d(ResonantInduction.PREFIX + "machine");
} }
@Override @Override
@ -47,11 +49,11 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, int id) public void onNeighborBlockChange(World world, int x, int y, int z, int id)
{ {
if(!world.isRemote) if (!world.isRemote)
{ {
if(id == blockID) if (id == blockID)
{ {
TileEntityBattery battery = (TileEntityBattery)world.getBlockTileEntity(x, y, z); TileEntityBattery battery = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
battery.update(); battery.update();
} }
@ -61,9 +63,9 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack)
{ {
if(!world.isRemote) if (!world.isRemote)
{ {
TileEntityBattery battery = (TileEntityBattery)world.getBlockTileEntity(x, y, z); TileEntityBattery battery = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
battery.update(); battery.update();
} }

View file

@ -20,7 +20,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
{ {
public BlockEMContractor(int id) public BlockEMContractor(int id)
{ {
super("contractor", id, Material.iron); super("contractor", id);
this.func_111022_d(ResonantInduction.PREFIX + "machine"); this.func_111022_d(ResonantInduction.PREFIX + "machine");
} }

View file

@ -30,7 +30,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
public BlockMultimeter(int id) public BlockMultimeter(int id)
{ {
super("multimeter", id, Material.iron); super("multimeter", id);
} }
public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase) public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase)

View file

@ -23,7 +23,7 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
{ {
public BlockTesla(int id) public BlockTesla(int id)
{ {
super("tesla", id, Material.iron); super("tesla", id);
this.func_111022_d(ResonantInduction.PREFIX + "machine"); this.func_111022_d(ResonantInduction.PREFIX + "machine");
} }

View file

@ -168,17 +168,14 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
if (this.attackEntities && this.zapCounter % 5 == 0) if (this.attackEntities && this.zapCounter % 5 == 0)
{ {
double[] rotations = topTeslaVector.difference(targetVector).normalize().getDeltaRotationFromPosition(); MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(this.worldObj, targetVector.clone().translate(0.5));
MovingObjectPosition mop = topTeslaVector.rayTraceEntities(this.worldObj, rotations[0], rotations[1], distance);
// System.out.println(Vector3.getDeltaPositionFromRotation(rotations[0],
// rotations[1]) + " :" + mop);
if (mop != null && mop.entityHit != null) if (mop != null && mop.entityHit != null)
{ {
if (mop.entityHit instanceof EntityLivingBase) if (mop.entityHit instanceof EntityLivingBase)
{ {
mop.entityHit.attackEntityFrom(DamageSource.magic, 1); mop.entityHit.attackEntityFrom(DamageSource.magic, 3);
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), new Vector3(mop.entityHit)); ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit));
} }
} }
} }
@ -269,7 +266,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
@Override @Override
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
{ {
return PacketHandler.getTileEntityPacket(this, (byte) 1, this.getEnergyStored(), this.dyeID, this.canReceive); return PacketHandler.getTileEntityPacket(this, (byte) 1, this.getEnergyStored(), this.dyeID, this.canReceive, this.attackEntities);
} }
@Override @Override
@ -289,6 +286,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
this.energy = input.readFloat(); this.energy = input.readFloat();
this.dyeID = input.readInt(); this.dyeID = input.readInt();
this.canReceive = input.readBoolean(); this.canReceive = input.readBoolean();
this.attackEntities = input.readBoolean();
break; break;
} }