Jump to content

Heen

Members
  • Posts

    9
  • Joined

  • Last visited

Heen's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm not doing all the specific handling of which items are getting damaged (like checking to see if they are the ones applicable), but at the moment the only thing applying the potion effect is when the player has set items equipped in the mainhand + offhand. Like dual wielding weapons. Will report back when I change the event parameters. EDIT: Works perfectly now! Thanks diesieben07!
  2. Hello again! I hope this isn't too difficult to conquer, but I'm trying to make a potion effect that is similar to strength. Specifically trying to take the current damage being done by the player and multiply it by 1.75 while under the effect. The potion effect is being applied to the player, but the effect of it is not working as intended. This is my not quite exciting attempt: @SubscribeEvent public void newPotionHandling(AttackEntityEvent e){ if(e.getEntityPlayer().isPotionActive(MyMod.Strengthlikepotion)){ if(e.getEntityPlayer().getActivePotionEffect(MyMod.Strengthlikepotion).getDuration()==0){ e.getEntityPlayer().removePotionEffect(MyMod.Strengthlikepotion); return; } else{ EntityPlayer inquesiton = e.getEntityPlayer(); ItemStack primary = inquesiton.getHeldItemMainhand(); ItemStack seconary = inquesiton.getHeldItemOffhand(); if(primary.isItemStackDamageable()) primary.damageItem(1, inquesiton); if(seconary.isItemStackDamageable()) seconary.damageItem(1, inquesiton); //System.out.println(e.getEntityPlayer().getHeldItemOffhand().toString()); e.getTarget().attackEntityFrom(DamageSource.GENERIC,(float) (e.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()*1.75)); } } } The attackEntityFrom() call is entirely preventing the damage type from the weapon/empty hand/tool from taking effect at all and is only doing the damage done with the method. Sort of like assigning damage to the target on attack. I feel as though this approach is not the right way of doing it, any experience or even better the reference to how the vanilla strength potion works would be greatly appreciated because I can't seem to get to it with my IDE. Thanks!
  3. Currently doing the calls in the onItemUse method of an item to generate the structure to make sure it looks okay before putting it in my structureGen class. I'm still trying to do the entire structure generation via just setBlockStates, I'm aware of the newer structure based method, but haven't given it a shot. Going to remove the NBT nonsense to see maybe if its conflicting with the spawner logic. UPDATE: This fixed it. Seems to work fine now. Thanks guys!
  4. Hello all again! I'm trying to determine how to set a mob spawner to a certain mob and I feel like I'm doing something wrong. From what I read, the mob spawner needs to be set after its placed. worldIn.setBlockState(new BlockPos(x+2,y,z+2), Blocks.MOB_SPAWNER.getStateFromMeta(1)); TileEntityMobSpawner spawn = (TileEntityMobSpawner)worldIn.getTileEntity(new BlockPos(x+2,y,z+2)); NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound2 = new NBTTagCompound(); spawn.writeToNBT(compound); compound2.setString("id","minecraft:zombie"); compound.setTag("SpawnData", compound2); spawn.readFromNBT(compound); This is how I was attempting to do it first with some confusing results like this: https://i.gyazo.com/feb4ff50914044fd7d15e8e6ce9d902e.mp4 Unsure of how the mob spawner changed to the default entity after one spawn event. I read in another post to try modifying the mobspawnerbaselogic, but this appears to have not done anything. MobSpawnerBaseLogic john = spawn.getSpawnerBaseLogic(); john.setEntityId(new ResourceLocation("Zombie")); //spawn.update(); Any help is appreciated!
  5. That's fairly straight forward, I was just confirming that the tickevent itself holds no information regarding the player. Thanks for the clarification though, I am fairly new to modding and am still trying to determine which side can handle what.
  6. I would love to see how a ClientTickEvent itself could fetch information about a specific player's armor slot contents. Being it has no field data for the player itself.
  7. So I would need to create a music ticker to call the playMusic() method. The question becomes how do I call this if I shouldn't utilize the timing generated from the ClientTickEvent method? The client tick event itself cannot determine whether or not a player is wearing armor either, where as a playerOnTick event can. I would imagine I can put the music ticker play music method call in the checkForPartyGlasses block of the onPlayerTick method, but wouldn't this be called, like a lot of times and calling playMusic seems to stop the current music if its the same as the one its trying to play to start it again?
  8. @SubscribeEvent public void onClientTick(ClientTickEvent event){ if(secondCounter==0){ System.out.println("Play music here!"); } secondCounter++; if(secondCounter>1238){ System.out.println("Reset at "+secondCounter); secondCounter = 0; } if(event.phase == Phase.START){ System.out.println("We are in phase start at "+secondCounter+" ticks."); } if(event.phase == Phase.END){ System.out.println("We are in phase end at "+secondCounter+" ticks."); } if(event.phase != Phase.END&&event.phase != Phase.START){ System.out.println("We are in an unknown phase."); } } So from what I'm seeing from playing around with this here is, that there are 40 ticks per second (which was just me being dumb), Minecraft is always calling the onClientTick even when the game itself isn't "playing" (like at the menus), and these START and END phases are the only two phases in which is goes through unless forced into another custom phase. They kind of act like a rising/falling edge of clock and the frequency is changing from START to END every tick. I know this is bad for the game itself, creating lag from flushing the print buffer so timing isn't perfect, but close enough. I will try fudging some code in here and return to discuss potential issues/successes. Thanks a bunch diesieben07!
  9. Hello MinecraftForge forum users, I have been struggling like crazy to get an item that's simple in theory to exist, but it appears the constraints of what you can and cannot do within Minecraft is a bit inconsistent or unexpected for me. I'm hoping those with more experience can help me out, and thank you for taking the time to help if you do! I'm trying to create a piece of armor that will play music for the user while its being worn for the local user only. I have tried handling this problem using the EventHandler and in the ModArmor classes of my mod and I can't find a best way of doing this. Here is my, what I thought to have been my closest attempt yet: @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int slot, boolean inHand) { if (checkForPartyGlasses((EntityPlayer)entity)&&entity instanceof EntityPlayer) { System.out.println(this.partyCount); if(this.partyCount==0||this.partyCount==1){ System.out.println("Play music"); if(!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying((ISound)ModMusic.partyMusic)) entity.playSound(ModMusic.partyMusic, 100, 1); } this.partyCount++; if(this.partyCount>1180){ this.partyCount=0; } } I took some inspiration from my coding in Verilog to make some type of clock counter. The item itself has a partyCount property initialized to 0 (I'm also assuming that this is unique for all players with this item in a server scenario). I am checking for both 0 and 1 to start playing because of what I presume to be multi threading causing the actual playSound method not to call when the print statement for play music to not. The main idea here is that I want to have some kind of counter, counting the number of ticks that have passed and after a certain duration have passed, it will replay the sound again. Problems: Where I read onUpdate is called every tick is FALSE. It is called much more frequently and variable to the number of PartyGlasses items you have, also showing that the this.partyCount is only unique to all instances of PartyGlasses as opposed to each individual item instance. With one item it's called about 45-60 times a second. In the line: if(!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying((ISound)ModMusic.partyMusic)) The game will crash entirely even though it is being called, at most, twice per full song cycle. I am unsure why this is illegal to be called in the ModArmor class. What I am trying to do: I would like for the song to be played every 618 ticks (20/second) if the player is wearing the glasses and only to the player. Thanks for reading, and any help/direction is greatly appreciated! COMPLETE SIDE QUESTION: Is there an easy way to have animated armor textures (ie. using .mcmeta files like for item textures)?
×
×
  • Create New...

Important Information

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