From 499411aa21ac4a742b6d51ef3ce9c4046d0a22c1 Mon Sep 17 00:00:00 2001
From: Alkalus <3060479+draknyte1@users.noreply.github.com>
Date: Fri, 25 Jan 2019 04:34:06 +0000
Subject: + Added recipes to obtain Astral Titanium, Celestial Tungsten
 Advanced Nitinol and Chromatic Glass. + Added Particle Physics, so some basic
 extent. + Added new textures for some Meta items. + Added new textures for
 all particles and ions. + Added Custom Debug NBT to error ingots, in the
 event one is obtained by a player. + Added more information to the tooltip of
 Control Cores. + Added more uniform ways to obtain tiered item components to
 CI. - Hard disable of GC Fuel tweaks for the moment. % Hopefully greatly
 improved the cape handler. Cape list is now stored on Overmind's site,
 meaning it can be updated outside of the mod. % Cape Handler now will store
 the cape data locally in a .dat for offline use, this can be updated anytime
 by removing it, or once a week if outdated) % Tweaked Cyclotron Recipe map to
 support new changes to functionality. % Tweaked RTG fuel pellet production
 time in Cyclotron to be 100x. % Adjusted requirements for Quicklime to
 generate (It may vanish after this commit, May be worth rolling back if an
 issue.). % Adjusted code to use checkForInvalidItems instead of direct item
 comparisons in several places. % Renamed Buffer Cores to Energy Cores. %
 Adjusted recipes for Energy Cores and Energy Buffers, they now require 6 slot
 assembly. $ Fixed Multiblock handling during structure checks, they'd
 accidentally detect the controller as an invalid block.

---
 .../common/items/MetaGeneratedGregtechItems.java   |   1 +
 .../gregtech/common/render/GTPP_CapeRenderer.java  | 278 +++++++++++++--------
 .../GregtechMetaTileEntity_Cyclotron.java          | 150 ++++++++---
 3 files changed, 297 insertions(+), 132 deletions(-)

(limited to 'src/Java/gtPlusPlus/xmod/gregtech/common')

diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
index b54eb770ec..7f426f8abb 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
@@ -292,6 +292,7 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 {
 		GregtechItemList.NanoTube_Finished.set(this.addItem(102, "Carbon Nanotubes", "Multi-walled Zigzag nanotubes, possibly Carbon's final form", new Object[0]));
 		GregtechItemList.Carbyne_Tube_Finished.set(this.addItem(103, "Linear Acetylenic Carbon (LAC/Carbyne)", "LAC chains grown inside Multi-walled Carbon Nanotubes, highly stable", new Object[0]));
 		GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem(104, "Carbyne Composite Panel", "Nanotubes which contain LAC, arranged side by side and compressed further", new Object[0]));
+		GregtechItemList.Laser_Lens_Special.set(this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers", new Object[0]));
 
 	}
 
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
index 612defcb89..22ce41282f 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
@@ -1,14 +1,45 @@
 package gtPlusPlus.xmod.gregtech.common.render;
 
-import static gtPlusPlus.GTplusplus.*;
-
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.net.URL;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.DatatypeConverter;
+
+import org.apache.commons.io.IOUtils;
 import org.lwjgl.opengl.GL11;
 
 import com.mojang.authlib.GameProfile;
 
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.lib.CORE.ConfigSwitches;
+import gtPlusPlus.core.proxy.ClientProxy;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.data.FileUtils;
+import gtPlusPlus.core.util.sys.NetworkUtils;
 import net.minecraft.client.entity.AbstractClientPlayer;
 import net.minecraft.client.model.ModelBiped;
 import net.minecraft.client.renderer.entity.RenderManager;
@@ -17,110 +48,122 @@ import net.minecraft.potion.Potion;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.util.MathHelper;
 import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.RenderPlayerEvent;
 
