Everything posted by Ocraftyone
-
[SOLVED][1.11]Custom Sound Played to a Single Player on the right click of an Item
I am able to compare these strings. It works 100% in all testing
-
[SOLVED][1.11]Custom Sound Played to a Single Player on the right click of an Item
Thank you!!!! Solved the problem with this code: worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, ModSoundHandler.DOORBELL, SoundCategory.PLAYERS, 1, 1);
-
[SOLVED][1.11]Custom Sound Played to a Single Player on the right click of an Item
i still dont get how to play a sound to just the person who clicked the item
-
[SOLVED][1.11]Custom Sound Played to a Single Player on the right click of an Item
then how should I solve this problem. i am just having a problem with playing the sound from the code
-
[SOLVED][1.11]Custom Sound Played to a Single Player on the right click of an Item
I would like my custom sound played to the player who right clicks this item. I have the sound set up and registered correctly because if I use /playsound, it works perfectly. Here is the code for the item that I want the sound to be played on when right-clicked: package ocraftyone.MoreEverything.items; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import ocraftyone.MoreEverything.handlers.ModSoundHandler; import ocraftyone.MoreEverything.init.ModItemBasic; public class ItemHome extends ModItemBasic { public ItemHome(String name, CreativeTabs tab) { super(name, tab); this.setMaxStackSize(1); } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if(stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setBoolean("homeSet", false); } } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemStack = playerIn.getHeldItem(handIn); if(!worldIn.isRemote) { NBTTagCompound nbt = itemStack.getTagCompound(); if(playerIn.isSneaking()) { nbt.setInteger("xpos", playerIn.getPosition().getX()); nbt.setInteger("ypos", playerIn.getPosition().getY()); nbt.setInteger("zpos", playerIn.getPosition().getZ()); nbt.setInteger("dim", playerIn.dimension); nbt.setString("playerName", playerIn.getName()); nbt.setBoolean("homeSet", true); playerIn.sendMessage(new TextComponentString("Succesfully set home! Bound to " + playerIn.getName() + ".")); }else { if(nbt.getBoolean("homeSet") == true) { if(playerIn.getName() == nbt.getString("playerName")) { if(nbt.getInteger("dim") != playerIn.dimension) { playerIn.changeDimension(nbt.getInteger("dim")); playerIn.attemptTeleport(nbt.getInteger("xpos"), nbt.getInteger("ypos"), nbt.getInteger("zpos")); playerIn.playSound(ModSoundHandler.DOORBELL, 1.01F, 1.0F); } else { playerIn.attemptTeleport(nbt.getInteger("xpos"), nbt.getInteger("ypos"), nbt.getInteger("zpos")); playerIn.playSound(ModSoundHandler.DOORBELL, 1.0F, 1.0F); //worldIn.playSound(playerIn, playerIn.getPosition(), ModSoundHandler.DOORBELL, SoundCategory.PLAYERS, 1.0F, 1.0F); } }else { playerIn.sendMessage(new TextComponentString("You can not use another person's home item! (Owner: " + nbt.getString("playerName") + ")")); } }else { playerIn.sendMessage(new TextComponentString("Invalid home!")); } } } return super.onItemRightClick(worldIn, playerIn, handIn); } } I have also heard in another post to cast EntityPlayerSP, but I could not get that to work: What they wanted me to do: //Cast EntityPlayer to EntityPlayerSP EntityPlayerSP playerSP = (EntityPlayerSP) playerIn; //Play sound to EntityPlayerSP playerSP.playSound(ModSoundHandler.DOORBELL, 1, 1); //Log said that EntityPlayerMP could not be cast to EntityPlayerSP
-
[SOLVED] set the container item for only select metadata items
Thank you everyone who helped me! Here was my final code: @Override public boolean hasContainerItem(ItemStack stack) { if(7 > stack.getMetadata()) { if(0 != stack.getMetadata()) { return true; } } return false; } @Override public ItemStack getContainerItem(ItemStack itemStack) { if(7 > itemStack.getMetadata()) { if(0 != itemStack.getMetadata()) { return new ItemStack(ModItems.itemCupcakePan); } } return null; }
-
[SOLVED] set the container item for only select metadata items
i feel like i am being dumb. especially for working on this one problem for many days. Do you see a problem with my code? i want metadata 7-12 to have the container item @Override public ItemStack getContainerItem(ItemStack itemStack) { if(7 > itemStack.getMetadata()) { return super.getContainerItem(new ItemStack(ModItems.itemCupcakePan)); } return null; }
-
[SOLVED] set the container item for only select metadata items
i got that part. i just need help with what to do in the //do something area
-
[SOLVED] set the container item for only select metadata items
i am a very visual person. would you mind typing out that block of code with place holders?
-
[SOLVED] set the container item for only select metadata items
so what you are saying to do is this: this.getContainerItem(new ItemStack(ModItems.itemCupcakePan, 1, metadata) is this right?
-
[SOLVED] set the container item for only select metadata items
I want to be able to set the container item for only select metadata items but so far it just adds the container item for all of the metadata items Here is my code: package ocraftyone.MoreEverything.items; import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.fml.common.Mod.Metadata; import ocraftyone.MoreEverything.handlers.EnumHandler.CupcakePanTypes; import ocraftyone.MoreEverything.init.ModItemBasic; public class ItemCupcakePan extends ModItemBasic { public ItemCupcakePan(String name) { super(name); this.setHasSubtypes(true); this.setMaxStackSize(1); } @Override public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) { for(int i = 0; i < CupcakePanTypes.values().length; i++) { subItems.add(new ItemStack(itemIn, 1, i)); } } @Override public String getUnlocalizedName(ItemStack stack) { for(int i = 0; i < CupcakePanTypes.values().length; i++) { if(stack.getItemDamage() == i) { return this.getUnlocalizedName() + "." + CupcakePanTypes.values()[i].getName(); } else { continue; } } return this.getUnlocalizedName() + "." + CupcakePanTypes.EMPTY.getName(); } @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { switch(stack.getItemDamage()) { case 0: break; case 1: tooltip.add("1/6 Cupcakes"); break; case 2: tooltip.add("2/6 Cupcakes"); break; case 3: tooltip.add("3/6 Cupcakes"); break; case 4: tooltip.add("4/6 Cupcakes"); break; case 5: tooltip.add("5/6 Cupcakes"); break; case 6: tooltip.add("6/6 Cupcakes"); break; case 7: tooltip.add("1/6 Dough"); break; case 8: tooltip.add("2/6 Dough"); break; case 9: tooltip.add("3/6 Dough"); break; case 10: tooltip.add("4/6 Dough"); break; case 11: tooltip.add("5/6 Dough"); break; case 12: tooltip.add("6/6 Dough"); break; } } } I want it to be that metadata items 7-12 have the .setContainerItem to be set to ModItems.itemCupcakePan some example code would be greatly appreciated
-
Can't install due to network issue (possibly)?
do you have java installed? is it a java jdk?
-
[Solved] [1.11.2-13.20.0.2226] Package Manager Throwing exceptions
if you are just trying to send a message to the player on login, use this code. I found it on another thread and had to modify for 1.11 public class PlayerJoinMessegeEventHandler { @SubscribeEvent public void PlayerJoin(EntityJoinWorldEvent event) { if(!(event.getEntity() instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) event.getEntity(); if(!event.getEntity().getEntityWorld().isRemote) { player.sendMessage(new TextComponentString("\u00A7a" + "Thank you, "+ player.getName() + ", for downloading " + Reference.modname + ", version " + Reference.version + "!")); } } } @EventHandler public void init(FMLInitializationEvent event){ MinecraftForge.EVENT_BUS.register(new PlayerJoinMessegeEventHandler()); } it basically just says thank you, playername, for downloading modname version!
IPS spam blocked by CleanTalk.