mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Hibike! Cacophonium
This commit is contained in:
1 parent
3a078edafe
commit
5b67f181ca
9 files changed
+116
-1
No files matched your search
@@ -186,6 +186,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.terrasteelLegs);
|
||||
addItem(ModItems.terrasteelBoots);
|
||||
addItem(ModItems.phantomInk);
|
||||
addItem(ModItems.cacophonium);
|
||||
addItem(ModItems.recordGaia1);
|
||||
addItem(ModItems.recordGaia2);
|
||||
addItem(ModItems.ancientWill);
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Jul 20, 2015, 9:53:57 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntitySlime;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class ItemCacophonium extends ItemMod {
|
||||
|
||||
private static final String TAG_SOUND = "sound";
|
||||
private static final String TAG_SOUND_NAME = "soundName";
|
||||
private static final String TAG_HAS_SOUND = "hasSound";
|
||||
|
||||
public ItemCacophonium() {
|
||||
setMaxStackSize(1);
|
||||
setUnlocalizedName(LibItemNames.CACOPHONIUM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) {
|
||||
if(entity instanceof EntityLiving) {
|
||||
EntityLiving living = (EntityLiving) entity;
|
||||
String sound = null;
|
||||
try {
|
||||
if(living instanceof EntityCreeper)
|
||||
sound = "creeper.primed";
|
||||
else if(living instanceof EntitySlime)
|
||||
sound = "mob.slime." + (((EntitySlime) living).getSlimeSize() > 1 ? "big" : "small");
|
||||
else sound = (String) ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND).invoke(living);
|
||||
|
||||
if(sound != null) {
|
||||
String s = EntityList.getEntityString(entity);
|
||||
if(s == null)
|
||||
s = "generic";
|
||||
|
||||
ItemNBTHelper.setString(stack, TAG_SOUND, sound);
|
||||
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name");
|
||||
ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true);
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy());
|
||||
|
||||
if(player.worldObj.isRemote)
|
||||
player.swingItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false))
|
||||
list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false))
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, 72000);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
|
||||
if(count % 6 == 0 && sound != null && !sound.isEmpty())
|
||||
player.worldObj.playSoundAtEntity(player, sound, 0.9F, (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F + 1.0F);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,9 @@ public class ItemObedienceStick extends ItemMod {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(player.worldObj.isRemote)
|
||||
player.swingItem();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ public final class ModItems {
|
||||
public static Item terraAxe;
|
||||
public static Item waterBowl;
|
||||
public static Item obedienceStick;
|
||||
public static Item cacophonium;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -380,6 +381,7 @@ public final class ModItems {
|
||||
terraAxe = new ItemTerraAxe();
|
||||
waterBowl = new ItemWaterBowl();
|
||||
obedienceStick = new ItemObedienceStick();
|
||||
cacophonium = new ItemCacophonium();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
|
||||
@@ -146,6 +146,7 @@ public final class LibItemNames {
|
||||
public static final String TERRA_AXE = "terraAxe";
|
||||
public static final String WATER_BOWL = "waterBowl";
|
||||
public static final String OBEDIENCE_STICK = "obedienceStick";
|
||||
public static final String CACOPHONIUM = "cacophonium";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
|
||||
@@ -76,5 +76,7 @@ public final class LibObfuscation {
|
||||
// GuiChat
|
||||
public static final String[] INPUT_FIELD = new String[] { "inputField", "field_146415_a", "a" };
|
||||
public static final String[] COMPLETE_FLAG = new String[] { "field_146414_r", "r" };
|
||||
|
||||
// Entityliving
|
||||
public static final String[] GET_LIVING_SOUND = new String[] { "getLivingSound", "func_70639_aQ", "t" };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user