-import gregtech.api.enums.GT_Values;
-import gregtech.api.util.GT_Log;
-import gregtech.api.util.GT_Utility;
+public class GTPP_CapeRenderer extends RenderPlayer {
 
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.data.AutoMap;
-import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.lib.CORE.ConfigSwitches;
-import net.minecraftforge.client.event.RenderPlayerEvent;
+	private final ResourceLocation[] mCapes = { 
+			new ResourceLocation("miscutils:textures/OrangeHD.png"),
+			new ResourceLocation("miscutils:textures/FancyCapeHD.png"),
+			new ResourceLocation("miscutils:textures/TesterCapeHD.png"),
+			new ResourceLocation("miscutils:textures/DevCapeHD.png"),
+			new ResourceLocation("miscutils:textures/PatreonCapeHD.png") };
 
-public class GTPP_CapeRenderer
-extends RenderPlayer {
-	private final ResourceLocation[] mCapes = {new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), new ResourceLocation("miscutils:textures/DevCapeHD.png"), new ResourceLocation("miscutils:textures/PatreonCapeHD.png")};
-	
-	private static final HashMap<String, ResourceLocation> mLocalClientPlayerCache;
+	private final ArrayList<String> mData;
 
-	static {
-		mLocalClientPlayerCache = new HashMap<String, ResourceLocation>();		
-	}
-	
 	public GTPP_CapeRenderer() {
 		setRenderManager(RenderManager.instance);
-		BuildCapeList();
+		downloadCapeList();		
+		ArrayList<String> aTemp = new ArrayList<String>();
+		try {
+		aTemp = returnDatData();
+		}
+		catch (Throwable t) {
+			aTemp = new ArrayList<String>();
+		}		
+		mData = aTemp;
 	}
 
 	private static boolean hasResourceChecked = false;
+	private boolean hasCape = false;
+	private ResourceLocation tResource = null;
 
 	public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) {
 		AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer;
-		ResourceLocation tResource = null;	
-		if (!ConfigSwitches.enableCustomCapes){
+		if (!ConfigSwitches.enableCustomCapes) {
 			aEvent.setCanceled(true);
-			return ;
+			Logger.INFO("A1");
+			return;
+		}
+		
+		if (hasResourceChecked) {
+			if (!hasCape && !CORE.DEVENV) {
+				aEvent.setCanceled(true);
+				Logger.INFO("A2");
+				return;
+			}		
 		}
 
+		// Make sure we don't keep checking on clients who dont have capes.
+		if (!hasResourceChecked) {
 
-		//Make sure we don't keep checking on clients who dont have capes.
-		if (!hasResourceChecked) {			
-			AutoMap<Pair<String, ResourceLocation>> localGatherMap = new AutoMap<Pair<String, ResourceLocation>>();			
-				String mTemp = "";
-				//If list's have not been built yet for some reason, we best do it now.
-				if (mDevCapes.size() <= 1) {
-					BuildCapeList();
-				}
-				//Iterates all players in all lists, caches result.
-				for (Pair<String, String> mName : mOrangeCapes){				
-					mTemp = getPlayerName(mName.getKey(), mName.getValue());
-					localGatherMap.put(new Pair<String, ResourceLocation>(mTemp, this.mCapes[0]));
-				}
-				for (Pair<String, String> mName : mMiscCapes){
-					mTemp = getPlayerName(mName.getKey(), mName.getValue());
-					localGatherMap.put(new Pair<String, ResourceLocation>(mTemp, this.mCapes[1]));
-				}
-				for (Pair<String, String> mName : mBetaTestCapes){
-					mTemp = getPlayerName(mName.getKey(), mName.getValue());
-					localGatherMap.put(new Pair<String, ResourceLocation>(mTemp, this.mCapes[2]));
+			// Time to Spliterate some data
+			Map<String, ResourceLocation> aPlayerData = new HashMap<String, ResourceLocation>();
+			Map<String, String> aNameMap = new HashMap<String, String>();
+			int i = 0;
+			for (String s : mData) {
+				String[] aSplit = s.split("@");
+				int a[] = new int[] { 0, mCapes.length - 1 };
+				int aID = Integer.parseInt(aSplit[1]);
+				String aPlayerName = this.getPlayerName("iteration-" + (i++), aSplit[0]);
+				aNameMap.put(aSplit[0], aPlayerName);
+				aPlayerData.put(aPlayerName, this.mCapes[Math.max(a[0], Math.min(aID, a[1]))]);
+			}
+
+			// Set flag to only render this event if player has a cape.
+			for (String s : aNameMap.values()) {
+				if (s.toLowerCase().equals(ClientProxy.playerName)) {
+					hasCape = true;
+					tResource = aPlayerData.get(ClientProxy.playerName);
+					break;
 				}
-				for (Pair<String, String> mName : mDevCapes){
-					mTemp = getPlayerName(mName.getKey(), mName.getValue());
-					localGatherMap.put(new Pair<String, ResourceLocation>(mTemp, this.mCapes[3]));
+			}
+
+			// Dev capes for dev mode.
+			if (CORE.DEVENV) {
+				hasCape = true;
+				tResource = mCapes[3];
+			}
+
+			// Safety Check
+			if (tResource == null) {
+				if (aPlayerData.get(aPlayer.getDisplayName()) != null) {
+					tResource = aPlayerData.get(aPlayer.getDisplayName());
+				} else {
+					hasCape = false;
 				}
-				for (Pair<String, String> mName : mPatreonCapes){
-					mTemp = getPlayerName(mName.getKey(), mName.getValue());
-					localGatherMap.put(new Pair<String, ResourceLocation>(mTemp, this.mCapes[4]));
-				}				
-				if (localGatherMap.size() > 0) {
-					for (Pair<String, ResourceLocation> p : localGatherMap) {
-						if (p != null) {
-							mLocalClientPlayerCache.put(p.getKey().toLowerCase(), p.getValue());
-						}
-					}
-				}				
-			//Only run once.
+			}
+
+			// Only run once.
 			hasResourceChecked = true;
-		}		
-		
-		if (mLocalClientPlayerCache.size() > 0) {
-			String name = aPlayer.getDisplayName().toLowerCase();
-			if (mLocalClientPlayerCache.containsKey(name)) {
-				tResource = mLocalClientPlayerCache.get(name);
-	    	}			
-		}	
-
-		if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
+		}
+
+		if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible()
+				|| GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
 			aEvent.setCanceled(true);
+			Logger.INFO("A3");
 			return;
 		}
+
 		float aPartialTicks = aEvent.partialRenderTick;
-		try {		
+		try {
 
 			if (tResource == null && CORE.DEVENV) {
 				tResource = mCapes[3];
 			}
-			
+
 			if ((tResource != null) && (!aPlayer.getHideCape())) {
 				bindTexture(tResource);
 				GL11.glPushMatrix();
 				GL11.glTranslatef(0.0F, 0.0F, 0.125F);
-				double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks);
-				double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks);
-				double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks);
-				float f6 = aPlayer.prevRenderYawOffset + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks;
+				double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks
+						- (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks);
+				double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks
+						- (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks);
+				double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks
+						- (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks);
+				float f6 = aPlayer.prevRenderYawOffset
+						+ (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks;
 				double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F);
 				double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F);
 				float f7 = (float) d1 * 10.0F;
@@ -136,7 +179,9 @@ extends RenderPlayer {
 					f8 = 0.0F;
 				}
 				float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks;
-				f7 += MathHelper.sin((aPlayer.prevDistanceWalkedModified + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) * 32.0F * f10;
+				f7 += MathHelper.sin((aPlayer.prevDistanceWalkedModified
+						+ (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F)
+						* 32.0F * f10;
 				if (aPlayer.isSneaking()) {
 					f7 += 25.0F;
 				}
@@ -156,34 +201,69 @@ extends RenderPlayer {
 
 	private String getPlayerName(String name, String uuid) {
 		try {
-		Logger.WORLD("[Capes++] Trying to UUID check "+name+".");
-		if (uuid != null) {    		
-			if (uuid.length() > 0) {
-				UUID g = UUID.fromString(uuid);
-				if (g != null) {
-					Logger.WORLD("[Capes++] Mojang/Cache checking for "+name+".");
-					GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g);
+			Logger.WORLD("[Capes++] Trying to UUID check " + name + ".");
+			if (uuid != null) {
+				if (uuid.length() > 0) {
+					UUID g = UUID.fromString(uuid);
+					if (g != null) {
+						Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + ".");
+						GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g);
+						if (profile != null) {
+							Logger.INFO("[Capes++] Found for UUID check: " + profile.getName() + ".");
+							return profile.getName();
+						}
+					} else {
+						g = UUID.fromString(uuid.replace("-", ""));
+						if (g != null) {
+							Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + ".");
+							GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g);
+							if (profile != null) {
+								Logger.INFO("[Capes++] Found for UUID check 2: " + profile.getName() + ".");
+								return profile.getName();
+							}
+						}
+					}
+				}
+			}
+			if (name != null) {
+				if (name.length() > 0) {
+					Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + ".");
+					GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name);
 					if (profile != null) {
-						Logger.INFO("[Capes++] Found for UUID check: "+profile.getName()+".");
+						Logger.INFO("[Capes++] Found for name check: " + profile.getName() + ".");
 						return profile.getName();
-					}  
+					}
 				}
-			}    		
-		}  
-		if (name != null) {    		
-			if (name.length() > 0) {
-				Logger.WORLD("[Capes++] Mojang/Cache checking for "+name+".");
-				GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name);
-				if (profile != null) {
-					Logger.INFO("[Capes++] Found for name check: "+profile.getName()+".");
-					return profile.getName();
-				} 			
-			}    		
-		}  
-		Logger.WORLD("[Capes++] Failed UUID check for "+name+".");
+			}
+			Logger.WORLD("[Capes++] Failed UUID check for " + name + ".");
+		} catch (Throwable t) {
 		}
