use of gregapi.code.HashSetNoNulls in project gregtech6 by GregTech6.
the class Loader_Recipes_Replace method run.
@SuppressWarnings("rawtypes")
@Override
public void run() {
OUT.println("GT_Mod: Replacing Vanilla alike Recipes.");
NON_REPLACEABLE.add(ST.make(ToolsGT.sMetaTool, 1, W));
NON_REPLACEABLE.add(ST.make(Items.bow, 1, W));
NON_REPLACEABLE.add(ST.make(Items.fishing_rod, 1, W));
NON_REPLACEABLE.add(IL.IC2_ForgeHammer.getWithMeta(1, W));
NON_REPLACEABLE.add(IL.IC2_WireCutter.getWithMeta(1, W));
NON_REPLACEABLE.add(ST.mkic("painter", 1, W));
NON_REPLACEABLE.add(ST.mkic("blackPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("redPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("greenPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("brownPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("bluePainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("purplePainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("cyanPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("lightGreyPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("darkGreyPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("pinkPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("limePainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("yellowPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("cloudPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("magentaPainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("orangePainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("whitePainter", 1, W));
NON_REPLACEABLE.add(ST.mkic("cfPack", 1, W));
NON_REPLACEABLE.add(ST.mkic("jetpack", 1, W));
NON_REPLACEABLE.add(ST.mkic("treetap", 1, W));
NON_REPLACEABLE.add(ST.mkic("weedEx", 1, W));
NON_REPLACEABLE.add(ST.mkic("staticBoots", 1, W));
NON_REPLACEABLE.add(ST.mkic("compositeArmor", 1, W));
NON_REPLACEABLE.add(ST.mkic("hazmatHelmet", 1, W));
NON_REPLACEABLE.add(ST.mkic("hazmatChestplate", 1, W));
NON_REPLACEABLE.add(ST.mkic("hazmatLeggings", 1, W));
NON_REPLACEABLE.add(ST.mkic("hazmatBoots", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.disk", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.blade", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "part.turbine.rotor", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.diamond", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.steel", 1, W));
NON_REPLACEABLE.add(ST.make(MD.RC, "borehead.iron", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.plateNaga", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.legsNaga", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticHelm", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticPlate", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticLegs", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.arcticBoots", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiHelm", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiPlate", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiLegs", 1, W));
NON_REPLACEABLE.add(ST.make(MD.TF, "item.yetiBoots", 1, W));
NON_REPLACEABLE.add(ST.make(MD.AE, "item.ToolCertusQuartzCuttingKnife", 1, W));
NON_REPLACEABLE.add(ST.make(MD.AE, "item.ToolNetherQuartzCuttingKnife", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristHelmet", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristChest", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristLegs", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "apiaristBoots", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "frameUntreated", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "frameImpregnated", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "frameProven", 1, W));
NON_REPLACEABLE.add(ST.make(MD.FR, "waxCast", 1, W));
NON_REPLACEABLE.add(ST.make(MD.GC, "item.sensorGlasses", 1, W));
NON_REPLACEABLE.add(ST.make(MD.NC, "ItemToolThermometer", 1, W));
List<ItemStack> tStickList = OreDictionary.getOres(OD.stickWood.toString());
HashSetNoNulls<Object> tAlreadyScannedItems = new HashSetNoNulls<>();
ArrayListNoNulls<RecipeReplacement> tList = new ArrayListNoNulls<>();
List<IRecipe> tRecipeList = CR.list();
boolean tUseProgressBar = UT.LoadingBar.start("Looking up Recipes", tRecipeList.size());
for (int l = 0; l < tRecipeList.size(); l++) {
IRecipe tRecipe = tRecipeList.get(l);
if (tUseProgressBar)
UT.LoadingBar.step("");
ItemStack aOutput = tRecipe.getRecipeOutput();
if (ST.invalid(aOutput))
continue;
if (aOutput.stackSize != 1)
continue;
if (aOutput.getMaxDamage() <= 0)
continue;
if (aOutput.getMaxStackSize() != 1)
continue;
if (tRecipe instanceof ShapelessRecipes)
continue;
if (tRecipe instanceof ShapelessOreRecipe)
continue;
if (tRecipe instanceof ICraftingRecipeGT)
continue;
if (ST.block(aOutput) != NB)
continue;
if (COMPAT_IC2 != null && COMPAT_IC2.isReactorItem(aOutput))
continue;
if (COMPAT_EU_ITEM != null && COMPAT_EU_ITEM.is(aOutput))
continue;
if (NON_REPLACEABLE.contains(aOutput, T))
continue;
if (sNonReplaceableNames.contains(aOutput.getUnlocalizedName()))
continue;
Object[] tRecipeInputs = null;
if (tRecipe instanceof ShapedOreRecipe) {
tRecipeInputs = ((ShapedOreRecipe) tRecipe).getInput();
} else if (tRecipe instanceof ShapedRecipes) {
tRecipeInputs = ((ShapedRecipes) tRecipe).recipeItems;
} else if (MD.IC2.mLoaded && tRecipe instanceof ic2.core.AdvRecipe) {
tRecipeInputs = ((ic2.core.AdvRecipe) tRecipe).input;
}
if (tRecipeInputs == null || tRecipeInputs.length <= 0)
continue;
OreDictPrefix tPrefix = null;
OreDictMaterial tMat = null, tRod = null;
boolean temp = T;
tAlreadyScannedItems.clear();
for (int i = 0; i < tRecipeInputs.length; i++) {
Object tObject = tRecipeInputs[i];
if (!tAlreadyScannedItems.add(tObject))
continue;
OreDictItemData tData = null;
if (tObject instanceof ItemStack) {
if (IL.Stick.equal(tObject, T, T)) {
tRod = ANY.Wood;
continue;
}
tData = OM.anyassociation((ItemStack) tObject);
} else if (MD.IC2.mLoaded && tObject instanceof ic2.api.recipe.RecipeInputItemStack) {
if (IL.Stick.equal(((ic2.api.recipe.RecipeInputItemStack) tObject).input, T, T)) {
tRod = ANY.Wood;
continue;
}
tData = OM.anyassociation(((ic2.api.recipe.RecipeInputItemStack) tObject).input);
} else if (MD.IC2.mLoaded && tObject instanceof ic2.api.recipe.RecipeInputOreDict) {
if (OD.stickWood.toString().equals(((ic2.api.recipe.RecipeInputOreDict) tObject).input)) {
tRod = ANY.Wood;
continue;
}
if (OD.stickAnyWood.toString().equals(((ic2.api.recipe.RecipeInputOreDict) tObject).input)) {
tRod = ANY.Wood;
continue;
}
tData = OM.data(((ic2.api.recipe.RecipeInputOreDict) tObject).input);
} else if (tObject instanceof List) {
if (tStickList == tObject) {
tRod = ANY.Wood;
continue;
}
switch(((List) tObject).size()) {
case 0:
temp = F;
break;
case 1:
if (((List) tObject).get(0) instanceof ItemStack) {
tData = OM.anyassociation((ItemStack) (((List) tObject).get(0)));
} else {
temp = F;
}
break;
default:
for (Object tContent : ((List) tObject)) if (tContent instanceof ItemStack) {
if (tData == null) {
tData = OM.anyassociation((ItemStack) tContent);
if (tData == null || !tData.hasValidPrefixMaterialData()) {
temp = F;
break;
}
} else {
OreDictItemData tAssociation = OM.anyassociation((ItemStack) tContent);
if (tAssociation == null || tAssociation.mPrefix != tData.mPrefix || tAssociation.mMaterial.mMaterial != tData.mMaterial.mMaterial) {
temp = F;
break;
}
}
} else {
temp = F;
break;
}
break;
}
if (!temp)
break;
} else {
temp = F;
break;
}
if (tData == null) {
temp = F;
break;
}
if (tData.mPrefix == OP.stick) {
if (tRod != null && tRod != tData.mMaterial.mMaterial) {
temp = F;
break;
}
tRod = tData.mMaterial.mMaterial;
} else {
if (tMat != null && tMat != tData.mMaterial.mMaterial) {
temp = F;
break;
}
if (tData.mPrefix != OP.ingot && tData.mPrefix != OP.gem) {
temp = F;
break;
}
tMat = tData.mMaterial.mMaterial;
tPrefix = tData.mPrefix;
}
}
if (temp)
tList.add(new RecipeReplacement(tRecipe, tPrefix, tMat, tRod));
}
if (tUseProgressBar)
UT.LoadingBar.finish();
tUseProgressBar = UT.LoadingBar.start("Replacing Recipes", tList.size());
for (RecipeReplacement aRecipe : tList) {
if (tUseProgressBar)
UT.LoadingBar.step(aRecipe.mMat);
if (aRecipe.mPrefix == null || aRecipe.mMat == null)
continue;
ItemStack tMat = aRecipe.mPrefix.mat(aRecipe.mMat, 1);
if (tMat == null)
continue;
INGT.func_150996_a(tMat.getItem());
INGT.stackSize = 1;
ST.meta_(INGT, ST.meta_(tMat));
RecipeReplacer[] tReplacer = sRecipesMat;
if (aRecipe.mRod != null) {
ItemStack tRod = (aRecipe.mRod == ANY.Wood ? IL.Stick.get(1) : OP.stick.mat(aRecipe.mRod, 1));
if (tRod == null)
continue;
STCK.func_150996_a(tRod.getItem());
STCK.stackSize = 1;
ST.meta_(STCK, ST.meta_(tRod));
tReplacer = sRecipesRod;
}
for (RecipeReplacer aReplacer : tReplacer) {
ItemStack tCrafted = getRecipeOutput(aRecipe.mRecipe, aReplacer.mRecipe);
if (tCrafted == null)
continue;
int tMatCount = 0, tRodCount = 0;
for (ItemStack tStack : aReplacer.mRecipe) if (tStack == INGT)
tMatCount++;
else if (tStack == STCK)
tRodCount++;
OM.dat2(tCrafted, aRecipe.mMat, aRecipe.mPrefix.mAmount * tMatCount, OM.stack(aRecipe.mRod, OP.stick.mAmount * tRodCount));
if (aRecipe.mPrefix != OP.ingot)
continue;
ItemStack tPlate = OP.plate.mat(aRecipe.mMat, 1);
if (tPlate == null || aReplacer.mShape == null || aReplacer.mShape.length <= 0)
continue;
if (!ConfigsGT.RECIPES.get(ConfigCategories.Recipes.recipereplacements, aRecipe.mMat + "." + aReplacer.mName, T))
continue;
if (!tRecipeList.remove(aRecipe.mRecipe))
continue;
Object tNamePlate = OreDictionary.getOres(OP.plate.dat(aRecipe.mMat).toString()).isEmpty() ? OP.ingot.dat(aRecipe.mMat) : OP.plate.dat(aRecipe.mMat), tNameCurve = OreDictionary.getOres(OP.plateCurved.dat(aRecipe.mMat).toString()).isEmpty() ? tNamePlate : OP.plateCurved.dat(aRecipe.mMat);
switch(aReplacer.mShape.length) {
case 1:
CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
break;
case 2:
CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], aReplacer.mShape[1], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
break;
default:
CR.shaped(tCrafted, CR.DEF, new Object[] { aReplacer.mShape[0], aReplacer.mShape[1], aReplacer.mShape[2], PLT.charAt(0), tNamePlate, CRV.charAt(0), tNameCurve, ROD.charAt(0), OP.stick.dat(aRecipe.mRod == null ? aRecipe.mMat : aRecipe.mRod), NGT.charAt(0), OP.ingot.dat(aRecipe.mMat) });
break;
}
}
}
if (tUseProgressBar)
UT.LoadingBar.finish();
}
use of gregapi.code.HashSetNoNulls in project gregtech6 by GregTech6.
the class MultiTileEntityCrucible method onServerTickPost.
@SuppressWarnings("unchecked")
@Override
public void onServerTickPost(boolean aFirst) {
long tTemperature = WD.envTemp(worldObj, xCoord, yCoord, zCoord), tHash = mContent.hashCode();
if (!checkStructure(F)) {
if (SERVER_TIME % 10 == 0) {
if (mTemperature > tTemperature)
mTemperature--;
if (mTemperature < tTemperature)
mTemperature++;
}
mTemperature = Math.max(mTemperature, Math.min(200, tTemperature));
return;
}
if (!slotHas(0))
slot(0, WD.suck(worldObj, xCoord - 0.5, yCoord + PX_P[2], zCoord - 0.5, 2, 3, 2));
ItemStack tStack = slot(0);
if (ST.valid(tStack)) {
OreDictItemData tData = OM.anydata_(tStack);
if (tData == null) {
slotTrash(0);
UT.Sounds.send(SFX.MC_FIZZ, this);
} else if (tData.mPrefix == null) {
List<OreDictMaterialStack> tList = new ArrayListNoNulls<>();
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) if (tMaterial.mAmount > 0)
tList.add(tMaterial.clone());
if (addMaterialStacks(tList, tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix == OP.oreRaw) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier)), tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix == OP.blockRaw) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier * 9)), tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix == OP.crateGtRaw) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier * 16)), tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix == OP.crateGt64Raw) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier * 64)), tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix.contains(TD.Prefix.STANDARD_ORE)) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier)), tTemperature))
decrStackSize(0, 1);
} else if (tData.mPrefix.contains(TD.Prefix.DENSE_ORE)) {
if (addMaterialStacks(Arrays.asList(OM.stack(tData.mMaterial.mMaterial.mTargetCrushing.mMaterial, tData.mMaterial.mMaterial.mTargetCrushing.mAmount * tData.mMaterial.mMaterial.mOreMultiplier * 2)), tTemperature))
decrStackSize(0, 1);
} else {
List<OreDictMaterialStack> tList = new ArrayListNoNulls<>();
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) if (tMaterial.mAmount > 0)
tList.add(tMaterial.clone());
if (addMaterialStacks(tList, tTemperature))
decrStackSize(0, 1);
}
}
Set<OreDictMaterial> tAlreadyCheckedAlloys = new HashSetNoNulls<>();
OreDictMaterial tPreferredAlloy = null;
IOreDictConfigurationComponent tPreferredRecipe = null;
long tMaxConversions = 0;
boolean tNewContent = (tHash != mContent.hashCode());
for (OreDictMaterialStack tMaterial : mContent) {
if (mTemperature >= tMaterial.mMaterial.mMeltingPoint) {
for (OreDictMaterial tAlloy : tMaterial.mMaterial.mAlloyComponentReferences) if (tAlreadyCheckedAlloys.add(tAlloy) && mTemperature >= tAlloy.mMeltingPoint) {
for (IOreDictConfigurationComponent tAlloyRecipe : tAlloy.mAlloyCreationRecipes) {
List<OreDictMaterialStack> tNeededStuff = new ArrayListNoNulls<>();
for (OreDictMaterialStack tComponent : tAlloyRecipe.getUndividedComponents()) {
tNeededStuff.add(OM.stack(tComponent.mMaterial, Math.max(1, tComponent.mAmount / U)));
}
if (!tNeededStuff.isEmpty()) {
int tNonMolten = 0;
boolean tBreak = F;
long tConversions = Long.MAX_VALUE;
for (OreDictMaterialStack tComponent : tNeededStuff) {
if (mTemperature < tComponent.mMaterial.mMeltingPoint)
tNonMolten++;
tBreak = T;
for (OreDictMaterialStack tContent : mContent) {
if (tContent.mMaterial == tComponent.mMaterial) {
tConversions = Math.min(tConversions, tContent.mAmount / tComponent.mAmount);
tBreak = F;
break;
}
}
if (tBreak)
break;
}
if (!tBreak && tNonMolten <= 1 && tConversions > 0) {
if (tPreferredAlloy == null || tPreferredRecipe == null || tConversions * tAlloyRecipe.getCommonDivider() > tMaxConversions * tPreferredRecipe.getCommonDivider()) {
tMaxConversions = tConversions;
tPreferredRecipe = tAlloyRecipe;
tPreferredAlloy = tAlloy;
}
}
}
}
}
}
}
if (tPreferredAlloy != null && tPreferredRecipe != null) {
for (OreDictMaterialStack tComponent : tPreferredRecipe.getUndividedComponents()) {
for (OreDictMaterialStack tContent : mContent) {
if (tContent.mMaterial == tComponent.mMaterial) {
tContent.mAmount -= UT.Code.units_(tMaxConversions, U, tComponent.mAmount, T);
break;
}
}
}
OM.stack(tPreferredAlloy, tPreferredRecipe.getCommonDivider() * tMaxConversions).addToList(mContent);
}
List<OreDictMaterialStack> tToBeAdded = new ArrayListNoNulls<>();
for (int i = 0; i < mContent.size(); i++) {
OreDictMaterialStack tMaterial = mContent.get(i);
if (tMaterial == null || tMaterial.mMaterial == MT.NULL || tMaterial.mMaterial == MT.Air || tMaterial.mAmount <= 0) {
GarbageGT.trash(mContent.remove(i--));
} else if (tMaterial.mMaterial.mGramPerCubicCentimeter <= WEIGHT_AIR_G_PER_CUBIC_CENTIMETER) {
GarbageGT.trash(mContent.remove(i--));
UT.Sounds.send(SFX.MC_FIZZ, this);
} else if (mTemperature >= tMaterial.mMaterial.mBoilingPoint || (mTemperature > C + 40 && tMaterial.mMaterial.contains(TD.Properties.FLAMMABLE) && !tMaterial.mMaterial.containsAny(TD.Properties.UNBURNABLE, TD.Processing.MELTING))) {
GarbageGT.trash(mContent.remove(i--));
UT.Sounds.send(SFX.MC_FIZZ, this);
if (tMaterial.mMaterial.mBoilingPoint >= 320)
try {
for (EntityLivingBase tLiving : (List<EntityLivingBase>) worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box(-GAS_RANGE, -1, -GAS_RANGE, GAS_RANGE + 1, GAS_RANGE + 1, GAS_RANGE + 1))) UT.Entities.applyTemperatureDamage(tLiving, tMaterial.mMaterial.mBoilingPoint, 4);
} catch (Throwable e) {
e.printStackTrace(ERR);
}
if (tMaterial.mMaterial.mBoilingPoint >= 2000)
for (int j = 0, k = Math.max(1, UT.Code.bindInt((9 * tMaterial.mAmount) / U)); j < k; j++) WD.fire(worldObj, xCoord - FLAME_RANGE + rng(2 * FLAME_RANGE + 1), yCoord - 1 + rng(2 + FLAME_RANGE), zCoord - FLAME_RANGE + rng(2 * FLAME_RANGE + 1), rng(3) != 0);
if (tMaterial.mMaterial.contains(TD.Properties.EXPLOSIVE))
explode(UT.Code.scale(tMaterial.mAmount, MAX_AMOUNT, 8, F));
return;
} else if (!mAcidProof && tMaterial.mMaterial.contains(TD.Properties.ACID)) {
GarbageGT.trash(mContent.remove(i--));
UT.Sounds.send(SFX.MC_FIZZ, this);
setToAir();
return;
} else if (mTemperature >= tMaterial.mMaterial.mMeltingPoint && (oTemperature < tMaterial.mMaterial.mMeltingPoint || tNewContent)) {
mContent.remove(i--);
OM.stack(tMaterial.mMaterial.mTargetSmelting.mMaterial, UT.Code.units_(tMaterial.mAmount, U, tMaterial.mMaterial.mTargetSmelting.mAmount, F)).addToList(tToBeAdded);
} else if (mTemperature < tMaterial.mMaterial.mMeltingPoint && (oTemperature >= tMaterial.mMaterial.mMeltingPoint || tNewContent)) {
mContent.remove(i--);
OM.stack(tMaterial.mMaterial.mTargetSolidifying.mMaterial, UT.Code.units_(tMaterial.mAmount, U, tMaterial.mMaterial.mTargetSolidifying.mAmount, F)).addToList(tToBeAdded);
}
}
for (int i = 0; i < tToBeAdded.size(); i++) {
OreDictMaterialStack tMaterial = tToBeAdded.get(i);
if (tMaterial == null || tMaterial.mMaterial == MT.NULL || tMaterial.mMaterial == MT.Air || tMaterial.mAmount <= 0) {
GarbageGT.trash(tToBeAdded.remove(i--));
} else {
tMaterial.addToList(mContent);
}
}
double tWeight = mMaterial.getWeight(U * 100);
long tTotal = 0;
OreDictMaterialStack tLightest = null;
for (OreDictMaterialStack tMaterial : mContent) {
if (tLightest == null || tMaterial.mMaterial.mGramPerCubicCentimeter < tLightest.mMaterial.mGramPerCubicCentimeter)
tLightest = tMaterial;
tWeight += tMaterial.weight();
tTotal += tMaterial.mAmount;
}
oTemperature = mTemperature;
short tDisplayedFluid = mDisplayedFluid, tDisplayedHeight = mDisplayedHeight;
mDisplayedHeight = (byte) UT.Code.scale(tTotal, MAX_AMOUNT, 255, F);
mDisplayedFluid = (tLightest == null || tLightest.mMaterial.mMeltingPoint > mTemperature ? -1 : tLightest.mMaterial.mID);
if (mDisplayedFluid != tDisplayedFluid || mDisplayedHeight != tDisplayedHeight)
updateClientData();
long tRequiredEnergy = 1 + (long) (tWeight / KG_PER_ENERGY), tConversions = mEnergy / tRequiredEnergy;
if (mCooldown > 0)
mCooldown--;
if (tConversions != 0) {
mEnergy -= tConversions * tRequiredEnergy;
mTemperature += tConversions;
mCooldown = 100;
}
if (mCooldown <= 0) {
mCooldown = 10;
if (mTemperature > tTemperature)
mTemperature--;
if (mTemperature < tTemperature)
mTemperature++;
}
mTemperature = Math.max(mTemperature, Math.min(200, tTemperature));
if (mTemperature > getTemperatureMax(SIDE_INSIDE)) {
UT.Sounds.send(SFX.MC_FIZZ, this);
GarbageGT.trash(mContent);
if (mTemperature >= 320)
try {
for (EntityLivingBase tLiving : (List<EntityLivingBase>) worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box(-GAS_RANGE, -1, -GAS_RANGE, GAS_RANGE + 1, GAS_RANGE + 1, GAS_RANGE + 1))) UT.Entities.applyTemperatureDamage(tLiving, mTemperature, 4);
} catch (Throwable e) {
e.printStackTrace(ERR);
}
for (int j = 0, k = UT.Code.bindInt(mTemperature / 25); j < k; j++) WD.fire(worldObj, xCoord - FLAME_RANGE + rng(2 * FLAME_RANGE + 1), yCoord - 1 + rng(2 + FLAME_RANGE), zCoord - FLAME_RANGE + rng(2 * FLAME_RANGE + 1), rng(3) != 0);
for (int i = -1; i < 2; i++) for (int j = -1; j < 2; j++) {
worldObj.setBlock(xCoord + i, yCoord, zCoord + j, Blocks.flowing_lava, 1, 3);
worldObj.setBlock(xCoord + i, yCoord + 1, zCoord + j, Blocks.flowing_lava, 1, 3);
worldObj.setBlock(xCoord + i, yCoord + 2, zCoord + j, Blocks.flowing_lava, 1, 3);
}
return;
}
if (mMeltDown != (mTemperature + 100 > getTemperatureMax(SIDE_ANY))) {
mMeltDown = !mMeltDown;
updateClientData();
}
}
use of gregapi.code.HashSetNoNulls in project gregtech6 by GregTech6.
the class MultiTileEntityLogisticsCore method onServerTickPre.
@Override
@SuppressWarnings("unchecked")
public void onServerTickPre(boolean aFirst) {
// Sync up with other Stuff that happens to check for visual Updates every 20 Ticks to reduce Lag.
if (SYNC_SECOND) {
int tCPU_Logic = oCPU_Logic, tCPU_Control = oCPU_Control, tCPU_Storage = oCPU_Storage, tCPU_Conversion = oCPU_Conversion;
oCPU_Logic = 0;
oCPU_Control = 0;
oCPU_Storage = 0;
oCPU_Conversion = 0;
if (checkStructure(F) && mEnergy >= 128L + mCPU_Logic * 64L * mCPU_Conversion) {
int tX = getOffsetXN(mFacing, 2), tY = getOffsetYN(mFacing, 2), tZ = getOffsetZN(mFacing, 2);
ItemStackSet<ItemStackContainer> tFilteredFor = new ItemStackSet<>();
final List<LogisticsData> tStackImportsGeneric = new ArrayListNoNulls<>(), tStackImportsSemi = new ArrayListNoNulls<>(), tStackImportsFiltered = new ArrayListNoNulls<>(), tStackExportsGeneric = new ArrayListNoNulls<>(), tStackExportsSemi = new ArrayListNoNulls<>(), tStackExportsFiltered = new ArrayListNoNulls<>(), tStackStorageGeneric = new ArrayListNoNulls<>(), tStackStorageSemi = new ArrayListNoNulls<>(), tStackStorageFiltered = new ArrayListNoNulls<>(), tStackDumps = new ArrayListNoNulls<>(), tFluidImportsGeneric = new ArrayListNoNulls<>(), tFluidImportsSemi = new ArrayListNoNulls<>(), tFluidImportsFiltered = new ArrayListNoNulls<>(), tFluidExportsGeneric = new ArrayListNoNulls<>(), tFluidExportsSemi = new ArrayListNoNulls<>(), tFluidExportsFiltered = new ArrayListNoNulls<>(), tFluidStorageGeneric = new ArrayListNoNulls<>(), tFluidStorageSemi = new ArrayListNoNulls<>(), tFluidStorageFiltered = new ArrayListNoNulls<>(), tExports1[][] = new List[][] { { tFluidExportsFiltered, tStackExportsFiltered }, { tFluidExportsSemi, tStackExportsSemi }, { tFluidExportsGeneric, tStackExportsGeneric }, { tFluidStorageFiltered, tStackStorageFiltered }, { tFluidStorageSemi, tStackStorageSemi }, { tFluidStorageGeneric, tStackStorageGeneric } }, tExports2[][] = new List[][] { { tFluidExportsFiltered, tStackExportsFiltered }, { tFluidExportsSemi, tStackExportsSemi }, { tFluidExportsGeneric, tStackExportsGeneric } }, tImports1[][] = new List[][] { { tFluidImportsGeneric, tStackImportsGeneric }, { tFluidImportsSemi, tStackImportsSemi }, { tFluidImportsFiltered, tStackImportsFiltered } }, tImports2[][] = new List[][] { { tFluidStorageGeneric, tStackStorageGeneric }, { tFluidStorageSemi, tStackStorageSemi }, { tFluidStorageFiltered, tStackStorageFiltered } };
Set<ITileEntityLogistics> tScanning = new HashSetNoNulls<>(), tScanningNext = new HashSetNoNulls<>();
Set<TileEntity> tScanned = new HashSetNoNulls<>();
for (int i = -2; i <= 2; i++) for (int j = -2; j <= 2; j++) for (int k = -2; k <= 2; k++) {
TileEntity tTileEntity = WD.te(worldObj, tX + i, tY + j, tZ + k, T);
if (tScanned.add(tTileEntity) && tTileEntity instanceof ITileEntityLogistics)
tScanning.add((ITileEntityLogistics) tTileEntity);
}
while (!tScanning.isEmpty()) {
for (ITileEntityLogistics tLogistics : tScanning) {
if (tLogistics instanceof ITileEntityLogisticsStorage) {
tFilteredFor.add(((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem());
if (tLogistics instanceof ITileEntityLogisticsSemiFilteredItem) {
tFilteredFor.addAll(((ITileEntityLogisticsSemiFilteredItem) tLogistics).getLogisticsFilter(SIDE_ANY));
}
switch(((ITileEntityLogisticsStorage) tLogistics).getLogisticsPriorityFluid()) {
case 1:
tFluidStorageGeneric.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
break;
case 2:
tFluidStorageSemi.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
break;
case 3:
tFluidStorageFiltered.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterFluid()));
break;
}
switch(((ITileEntityLogisticsStorage) tLogistics).getLogisticsPriorityItem()) {
case 1:
tStackStorageGeneric.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
break;
case 2:
tStackStorageSemi.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
break;
case 3:
tStackStorageFiltered.add(new LogisticsData(new DelegatorTileEntity<>((TileEntity) tLogistics, SIDE_ANY), ((ITileEntityLogisticsStorage) tLogistics).getLogisticsFilterItem()));
break;
}
}
CoverData tCovers = tLogistics.getCoverData();
if (tCovers != null && !tCovers.mStopped) {
for (byte tSide : ALL_SIDES_VALID) if (tCovers.mBehaviours[tSide] instanceof AbstractCoverAttachmentLogistics) {
if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPULogic.INSTANCE) {
tCovers.value(tSide, (short) (tCPU_Logic <= 0 ? 0 : tCPU_Logic >= mCPU_Logic ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Logic - tCPU_Logic) * 14L) / mCPU_Logic))), T);
tCovers.visual(tSide, (short) (tCPU_Logic <= 0 ? 0 : tCPU_Logic >= mCPU_Logic ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Logic - tCPU_Logic) * 9L) / mCPU_Logic))));
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUControl.INSTANCE) {
tCovers.value(tSide, (short) (tCPU_Control <= 0 ? 0 : tCPU_Control >= mCPU_Control ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Control - tCPU_Control) * 14L) / mCPU_Control))), T);
tCovers.visual(tSide, (short) (tCPU_Control <= 0 ? 0 : tCPU_Control >= mCPU_Control ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Control - tCPU_Control) * 9L) / mCPU_Control))));
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUStorage.INSTANCE) {
tCovers.value(tSide, (short) (tCPU_Storage <= 0 ? 0 : tCPU_Storage >= mCPU_Storage ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Storage - tCPU_Storage) * 14L) / mCPU_Storage))), T);
tCovers.visual(tSide, (short) (tCPU_Storage <= 0 ? 0 : tCPU_Storage >= mCPU_Storage ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Storage - tCPU_Storage) * 9L) / mCPU_Storage))));
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsDisplayCPUConversion.INSTANCE) {
tCovers.value(tSide, (short) (tCPU_Conversion <= 0 ? 0 : tCPU_Conversion >= mCPU_Conversion ? 15 : 14 - (int) Math.max(0, Math.min(13, ((mCPU_Conversion - tCPU_Conversion) * 14L) / mCPU_Conversion))), T);
tCovers.visual(tSide, (short) (tCPU_Conversion <= 0 ? 0 : tCPU_Conversion >= mCPU_Conversion ? 10 : 9 - (int) Math.max(0, Math.min(8, ((mCPU_Conversion - tCPU_Conversion) * 9L) / mCPU_Conversion))));
continue;
}
DelegatorTileEntity<TileEntity> tAdjacent = tLogistics.getAdjacentTileEntity(tSide);
if (tAdjacent.mTileEntity instanceof ITileEntityLogistics && ((ITileEntityLogistics) tAdjacent.mTileEntity).canLogistics(SIDE_ANY)) {
// Ignore those ones to reduce likelihood of infinite Loops.
} else {
if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidExport.INSTANCE) {
FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
if (tFluid != null && tFluid.getFluid() != null) {
switch(tCovers.mValues[tSide] & 3) {
case 1:
tFluidExportsGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
case 2:
tFluidExportsSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
default:
tFluidExportsFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
}
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidImport.INSTANCE) {
FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
if (tFluid != null && tFluid.getFluid() != null) {
switch(tCovers.mValues[tSide] & 3) {
case 1:
tFluidImportsGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
case 2:
tFluidImportsSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
default:
tFluidImportsFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
}
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsFluidStorage.INSTANCE) {
FluidStack tFluid = FL.load(tCovers.mNBTs[tSide], "gt.filter.fluid");
if (tFluid != null && tFluid.getFluid() != null) {
switch(tCovers.mValues[tSide] & 3) {
case 1:
tFluidStorageGeneric.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
case 2:
tFluidStorageSemi.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
default:
tFluidStorageFiltered.add(new LogisticsData(tAdjacent, tFluid.getFluid()));
break;
}
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsItemExport.INSTANCE) {
ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
if (ST.valid(tStack)) {
tFilteredFor.add(tStack);
switch(tCovers.mValues[tSide] & 3) {
case 1:
tStackExportsGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
case 2:
tStackExportsSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
default:
tStackExportsFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
}
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsItemImport.INSTANCE) {
ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
if (ST.valid(tStack)) {
tFilteredFor.add(tStack);
switch(tCovers.mValues[tSide] & 3) {
case 1:
tStackImportsGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
case 2:
tStackImportsSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
default:
tStackImportsFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
}
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsItemStorage.INSTANCE) {
ItemStack tStack = ST.load(tCovers.mNBTs[tSide], "gt.filter.item");
if (ST.valid(tStack)) {
tFilteredFor.add(tStack);
switch(tCovers.mValues[tSide] & 3) {
case 1:
tStackStorageGeneric.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
case 2:
tStackStorageSemi.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
default:
tStackStorageFiltered.add(new LogisticsData(tAdjacent, tStack, (tCovers.mValues[tSide] >> 2) & 127));
break;
}
}
continue;
}
LogisticsData tTarget = new LogisticsData(tAdjacent, (tCovers.mValues[tSide] >> 2) & 127);
if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericDump.INSTANCE) {
tStackDumps.add(tTarget);
continue;
}
int tDefault = (tCovers.mValues[tSide] & 3);
boolean aAllowFluids = T;
if (tAdjacent.mTileEntity instanceof ITileEntityLogisticsSemiFilteredItem) {
aAllowFluids = F;
ItemStackSet<ItemStackContainer> tFilter = ((ITileEntityLogisticsSemiFilteredItem) tAdjacent.mTileEntity).getLogisticsFilter(tAdjacent.mSideOfTileEntity);
if (tFilter != null) {
tFilteredFor.addAll(tFilter);
if (tDefault == 0)
tDefault = 2;
}
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericExport.INSTANCE) {
switch(tDefault) {
default:
if (aAllowFluids)
tFluidExportsGeneric.add(tTarget);
tStackExportsGeneric.add(tTarget);
break;
case 2:
if (aAllowFluids)
tFluidExportsSemi.add(tTarget);
tStackExportsSemi.add(tTarget);
break;
case 3:
if (aAllowFluids)
tFluidExportsFiltered.add(tTarget);
tStackExportsFiltered.add(tTarget);
break;
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericImport.INSTANCE) {
switch(tDefault) {
default:
if (aAllowFluids)
tFluidImportsGeneric.add(tTarget);
tStackImportsGeneric.add(tTarget);
break;
case 2:
if (aAllowFluids)
tFluidImportsSemi.add(tTarget);
tStackImportsSemi.add(tTarget);
break;
case 3:
if (aAllowFluids)
tFluidImportsFiltered.add(tTarget);
tStackImportsFiltered.add(tTarget);
break;
}
continue;
}
if (tCovers.mBehaviours[tSide] == CoverLogisticsGenericStorage.INSTANCE) {
switch(tDefault) {
default:
if (aAllowFluids)
tFluidStorageGeneric.add(tTarget);
tStackStorageGeneric.add(tTarget);
break;
case 2:
if (aAllowFluids)
tFluidStorageSemi.add(tTarget);
tStackStorageSemi.add(tTarget);
break;
case 3:
if (aAllowFluids)
tFluidStorageFiltered.add(tTarget);
tStackStorageFiltered.add(tTarget);
break;
}
continue;
}
}
}
}
if (tLogistics.getWorld() == worldObj)
for (byte tSide : ALL_SIDES_VALID) if (tLogistics.canLogistics(tSide)) {
int tMaxDistance = Math.max(Math.abs(tLogistics.getOffsetX(tSide) - tX), Math.max(Math.abs(tLogistics.getOffsetY(tSide) - tY), Math.abs(tLogistics.getOffsetZ(tSide) - tZ)));
if (tMaxDistance <= mCPU_Control + 2) {
oCPU_Control = Math.max(oCPU_Control, tMaxDistance - 2);
DelegatorTileEntity<TileEntity> tAdjacent = tLogistics.getAdjacentTileEntity(tSide);
if (tAdjacent.mTileEntity instanceof ITileEntityLogistics && ((ITileEntityLogistics) tAdjacent.mTileEntity).canLogistics(tAdjacent.mSideOfTileEntity) && tScanned.add(tAdjacent.mTileEntity))
tScanningNext.add((ITileEntityLogistics) tAdjacent.mTileEntity);
}
}
}
tScanning.clear();
tScanning.addAll(tScanningNext);
tScanningNext.clear();
}
while (++oCPU_Logic <= mCPU_Logic) {
boolean tBreak = F;
// Import Export Business
for (List<LogisticsData>[] tExports : tExports1) {
for (List<LogisticsData>[] tImports : tImports1) {
if (moveFluids(tImports[0], tExports[0])) {
tBreak = T;
break;
}
if (moveStacks(tImports[1], tExports[1])) {
tBreak = T;
break;
}
}
if (tBreak)
break;
}
if (tBreak)
continue;
for (List<LogisticsData>[] tExports : tExports2) {
for (List<LogisticsData>[] tImports : tImports2) {
if (moveFluids(tImports[0], tExports[0])) {
tBreak = T;
break;
}
if (moveStacks(tImports[1], tExports[1])) {
tBreak = T;
break;
}
}
if (tBreak)
break;
}
if (tBreak)
continue;
// Defragmentation
if (moveFluids(tFluidStorageGeneric, tFluidStorageFiltered))
continue;
if (moveStacks(tStackStorageGeneric, tStackStorageFiltered))
continue;
if (moveFluids(tFluidStorageGeneric, tFluidStorageSemi))
continue;
if (moveStacks(tStackStorageGeneric, tStackStorageSemi))
continue;
// Dump
for (LogisticsData tImport : tStackStorageGeneric) {
for (LogisticsData tExport : tStackDumps) {
for (int j = 0; j < mCPU_Conversion; j++) {
long tMoved = ST.move(tImport.mTarget, tExport.mTarget, tFilteredFor, F, F, T, F, 64, 1, 64, 1);
if (tMoved > 0) {
oCPU_Conversion = Math.max(oCPU_Conversion, j + 1);
mEnergy -= tMoved;
tBreak = T;
continue;
}
break;
}
if (tBreak)
break;
}
if (tBreak)
break;
}
if (tBreak)
continue;
// Core didn't actually get used.
oCPU_Logic--;
break;
}
}
}
mEnergy -= 20 + mCPU_Logic + mCPU_Control + mCPU_Storage + mCPU_Conversion;
if (mEnergy < 0)
mEnergy = 0;
}
use of gregapi.code.HashSetNoNulls in project gregtech6 by GregTech6.
the class MultiTileEntityLongDistancePipelineItem method scanPipes.
private void scanPipes() {
if (mSender != null && !mSender.isDead() && mSender.mTarget == this)
return;
mIgnoreUnloadedChunks = F;
mTargetPos = getCoords();
mTarget = this;
mSender = null;
Block aBlock = getBlockAtSide(OPOS[mFacing]);
byte aMetaData = getMetaDataAtSide(OPOS[mFacing]);
if (aBlock instanceof BlockLongDistPipe) {
if (((BlockLongDistPipe) aBlock).mTemperatures[aMetaData] >= 0)
return;
HashSetNoNulls<ChunkCoordinates> tNewChecks = new HashSetNoNulls<>(), tOldChecks = new HashSetNoNulls<>(F, getCoords()), tToCheck = new HashSetNoNulls<>(F, getOffsetN(mFacing, 1)), tWires = new HashSetNoNulls<>();
while (!tToCheck.isEmpty()) {
for (ChunkCoordinates aCoords : tToCheck) {
if (getBlock(aCoords) == aBlock && getMetaData(aCoords) == aMetaData) {
tWires.add(aCoords);
ChunkCoordinates tCoords;
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1)))
tNewChecks.add(tCoords);
} else {
TileEntity tTileEntity = getTileEntity(aCoords);
if (tTileEntity != this && tTileEntity instanceof MultiTileEntityLongDistancePipelineItem) {
if (tWires.contains(((MultiTileEntityLongDistancePipelineItem) tTileEntity).getOffset(((MultiTileEntityLongDistancePipelineItem) tTileEntity).mFacing, 1))) {
mTarget = (MultiTileEntityLongDistancePipelineItem) tTileEntity;
mTargetPos = mTarget.getCoords();
mIgnoreUnloadedChunks = T;
return;
}
tOldChecks.remove(aCoords);
}
}
}
tToCheck.clear();
tToCheck.addAll(tNewChecks);
tNewChecks.clear();
}
}
mIgnoreUnloadedChunks = T;
}
use of gregapi.code.HashSetNoNulls in project gregtech6 by GregTech6.
the class MultiTileEntityLongDistanceTransformer method scanWires.
private void scanWires(boolean aBurnWires) {
if (mSender != null && !mSender.isDead() && mSender.mTarget == this)
return;
mIgnoreUnloadedChunks = F;
mTargetPos = getCoords();
mTarget = this;
mSender = null;
mDistance = 0;
mThroughput = 0;
Block aBlock = getBlockAtSide(OPOS[mFacing]);
byte aMetaData = getMetaDataAtSide(OPOS[mFacing]);
if (aBlock instanceof BlockLongDistWire) {
mThroughput = VMAX[((BlockLongDistWire) aBlock).mTiers[aMetaData]];
HashSetNoNulls<ChunkCoordinates> tNewChecks = new HashSetNoNulls<>(), tOldChecks = new HashSetNoNulls<>(F, getCoords()), tToCheck = new HashSetNoNulls<>(F, getOffsetN(mFacing, 1)), tWires = new HashSetNoNulls<>();
mDistance = -1;
while (!tToCheck.isEmpty()) {
mDistance++;
for (ChunkCoordinates aCoords : tToCheck) {
if (getBlock(aCoords) == aBlock && getMetaData(aCoords) == aMetaData) {
tWires.add(aCoords);
ChunkCoordinates tCoords;
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1)))
tNewChecks.add(tCoords);
if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1)))
tNewChecks.add(tCoords);
if (aBurnWires) {
WD.burn(worldObj, aCoords, T, F);
worldObj.setBlock(aCoords.posX, aCoords.posY, aCoords.posZ, Blocks.fire, 0, 3);
}
} else {
TileEntity tTileEntity = getTileEntity(aCoords);
if (tTileEntity != this && tTileEntity instanceof MultiTileEntityLongDistanceTransformer) {
if (tWires.contains(((MultiTileEntityLongDistanceTransformer) tTileEntity).getOffset(((MultiTileEntityLongDistanceTransformer) tTileEntity).mFacing, 1))) {
mTarget = (MultiTileEntityLongDistanceTransformer) tTileEntity;
mTargetPos = mTarget.getCoords();
mIgnoreUnloadedChunks = T;
return;
}
tOldChecks.remove(aCoords);
}
}
}
tToCheck.clear();
tToCheck.addAll(tNewChecks);
tNewChecks.clear();
}
}
mIgnoreUnloadedChunks = T;
}
Aggregations