diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-08-10 18:52:45 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-08-10 18:52:45 +0300 |
| commit | 0427ab89f1753a44b30cbc35ce021cbbdc845109 (patch) | |
| tree | abe418ff5ec174e712fe8dedd434548a945b15a3 /src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java | |
| parent | 877312184c472d9845e5ef1008bc538f4634059f (diff) | |
fix missing source folder
Diffstat (limited to 'src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java')
| -rw-r--r-- | src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java b/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java new file mode 100644 index 0000000..6cd61fc --- /dev/null +++ b/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java @@ -0,0 +1,48 @@ +package ihl.enviroment;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import ic2.api.event.LaserEvent;
+import ic2.core.item.tool.EntityMiningLaser;
+import net.minecraft.entity.Entity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class LaserHitMirrorEventHandler
+{
+ public LaserHitMirrorEventHandler(){}
+
+ @SubscribeEvent
+ public void onLaserHit(LaserEvent.LaserHitsBlockEvent event)
+ {
+ TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
+ if(te instanceof MirrorTileEntity)
+ {
+ ForgeDirection mirrorDirection = ForgeDirection.getOrientation(((MirrorTileEntity)te).getFacing());
+ Entity ls = event.lasershot;
+ if((ls.motionX*mirrorDirection.offsetX+ls.motionY*mirrorDirection.offsetY+ls.motionZ*mirrorDirection.offsetZ)<0)
+ {
+ if(mirrorDirection.offsetX!=0)
+ {
+ ls.motionX=-ls.motionX;
+ }
+ if(mirrorDirection.offsetY!=0)
+ {
+ ls.motionY=-ls.motionY;
+ }
+ if(mirrorDirection.offsetZ!=0)
+ {
+ ls.motionZ=-ls.motionZ;
+ }
+ if(!event.world.isRemote)
+ {
+ EntityMiningLaser tLaser = new EntityMiningLaser(event.world, event.owner, event.range, event.power, event.blockBreaks, event.explosive, 0, 0, ls.posY);
+ tLaser.setPosition(ls.posX, ls.posY, ls.posZ);
+ tLaser.setLaserHeading(ls.motionX, ls.motionY, ls.motionZ, 1d);
+ ls.setDead();
+ event.world.spawnEntityInWorld(tLaser);
+ }
+ event.setCanceled(true);
+ }
+ }
+ }
+}
|
