use of gregapi.oredict.OreDictMaterialStack in project gregtech6 by GregTech6.
the class GT_API_Proxy method onWorldTick.
@SubscribeEvent
public void onWorldTick(WorldTickEvent aEvent) {
if (aEvent.side.isServer() && aEvent.phase == Phase.END) {
ArrayListNoNulls<EntityXPOrb> tOrbs = (XP_ORB_COMBINING && SERVER_TIME % 40 == 31 ? new ArrayListNoNulls<EntityXPOrb>(128) : null);
for (int i = 0; i < aEvent.world.loadedEntityList.size(); i++) {
Entity aEntity = (Entity) aEvent.world.loadedEntityList.get(i);
if (aEntity == null || aEntity.isDead)
continue;
if (aEntity instanceof EntityXPOrb) {
if (tOrbs != null)
tOrbs.add((EntityXPOrb) aEntity);
} else if (aEntity instanceof EntityItem) {
ItemStack aStack = ((EntityItem) aEntity).getEntityItem();
if (ST.valid(aStack)) {
ItemStack rStack = ST.copy(aStack);
boolean tBreak = F, tFireProof = F;
// TODO make a case for Armor too whenever I decide to even add Armor.
if (rStack.getItem() instanceof MultiItemTool) {
if (MultiItemTool.getPrimaryMaterial(aStack).contains(TD.Properties.UNBURNABLE))
tFireProof = T;
if (MultiItemTool.getSecondaryMaterial(aStack).contains(TD.Properties.UNBURNABLE))
tFireProof = T;
}
OreDictItemData aData = OM.anydata_(rStack);
if (aData != null) {
if (aData.hasValidPrefixData())
for (IOreDictListenerItem tListener : aData.mPrefix.mListenersItem) {
rStack = tListener.onTickWorld(aData.mPrefix, aData.mMaterial.mMaterial, rStack, (EntityItem) aEntity);
if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
tBreak = T;
break;
}
}
if (!tBreak && aData.hasValidMaterialData())
for (OreDictMaterialStack tMaterial : aData.getAllMaterialStacks()) {
if (tBreak)
break;
if (tMaterial.mMaterial.contains(TD.Properties.UNBURNABLE))
tFireProof = T;
for (IOreDictListenerItem tListener : tMaterial.mMaterial.mListenersItem) {
rStack = tListener.onTickWorld(aData.mPrefix, tMaterial.mMaterial, rStack, (EntityItem) aEntity);
if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
tBreak = T;
break;
}
}
}
}
if (rStack == null || rStack.stackSize <= 0) {
((EntityItem) aEntity).setEntityItemStack(NI);
((EntityItem) aEntity).setDead();
} else if (!ST.equal(rStack, aStack) || rStack.stackSize != aStack.stackSize) {
((EntityItem) aEntity).setEntityItemStack(rStack);
((EntityItem) aEntity).delayBeforeCanPickup = 40;
}
if (!aEntity.isDead && aEntity.isBurning() && (tBreak || (tFireProof && !MD.MC.owns(rStack)))) {
UT.Reflection.setField(EntityItem.class, aEntity, "health", 250, F);
UT.Reflection.setField(EntityItem.class, aEntity, "field_70291_e", 250, F);
aEntity.extinguish();
}
}
} else if (aEntity instanceof EntityLivingBase) {
if (ENTITY_CRAMMING > 0 && SERVER_TIME % 50 == 0 && !(aEntity instanceof EntityPlayer) && ((EntityLivingBase) aEntity).canBePushed() && ((EntityLivingBase) aEntity).getHealth() > 0) {
List<?> tList = aEntity.worldObj.getEntitiesWithinAABBExcludingEntity(aEntity, aEntity.boundingBox.expand(0.2, 0.0, 0.2));
Class<? extends Entity> tClass = aEntity.getClass();
int aEntityCount = 1;
if (tList != null)
for (int j = 0; j < tList.size(); j++) if (tList.get(j) != null && tList.get(j).getClass() == tClass)
aEntityCount++;
if (aEntityCount > ENTITY_CRAMMING)
aEntity.attackEntityFrom(DamageSource.inWall, (aEntityCount - ENTITY_CRAMMING) * TFC_DAMAGE_MULTIPLIER);
}
}
}
if (tOrbs != null && tOrbs.size() > 32)
for (EntityXPOrb aOrb : tOrbs) {
if (aOrb.xpValue >= Short.MAX_VALUE)
continue;
if (aOrb.xpValue <= 0) {
aOrb.xpValue = 0;
aOrb.setDead();
continue;
}
for (EntityXPOrb tOrb : tOrbs) if (aOrb != tOrb && !tOrb.isDead && tOrb.xpValue > 0 && tOrb.xpValue < Short.MAX_VALUE && aOrb.getDistanceSqToEntity(tOrb) <= 3) {
aOrb.xpOrbAge = Math.min(aOrb.xpOrbAge, tOrb.xpOrbAge);
if (aOrb.xpValue + tOrb.xpValue > Short.MAX_VALUE) {
tOrb.xpValue -= (Short.MAX_VALUE - aOrb.xpValue);
aOrb.xpValue = Short.MAX_VALUE;
break;
}
aOrb.xpValue += tOrb.xpValue;
tOrb.xpValue = 0;
tOrb.setDead();
break;
}
}
if (SERVER_TIME % 20 == 1) {
checkSaveLocation(aEvent.world.getSaveHandler().getWorldDirectory(), T);
for (int i = 0; i < aEvent.world.loadedTileEntityList.size(); i++) {
TileEntity aTileEntity = (TileEntity) aEvent.world.loadedTileEntityList.get(i);
if (aTileEntity instanceof ITileEntityNeedsSaving)
WD.mark(aTileEntity);
}
}
}
}
use of gregapi.oredict.OreDictMaterialStack in project gregtech6 by GregTech6.
the class GT_API_Proxy_Client method onItemTooltip.
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent aEvent) {
if (Abstract_Mod.sFinalized < Abstract_Mod.sModCountUsingGTAPI || ST.invalid(aEvent.itemStack))
return;
if (!DISPLAY_TEMP_TOOLTIP) {
DISPLAY_TEMP_TOOLTIP = T;
return;
}
try {
if (UT.NBT.getNBT(aEvent.itemStack).getBoolean("gt.err.oredict.output")) {
aEvent.toolTip.clear();
aEvent.toolTip.add(0, LH.Chat.BLINKING_RED + "A Recipe used an OreDict Item as Output directly, without copying it before!");
aEvent.toolTip.add(1, LH.Chat.BLINKING_RED + "This is a typical CallByReference/CallByValue Error of the Modder doing it.");
aEvent.toolTip.add(2, LH.Chat.BLINKING_RED + "Please check all Recipes outputting this Item, and report the Recipes to their Owner.");
aEvent.toolTip.add(3, LH.Chat.BLINKING_RED + "The Owner of the RECIPE, NOT the Owner of the Item!");
return;
}
String aRegName = ST.regName(aEvent.itemStack);
if (aRegName == null) {
aEvent.toolTip.set(0, LH.Chat.BLINKING_RED + "ERROR: THIS ITEM HAS NOT BEEN REGISTERED!!!");
aRegName = "ERROR: THIS ITEM HAS NOT BEEN REGISTERED!!!";
}
short aMeta = ST.meta_(aEvent.itemStack);
byte aBlockMeta = UT.Code.bind4(aMeta);
Block aBlock = ST.block(aEvent.itemStack);
Item aItem = ST.item(aEvent.itemStack);
if (aEvent.itemStack.getTagCompound() == null) {
if (aBlock == Blocks.dirt && aBlockMeta == 1) {
aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Dirt", "Coarse Dirt"));
}
if (MD.RC.mLoaded && "Railcraft:part.plate".equalsIgnoreCase(aRegName)) {
switch(aMeta) {
case 0:
aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateIron.name"));
break;
case 1:
aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateSteel.name"));
break;
case 2:
aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateTinAlloy.name"));
break;
case 3:
aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateCopper.name"));
break;
case 4:
aEvent.toolTip.set(0, LH.Chat.WHITE + LH.get("oredict.plateLead.name"));
break;
}
}
}
if (MD.Mek.owns(aRegName)) {
aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Osmium", MT.Ge.mNameLocal));
}
if (ItemsGT.RECIPE_REMOVED_USE_TRASH_BIN_INSTEAD.contains(aEvent.itemStack, T)) {
aEvent.toolTip.add(LH.Chat.BLINKING_RED + "Recipe has been removed in favour of the GregTech Ender Garbage Bin");
}
ICover tCover = CoverRegistry.get(aEvent.itemStack);
if (tCover != null)
tCover.addToolTips(aEvent.toolTip, aEvent.itemStack, aEvent.showAdvancedItemTooltips);
if (aBlock != NB) {
if (IL.TC_Warded_Glass.equal(aEvent.itemStack, F, T)) {
aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 999));
} else if (ItemsGT.SHOW_RESISTANCE.contains(aEvent.itemStack, T)) {
if (IL.ICBM_Concrete.block() == aBlock) {
switch(aMeta) {
default:
aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 30));
break;
case 1:
aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 38));
break;
case 2:
aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, 48));
break;
}
} else {
aEvent.toolTip.add(LH.getToolTipBlastResistance(aBlock, aBlock.getExplosionResistance(null)));
}
aEvent.toolTip.add(LH.getToolTipHarvest(aBlock.getMaterial(), aBlock.getHarvestTool(aBlockMeta), aBlock.getHarvestLevel(aBlockMeta)));
}
if (BlocksGT.openableCrowbar.contains(aBlock)) {
aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOL_TO_OPEN_CROWBAR));
}
}
if (BooksGT.BOOK_REGISTER.containsKey(aEvent.itemStack, T)) {
aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_SHELFABLE));
}
if (Sandwiches.INGREDIENTS.containsKey(aEvent.itemStack, T)) {
aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_SANDWICHABLE));
}
if (aItem.isBeaconPayment(aEvent.itemStack)) {
aEvent.toolTip.add(LH.Chat.DGRAY + LH.get(LH.TOOLTIP_BEACON_PAYMENT));
}
OreDictItemData tData = OM.anydata_(aEvent.itemStack);
if (!(aItem instanceof ItemFluidDisplay) && SHOW_INTERNAL_NAMES) {
if (tData != null && tData.hasValidPrefixMaterialData()) {
if (tData.mBlackListed) {
if (ST.isGT(aItem))
aEvent.toolTip.add(LH.Chat.ORANGE + tData.toString());
else
aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta + LH.Chat.WHITE + " - " + LH.Chat.ORANGE + tData.toString());
} else {
if (ST.isGT(aItem))
aEvent.toolTip.add(LH.Chat.GREEN + tData.toString());
else
aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta + LH.Chat.WHITE + " - " + LH.Chat.GREEN + tData.toString());
}
} else {
if (!ST.isGT(aItem))
aEvent.toolTip.add(LH.Chat.DCYAN + aRegName + LH.Chat.WHITE + " - " + LH.Chat.CYAN + aMeta);
}
}
if (tData != null) {
if (tData.hasValidPrefixData()) {
for (IOreDictListenerItem tListener : tData.mPrefix.mListenersItem) {
String tToolTip = tListener.getListenerToolTip(tData.mPrefix, tData.mMaterial.mMaterial, aEvent.itemStack);
if (tToolTip != null)
aEvent.toolTip.add(tToolTip);
}
} else {
if (IL.RC_Firestone_Refined.equal(aEvent.itemStack, T, T))
aEvent.toolTip.add(LH.Chat.CYAN + "Works in Burning Boxes (" + (800 * EU_PER_LAVA) + " HU per Lava Block)");
else if (IL.RC_Firestone_Cracked.equal(aEvent.itemStack, T, T))
aEvent.toolTip.add(LH.Chat.CYAN + "Works in Burning Boxes (" + (600 * EU_PER_LAVA) + " HU per Lava Block)");
else if (IL.TF_Pick_Giant.equal(aEvent.itemStack, T, T))
aEvent.toolTip.add(LH.Chat.CYAN + "Can be repaired with Knightmetal Ingots on the Anvil");
else if (IL.TF_Sword_Giant.equal(aEvent.itemStack, T, T))
aEvent.toolTip.add(LH.Chat.CYAN + "Can be repaired with Ironwood Ingots on the Anvil");
else if (IL.TF_Lamp_of_Cinders.equal(aEvent.itemStack, T, T))
aEvent.toolTip.add(LH.Chat.CYAN + "Can be used as a Lighter for GT6 things and TNT");
}
if (tData.hasValidMaterialData()) {
boolean tUnburnable = F;
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) {
if (tMaterial.mMaterial.contains(TD.Properties.UNBURNABLE))
tUnburnable = T;
for (IOreDictListenerItem tListener : tMaterial.mMaterial.mListenersItem) {
String tToolTip = tListener.getListenerToolTip(tData.mPrefix, tData.mMaterial.mMaterial, aEvent.itemStack);
if (tToolTip != null)
aEvent.toolTip.add(tToolTip);
}
}
if (tData.mMaterial.mMaterial.mToolTypes > 0 && (tData.mPrefix != null || (aEvent.itemStack.getMaxStackSize() > 1 && tData.mByProducts.length == 0 && tData.mMaterial.mAmount <= U))) {
aEvent.toolTip.add(LH.Chat.BLUE + "Q: " + tData.mMaterial.mMaterial.mToolQuality + " - S: " + tData.mMaterial.mMaterial.mToolSpeed + " - D: " + tData.mMaterial.mMaterial.mToolDurability);
}
if (SHOW_CHEM_FORMULAS && UT.Code.stringValid(tData.mMaterial.mMaterial.mTooltipChemical) && (tData.mPrefix == null ? tData.mByProducts.length == 0 : tData.mPrefix.contains(TD.Prefix.TOOLTIP_MATERIAL))) {
aEvent.toolTip.add(LH.Chat.YELLOW + tData.mMaterial.mMaterial.mTooltipChemical);
}
if (tData.mMaterial.mMaterial == MT.Nikolite) {
aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("(Teslatite|Electrotine)", MT.Nikolite.mNameLocal));
}
if (tData.mMaterial.mMaterial == MT.Ge) {
aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll("Osmium", MT.Ge.mNameLocal));
}
if (tData.hasValidPrefixData()) {
if (tData.mPrefix == OP.dustTiny && ANY.Blaze.mToThis.contains(tData.mMaterial.mMaterial)) {
aEvent.toolTip.set(0, aEvent.toolTip.get(0).replaceAll(tData.mMaterial.mMaterial.mNameLocal, OP.dustTiny.mMaterialPre + tData.mMaterial.mMaterial.mNameLocal));
}
if (tData.mPrefix.contains(TD.Prefix.NEEDS_SHARPENING))
aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_NEEDS_SHARPENING));
if (tData.mPrefix.contains(TD.Prefix.NEEDS_HANDLE))
aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_NEEDS_HANDLE) + LH.Chat.WHITE + tData.mMaterial.mMaterial.mHandleMaterial.getLocal());
ArrayListNoNulls<Integer> tShapelessAmounts = new ArrayListNoNulls<>();
for (AdvancedCrafting1ToY tHandler : tData.mPrefix.mShapelessManagersSingle) if (tHandler.hasOutputFor(tData.mMaterial.mMaterial))
tShapelessAmounts.add(1);
for (AdvancedCraftingXToY tHandler : tData.mPrefix.mShapelessManagers) if (tHandler.hasOutputFor(tData.mMaterial.mMaterial))
tShapelessAmounts.add(tHandler.mInputCount);
if (!tShapelessAmounts.isEmpty()) {
Collections.sort(tShapelessAmounts);
aEvent.toolTip.add(LH.Chat.CYAN + LH.get(LH.TOOLTIP_SHAPELESS_CRAFT) + LH.Chat.WHITE + tShapelessAmounts);
}
if (tData.mPrefix.contains(TD.Prefix.TOOLTIP_ENCHANTS)) {
if (!tData.mMaterial.mMaterial.mEnchantmentTools.isEmpty()) {
if (!tData.mPrefix.contains(TD.Prefix.AMMO_ALIKE)) {
if (tData.mMaterial.mMaterial.mEnchantmentTools.size() <= 5) {
aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_POSSIBLE_TOOL_ENCHANTS));
for (ObjectStack<Enchantment> tEnchantment : tData.mMaterial.mMaterial.mEnchantmentTools) {
if (tEnchantment.mObject == Enchantment.fortune) {
aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fortune.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.looting.getTranslatedName((int) tEnchantment.mAmount));
} else if (tEnchantment.mObject == Enchantment.knockback) {
aEvent.toolTip.add(LH.Chat.PINK + Enchantment.knockback.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.punch.getTranslatedName((int) tEnchantment.mAmount));
} else if (tEnchantment.mObject == Enchantment.fireAspect) {
if (tEnchantment.mAmount >= 3)
aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fireAspect.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.flame.getTranslatedName((int) tEnchantment.mAmount) + " / Auto Smelt I");
else
aEvent.toolTip.add(LH.Chat.PINK + Enchantment.fireAspect.getTranslatedName((int) tEnchantment.mAmount) + " / " + Enchantment.flame.getTranslatedName((int) tEnchantment.mAmount));
} else {
aEvent.toolTip.add(LH.Chat.PINK + tEnchantment.mObject.getTranslatedName((int) tEnchantment.mAmount));
}
}
} else {
aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_TOO_MANY_TOOL_ENCHANTS));
}
}
}
if (MD.BTL.mLoaded && tData.mMaterial.mMaterial.contains(TD.Properties.BETWEENLANDS)) {
aEvent.toolTip.add(LH.Chat.GREEN + LH.get(LH.TOOLTIP_BETWEENLANDS_RESISTANCE));
}
if (!tData.mPrefix.containsAny(TD.Prefix.TOOL_HEAD, TD.Prefix.WEAPON_ALIKE, TD.Prefix.AMMO_ALIKE, TD.Prefix.TOOL_ALIKE)) {
if (!tData.mMaterial.mMaterial.mEnchantmentArmors.isEmpty()) {
if (tData.mMaterial.mMaterial.mEnchantmentArmors.size() <= 3) {
aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_POSSIBLE_ARMOR_ENCHANTS));
for (ObjectStack<Enchantment> tEnchantment : tData.mMaterial.mMaterial.mEnchantmentArmors) {
aEvent.toolTip.add(LH.Chat.PINK + tEnchantment.mObject.getTranslatedName((int) tEnchantment.mAmount));
}
} else {
aEvent.toolTip.add(LH.Chat.PURPLE + LH.get(LH.TOOLTIP_TOO_MANY_ARMOR_ENCHANTS));
}
}
if ((IL.TF_Mazestone.exists() || IL.TF_Mazehedge.exists()) && tData.mMaterial.mMaterial.contains(TD.Properties.MAZEBREAKER)) {
aEvent.toolTip.add(LH.Chat.PINK + LH.get(LH.TOOLTIP_TWILIGHT_MAZE_BREAKING));
}
}
}
if (aBlock == NB || !(aBlock instanceof MultiTileEntityBlockInternal || aBlock instanceof IBlockBase)) {
if (tData.mMaterial.mMaterial.contains(TD.Properties.FLAMMABLE)) {
if (tData.mMaterial.mMaterial.contains(TD.Properties.EXPLOSIVE)) {
aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_FLAMMABLE_AND_EXPLOSIVE));
} else {
aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_FLAMMABLE));
}
} else if (tData.mMaterial.mMaterial.contains(TD.Properties.EXPLOSIVE)) {
aEvent.toolTip.add(LH.Chat.RED + LH.get(LH.TOOLTIP_EXPLOSIVE));
}
}
}
if (tUnburnable && !MD.MC.owns(aRegName))
aEvent.toolTip.add(LH.Chat.GREEN + LH.get(LH.TOOLTIP_UNBURNABLE));
}
if (aEvent.showAdvancedItemTooltips) {
boolean temp = T;
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) if (tMaterial.mAmount != 0 && !tMaterial.mMaterial.contains(TD.Properties.DONT_SHOW_THIS_COMPONENT)) {
if (temp) {
aEvent.toolTip.add(LH.Chat.DCYAN + LH.get(LH.TOOLTIP_CONTAINED_MATERIALS));
temp = F;
}
StringBuilder tString = new StringBuilder(128);
double aWeight = tMaterial.weight();
long tWeight = ((long) (aWeight * 1000)) % 1000;
tString.append(LH.Chat.WHITE).append(UT.Code.displayUnits(tMaterial.mAmount)).append(" ");
tString.append(LH.Chat.YELLOW).append(tMaterial.mMaterial.getLocal());
tString.append(LH.Chat.WHITE).append(" (");
tString.append(LH.Chat.CYAN).append("M: ");
tString.append(LH.Chat.WHITE).append(tMaterial.mMaterial.mMeltingPoint);
tString.append(LH.Chat.RED).append("K ");
tString.append(LH.Chat.CYAN).append(" B: ");
tString.append(LH.Chat.WHITE).append(tMaterial.mMaterial.mBoilingPoint);
tString.append(LH.Chat.RED).append("K ");
tString.append(LH.Chat.CYAN).append(" W: ");
tString.append(LH.Chat.WHITE).append((long) aWeight).append(".").append(tWeight < 1 ? "000" : tWeight < 10 ? "00" + tWeight : tWeight < 100 ? "0" + tWeight : tWeight);
tString.append(LH.Chat.YELLOW).append("kg");
tString.append(LH.Chat.WHITE).append(")");
aEvent.toolTip.add(tString.toString());
}
} else {
aEvent.toolTip.add(LH.Chat.DGRAY + "Enable F3+H Mode for Info about contained Materials.");
}
if (ST.isGT(aItem) && tData.hasValidPrefixMaterialData()) {
if (tData.mMaterial.mMaterial.mOriginalMod == null) {
aEvent.toolTip.add(LH.Chat.BLUE + "Material from an Unknown Mod");
} else if (tData.mMaterial.mMaterial.mOriginalMod == MD.MC) {
aEvent.toolTip.add(LH.Chat.BLUE + "Vanilla Material");
} else if (tData.mMaterial.mMaterial.mOriginalMod == MD.GAPI) {
if (tData.mMaterial.mMaterial.mID > 0 && tData.mMaterial.mMaterial.mID < 8000) {
aEvent.toolTip.add(LH.Chat.BLUE + "Material from the Periodic Table of Elements");
} else {
aEvent.toolTip.add(LH.Chat.BLUE + "Random Material handled by Greg API");
}
} else {
aEvent.toolTip.add(LH.Chat.BLUE + "Material from " + tData.mMaterial.mMaterial.mOriginalMod.mName);
}
}
}
// Remove all Nulls and fix eventual Formatting mistakes.
for (int i = 1, j = aEvent.toolTip.size(); i < j; i++) {
String tTooltip = aEvent.toolTip.get(i);
if (tTooltip == null) {
aEvent.toolTip.remove(i--);
j--;
} else
aEvent.toolTip.set(i, tTooltip + LH.Chat.RESET_TOOLTIP);
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
}
use of gregapi.oredict.OreDictMaterialStack in project gregtech6 by GregTech6.
the class PrefixBlock method removeMaterialFromSide.
@Override
public boolean removeMaterialFromSide(World aWorld, int aX, int aY, int aZ, byte aSide, OreDictMaterialStack aMaterial) {
OreDictMaterialStack tMaterial = getMaterialAtSide(aWorld, aX, aY, aZ, aSide);
if (aMaterial.mMaterial == tMaterial.mMaterial && aMaterial.mAmount > 0 && aMaterial.mAmount <= tMaterial.mAmount) {
ItemStack tStack = OM.dust(aMaterial.mMaterial, tMaterial.mAmount - aMaterial.mAmount);
if (tStack != null)
ST.drop(aWorld, aX + 0.5, aY + 0.5, aZ + 0.5, tStack);
aWorld.setBlockToAir(aX, aY, aZ);
return T;
}
return F;
}
use of gregapi.oredict.OreDictMaterialStack in project gregtech6 by GregTech6.
the class RecipeMapShredder method getRecipeFor.
@Override
public Recipe getRecipeFor(ItemStack aInput) {
OreDictItemData aData = OM.anydata(aInput);
if (aData == null || (aData.mPrefix != null && (!aData.mPrefix.contains(TD.Prefix.RECYCLABLE) || aData.mPrefix.containsAny(TD.Prefix.DUST_BASED, TD.Prefix.ORE, TD.Prefix.ORE_PROCESSING_BASED, TD.Prefix.IS_CONTAINER))) || (aData.mMaterial != null && aData.mMaterial.mMaterial.contains(TD.Atomic.ANTIMATTER)) || FL.getFluid(aInput, T) != null)
return null;
List<OreDictMaterialStack> tList = new ArrayListNoNulls<>();
for (OreDictMaterialStack tMaterial : aData.getAllMaterialStacks()) if (tMaterial.mMaterial.mTargetPulver.mAmount > 0)
OM.stack(UT.Code.units(tMaterial.mAmount, U, tMaterial.mMaterial.mTargetPulver.mAmount, F), tMaterial.mMaterial.mTargetPulver.mMaterial).addToList(tList);
if (tList.isEmpty())
return null;
ItemStack[] tOutputs = new ItemStack[Math.min(tList.size(), mOutputItemsCount)];
int i = 0, tDuration = 0;
for (OreDictMaterialStack tMaterial : tList) {
tDuration += UT.Code.units(tMaterial.mAmount, U, 256 * Math.max(1, tMaterial.mMaterial.mToolQuality + 1), T);
if (i < tOutputs.length) {
ItemStack tStack = OM.dust(tMaterial);
if (tStack != null)
tOutputs[i++] = tStack;
}
}
if (!UT.Code.exists(0, tOutputs))
return null;
return new Recipe(F, F, F, ST.array(ST.amount(1, aInput)), tOutputs, null, null, ZL_FS, ZL_FS, Math.max(1, tDuration), 16, 0);
}
use of gregapi.oredict.OreDictMaterialStack in project gregtech6 by GregTech6.
the class Behavior_Gun method trace.
public MovingObjectPosition trace(World aWorld, Vec3 aPosA, Vec3 aPosB, boolean aHitThings) {
if (Double.isNaN(aPosA.xCoord) || Double.isNaN(aPosA.yCoord) || Double.isNaN(aPosA.zCoord) || Double.isNaN(aPosB.xCoord) || Double.isNaN(aPosB.yCoord) || Double.isNaN(aPosB.zCoord))
return null;
int tCount = 1000, aAX = UT.Code.roundDown(aPosA.xCoord), aAY = UT.Code.roundDown(aPosA.yCoord), aAZ = UT.Code.roundDown(aPosA.zCoord), aBX = UT.Code.roundDown(aPosB.xCoord), aBY = UT.Code.roundDown(aPosB.yCoord), aBZ = UT.Code.roundDown(aPosB.zCoord);
byte tSide = SIDE_UNKNOWN;
while (tCount-- >= 0) {
Block aBlock = WD.block(aWorld, aAX, aAY, aAZ);
byte aMeta = WD.meta(aWorld, aAX, aAY, aAZ);
if (aBlock.getMaterial() == Material.water || aBlock.getMaterial() == Material.lava) {
return new MovingObjectPosition(aAX, aAY, aAZ, tSide, aPosA, T);
} else if (aBlock.getMaterial() == Material.glass || aBlock == Blocks.redstone_lamp || aBlock == Blocks.lit_redstone_lamp) {
if (aHitThings) {
OreDictItemData tData = OM.anydata(ST.make(aBlock, 1, aMeta));
for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) {
long tAmount = tMaterial.mAmount / OP.scrapGt.mAmount;
while (tAmount-- > 0) ST.drop(aWorld, aAX + 0.2 + RNGSUS.nextFloat() * 0.6, aAY + 0.1 + RNGSUS.nextFloat() * 0.5, aAZ + 0.2 + RNGSUS.nextFloat() * 0.6, OP.scrapGt.mat(tMaterial.mMaterial, 1));
}
}
} else if (aBlock == Blocks.fence || aBlock == Blocks.fence_gate || aBlock == Blocks.web || aBlock == Blocks.mob_spawner || aBlock instanceof BlockPane || aBlock instanceof BlockRail || aBlock instanceof BlockTorch || aBlock instanceof BlockBaseBars || aBlock instanceof BlockBaseSpike || aBlock.getMaterial() == Material.cactus || aBlock.getMaterial() == Material.fire || aBlock.getMaterial() == Material.air || aBlock.getMaterial() == Material.carpet || aBlock.getMaterial() == Material.cloth || aBlock.getMaterial() == Material.leaves || aBlock.getMaterial() == Material.plants || aBlock.getMaterial() == Material.vine) {
// Just ignore or assume the Player shot through them.
} else if (aBlock.canCollideCheck(aMeta, F)) {
MovingObjectPosition tPos = aBlock.collisionRayTrace(aWorld, aAX, aAY, aAZ, aPosA, aPosB);
if (tPos != null)
return tPos;
}
if (aAX == aBX && aAY == aBY && aAZ == aBZ)
return null;
if (Double.isNaN(aPosA.xCoord) || Double.isNaN(aPosA.yCoord) || Double.isNaN(aPosA.zCoord))
return null;
tSide = SIDE_UNKNOWN;
double tAX = aAX, tAY = aAY, tAZ = aAZ, tBX = aAX, tBY = aAY, tBZ = aAZ;
double tDiffX = aPosB.xCoord - aPosA.xCoord, tDiffY = aPosB.yCoord - aPosA.yCoord, tDiffZ = aPosB.zCoord - aPosA.zCoord;
if (aAX != aBX) {
if (aBX > aAX)
tAX++;
tBX = (tAX - aPosA.xCoord) / tDiffX;
}
if (aAY != aBY) {
if (aBY > aAY)
tAY++;
tBY = (tAY - aPosA.yCoord) / tDiffY;
}
if (aAZ != aBZ) {
if (aBZ > aAZ)
tAZ++;
tBZ = (tAZ - aPosA.zCoord) / tDiffZ;
}
if (tBX < tBY && tBX < tBZ) {
if (aBX > aAX)
tSide = SIDE_X_NEG;
else
tSide = SIDE_X_POS;
aPosA.xCoord = tAX;
aPosA.yCoord += tDiffY * tBX;
aPosA.zCoord += tDiffZ * tBX;
} else if (tBY < tBZ) {
if (aBY > aAY)
tSide = SIDE_Y_NEG;
else
tSide = SIDE_Y_POS;
aPosA.xCoord += tDiffX * tBY;
aPosA.yCoord = tAY;
aPosA.zCoord += tDiffZ * tBY;
} else {
if (aBZ > aAZ)
tSide = SIDE_Z_NEG;
else
tSide = SIDE_Z_POS;
aPosA.xCoord += tDiffX * tBZ;
aPosA.yCoord += tDiffY * tBZ;
aPosA.zCoord = tAZ;
}
aAX = UT.Code.roundDown(aPosA.xCoord);
if (tSide == SIDE_X_POS)
aAX--;
aAY = UT.Code.roundDown(aPosA.yCoord);
if (tSide == SIDE_Y_POS)
aAY--;
aAZ = UT.Code.roundDown(aPosA.zCoord);
if (tSide == SIDE_Z_POS)
aAZ--;
}
return null;
}
Aggregations