first 1.11.1 attempt

This commit is contained in:
2017-07-08 22:14:01 +02:00
parent 4b256caff9
commit 2e51738c45
48 changed files with 449 additions and 74 deletions

View File

@@ -3,19 +3,23 @@ package com.sosnitzka.taiga.traits;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
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 java.util.Optional;
public class TraitReviving extends AbstractTrait {
@@ -31,21 +35,23 @@ public class TraitReviving extends AbstractTrait {
public void onEntityKill(LivingDeathEvent e) {
BlockPos pos = e.getEntity().getPosition();
World w = e.getEntity().getEntityWorld();
if (!w.isRemote && e.getSource().getEntity() != null) {
if (e.getSource().getEntity() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getEntity()).getHeldItemMainhand()), identifier)) {
String name = EntityList.getEntityString(e.getEntity());
Entity ent = EntityList.createEntityByName(name, w);
if (!w.isRemote && e.getSource().getTrueSource() != null) {
if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
int id = e.getEntity().getEntityId();
Entity ent = EntityList.createEntityByID(id, w);
if (ent != null) {
if (ent instanceof EntitySkeleton && e.getEntity() instanceof EntitySkeleton) {
((EntitySkeleton) ent).setSkeletonType(((EntitySkeleton) e.getEntity()).getSkeletonType());
}
ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
w.spawnEntity(ent);
e.getSource().getEntity().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
e.getSource().getTrueSource().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
}
}
}
}
}
@Override
public Optional<RecipeMatch.Match> matches(NonNullList<ItemStack> stacks) {
return null;
}
}