mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 05:44:27 +00:00
LASERS
This commit is contained in:
1 parent
1cfaec3692
commit
b29f2adc4d
7 files changed
+93
-29
No files matched your search
@@ -1,9 +1,13 @@
|
||||
package mekanism.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.Pos3D;
|
||||
import mekanism.api.lasers.ILaserReceptor;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
@@ -12,21 +16,27 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class LaserManager
|
||||
{
|
||||
public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world)
|
||||
public static void fireLaser(TileEntity from, ForgeDirection direction, double energy, World world)
|
||||
{
|
||||
Coord4D rangeFrom = from.getFromSide(direction, 1);
|
||||
Coord4D to = from.getFromSide(direction, general.laserRange);
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord));
|
||||
fireLaser(new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world);
|
||||
}
|
||||
|
||||
public static void fireLaser(Pos3D from, ForgeDirection direction, double energy, World world)
|
||||
{
|
||||
Pos3D to = from.clone().translate(direction, general.laserRange);
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos));
|
||||
|
||||
if(mop != null)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
to = new Pos3D(mop.hitVec);
|
||||
Coord4D toCoord = new Coord4D(mop.blockX, mop.blockY, mop.blockZ);
|
||||
TileEntity tile = toCoord.getTileEntity(world);
|
||||
|
||||
if(tile instanceof ILaserReceptor)
|
||||
{
|
||||
if(((ILaserReceptor)tile).canLasersDig() && energy > ((ILaserReceptor)tile).energyToDig())
|
||||
{
|
||||
//TODO dig block
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -34,22 +44,32 @@ public class LaserManager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
from.translateExcludingSide(direction, -0.1);
|
||||
to.translateExcludingSide(direction, 0.1);
|
||||
|
||||
for(Entity e : (List<Entity>)world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to)))
|
||||
{
|
||||
if(!e.isImmuneToFire()) e.setFire((int)(energy / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
public static void fireLaserClient(Coord4D from, ForgeDirection direction, World world)
|
||||
public static void fireLaserClient(TileEntity from, ForgeDirection direction, double energy, World world)
|
||||
{
|
||||
Coord4D rangeFrom = from.getFromSide(direction, 1);
|
||||
Coord4D to = from.getFromSide(direction, general.laserRange);
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord));
|
||||
fireLaserClient(new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world);
|
||||
}
|
||||
|
||||
public static void fireLaserClient(Pos3D from, ForgeDirection direction, double energy, World world)
|
||||
{
|
||||
Pos3D to = from.clone().translate(direction, general.laserRange);
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos));
|
||||
|
||||
if(mop != null)
|
||||
{
|
||||
Mekanism.proxy.renderLaser(world, from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ), direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mekanism.proxy.renderLaser(world, from, to, direction);
|
||||
to = new Pos3D(mop.hitVec);
|
||||
}
|
||||
from.translate(direction, -0.501);
|
||||
Mekanism.proxy.renderLaser(world, from, to, direction, energy);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user