Jump to content

Fizzixnerd

Members
  • Posts

    3
  • Joined

  • Last visited

Fizzixnerd's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thank you very much. I will check how to use packets. For the sound, I still can't get it to work right now. I'll post back if I figure it out.
  2. I have the following class (Scala). class ItemMyItem extends Item { setRegistryName("my_item") setUnlocalizedName("my_item") maxStackSize = 1 setCreativeTab(CreativeTabs.TOOLS) def spawnParticles(world: World, pos: BlockPos): Unit = { for (_ <- 1 to 50000) { val randX = Random.nextDouble() val randZ = Random.nextDouble() val randPlusX = Random.nextBoolean() val randPlusY = Random.nextBoolean() val randPlusZ = Random.nextBoolean() val d0 = pos.getX + 20.0 * (if (randPlusX) randX else -randX) val d1 = pos.getY + (if (randPlusY) randX else -randX) * 6.0 / 16.0 val d2 = pos.getZ + 20.0 * (if (randPlusZ) randZ else -randZ) world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, 20.0 * (if (randPlusX) randX else -randX), 1.0, 20.0 * (if (randPlusZ) randZ else -randZ)) } } override def itemInteractionForEntity(stack: ItemStack, playerIn: EntityPlayer, target: EntityLivingBase, hand: EnumHand): Boolean = { super.itemInteractionForEntity(stack, playerIn, target, hand) playerIn.playSound(MyMod.mySound, 1.0F, 1.0F) spawnParticles(playerIn.getEntityWorld, playerIn.getPosition) true } } The problem is that when I test in multiplayer, only the person using the item can see the particles and hear the sound. They can see the arm swing animation on use. I was wondering why that was, and how I could get other players to see/hear them. Only on the client proxy do I register the sound. I am using vanilla particles, so I don't ever register those. I checked the docs and they seem to suggest it should be run on both sides automatically. Any help would be appreciated.
  3. I'm adapting this tutorial (which is quite old) to a newer Forge version. One of the things you do in it is make a "wheat and steel" item. This is a damageable item that plants a seed. Tutorial suggests as an extension that we add the ability to hoe the ground first before attempting to place the seed. I thought I would try to just reuse the implementations of ItemHoe and ItemSeeds. Here is my code (Scala). package com.fizzixnerd.mymod import net.minecraft.creativetab.CreativeTabs import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.{Item, ItemHoe, ItemSeeds, ItemStack} import net.minecraft.util.{EnumActionResult, EnumFacing, EnumHand, ResourceLocation} import net.minecraft.util.math.BlockPos import net.minecraft.world.World import net.minecraftforge.common.IPlantable import net.minecraftforge.fml.common.registry.GameRegistry object ItemWheatAndSteel extends Item { setRegistryName("wheat_and_steel") maxStackSize = 1 setMaxDamage(64) setCreativeTab(CreativeTabs.TOOLS) private val virtualSeeds = GameRegistry.findRegistry(classOf[Item]).getValue(new ResourceLocation(("minecraft:wheat_seeds"))) override def onItemUse(player: EntityPlayer, world: World, pos: BlockPos, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): EnumActionResult = { val itemStack = player.getHeldItem(hand) if (!player.canPlayerEdit(pos.offset(side), side, itemStack)) { EnumActionResult.FAIL } else { // Create a virtual hoe to till the ground first. val virtualHoe = new ItemHoe(Item.ToolMaterial.IRON) val success = virtualHoe.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) if (success == EnumActionResult.SUCCESS) { val success = virtualSeeds.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) if (success == EnumActionResult.SUCCESS) { itemStack.damageItem(1, player) } success } else { success } } } } This does not give the desired behavior. After using the item once, it disappears from the players inventory. What happens is that inside ItemSeeds class is that at the end of planting the seed, it decrements the number of items the player is holding, whatever that happens to be. Is there a way to reuse the behavior of ItemSeeds and ItemHoe without reimplementing them directly in my own class?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.