Make the lens of the killer actually drop player only drops

Closes #389
This commit is contained in:
Ellpeck 2016-11-22 08:40:11 +01:00
parent 73d3dc95bc
commit c7912a01d7

View file

@ -13,18 +13,26 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.entity.EntityLivingBase; 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; import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class LensEvenMoarDeath extends LensDeath{ public class LensEvenMoarDeath extends LensDeath{
@Override @Override
protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile){ protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile){
if(tile.getWorldObject() instanceof WorldServer){
try{ try{
ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, 100, 37); FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer)tile.getWorldObject());
ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, fake, 37);
ReflectionHelper.setPrivateValue(EntityLivingBase.class, entity, 100, 38);
} }
catch(Exception e){ 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); 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); super.onAttacked(entity, tile);
} }