use of gregapi.oredict.OreDictItemData 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.oredict.OreDictItemData in project gregtech6 by GregTech6.
the class MultiTileEntityGearBox method onToolClick2.
@Override
public long onToolClick2(String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, byte aSide, float aHitX, float aHitY, float aHitZ) {
if (isClientSide())
return 0;
if (aTool.equals(TOOL_wrench)) {
if (SIDES_INVALID[aSide])
return 0;
byte tSide = UT.Code.getSideWrenching(aSide, aHitX, aHitY, aHitZ);
if (FACE_CONNECTED[tSide][mAxleGear & 63]) {
mAxleGear &= ~B[tSide];
ItemStack tGear = OP.gearGt.mat(mMaterial, 1);
if (!(aPlayer instanceof EntityPlayer) || !UT.Inventories.addStackToPlayerInventory((EntityPlayer) aPlayer, tGear))
ST.place(getWorld(), getOffset(tSide, 1), tGear);
mJammed = F;
mGearsWork = checkGears();
updateClientData();
causeBlockUpdate();
return 10000;
}
if (UT.Entities.hasInfiniteItems(aPlayer)) {
mAxleGear |= B[tSide];
mJammed = F;
mGearsWork = checkGears();
updateClientData();
causeBlockUpdate();
return 10000;
}
if (aPlayerInventory != null)
for (int i = 0, j = aPlayerInventory.getSizeInventory(); i < j; i++) {
OreDictItemData tData = OM.data(aPlayerInventory.getStackInSlot(i));
if (tData != null && tData.mPrefix == OP.gearGt && (tData.mMaterial.mMaterial == mMaterial || mMaterial.mToThis.contains(tData.mMaterial.mMaterial))) {
if (aPlayer == null)
aPlayerInventory.decrStackSize(i, 1);
else
ST.use(aPlayer, T, aPlayerInventory.getStackInSlot(i));
mAxleGear |= B[tSide];
mJammed = F;
mGearsWork = checkGears();
updateClientData();
causeBlockUpdate();
return 10000;
}
}
if (aChatReturn != null)
aChatReturn.add("You dont have a Gear of the corresponding Material in your Inventory!");
return 0;
}
if (aTool.equals(TOOL_monkeywrench)) {
if (SIDES_INVALID[aSide])
return 0;
byte tSide = UT.Code.getSideWrenching(aSide, aHitX, aHitY, aHitZ);
if (SIDES_AXIS_X[tSide])
if (((mAxleGear >>> 6) & 3) != 1)
mAxleGear = (byte) ((mAxleGear & 63) | (1 << 6));
else
mAxleGear &= 63;
if (SIDES_AXIS_Y[tSide])
if (((mAxleGear >>> 6) & 3) != 2)
mAxleGear = (byte) ((mAxleGear & 63) | (2 << 6));
else
mAxleGear &= 63;
if (SIDES_AXIS_Z[tSide])
if (((mAxleGear >>> 6) & 3) != 3)
mAxleGear = (byte) ((mAxleGear & 63) | (3 << 6));
else
mAxleGear &= 63;
mJammed = F;
mGearsWork = checkGears();
updateClientData();
causeBlockUpdate();
return 10000;
}
if (aTool.equals(TOOL_softhammer)) {
mJammed = !mJammed;
mGearsWork = checkGears();
updateClientData();
causeBlockUpdate();
return 10000;
}
if (aTool.equals(TOOL_magnifyingglass)) {
mGearsWork = checkGears();
if (aChatReturn != null)
aChatReturn.add(mGearsWork ? mJammed ? "Gears interlocked properly, but they are jammed!" : "Gears interlocked properly." : "Gears interlocked improperly!");
return 1;
}
return 0;
}
use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.
the class CoverFilterFluid method onCoverClickedRight.
@Override
public boolean onCoverClickedRight(byte aCoverSide, CoverData aData, Entity aPlayer, byte aSideClicked, float aHitX, float aHitY, float aHitZ) {
if (aPlayer instanceof EntityPlayer && aData.mTileEntity.isServerSide()) {
if (aData.mNBTs[aCoverSide] == null || !aData.mNBTs[aCoverSide].hasKey("gt.filter.fluid")) {
ItemStack tStack = ((EntityPlayer) aPlayer).getCurrentEquippedItem();
if (ST.valid(tStack)) {
FluidStack tFluid = FL.getFluid(tStack, T);
if (tFluid == null) {
OreDictItemData tData = OM.anyassociation_(tStack);
if (tData != null && tData.mPrefix.contains(TD.Prefix.IS_CONTAINER) && !tData.mPrefix.contains(TD.Prefix.IS_CRATE)) {
tFluid = tData.mMaterial.mMaterial.fluid(U, T);
}
}
if (tFluid != null && tFluid.getFluid() != null && !FL.Error.is(tFluid)) {
aData.mNBTs[aCoverSide] = FL.save(null, "gt.filter.fluid", tFluid);
UT.Sounds.send(aData.mTileEntity.getWorld(), SFX.MC_CLICK, 1, 1, aData.mTileEntity.getCoords());
UT.Entities.sendchat(aPlayer, "Filters for: " + LH.Chat.CYAN + tFluid.getFluid().getName());
}
}
}
}
return T;
}
use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.
the class CoverLogisticsFluidExport method onCoverClickedRight.
@Override
public boolean onCoverClickedRight(byte aCoverSide, CoverData aData, Entity aPlayer, byte aSideClicked, float aHitX, float aHitY, float aHitZ) {
if (aPlayer instanceof EntityPlayer && aData.mTileEntity.isServerSide()) {
if (aData.mNBTs[aCoverSide] == null || !aData.mNBTs[aCoverSide].hasKey("gt.filter.fluid")) {
ItemStack tStack = ((EntityPlayer) aPlayer).getCurrentEquippedItem();
if (ST.valid(tStack)) {
FluidStack tFluid = FL.getFluid(tStack, T);
if (tFluid == null) {
OreDictItemData tData = OM.anyassociation_(tStack);
if (tData != null && tData.mPrefix.contains(TD.Prefix.IS_CONTAINER) && !tData.mPrefix.contains(TD.Prefix.IS_CRATE)) {
tFluid = tData.mMaterial.mMaterial.fluid(U, T);
}
}
if (tFluid != null && tFluid.getFluid() != null && !FL.Error.is(tFluid)) {
aData.mNBTs[aCoverSide] = FL.save(null, "gt.filter.fluid", tFluid);
UT.Sounds.send(aData.mTileEntity.getWorld(), SFX.MC_CLICK, 1, 1, aData.mTileEntity.getCoords());
UT.Entities.sendchat(aPlayer, "Exports: " + LH.Chat.CYAN + tFluid.getFluid().getName());
}
}
}
}
return T;
}
use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.
the class CoverLogisticsFluidImport method onCoverClickedRight.
@Override
public boolean onCoverClickedRight(byte aCoverSide, CoverData aData, Entity aPlayer, byte aSideClicked, float aHitX, float aHitY, float aHitZ) {
if (aPlayer instanceof EntityPlayer && aData.mTileEntity.isServerSide()) {
if (aData.mNBTs[aCoverSide] == null || !aData.mNBTs[aCoverSide].hasKey("gt.filter.fluid")) {
ItemStack tStack = ((EntityPlayer) aPlayer).getCurrentEquippedItem();
if (ST.valid(tStack)) {
FluidStack tFluid = FL.getFluid(tStack, T);
if (tFluid == null) {
OreDictItemData tData = OM.anyassociation_(tStack);
if (tData != null && tData.mPrefix.contains(TD.Prefix.IS_CONTAINER) && !tData.mPrefix.contains(TD.Prefix.IS_CRATE)) {
tFluid = tData.mMaterial.mMaterial.fluid(U, T);
}
}
if (tFluid != null && tFluid.getFluid() != null && !FL.Error.is(tFluid)) {
aData.mNBTs[aCoverSide] = FL.save(null, "gt.filter.fluid", tFluid);
UT.Sounds.send(aData.mTileEntity.getWorld(), SFX.MC_CLICK, 1, 1, aData.mTileEntity.getCoords());
UT.Entities.sendchat(aPlayer, "Imports: " + LH.Chat.CYAN + tFluid.getFluid().getName());
}
}
}
}
return T;
}
Aggregations