From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/enviroment/LaserHitMirrorEventHandler.java | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ihl/enviroment/LaserHitMirrorEventHandler.java (limited to 'ihl/enviroment/LaserHitMirrorEventHandler.java') diff --git a/ihl/enviroment/LaserHitMirrorEventHandler.java b/ihl/enviroment/LaserHitMirrorEventHandler.java new file mode 100644 index 0000000..9baee2d --- /dev/null +++ b/ihl/enviroment/LaserHitMirrorEventHandler.java @@ -0,0 +1,48 @@ +package ihl.enviroment; + +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; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +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); + } + } + } +} -- cgit v1.2.3