Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dependencies {


compileOnly("com.github.GTNewHorizons:StructureLib:1.4.32:dev")
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.362:dev")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several other mods in GTNH that derive food stats. Have you checked what API is being used for that? If there is none, should we allow GTNH commit the sin of being exclusive at the cost of all the other mods?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most notable mods that add food to the game imo are

  • Pam's
  • Natura
  • Binnies
    Natura and Binnies both extend ItemFood, so they get caught by the first check and get consumed ingame. When checking ingame, Pam's food also gets consumed, so I suppose they also extend ItemFood.

So I don't see any "exclusiveness" for GT Food, i just see them being treated the same as the other food.
If im misunderstanding your question, please correct me.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm postulating is that the real bug is actually that GregTech foods do not implement ItemFood, and this merge request is a poor man's excuse for not fixing the root cause of the problem.

That is the argument that you have to disprove.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are metaitems so they cannot extend ItemFood. It's not an interface.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Four says, its impossible for them to implement ItemFood, due to them being metaitems. That should "disprove" your argument enough.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not change the conclusion that GregTech broke compatibility on its own volition by refusing to use ItemFood (and yes I'm aware that migration from one item to another is going to be annoying) and therefore it should normally carry the burden of responsibility.

The other question is also yet unanswered: how do all the other food-related mods interoperate with gregtech foods? There's at least spice of life and a NEI integration that also know how to obtain the food value.

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package vazkii.botania.common.block.subtile.generating.compat;

import net.minecraft.item.ItemStack;

import gregtech.api.interfaces.IFoodStat;
import gregtech.api.items.MetaGeneratedItem;

public class GTFoodHelper {

public static int getFoodHungerValue(ItemStack stack) {
if (!(stack.getItem() instanceof MetaGeneratedItem)) return -1;

MetaGeneratedItem metaItem = (MetaGeneratedItem) stack.getItem();
IFoodStat foodStat = metaItem.mFoodStats.get((short) stack.getItemDamage());
if (foodStat == null) return -1;

int hungerValue = foodStat.getFoodLevel(metaItem, stack, null);
return hungerValue > 0 ? hungerValue : -1;
}
}
2 changes: 2 additions & 0 deletions src/main/java/vazkii/botania/common/Botania.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class Botania {
public static boolean etFuturumLoaded = false;
public static boolean storageDrawersLoaded = false;
public static boolean structureLibLoaded = false;
public static boolean gt5Loaded = false;

public static ILightHelper lightHelper;

Expand All @@ -63,6 +64,7 @@ public void preInit(FMLPreInitializationEvent event) {
etFuturumLoaded = Loader.isModLoaded("etfuturum");
storageDrawersLoaded = Loader.isModLoaded("StorageDrawers");
structureLibLoaded = Loader.isModLoaded("structurelib");
gt5Loaded = Loader.isModLoaded("gregtech");

lightHelper = coloredLightsLoaded ? new LightHelperColored() : new LightHelperVanilla();
proxy.preInit(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,34 @@
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileGenerating;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.subtile.generating.compat.GTFoodHelper;

public class SubTileGourmaryllis extends SubTileGenerating {

private static final String TAG_COOLDOWN = "cooldown";
private static final String TAG_STORED_MANA = "storedMana";
private static final int RANGE = 1;

int cooldown = 0;
int storedMana = 0;

private int getFoodHungerValue(ItemStack stack) {
if (stack == null) return -1;

Comment thread
Yoshy2002 marked this conversation as resolved.
// Vanilla food
if (stack.getItem() instanceof ItemFood) {
return ((ItemFood) stack.getItem()).func_150905_g(stack);
}

// GregTech food
if (Botania.gt5Loaded) {
return GTFoodHelper.getFoodHungerValue(stack);
}

return -1;
}

@Override
public void onUpdate() {
super.onUpdate();
Expand All @@ -49,42 +68,43 @@ public void onUpdate() {
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1));
for(EntityItem item : items) {
ItemStack stack = item.getEntityItem();
if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) {
if(cooldown == 0) {
if(!remote) {
int val = ((ItemFood) stack.getItem()).func_150905_g(stack);
storedMana = val * val * 64;
cooldown = val * 10;
supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 0.2F, 0.5F + (float) Math.random() * 0.5F);
sync();
} else
for(int i = 0; i < 10; i++) {
float m = 0.2F;
float mx = (float) (Math.random() - 0.5) * m;
float my = (float) (Math.random() - 0.5) * m;
float mz = (float) (Math.random() - 0.5) * m;
supertile.getWorldObj().spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()), item.posX, item.posY, item.posZ, mx, my, mz);
}

if (stack == null || item.isDead || item.age < slowdown) continue;

int hungerValue = getFoodHungerValue(stack);
if (hungerValue <= 0) continue;

if (cooldown == 0) {
if (!remote) {
storedMana = hungerValue * hungerValue * 64;
cooldown = hungerValue * 10;
supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "random.eat", 0.2F, 0.5F + (float) Math.random() * 0.5F);
sync();
} else {
for (int i = 0; i < 10; i++) {
float m = 0.2F;
float mx = (float) (Math.random() - 0.5) * m;
float my = (float) (Math.random() - 0.5) * m;
float mz = (float) (Math.random() - 0.5) * m;
supertile.getWorldObj().spawnParticle("iconcrack_" + Item.getIdFromItem(stack.getItem()), item.posX, item.posY, item.posZ, mx, my, mz);
}
}

if(!remote)
item.setDead();
}
if (!remote) item.setDead();
}
}

@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
super.writeToPacketNBT(cmp);
cmp.setInteger(TAG_COOLDOWN, cooldown);
cmp.setInteger(TAG_COOLDOWN, cooldown);
cmp.setInteger(TAG_STORED_MANA, storedMana);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs to a different feature not attributed in the MR

}

@Override
public void readFromPacketNBT(NBTTagCompound cmp) {
super.readFromPacketNBT(cmp);
cooldown = cmp.getInteger(TAG_COOLDOWN);
storedMana = cmp.getInteger(TAG_STORED_MANA);
}

@Override
Expand Down
Loading