Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Magnet pulling fake item entities #59

Merged
merged 2 commits into from
Jan 17, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.IConfigurableItem;
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
import com.brandon3055.draconicevolution.integration.ModHelper;

import baubles.api.BaubleType;
import baubles.api.IBauble;
Expand Down Expand Up @@ -112,7 +113,7 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int slot, bool
boolean playSound = false;

for (EntityItem item : items) {
if (item.getEntityItem() == null) {
if (item.getEntityItem() == null || ModHelper.isAE2EntityFloatingItem(item)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.brandon3055.draconicevolution.integration;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
Expand All @@ -21,22 +22,26 @@ public class ModHelper {
// private static boolean isRotaryCraftInstalled;
private static final boolean isGregTechInstalled;
private static final boolean isBartworkdsInstalled;
private static final boolean isAE2Installed;

private static Item cleaver;
private static Item avaritiaSword;
// private static Item bedrockSword;

private static Class<?> bwores;
private static Class<?> GTores;
private static Class<?> AE2FItem;

static {
isTConInstalled = Loader.isModLoaded("TConstruct");
isAvaritiaInstalled = Loader.isModLoaded("Avaritia");
// isRotaryCraftInstalled = Loader.isModLoaded("RotaryCraft");
isGregTechInstalled = Loader.isModLoaded("gregtech");
isBartworkdsInstalled = Loader.isModLoaded("bartworks");
isAE2Installed = Loader.isModLoaded("appliedenergistics2");
final String GT_ORE_CLASS = "gregtech.common.blocks.TileEntityOres";
final String BW_ORE_CLASS = "bartworks.system.material.BWMetaGeneratedOres";
final String AE2_FITEM_CLASS = "appeng.entity.EntityFloatingItem";
if (isGregTechInstalled) try {
GTores = Class.forName(GT_ORE_CLASS);
} catch (ClassNotFoundException e) {
Expand All @@ -47,6 +52,11 @@ public class ModHelper {
} catch (ClassNotFoundException e) {
LogHelper.error("Couldn't reflect class " + BW_ORE_CLASS);
}
if (isAE2Installed) try {
AE2FItem = Class.forName(AE2_FITEM_CLASS);
} catch (ClassNotFoundException e) {
LogHelper.error("Couldn't reflect class " + AE2_FITEM_CLASS);
}
}

public static boolean isHoldingCleaver(EntityPlayer player) {
Expand Down Expand Up @@ -112,4 +122,8 @@ else if (event.source.isUnblockable() || event.source.canHarmInCreative()) {
public static boolean isGregTechTileEntityOre(TileEntity te) {
return isGregTechInstalled && GTores.isInstance(te) || isBartworkdsInstalled && bwores.isInstance(te);
}

public static boolean isAE2EntityFloatingItem(EntityItem item) {
return isAE2Installed && AE2FItem.isInstance(item);
}
}