Skip to content

Commit

Permalink
Add item that spawns a Medicine Man
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfa-ag committed Nov 12, 2017
1 parent 234f365 commit f2ec1fa
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import pokefenn.totemic.api.ceremony.Ceremony;
import pokefenn.totemic.api.music.MusicInstrument;

public class CeremonyBuffaloDance extends Ceremony
{
private static final boolean ANIMANIA_LOADED = Loader.isModLoaded("animania");
//private static final boolean ANIMANIA_LOADED = Loader.isModLoaded("animania");

public CeremonyBuffaloDance(String name, int musicNeeded, int maxStartupTime, MusicInstrument... instruments)
{
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pokefenn/totemic/init/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class ModItems
public static final ItemBaykokBow baykok_bow = null;
public static final ItemMedicineBag medicine_bag = null;
public static final ItemCeremonyCheat ceremony_cheat = null;
public static final ItemSpawnTotemicVillager spawn_villager = null;

@SubscribeEvent
public static void init(RegistryEvent.Register<Item> event)
Expand Down Expand Up @@ -74,7 +75,8 @@ public static void init(RegistryEvent.Register<Item> event)
new ItemFood(9, 0.9F, true).setRegistryName(Strings.COOKED_BUFFALO_MEAT_NAME).setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.COOKED_BUFFALO_MEAT_NAME).setCreativeTab(Totemic.tabsTotem),
new ItemBaykokBow(),
new ItemMedicineBag(),
new ItemCeremonyCheat());
new ItemCeremonyCheat(),
new ItemSpawnTotemicVillager());
}

private static ItemBlock makeItemBlock(Block block)
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/pokefenn/totemic/item/ItemSpawnTotemicVillager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package pokefenn.totemic.item;

import java.util.List;

import javax.annotation.Nullable;

import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import pokefenn.totemic.init.ModVillagers;
import pokefenn.totemic.lib.Strings;

public class ItemSpawnTotemicVillager extends ItemTotemic
{
public ItemSpawnTotemicVillager()
{
super(Strings.SPAWN_VILLAGER_NAME);
}

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand,
EnumFacing facing, float hitX, float hitY, float hitZ)
{
if(world.isRemote)
return EnumActionResult.SUCCESS;
pos = pos.offset(facing);
EntityVillager villager = new EntityVillager(world);
villager.setProfession(ModVillagers.profTotemist);
villager.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
world.spawnEntity(villager);
player.getHeldItem(hand).shrink(1);
return EnumActionResult.SUCCESS;
}

@Override
public String getItemStackDisplayName(ItemStack stack)
{
return "Spawn Medicine Man";
}

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag)
{
tooltip.add("For BTM Moon only");
}
}
1 change: 1 addition & 0 deletions src/main/java/pokefenn/totemic/lib/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class Strings
public static final String BAYKOK_BOW_NAME = "baykok_bow";
public static final String MEDICINE_BAG_NAME = "medicine_bag";
public static final String CEREMONY_CHEAT_NAME = "ceremony_cheat";
public static final String SPAWN_VILLAGER_NAME = "spawn_villager";

//Entities
public static final String BUFFALO_NAME = "buffalo";
Expand Down

0 comments on commit f2ec1fa

Please sign in to comment.