Jump to content

TheRealMcrafter

Forge Modder
  • Posts

    137
  • Joined

  • Last visited

Everything posted by TheRealMcrafter

  1. Dont you need an @SidedProxy annotation in your main class?
  2. Probably a better way, but I would create a TileEntity for the block, and then in the updateEntity() method you can time it. updateEntity() is called every tick, and there are 20 ticks in a second.
  3. Actually, that tutorial is the best. You put the client code in the wrong event. Jabelar said FMLPostInitializationevent. You put it in FMLInitializationEvent
  4. Am I on the right track here? @Override public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setByte("renderValue", this.renderValue); nbt.setString("state", this.state); NBTTagCompound siren = new NBTTagCompound(); for (int i = 0; i < sirens.size(); i++){ siren.setInteger("x" + i, sirens.get(i).xCoord); siren.setInteger("y" + i, sirens.get(i).yCoord); siren.setInteger("z" + i, sirens.get(i).zCoord); siren.setInteger("listSize", i); } NBTTagList list = new NBTTagList(); list.appendTag(siren); nbt.setTag("sirens", list); } @Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); this.renderValue = nbt.getByte("renderValue"); this.state = nbt.getString("state"); NBTTagList list = (NBTTagList) nbt.getTag("sirens"); NBTTagCompound siren = list.getCompoundTagAt(0); for (int i = 0; i < siren.getInteger("listSize"); i ++){ TileEntity tile = new TileEntity(); //tile.xCoord is (siren.getInteger("x" + i); this.sirens.add(tile); } }
  5. Title says it all. How would I go about saving ArrayList<TileEntity> to NBT in my tile entity class?
  6. If you go into an MC world and spawn about 15 - 20 mobs in an enclosed space, they start to spam that weird footstep sound. And that makes sense now, because killing off one villager will allow the sound to play a bit longer than before.
  7. Well that stinks. What about canceling the footstep sounds?
  8. Hmm, any way to change the priority of my sound in some way?
  9. So can I put my sound on a separate thread? Or is that just not possible. I thought I saw something about this before.
  10. Neither do I. You know the sound that plays when you spawn a ton of mobs in a limited space? It sounds sorta like footsteps running. If i have a few villagers, and I activate the sound and they panic, the siren keeps playing. If there are closer to 20 or so villagers, and I activate the siren and they panic, as soon as that strange footstep sound starts playing, the siren cuts out. Its like Minecraft is stopping my sound based on priority or something like that. Can you think of a workaround for this?
  11. https://gist.github.com/TheRealMcrafter/9f460f45db6b094097b3
  12. Okay, so then what can I do about my sirens cutting out?
  13. Do I actually need packets, or can I just mark the block for update? Edit: Marking the block for update seems to work fine, it pushes the correct shouldStop value to the client, and then the client retrieves that and uses it.
  14. playerIn is a name Ernio assigned to EntityLivingBase. Basically you want to check if EntityLivingBase is an instance of EntityPlayer. In java its a simple as this: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. } return false; } If the Entity is a player, then we want to replace the item. If it is a zombie, or a chicken, we don't. So we can add an else statement. public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. return true; } else { //The Entity Is Not A Player. return false; } } Since the entity is a player, we want to get the current stack theyre holding, and then replace it with your own. You can do this by casting the Entity to EntityPlayer: EntityPlayer player = (EntityPlayer) theEntityYoureChecking; ^ That is called "Casting" and then getting the slot theyre currently using, like this: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot= player.inventory.currentItem; //The Entity Is A Player. return true; } else { //The Entity Is Not A Player. return false; } } To replace it with your own items, you need to create a new ItemStack() with the items you want. It is done like this: ItemStack stack = new ItemStack(ItemYouWantHere, AmountOfItems); an example: ItemStack stack = new ItemStack(Items.egg, 5); This would make a new ItemStack with 5 eggs in it. You can add that to your method. public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot = player.inventory.currentItem; ItemStack stack = new ItemStack(Items.egg, 5); return true; } else { //The Entity Is Not A Player. return false; } } Now, it is very simple. Just replace the players current held ItemStack with the one you created. That is done like this: player.inventory.setInventorySlotContents(slotToPutItIn, itemStackToPut); Since we already have the slot the player is currently using, and we have out stack to put in it, we can add the final part to our method: public boolean onEntitySwing(EntityLivingBase theEntityYoureChecking, ItemStack theItemStackTheEntityIsHolding){ if (theEntityYoureChecking instanceof EntityPlayer){ //The Entity Is A Player. EntityPlayer player = (EntityPlayer) theEntityYoureChecking; Int slot = player.inventory.currentItem; ItemStack stack = new ItemStack(Items.egg, 5); player.inventory.setInventorySlotContents(slot, stack); return true; } else { //The Entity Is Not A Player. return false; } } Hope I helped!
  15. Nothing has changed, except for me updating the shouldStop field to the client. It only stops when you can start to hear the villagers footsteps running, at about 20 or so villagers spawned.
  16. Do I have to put my sound on a separate thread? I think I saw something like this before.
  17. Well I figured it out. It only happens when I have around 20 villagers near the siren. I think the sound of the villagers running is stopping my sound. Any way to fix this? It doesnt happen when theres only a few villagers.
  18. So I can just mark the block for update? EDIT: I put a System.out.println(); in the shouldStop method. It isn't called, but the sound still stops. The siren doesnt stop until props.isScared = true; is called.
  19. It seems to work fine, even on a dedicated server. Any idea why my sirens stop when I implement that AI?
  20. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){ if (!world.isRemote && player.isSneaking()){ //Player is Sneak + Right Clicking } else { //Player is just clicking } return true; }
×
×
  • Create New...

Important Information

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