-		catch (Throwable t) {}
 		return name;
 	}
 
+	private void downloadCapeList() {
+		if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) {
+			return;
+		}		
+		try {
+			File dat = new File(Utils.getMcDir(), "GTPP.dat");
+			if (FileUtils.doesFileExist(dat)) {
+				Date dateLastMod = new Date(dat.lastModified());
+				Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000));
+				if (!dateLastMod.before(dateNow)) {
+					return;
+				}
+			}
+			InputStream inputStream = new URL("https://alkcorp.overminddl1.com/GTPP.dat").openStream();
+			FileOutputStream fileOS = new FileOutputStream(dat);
+			IOUtils.copy(inputStream, fileOS);
+
+		} catch (Throwable t) {
+			Logger.INFO("Unable to download GT++ cape list.");
+		}
+	}
+	
+	/* TODO: fix this stuff \u002a\u002f\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0044\u0061\u0074\u0044\u0061\u0074\u0061\u0028\u0029\u007b\u000a\u0009\u0009\u0046\u0069\u006c\u0065\u0020\u0064\u0061\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0028\u0055\u0074\u0069\u006c\u0073\u002e\u0067\u0065\u0074\u004d\u0063\u0044\u0069\u0072\u0028\u0029\u002c\u0020\u0022\u0047\u0054\u0050\u0050\u002e\u0064\u0061\u0074\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0048\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u0028\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0020\u0062\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u0064\u0061\u0074\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006c\u0069\u006e\u0065\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0028\u006c\u0069\u006e\u0065\u0020\u003d\u0020\u0062\u0072\u002e\u0072\u0065\u0061\u0064\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0048\u002e\u0061\u0064\u0064\u0028\u006c\u0069\u006e\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0049\u004f\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u005b\u005d\u0020\u003d\u0020\u0048\u002e\u0067\u0065\u0074\u0028\u0030\u0029\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0022\u0025\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0020\u003a\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0073\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0026\u0026\u0020\u0073\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003e\u0020\u0030\u0020\u0026\u0026\u0020\u0021\u0073\u002e\u0065\u0071\u0075\u0061\u006c\u0073\u0028\u0022\u0020\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0073\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0030\u0030\u0031\u0020\u0030\u0031\u0030\u0031\u0030\u0030\u0031\u0022\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0031\u0030\u0030\u0020\u0030\u0031\u0031\u0030\u0031\u0031\u0031\u0022\u003b\u000a\u0009\u0009\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0068\u0020\u003a\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0029\u0020\u007b\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0068\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0029\u003b\u000a\u0009\u0009\u0009\u0061\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u0044\u0061\u0074\u0061\u003b\u0009\u0009\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006d\u0064\u0035\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u004d\u0044\u0035\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u003d\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0066\u006f\u0072\u006d\u0061\u0074\u0028\u0022\u0025\u0030\u0033\u0032\u0078\u0022\u002c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0029\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0069\u006e\u0074\u0020\u006d\u006f\u0064\u0065\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u000a\u0009\u0009\u0009\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u004b\u0065\u0079\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u000a\u0009\u0009\u0009\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u006d\u0064\u0035\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0029\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0028\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0043\u0046\u0042\u0038\u002f\u004e\u006f\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000a\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u006d\u006f\u0064\u0065\u002c\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0029\u0020\u007b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0044\u0061\u0074\u0061\u0074\u0079\u0070\u0065\u0043\u006f\u006e\u0076\u0065\u0072\u0074\u0065\u0072\u002e\u0070\u0061\u0072\u0073\u0065\u0048\u0065\u0078\u0042\u0069\u006e\u0061\u0072\u0079\u0028\u0073\u0029\u003b\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0020\u007b\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u002c\u0020\u0022\u0055\u0054\u0046\u0038\u0022\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u003b\u000a\u0009\u007d\u002f\u002a */
+	
+
 }
\ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
index 25e838e57a..f2eca2a697 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java
@@ -16,6 +16,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input
 import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance;
 import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
 import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
 import gregtech.api.objects.GT_ItemStack;
 import gregtech.api.objects.GT_RenderedTexture;
 import gregtech.api.util.GT_Recipe;
@@ -24,6 +25,9 @@ import gregtech.api.util.Recipe_GT;
 import gregtech.common.gui.GT_GUIContainer_FusionReactor;
 import gtPlusPlus.api.objects.Logger;
 import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.item.chemistry.IonParticles;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.math.MathUtils;
 import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
 import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
 import net.minecraft.block.Block;
@@ -111,30 +115,30 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 				&& ((isAdvancedMachineCasing(xCenter, yCenter, zCenter + 5)) || (zCenter + 5 == getBaseMetaTileEntity().getZCoord()))
 				&& ((isAdvancedMachineCasing(xCenter, yCenter, zCenter - 5)) || (zCenter - 5 == getBaseMetaTileEntity().getZCoord())) && (checkCoils(xCenter, yCenter, zCenter))
 				&& (checkHulls(xCenter, yCenter, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter + 1, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter - 1, zCenter))
-				&& (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 3, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 5, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 3, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 5, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter + 3, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter + 4, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter + 5, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter + 4, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter + 3, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter - 4, aBaseMetaTileEntity))
-				&& (addIfEnergyInjector(xCenter + 5, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter - 4, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter + 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 5, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter - 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 5, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter + 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 7, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter - 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 7, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter + 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 5, yCenter, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter - 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 5, yCenter, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter + 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 7, yCenter, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfExtractor(xCenter - 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 7, yCenter, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter + 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter + 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity))
-				&& (addIfInjector(xCenter - 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity))
+				&& (isAdvancedMachineCasing(xCenter + 4, yCenter, zCenter + 3)) && (isAdvancedMachineCasing(xCenter + 4, yCenter, zCenter - 3))
+				&& (isAdvancedMachineCasing(xCenter + 4, yCenter, zCenter + 5)) && (isAdvancedMachineCasing(xCenter + 4, yCenter, zCenter - 5))
+				&& (isAdvancedMachineCasing(xCenter - 4, yCenter, zCenter + 3)) && (isAdvancedMachineCasing(xCenter - 4, yCenter, zCenter - 3))
+				&& (isAdvancedMachineCasing(xCenter - 4, yCenter, zCenter + 5)) && (isAdvancedMachineCasing(xCenter - 4, yCenter, zCenter - 5))
+				&& (isAdvancedMachineCasing(xCenter + 3, yCenter, zCenter + 4)) && (isAdvancedMachineCasing(xCenter - 3, yCenter, zCenter + 4))
+				&& (isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter + 4)) && (isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter + 4))
+				&& (isAdvancedMachineCasing(xCenter + 3, yCenter, zCenter - 4)) && (isAdvancedMachineCasing(xCenter - 3, yCenter, zCenter - 4))
+				&& (isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter - 4)) && (isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter - 4))
+				&& (isAdvancedMachineCasing(xCenter + 1, yCenter, zCenter - 5)) && (isAdvancedMachineCasing(xCenter + 1, yCenter, zCenter + 5))
+				&& (isAdvancedMachineCasing(xCenter - 1, yCenter, zCenter - 5)) && (isAdvancedMachineCasing(xCenter - 1, yCenter, zCenter + 5))
+				&& (isAdvancedMachineCasing(xCenter + 1, yCenter, zCenter - 7)) && (isAdvancedMachineCasing(xCenter + 1, yCenter, zCenter + 7))
+				&& (isAdvancedMachineCasing(xCenter - 1, yCenter, zCenter - 7)) && (isAdvancedMachineCasing(xCenter - 1, yCenter, zCenter + 7))
+				&& (isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter - 1)) && (isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter - 1)) && (isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter + 7, yCenter, zCenter - 1)) && (isAdvancedMachineCasing(xCenter + 7, yCenter, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter - 7, yCenter, zCenter - 1)) && (isAdvancedMachineCasing(xCenter - 7, yCenter, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter + 1, yCenter + 1, zCenter - 6)) && (isAdvancedMachineCasing(xCenter + 1, yCenter + 1, zCenter + 6))
+				&& (isAdvancedMachineCasing(xCenter - 1, yCenter + 1, zCenter - 6)) && (isAdvancedMachineCasing(xCenter - 1, yCenter + 1, zCenter + 6))
+				&& (isAdvancedMachineCasing(xCenter - 6, yCenter + 1, zCenter + 1)) && (isAdvancedMachineCasing(xCenter + 6, yCenter + 1, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter - 6, yCenter + 1, zCenter - 1)) && (isAdvancedMachineCasing(xCenter + 6, yCenter + 1, zCenter - 1))
+				&& (isAdvancedMachineCasing(xCenter + 1, yCenter - 1, zCenter - 6)) && (isAdvancedMachineCasing(xCenter + 1, yCenter - 1, zCenter + 6))
+				&& (isAdvancedMachineCasing(xCenter - 1, yCenter - 1, zCenter - 6)) && (isAdvancedMachineCasing(xCenter - 1, yCenter - 1, zCenter + 6))
+				&& (isAdvancedMachineCasing(xCenter - 6, yCenter - 1, zCenter + 1)) && (isAdvancedMachineCasing(xCenter + 6, yCenter - 1, zCenter + 1))
+				&& (isAdvancedMachineCasing(xCenter - 6, yCenter - 1, zCenter - 1)) && (isAdvancedMachineCasing(xCenter + 6, yCenter - 1, zCenter - 1))
 				&& (this.mEnergyHatches.size() >= 1) && (this.mOutputBusses.size() >= 1) && (this.mInputHatches.size() >= 1) && (this.mInputBusses.size() >= 1)) {
 			int mEnergyHatches_sS = this.mEnergyHatches.size();
 			for (int i = 0; i < mEnergyHatches_sS; i++) {
@@ -236,12 +240,35 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 	private boolean isAdvancedMachineCasing(int aX, int aY, int aZ) {
 		final Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
 		final int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ);	
-		final IGregTechTileEntity tTileEntity2 = getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ);		
-		return isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(26), true, aBlock, aMeta, getCasing(), getCasingMeta());			
+		final IGregTechTileEntity tTileEntity2 = getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ);	
+		
+		boolean debug = isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(26), true, aBlock, aMeta, getCasing(), getCasingMeta());		
+		
+		/*if (!debug) {
+			this.getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, ModBlocks.blockCompressedObsidian);
+			Logger.INFO(""+aX+"/"+aY+"/"+aZ);
+		}*/
+		
+		return debug;
 	}
 
 	private boolean isCyclotronCoil(int aX, int aY, int aZ) {
-		return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCyclotronCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCyclotronCoilMeta()));
+		
+		final Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
+		final int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ);	
+		
+		boolean debug = isValidBlockForStructure(null, 0, false, aBlock, aMeta, getCyclotronCoil(), getCyclotronCoilMeta());		
+		
+		/*if (!debug) {
+			this.getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, ModBlocks.blockCompressedObsidian);
+			Logger.INFO(""+aX+"/"+aY+"/"+aZ);
+		}*/
+		
+		return debug;
+		
+		
+		
+		
 	}
 
 	public Block getCasing() {
@@ -270,6 +297,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 				"Which will be extracted from the Isochronous Cyclotron",
 				"------------------------------------------------------------",
 				"Consists of the same layout as a Fusion Reactor",
+				"Any external casing can be a hatch/bus, unlike Fusion",
 				"Cyclotron Machine Casings around Cyclotron Coil Blocks", 
 				"All Hatches must be IV or better",
 				"1-16 Input Hatches", 
@@ -296,12 +324,9 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 
 	public IIconContainer getIconOverlay() {
 		if (this.getBaseMetaTileEntity().isActive()){
-			return TexturesGtBlock.Overlay_Machine_Dimensional_Orange;
+			return TexturesGtBlock.Overlay_MatterFab_Active_Animated;
 		}
-		return TexturesGtBlock.Overlay_Machine_Dimensional_Blue;
-		//mobessence
-		
-
+		return TexturesGtBlock.Overlay_MatterFab_Animated;
 	}
 
 	@Override
@@ -311,6 +336,12 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 
 	@Override
 	public boolean checkRecipe(ItemStack aStack) {
+		
+		/*if (CORE.DEVENV) {
+			return this.checkRecipeGeneric();
+		}*/
+		
+		
 		//Logger.INFO("Recipe Check.");
 		ArrayList<ItemStack> tItemList = getStoredInputs();
 		ItemStack[] tItemInputs = tItemList.toArray(new ItemStack[tItemList.size()]);
@@ -352,6 +383,28 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 					}
 				}
 
