forked from TAIGA/TAIGA
first 1.11.1 attempt
This commit is contained in:
@@ -5,17 +5,21 @@ import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import slimeknights.mantle.util.RecipeMatch;
|
||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||
import slimeknights.tconstruct.library.utils.TagUtil;
|
||||
import slimeknights.tconstruct.library.utils.TinkerUtil;
|
||||
import slimeknights.tconstruct.library.utils.ToolHelper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.sosnitzka.taiga.util.Utils.isNight;
|
||||
|
||||
public class TraitArcane extends AbstractTrait {
|
||||
@@ -45,13 +49,18 @@ public class TraitArcane extends AbstractTrait {
|
||||
@SubscribeEvent
|
||||
public void onEntityKill(LivingDeathEvent e) {
|
||||
World w = e.getEntity().getEntityWorld();
|
||||
if (!w.isRemote && e.getSource().getEntity() != null) {
|
||||
if (e.getSource().getEntity() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
|
||||
ItemStack tool = ((EntityPlayer) e.getSource().getEntity()).getHeldItemMainhand();
|
||||
if (!w.isRemote && e.getSource().getTrueSource() != null) {
|
||||
if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
|
||||
ItemStack tool = ((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand();
|
||||
if (isNight((int) w.getWorldTime()) && random.nextFloat() < 0.1 && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
|
||||
ToolHelper.healTool(tool, random.nextInt(16), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<RecipeMatch.Match> matches(NonNullList<ItemStack> stacks) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user