Skip to content

Commit

Permalink
Fix Magnet pulling fake item entities (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruling-0 authored Jan 17, 2025
1 parent 07ed885 commit f7cac98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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);
}
}

0 comments on commit f7cac98

Please sign in to comment.