This is for advanced Minecraft Java mod makers. So i have this script:
import net.minecraft.entity.monster.SkeletonEntity;
import net.minecraft.item.Items;
import net.minecraft.item.EnchantedGoldenAppleItem;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class Example {
@SubscribeEvent
public void tameSkeleton(PlayerInteractEvent.EntityInteract event) {
if (event.getTarget() instanceof SkeletonEntity) {
SkeletonEntity skeleton = (SkeletonEntity) event.getTarget();
ItemStack itemstack = event.getPlayer().getHeldItem(event.getHand());
if (skeleton.isTamed()) {
return;
} else if (itemstack.getItem() instanceof EnchantedGoldenAppleItem) {
if (!event.getPlayer().abilities.isCreativeMode) {
itemstack.shrink(1);
}
if (!skeleton.world.isRemote) {
skeleton.setTamedBy(event.getPlayer());
skeleton.world.setEntityState(skeleton, (byte)7);
}
return;
}
}
}
@SubscribeEvent
public void skeletonDefendPlayer(LivingAttackEvent event) {
if (event.getEntity() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntity();
if (player.getAttackingEntity() instanceof SkeletonEntity) {
SkeletonEntity skeleton = (SkeletonEntity) player.getAttackingEntity();
if (skeleton.isTamed()) {
event.setCanceled(true);
skeleton.setAttackTarget(event.getSource().getTrueSource());
}
}
}
}
}
and it should make skeleton posible to tame. Apps that im using to create mods doesnt show any errors so why it doesnt work?