mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Cacotrollium block.
This commit is contained in:
1 parent
35bf694c57
commit
f9e41372ae
9 files changed
+205
-6
No files matched your search
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* 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 @ [Aug 23, 2015, 7:23:26 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.block.tile.TileCacophonium;
|
||||
import vazkii.botania.common.block.tile.TileSpecialFlower;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class BlockCacophonium extends BlockModContainer {
|
||||
|
||||
IIcon top;
|
||||
|
||||
protected BlockCacophonium() {
|
||||
super(Material.wood);
|
||||
setBlockName(LibBlockNames.CACOPHONIUM);
|
||||
setHardness(0.8F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
blockIcon = IconHelper.forBlock(reg, this, 0);
|
||||
top = IconHelper.forBlock(reg, this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return side == 1 ? blockIcon : top;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerInCreative() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean powered = (meta & 8) != 0;
|
||||
|
||||
if(power && !powered) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileCacophonium)
|
||||
((TileCacophonium) tile).annoyDirewolf();
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
|
||||
} else if(!power && powered)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
|
||||
if(!par6EntityPlayer.capabilities.isCreativeMode)
|
||||
dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> stacks = new ArrayList();
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileCacophonium) {
|
||||
stacks.add(new ItemStack(Blocks.noteblock));
|
||||
ItemStack thingy = ((TileCacophonium) tile).stack;
|
||||
if(thingy != null)
|
||||
stacks.add(thingy.copy());
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileCacophonium();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -112,6 +112,7 @@ import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileAltar;
|
||||
import vazkii.botania.common.block.tile.TileBifrost;
|
||||
import vazkii.botania.common.block.tile.TileBrewery;
|
||||
import vazkii.botania.common.block.tile.TileCacophonium;
|
||||
import vazkii.botania.common.block.tile.TileCocoon;
|
||||
import vazkii.botania.common.block.tile.TileCraftCrate;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
@@ -239,6 +240,7 @@ public final class ModBlocks {
|
||||
public static Block lightRelay;
|
||||
public static Block lightLauncher;
|
||||
public static Block manaBomb;
|
||||
public static Block cacophonium;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -319,7 +321,8 @@ public final class ModBlocks {
|
||||
lightRelay = new BlockLightRelay();
|
||||
lightLauncher = new BlockLightLauncher();
|
||||
manaBomb = new BlockManaBomb();
|
||||
|
||||
cacophonium = new BlockCacophonium();
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
@@ -411,6 +414,7 @@ public final class ModBlocks {
|
||||
registerTile(TileSparkChanger.class, LibBlockNames.SPARK_CHANGER);
|
||||
registerTile(TileCocoon.class, LibBlockNames.COCOON);
|
||||
registerTile(TileLightRelay.class, LibBlockNames.LIGHT_RELAY);
|
||||
registerTile(TileCacophonium.class, LibBlockNames.CACOPHONIUM);
|
||||
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_PUREDAISY, SubTilePureDaisy.class);
|
||||
BotaniaAPI.registerSubTile(LibBlockNames.SUBTILE_MANASTAR, SubTileManastar.class);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 @ [Aug 23, 2015, 7:25:38 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import vazkii.botania.common.item.ItemCacophonium;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileCacophonium extends TileMod {
|
||||
|
||||
private static final String TAG_STACK = "stack";
|
||||
|
||||
public ItemStack stack;
|
||||
|
||||
public void annoyDirewolf() {
|
||||
ItemCacophonium.playSound(worldObj, stack, xCoord, yCoord, zCoord, 1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
super.writeCustomNBT(cmp);
|
||||
|
||||
NBTTagCompound cmp1 = new NBTTagCompound();
|
||||
if(stack != null)
|
||||
stack.writeToNBT(cmp1);
|
||||
cmp.setTag(TAG_STACK, cmp1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
super.readCustomNBT(cmp);
|
||||
|
||||
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_STACK);
|
||||
stack = ItemStack.loadItemStackFromNBT(cmp1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,16 +12,20 @@ package vazkii.botania.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.init.Blocks;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileCacophonium;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
@@ -73,9 +77,34 @@ public class ItemCacophonium extends ItemMod {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
|
||||
boolean can = isDOIT(stack);
|
||||
if(!can) {
|
||||
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
|
||||
boolean doit = isDOIT(stack);
|
||||
if(sound != null && !sound.isEmpty())
|
||||
can = true;
|
||||
}
|
||||
|
||||
if(can) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(block == Blocks.noteblock) {
|
||||
world.setBlock(x, y, z, ModBlocks.cacophonium);
|
||||
((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy();
|
||||
stack.stackSize--;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false))
|
||||
if(isDOIT(stack))
|
||||
list.add(StatCollector.translateToLocal("botaniamisc.justDoIt"));
|
||||
else if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false))
|
||||
list.add(StatCollector.translateToLocal(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
|
||||
}
|
||||
|
||||
@@ -91,15 +120,31 @@ public class ItemCacophonium extends ItemMod {
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false))
|
||||
if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack))
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, 72000);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
if(count % (isDOIT(stack) ? 20 : 6) == 0)
|
||||
playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F);
|
||||
}
|
||||
|
||||
public static void playSound(World world, ItemStack stack, double x, double y, double z, float volume) {
|
||||
if(stack == null)
|
||||
return;
|
||||
|
||||
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);
|
||||
boolean doit = isDOIT(stack);
|
||||
if(doit)
|
||||
sound = "botania:doit";
|
||||
|
||||
if(sound != null && !sound.isEmpty())
|
||||
world.playSoundEffect(x, y, z, sound, volume, doit ? 1F : ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F));
|
||||
}
|
||||
|
||||
private static boolean isDOIT(ItemStack stack) {
|
||||
return stack != null && stack.getDisplayName().equalsIgnoreCase("shia labeouf");
|
||||
}
|
||||
}
|
||||
@@ -1005,7 +1005,7 @@ public final class LexiconData {
|
||||
challenges.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2")).setPriority().setIcon(new ItemStack(ModItems.cosmetic, 1, 31));
|
||||
|
||||
cacophonium = new BLexiconEntry(LibLexicon.MISC_CACOPHONIUM, categoryMisc);
|
||||
cacophonium.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium));
|
||||
cacophonium.setLexiconPages(new PageText("0"), new PageCraftingRecipe("1", ModCraftingRecipes.recipeCacophonium), new PageText("2"));
|
||||
|
||||
if(Botania.bcTriggersLoaded) {
|
||||
bcIntegration = new CLexiconEntry(LibLexicon.MISC_BC_INTEGRATION, categoryMisc, "BuildCraft");
|
||||
|
||||
@@ -93,6 +93,7 @@ public final class LibBlockNames {
|
||||
public static final String LIGHT_RELAY = "lightRelay";
|
||||
public static final String LIGHT_LAUNCHER = "lightLauncher";
|
||||
public static final String MANA_BOMB = "manaBomb";
|
||||
public static final String CACOPHONIUM = "cacophoniumBlock";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
@@ -135,6 +135,7 @@ botaniamisc.hideNotes=Hide Notes
|
||||
botaniamisc.showNotes=Show Notes
|
||||
botaniamisc.notes=Notes
|
||||
botaniamisc.pay2win=Upgrade your Mana Pool to infuse this item
|
||||
botaniamisc.justDoIt=DO IT
|
||||
|
||||
# NEI INTEGRATION
|
||||
botania.nei.brewery=Botanical Brewery
|
||||
@@ -1011,6 +1012,7 @@ tile.botania:buriedPetals12.name=Buried Brown Petal
|
||||
tile.botania:buriedPetals13.name=Buried Green Petal
|
||||
tile.botania:buriedPetals14.name=Buried Red Petal
|
||||
tile.botania:buriedPetals15.name=Buried Black Petal
|
||||
tile.botania:cacophoniumBlock.name=Cacophonium Block
|
||||
|
||||
# FLOWER NAMES
|
||||
tile.botania:flower..name=Botania Flower
|
||||
@@ -3005,6 +3007,7 @@ botania.page.challenges2=The challenges aren't obligatory in any way, and do not
|
||||
botania.entry.cacophonium=Cacophonium
|
||||
botania.page.cacophonium0=This interesting instrument, the &1Cacophonium&0, has the ability to mimic almost every living being's cries in nature, allowing for the "musician" to play them at will. Right clicking with it on an entity has the instrument learn its sound. It can then be played by holding right click.<br>Why anyone would ever want to make this, however, is beyond moral comprehension.
|
||||
botania.page.cacophonium1=Hibike! Cacophonium
|
||||
botania.page.cacophonium2=For maximum cacophony, the &1Cacophonium&0 can be shift-right clicked onto a &1Note Block&0, creating the ability to sound off animal or monster sounds on demand.<br>You monster.
|
||||
|
||||
# -- THAUMCRAFT INTEGRATION
|
||||
botania.entry.tcIntegration=Thaumcraft Integration
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in new issue
Block a user