Merge branch 'master' of https://github.com/calclavia/Resonant-Induction
This commit is contained in:
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 |
|
@ -15,11 +15,12 @@ import resonantinduction.TabRI;
|
|||
*/
|
||||
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.setUnlocalizedName(ResonantInduction.PREFIX + name);
|
||||
this.func_111022_d(ResonantInduction.PREFIX + name);
|
||||
this.setHardness(1f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,20 +244,21 @@ public class Vector3
|
|||
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;
|
||||
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);
|
||||
|
||||
double checkBorder = 1.1 * reachDistance;
|
||||
AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);
|
||||
;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Entity> entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
|
||||
double closestEntity = reachDistance;
|
||||
|
||||
if (entitiesHit == null || entitiesHit.isEmpty())
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.base.BlockBase;
|
||||
import resonantinduction.render.BlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -26,7 +27,8 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
public BlockBattery(int id)
|
||||
{
|
||||
super("battery", id, Material.iron);
|
||||
super("battery", id);
|
||||
this.func_111022_d(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
public BlockEMContractor(int id)
|
||||
{
|
||||
super("contractor", id, Material.iron);
|
||||
super("contractor", id);
|
||||
this.func_111022_d(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
|||
|
||||
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)
|
||||
|
|
|
@ -23,7 +23,7 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
public BlockTesla(int id)
|
||||
{
|
||||
super("tesla", id, Material.iron);
|
||||
super("tesla", id);
|
||||
this.func_111022_d(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
|
|
|
@ -168,17 +168,14 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
|
||||
if (this.attackEntities && this.zapCounter % 5 == 0)
|
||||
{
|
||||
double[] rotations = topTeslaVector.difference(targetVector).normalize().getDeltaRotationFromPosition();
|
||||
MovingObjectPosition mop = topTeslaVector.rayTraceEntities(this.worldObj, rotations[0], rotations[1], distance);
|
||||
// System.out.println(Vector3.getDeltaPositionFromRotation(rotations[0],
|
||||
// rotations[1]) + " :" + mop);
|
||||
MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(this.worldObj, targetVector.clone().translate(0.5));
|
||||
|
||||
if (mop != null && mop.entityHit != null)
|
||||
{
|
||||
if (mop.entityHit instanceof EntityLivingBase)
|
||||
{
|
||||
mop.entityHit.attackEntityFrom(DamageSource.magic, 1);
|
||||
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), new Vector3(mop.entityHit));
|
||||
mop.entityHit.attackEntityFrom(DamageSource.magic, 3);
|
||||
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
|
||||
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
|
||||
|
@ -289,6 +286,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe
|
|||
this.energy = input.readFloat();
|
||||
this.dyeID = input.readInt();
|
||||
this.canReceive = input.readBoolean();
|
||||
this.attackEntities = input.readBoolean();
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue