本文整理汇总了Java中net.minecraft.item.ItemRecord类的典型用法代码示例。如果您正苦于以下问题:Java ItemRecord类的具体用法?Java ItemRecord怎么用?Java ItemRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemRecord类属于net.minecraft.item包,在下文中一共展示了ItemRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public void playRecord(String recordName, BlockPos blockPosIn)
{
ISound isound = (ISound)this.mapSoundPositions.get(blockPosIn);
if (isound != null)
{
this.mc.getSoundHandler().stopSound(isound);
this.mapSoundPositions.remove(blockPosIn);
}
if (recordName != null)
{
ItemRecord itemrecord = ItemRecord.getRecord(recordName);
if (itemrecord != null)
{
this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
}
PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.create(new ResourceLocation(recordName), (float)blockPosIn.getX(), (float)blockPosIn.getY(), (float)blockPosIn.getZ());
this.mapSoundPositions.put(blockPosIn, positionedsoundrecord);
this.mc.getSoundHandler().playSound(positionedsoundrecord);
}
}
示例2: playRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos)
{
ISound isound = (ISound)this.mapSoundPositions.get(pos);
if (isound != null)
{
this.mc.getSoundHandler().stopSound(isound);
this.mapSoundPositions.remove(pos);
}
if (soundIn != null)
{
ItemRecord itemrecord = ItemRecord.getBySound(soundIn);
if (itemrecord != null)
{
this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
}
PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ());
this.mapSoundPositions.put(pos, positionedsoundrecord);
this.mc.getSoundHandler().playSound(positionedsoundrecord);
}
}
示例3: update
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Override
public void update() {
World world = entity.getWorld();
if(!world.isRemote && entity.ticksExisted()==Refs.TPS*5){
//grab the list of records
Map<String,ItemRecord> recordMap = ReflectionHelper.getPrivateValue(ItemRecord.class, (ItemRecord)Items.RECORD_13, "RECORDS","field_150928_b");//XXX recheck name when update
Collection<ItemRecord> records = recordMap.values();
//select a random number
Random rand = new Random();
int idx = rand.nextInt(records.size());
//grab the record that matches our random number
Iterator<ItemRecord> it = records.iterator();
ItemRecord current=it.next();
for(int i=1;i<idx;i++){
current = it.next();
}
//spawn the record
Utils.spawnItemCentered(world, getPos(), new ItemStack(current));
//world.playSoundEffect(getPos().getX(), getPos().getY(), getPos().getZ(), "mob.chicken.plop", 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
world.playSound(null,getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.ENTITY_CHICKEN_EGG, SoundCategory.BLOCKS, 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
this.onPatternBroken();//deactivate
}
}
示例4: playRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
/**
* Plays the specified record. Arg: recordName, x, y, z
*/
public void playRecord(String par1Str, int par2, int par3, int par4)
{
ChunkCoordinates var5 = new ChunkCoordinates(par2, par3, par4);
ISound var6 = (ISound)this.mapSoundPositions.get(var5);
if (var6 != null)
{
this.mc.getSoundHandler().func_147683_b(var6);
this.mapSoundPositions.remove(var5);
}
if (par1Str != null)
{
ItemRecord var7 = ItemRecord.func_150926_b(par1Str);
if (var7 != null)
{
this.mc.ingameGUI.setRecordPlayingMessage(var7.func_150927_i());
}
PositionedSoundRecord var8 = PositionedSoundRecord.func_147675_a(new ResourceLocation(par1Str), (float)par2, (float)par3, (float)par4);
this.mapSoundPositions.put(var5, var8);
this.mc.getSoundHandler().playSound(var8);
}
}
示例5: getIdentifierForRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Nullable
public static String getIdentifierForRecord(ItemRecord record, int x, int y, int z) {
ResourceLocation resource = record.getRecordResource("records." + record.recordName);
// if (resource == null) return null;
SoundEventAccessorComposite sound = getSoundHandler().getSound(resource);
float f1 = 16F;
if (sound == null) {
return null;
}
SoundPoolEntry soundpoolentry = sound.cloneEntry();
SoundCategory soundcategory = sound.getSoundCategory();
float volume = (float) MathHelper.clamp_double((double) f1 * soundpoolentry.getVolume() * (double) mc().gameSettings.getSoundLevel(soundcategory), 0.0D, MAX_VOLUME);
float pitch = (float) MathHelper.clamp_double((double) f1 * soundpoolentry.getVolume() * (double) mc().gameSettings.getSoundLevel(soundcategory), 0.0D, 1.0D);
// ResourceLocation resourcelocation = soundpoolentry.getSoundPoolEntryLocation();
// I know the type.
//noinspection unchecked
HashBiMap<String, ISound> playingSounds = (HashBiMap<String, ISound>) getSoundManager().playingSounds;
BiMap<ISound, String> inverse = playingSounds.inverse();
return inverse.get(new CustomSound(volume, resource, false, 0, pitch, x, y, z));
}
示例6: onBlockActivated
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz)
{
boolean ejected = super.onBlockActivated(world, x, y, z, player, side, px, py, pz);
if (!ejected && player != null && player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemRecord)) {
ItemStack held = player.getHeldItem();
this.func_149926_b(world, x, y, z, held);
world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, Item.getIdFromItem(held.getItem()));
--held.stackSize;
return true;
}
return false;
}
示例7: onLivingDrop
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDrop(LivingDropsEvent event)
{
if (event.entityLiving instanceof EntityCreeper)
{
boolean foundRecord = false;
Iterator<EntityItem> iter = event.drops.iterator();
while (iter.hasNext())
{
EntityItem e = iter.next();
if (e.getEntityItem().getItem() instanceof ItemRecord)
{
foundRecord = true;
}
}
if (foundRecord)
{
addRandomRecordToDrops(event.drops);
}
}
}
示例8: attached
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Override
public ItemStack attached(ItemStack i, Random rand, int[] eff) {
ArrayList<ItemRecord> recordList = new ArrayList<ItemRecord>();
//Fill record list with everything considered a record (vanilla or modded).
Iterator<Item> it = Item.itemRegistry.iterator();
while(it.hasNext()) {
Item item = it.next();
if(item instanceof ItemRecord) {
recordList.add((ItemRecord)item);
}
}
//If records were found (and there should always be some!), choose one randomly.
if(recordList.size() > 0) {
String record = recordList.get(rand.nextInt(recordList.size())).recordName;
i.getTagCompound().setString("record", record);
}
else {
System.out.println("No records?!?");
}
return i;
}
示例9: init
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public static void init(Item item) {
if (item instanceof ItemRecord) {
String key = Tool.<String>$(item, "displayName");
miscMap.put(key, getName(key, 1));
} else if (!(item instanceof ItemBlock))
itemMap.put(item.getUnlocalizedName() + ".name", getName(item.getUnlocalizedName()));
}
示例10: isItemValidForSlot
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Override
public boolean isItemValidForSlot( int slot, ItemStack stack )
{
if ( stack == null )
{
return true;
}
return ( stack.getItem() instanceof ItemRecord );
}
示例11: onMessage
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@Override
public IMessage onMessage(ServerPlayRecord message, MessageContext ctx) {
TileJukebox jukebox = Util.getTileEntity(ClientUtil.mc().thePlayer.worldObj, message.x, message.y, message.z, TileJukebox.class);
if (jukebox == null) {
//TODO: log;
return null;
}
if (jukebox.getStackInSlot(message.slot) == null) return null;
jukebox.setPlaying(true);
SoundSystemHelper.playRecord((ItemRecord) jukebox.getStackInSlot(message.slot).getItem(), message.x, message.y, message.z, jukebox.getIdentifier());
return null;
}
示例12: playSelectedRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public void playSelectedRecord() {
if (getStackInSlot(recordNumber) == null) return;
if (worldObj.isRemote) {
PacketHandler.INSTANCE.sendToServer(new ClientPlayRecord(this));
return;
}
lastPlayingRecord = ((ItemRecord) getStackInSlot(recordNumber).getItem()).recordName;
playing = true;
waitTicks = 20;
PacketHandler.INSTANCE.sendToAll(new ServerPlayRecord(this));
}
示例13: playRecord
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public void playRecord(String p_72702_1_, int p_72702_2_, int p_72702_3_, int p_72702_4_)
{
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(p_72702_2_, p_72702_3_, p_72702_4_);
ISound isound = (ISound)this.mapSoundPositions.get(chunkcoordinates);
if (isound != null)
{
this.mc.getSoundHandler().stopSound(isound);
this.mapSoundPositions.remove(chunkcoordinates);
}
if (p_72702_1_ != null)
{
ItemRecord itemrecord = ItemRecord.getRecord(p_72702_1_);
ResourceLocation resource = null;
if (itemrecord != null)
{
this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
resource = itemrecord.getRecordResource(p_72702_1_);
}
if (resource == null) resource = new ResourceLocation(p_72702_1_);
PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(resource, (float)p_72702_2_, (float)p_72702_3_, (float)p_72702_4_);
this.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord);
this.mc.getSoundHandler().playSound(positionedsoundrecord);
}
}
示例14: onTooltip
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
if (event.itemStack.getItem() instanceof INBTDamageItem) {
INBTDamageItem nitem = (INBTDamageItem)(event.itemStack.getItem());
boolean show = Minecraft.getMinecraft().gameSettings.advancedItemTooltips;
if (show && nitem.getNBTDamage(event.itemStack) > 0) {
event.toolTip.add("Durability: " + (nitem.getNBTMaxDamage(event.itemStack) - event.itemStack.getItemDamageForDisplay()) + " / " + nitem.getNBTMaxDamage(event.itemStack));
}
}
if (event.itemStack.stackTagCompound != null){
if (event.itemStack.stackTagCompound.hasKey(PhysisArtifacts.SOCKETEDTAG)) {
int index = -1;
for(int i=0; i<event.toolTip.size(); i++) {
if (event.toolTip.get(i).isEmpty()) {
index = i;
}
}
if (index != -1) {
addSocketTooltip(event.entityPlayer, event.itemStack, event.toolTip, index);
} else {
addSocketTooltip(event.entityPlayer, event.itemStack, event.toolTip, event.toolTip.size());
}
}
if (event.itemStack.stackTagCompound.hasKey(PhysisArtifacts.ARTIFACTTAG)) {
List<String> content = Physis.text.translateAndWrap(this.getTooltipForSocketable(event.itemStack), tipWidth);
event.toolTip.addAll(content);
}
} else if (event.itemStack.getItem() instanceof ItemRecord) {
ItemStack held = event.entityPlayer.getHeldItem();
if (held != null && held.getItem() == PhysisItems.addsocket) {
addRecordTooltip(event.itemStack, event.toolTip, event.toolTip.size());
}
}
}
示例15: func_72702_a
import net.minecraft.item.ItemRecord; //导入依赖的package包/类
public void func_72702_a(String p_72702_1_, int p_72702_2_, int p_72702_3_, int p_72702_4_) {
ItemRecord var5 = ItemRecord.func_90042_d(p_72702_1_);
if(p_72702_1_ != null && var5 != null) {
this.field_72777_q.field_71456_v.func_73833_a(var5.func_90043_g());
}
this.field_72777_q.field_71416_A.func_77368_a(p_72702_1_, (float)p_72702_2_, (float)p_72702_3_, (float)p_72702_4_);
}