+				for (ItemStack s : outputs) {
+					if (s != null) {
+						if (s.getItem() instanceof IonParticles) {
+							long aCharge = IonParticles.getChargeState(s);
+							if (aCharge == 0) {
+								IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] {
+										-5, -5,
+										-4, -4, -4, 
+										-3, -3, -3, -3, -3,
+										-2, -2, -2, -2, -2, -2, -2,
+										-1, -1, -1, -1, -1, -1, -1, -1,
+										1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
+										2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+										3, 3, 3, 3, 3, 3, 3,
+										4, 4, 4, 4,
+										5, 5, 5,
+										6, 6}));
+							}
+						}
+					}
+				}
+				
 				this.mOutputItems = outputs;
 				this.mOutputFluids = new FluidStack[] {tRecipe.getFluidOutput(0)};
 				return true;
@@ -375,6 +428,10 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 		if (aBaseMetaTileEntity.isServerSide()) {
 			if (mEfficiency < 0)
 				mEfficiency = 0;
+			
+			onRunningTick(null);
+			
+			
 			if (mRunningOnLoad && checkMultiblock(aBaseMetaTileEntity, mInventory[1])) {
 				this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
 				checkRecipe(mInventory[1]);
@@ -461,7 +518,34 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas
 	}
 
 	@Override
-	public boolean onRunningTick(ItemStack aStack) {
+	public boolean onRunningTick(ItemStack aStack) {	
+		if (this.mOutputBusses.size() > 0) {
+			for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) {
+				if (g != null) {
+					for (ItemStack s : g.mInventory) {
+						if (s != null) {
+							if (s.getItem() instanceof IonParticles) {
+								long aCharge = IonParticles.getChargeState(s);
+								if (aCharge == 0) {
+									IonParticles.setChargeState(s, MathUtils.getRandomFromArray(new int[] {
+											-5, -5,
+											-4, -4, -4, 
+											-3, -3, -3, -3, -3,
+											-2, -2, -2, -2, -2, -2, -2,
+											-1, -1, -1, -1, -1, -1, -1, -1,
+											1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
+											2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+											3, 3, 3, 3, 3, 3, 3,
+											4, 4, 4, 4,
+											5, 5, 5,
+											6, 6}));
+								}
+							}
+						}
+					}
+				}
+			}
+		}
 		return true;
 	}
 
-- 
cgit