From fbe73a2de925d012dddfa46b13e745028ce40679 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 18:50:58 +0000 Subject: + Added Tags to tooltips, which can be used to control base tooltips inherited from parents. % Mild update to tooltips of a few multis. % Adjusted Large Arc Furnace casing texture. % Renamed the 3 Factory Grade multis. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 47 +++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index ca231dbd63..d5e016bbf8 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -47,6 +47,10 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return set(object); } + public synchronized V add(V object){ + return set(object); + } + public synchronized V set(V object){ if (object == null) { return null; @@ -90,15 +94,19 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return true; } + private final Class getMapType() { + Class g = mInternalMap.get(0).getClass(); + return g; + } + public synchronized V[] toArray() { - Collection col = this.mInternalMap.values(); - V[] val = (V[]) new Object[col.size()]; - int counter = 0; - for (V i : col) { - val[counter] = i; - counter++; + /*Collection col = this.mInternalMap.values(); + List abcList = new ArrayList(); + for (V g : col) { + abcList.add(g); } - return val; + return (V[]) abcList.toArray();*/ + return (V[]) new AutoArray(this).getGenericArray(); } public synchronized final int getInternalID() { @@ -106,10 +114,35 @@ public class AutoMap implements Iterable, Cloneable, Serializable { } public synchronized final boolean remove(V value) { + value.getClass(); if (this.mInternalMap.containsValue(value)) { return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); } return false; } + + private class AutoArray { + + private final V[] arr; + public final int length; + + public AutoArray(AutoMap aMap) { + this.arr = (V[]) java.lang.reflect.Array.newInstance(aMap.getMapType(), aMap.size()); + this.length = aMap.size(); + } + private V get(int i) { + return arr[i]; + } + private void set(int i, V e) { + arr[i] = e; + } + protected V[] getGenericArray() { + return arr; + } + @Override + public String toString() { + return Arrays.toString(arr); + } + } } -- cgit From 1f48c6da89afb649c3b73674cb3c0664fa322a09 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Thu, 14 Feb 2019 20:03:07 +0000 Subject: + Added recipes for the Large Arc Furnace and Casings. - Disabled power output on Alternative Fusion. % Made the AutoMap implement Collection and Queue. $ Fixed energy buffers return bad inventory name. --- src/Java/gtPlusPlus/api/objects/data/AutoMap.java | 139 ++++++++++++++++------ 1 file changed, 103 insertions(+), 36 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index d5e016bbf8..4663229514 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -3,7 +3,7 @@ package gtPlusPlus.api.objects.data; import java.io.Serializable; import java.util.*; -public class AutoMap implements Iterable, Cloneable, Serializable { +public class AutoMap implements Iterable, Cloneable, Serializable, Collection, Queue { /** * The Internal Map @@ -47,8 +47,8 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return set(object); } - public synchronized V add(V object){ - return set(object); + public synchronized boolean add(V object){ + return set(object) != null; } public synchronized V set(V object){ @@ -87,62 +87,129 @@ public class AutoMap implements Iterable, Cloneable, Serializable { return mInternalMap.isEmpty(); } - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalNameMap.clear(); - return true; - } - - private final Class getMapType() { - Class g = mInternalMap.get(0).getClass(); - return g; + return; } + @SuppressWarnings("unchecked") public synchronized V[] toArray() { - /*Collection col = this.mInternalMap.values(); + Collection col = this.mInternalMap.values(); List abcList = new ArrayList(); for (V g : col) { abcList.add(g); } - return (V[]) abcList.toArray();*/ - return (V[]) new AutoArray(this).getGenericArray(); + return (V[]) abcList.toArray(); + //return (V[]) new AutoArray(this).getGenericArray(); } public synchronized final int getInternalID() { return mInternalID; - } + } - public synchronized final boolean remove(V value) { + public synchronized final boolean remove(Object value) { value.getClass(); if (this.mInternalMap.containsValue(value)) { return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); } return false; - } - - private class AutoArray { - - private final V[] arr; - public final int length; - - public AutoArray(AutoMap aMap) { - this.arr = (V[]) java.lang.reflect.Array.newInstance(aMap.getMapType(), aMap.size()); - this.length = aMap.size(); - } - private V get(int i) { - return arr[i]; - } - private void set(int i, V e) { - arr[i] = e; + } + + @Override + public boolean contains(Object o) { + for (V g : this.mInternalMap.values()) { + if (g.equals(o)) { + return true; + } } - protected V[] getGenericArray() { - return arr; + return false; + } + + @SuppressWarnings("unchecked") + @Override + public V[] toArray(V[] a) { + return (V[]) toArray(); + } + + @Override + public boolean containsAll(Collection c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.contains(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean addAll(Collection c) { + boolean aTrue = true; + for (V g : c) { + if (!this.add(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean removeAll(Collection c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.remove(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean retainAll(Collection c) { + AutoMap aTempAllocation = new AutoMap(); + boolean aTrue = false; + aTempAllocation = this; + aTempAllocation.removeAll(c); + aTrue = this.removeAll(aTempAllocation); + aTempAllocation.clear(); + return aTrue; + } + + @Override + public boolean offer(V e) { + return add(e); + } + + @Override + public V remove() { + V y = this.get(0); + if (remove(y)) + return y; + else + return null; + } + + @Override + public V poll() { + if (this.mInternalMap.isEmpty()) { + return null; } - @Override - public String toString() { - return Arrays.toString(arr); + return remove(); + } + + @Override + public V element() { + if (this.mInternalMap.isEmpty()) { + return null; } + return this.get(0); + } + + @Override + public V peek() { + return element(); } } -- cgit From 27b13101ab9042eacad45f5867c8cfee23cffbe0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 15 Feb 2019 02:49:31 +0000 Subject: $ Made achievement handling safer. $ Fixed GT Assembly Line recipe ASM, again. --- src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java index 73858e8d43..72ec0bc293 100644 --- a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java @@ -151,11 +151,11 @@ public class ReverseAutoMap extends AutoMap { } @Override - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalMapReverseLookup.clear(); - return true; + return; } @Override -- cgit From 0e8070f3eb5149c7223049f93b4df86adb63ea57 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 4 Mar 2019 23:03:46 +0000 Subject: - Removing some logging. $ Fixed Bed Height > 128 not working as intended. $ Fixed IC2 ASM for wrench harvesting. $ Fixed TC4 ASM. $ Fixed Invalid Giant Chicken Texture handling. --- src/Java/gtPlusPlus/api/objects/data/TypeCounter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java b/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java index 3d562bf76e..601a51392f 100644 --- a/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java +++ b/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java @@ -17,7 +17,7 @@ public class TypeCounter implements Set { private final Class mClass; public TypeCounter(Class o) { - Logger.INFO("Created new TypeCounter for "+o.getName()); + Logger.WARNING("Created new TypeCounter for "+o.getName()); mClass = o; } @@ -56,17 +56,17 @@ public class TypeCounter implements Set { InternalTypeCounterObject aValue = mInternalMap.get(aKey); if (aValue == null) { aValue = new InternalTypeCounterObject((V) arg0); - Logger.INFO("Adding new key to map: "+aKey); + Logger.WARNING("Adding new key to map: "+aKey); } aValue.add(); int a = aValue.count(); if (a > mHighestValue) { mHighestValue = a; mHighestValueKey = aKey; - Logger.INFO("New Highest Count - "+aKey+":"+a); + Logger.WARNING("New Highest Count - "+aKey+":"+a); } mInternalMap.put(aKey, aValue); - Logger.INFO(aKey+":"+a); + Logger.WARNING(aKey+":"+a); return true; } -- cgit From 40644c9f57ce7a931d9d955529583cc1cba623a5 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 8 Mar 2019 04:56:49 +0000 Subject: + Added ItemPackage.java. Allows better load control of item/recipe groupings. $ Improved load handling of Chemistry Packages. $ Fixed bug in StringUtils.java. --- .../api/objects/minecraft/ItemPackage.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java new file mode 100644 index 0000000000..e725d250cc --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -0,0 +1,41 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.handler.COMPAT_HANDLER; + +public abstract class ItemPackage implements RunnableWithInfo { + + public ItemPackage() { + // Register for late run + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + init(); + } + + @Override + public final void run() { + generateRecipes(); + } + + @Override + public final String getInfoData() { + return errorMessage(); + } + + public abstract String errorMessage(); + + public abstract boolean generateRecipes(); + + private final void init() { + items(); + blocks(); + fluids(); + } + + public abstract void items(); + + public abstract void blocks(); + + public abstract void fluids(); + + +} -- cgit From dbe1827984f9dd1e87d500882c541181bdaeb542 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 12 Mar 2019 05:08:33 +0000 Subject: + Added framework for additional Oil chemistry in future updates. + Added additional processes for obtaining Kerosene. % Mild rebalance to GT++ Rocket Fuels. % Swapped Coal by-products (Coal Tar, Coal Tar Oil and Sulfuric Coal Tar Oil) from Gas Turbine fuel to Semifluid fuel. % Allowed ItemPackages to register themselves to the onLoadComplete() event. $ Fixed GT++ Rocket Fuels being unusable in Rocket Engines. $ Fixed Tooltip on GC Fuel loader when the GC-ASM is not active. --- .../gtPlusPlus/api/objects/minecraft/ItemPackage.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java index e725d250cc..fa85f23cf3 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -1,13 +1,21 @@ package gtPlusPlus.api.objects.minecraft; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.core.handler.COMPAT_HANDLER; public abstract class ItemPackage implements RunnableWithInfo { public ItemPackage() { + this(false); + } + + public ItemPackage(boolean hasExtraLateRun) { // Register for late run - COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + if (hasExtraLateRun) { + COMPAT_HANDLER.mObjectsToRunInOnLoadComplete.put(this); + } init(); } @@ -37,5 +45,14 @@ public abstract class ItemPackage implements RunnableWithInfo { public abstract void fluids(); + /** + * Override this to handle GT Recipe map manipulation after they're Baked. + * @param event - the {@link FMLLoadCompleteEvent}. + * @return - Did we do anything? + */ + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + return false; + }; + } -- cgit From 94d7c2c8af9f13d70ab115f377e85502c3a96f7c Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 13 Mar 2019 11:11:52 +0000 Subject: + Added the Waste Collector. + Added new constructor to BlockPos.java. + Added some time handling functions to Utils.java. - Logging. --- .../gtPlusPlus/api/objects/minecraft/BlockPos.java | 5 + .../api/objects/minecraft/ThreadPooCollector.java | 111 +++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java index 8c940baba3..9ab0f2eefb 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -6,6 +6,7 @@ import java.util.Set; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import gtPlusPlus.api.objects.data.AutoMap; @@ -48,6 +49,10 @@ public class BlockPos implements Serializable{ public BlockPos(IGregTechTileEntity b) { this (b.getXCoord(), b.getYCoord(), b.getZCoord(), b.getWorld()); } + + public BlockPos(TileEntity b) { + this (b.xCoord, b.yCoord, b.zCoord, b.getWorldObj()); + } public String getLocationString() { return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"][Dim: "+this.dim+"]"; diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java new file mode 100644 index 0000000000..a5f466b19f --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java @@ -0,0 +1,111 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class ThreadPooCollector extends Thread { + + public boolean canRun = true; + public boolean isRunning = false; + + private static final long INIT_TIME; + private static long internalTickCounter = 0; + + private static final ThreadPooCollector mThread; + private static final HashMap> mPooCollectors = new LinkedHashMap>(); + + + static { + mThread = new ThreadPooCollector(); + INIT_TIME = (System.currentTimeMillis()); + } + + public ThreadPooCollector() { + setName("gtpp.handler.poop"); + run(); + } + + public static ThreadPooCollector getInstance() { + return mThread; + } + + public static void addTask(TileEntityPooCollector aTile) { + BlockPos aTempPos = new BlockPos(aTile); + mPooCollectors.put(aTempPos.getUniqueIdentifier(), new Pair(aTempPos, aTile)); + } + + public static void stopThread() { + mThread.canRun = false; + } + + + @Override + public void run() { + + if (!isRunning) { + isRunning = true; + } + else { + return; + } + + while (canRun) { + if (mPooCollectors.isEmpty() || GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + continue; + } else { + internalTickCounter = Utils.getTicksFromSeconds( + Utils.getSecondsFromMillis(Utils.getMillisSince(INIT_TIME, System.currentTimeMillis()))); + if (internalTickCounter % 100 == 0) { + for (Pair pair : mPooCollectors.values()) { + if (pair != null) { + BlockPos p = pair.getKey(); + if (p != null) { + if (p.world != null) { + World w = p.world; + if (w == null) { + continue; + } + Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); + if (c != null) { + if (c.isChunkLoaded) { + int startX = p.xPos - 2; + int startY = p.yPos; + int startZ = p.zPos - 2; + int endX = p.xPos + 3; + int endY = p.yPos + 5; + int endZ = p.zPos + 3; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, + endX, endY, endZ); + if (box != null) { + @SuppressWarnings("unchecked") + List animals = w.getEntitiesWithinAABB(EntityAnimal.class, box); + if (animals != null && !animals.isEmpty()) { + pair.getValue().onPostTick(animals); + } + } else { + continue; + } + } + } + } + } + } + } + } + } + } + } + + +} -- cgit From d8da94ede0ae3df9ea5c47145043c09874bffebe Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 13 Mar 2019 12:30:37 +0000 Subject: % Mild improvements to BTF_Inventory.java. % Finished Agricultural Sewer. --- .../api/objects/minecraft/BTF_Inventory.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 25968f1908..43a325f190 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -3,6 +3,7 @@ package gtPlusPlus.api.objects.minecraft; import java.util.ArrayList; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -160,5 +161,47 @@ public class BTF_Inventory implements ISidedInventory{ return this.mTile != null ? mTile.getInventoryName() : ""; } + public boolean isFull() { + for (int s=0;s Date: Thu, 14 Mar 2019 20:26:48 +0000 Subject: + Added more Carbon based chemicals for future use. % Mild tweaks to some Carbon based chemistry. % Updated en_US.lang. $ Fixed NPE in BTF_Inventory.java. --- .../api/objects/minecraft/BTF_Inventory.java | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'src/Java/gtPlusPlus/api') diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 43a325f190..04ce0dff19 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -3,8 +3,8 @@ package gtPlusPlus.api.objects.minecraft; import java.util.ArrayList; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.data.ArrayUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -20,6 +20,7 @@ public class BTF_Inventory implements ISidedInventory{ } public ItemStack[] getRealInventory() { + purgeNulls(); return this.mInventory; } @@ -140,6 +141,7 @@ public class BTF_Inventory implements ISidedInventory{ public void markDirty() { if (mTile != null) { + purgeNulls(); mTile.markDirty(); } } @@ -184,24 +186,43 @@ public class BTF_Inventory implements ISidedInventory{ return true; } - public boolean addItemStack(ItemStack aInput) { - if (isEmpty() || !isFull()) { + public boolean addItemStack(ItemStack aInput) { + if (aInput != null & (isEmpty() || !isFull())) { for (int s = 0; s < this.getSizeInventory(); s++) { - ItemStack slot = mInventory[s]; - if (slot == null - || (GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getMaxStackSize())) { - if (slot == null) { - slot = aInput.copy(); - } else { - slot.stackSize++; + if (mInventory != null && mInventory[s] != null) { + ItemStack slot = mInventory[s]; + if (slot == null || (slot != null && GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getItem().getItemStackLimit(slot))) { + if (slot == null) { + slot = aInput.copy(); + } else { + slot.stackSize++; + } + this.setInventorySlotContents(s, slot); + return true; } - this.setInventorySlotContents(s, slot); - return true; } } } return false; } + + public final void purgeNulls() { + ItemStack[] aTemp = ArrayUtils.removeNulls(this.mInventory); + for (int g=0;g