From c7912a01d79dd33f95244e930d714c2dec7fa45f Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 22 Nov 2016 08:40:11 +0100 Subject: [PATCH] Make the lens of the killer actually drop player only drops Closes #389 --- .../mod/items/lens/LensEvenMoarDeath.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensEvenMoarDeath.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensEvenMoarDeath.java index 5852b85f5..8f4cd299b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensEvenMoarDeath.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensEvenMoarDeath.java @@ -13,17 +13,25 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class LensEvenMoarDeath extends LensDeath{ @Override protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile){ - try{ - ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, 100, 37); - } - catch(Exception e){ - ModUtil.LOGGER.error("A Damage Lens at "+tile.getX()+", "+tile.getY()+", "+tile.getZ()+" in World "+tile.getWorldObject().provider.getDimension()+" threw an Exception! Don't let that happen again!", e); + if(tile.getWorldObject() instanceof WorldServer){ + try{ + FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer)tile.getWorldObject()); + ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, fake, 37); + + ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, 100, 38); + } + catch(Exception e){ + ModUtil.LOGGER.error("A Damage Lens at "+tile.getX()+", "+tile.getY()+", "+tile.getZ()+" in World "+tile.getWorldObject().provider.getDimension()+" threw an Exception! Don't let that happen again!", e); + } } super.onAttacked(entity, tile);