Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

TheRealMcrafter

Forge Modder
  • Posts

    137
  • Joined

  • Last visited

Posts posted by TheRealMcrafter

  1. What I am trying to do is to have it when you place a button, it swaps your current item with an item with higher damage, the problem I am having is that when I press the button, it takes the weapon from the slot, but it doesn't swap them, it just replaces the current held item with the swapped item, but doesn't take the current item and put it in the other slot.

     

    Here is my code for swapping:

     

     

    protected static void selectSlot(int slot)
    {
    	if ((slot < 0) || (slot > ) return;
    
    	InventoryPlayer inventory = mc.thePlayer.inventory;
    	ItemStack stack = inventory.getStackInSlot(slot);
    	inventory.setInventorySlotContents(inventory.currentItem, stack);
    	ItemStack stack1 = inventory.getStackInSlot(inventory.currentItem);
    	inventory.setInventorySlotContents(slot, stack1);
    }
    

     

     

     

     

    You are setting the inventory slot with your item, and then getting the item you just set. You want to do this:

    ItemStack slotStack = inventory.getStackInSlot(slot);
    ItemStack currentStack = inventory.getStackInSlot(inventory.currentItem);
    
    if (slotStack != null){
        inventory.setInventorySlotContents(inventory.currentItem, slotStack);
    } else {
        //return here? if you want to
    }
    
    if (currentStack != null){
        inventory.setInventorySlotContents(slot, currentStack);
    } else {
        //same as above
    }
    

     

    Also, I dont know if you can do these operations on the client side, since you are using Minecraft.getMinecraft().thePlayer (client side player)

  2. Try naming them something like SteamEngineWaterPortChanged, then back to steamEngineWaterPort

     

    I had this before, where I had SiliconOre, so I renamed it to siliconOre. Didn't fix the problem. Put it back to SiliconOre, then added something onto it. Then reverted it back to normal.

  3. I meant what super jedi said

    try this.getHealth()<=1000, is that what you meant?

     

    If you meant that, then you should have put that in your original post. How do you expect people to magically guess what you are doing?

     

    PS. why do you think that  if (this.getHealth() <= 1000){  sets the health, it gets it..

     

    Like I said above, you originally had

    if(this.gethealth = 1000<0){ 

    which Java is interpreting as trying to set the left side to the right side, so in this case, this.getHealth to false. You really need to read over what you write before you post it, because you make no sense whatsoever.

  4. The 72000 seems irrelevant in the way I do it, but I don't really know what it does.

     

    @SubscribeEvent
    public void decreaseBowUseDuration(PlayerUseItemEvent.Start event) {
    if (event.item.getItem() == null) {
    	return;
    }
    
    if (!(event.item.getItem() instanceof ItemBow)) {
    	return;
    }
    
    event.duration -= 10
    }
    

     

    The 10 can be any number from 0 to 18, I think. The higher the number is, the more the duration will be decreased.

    Doesn't seem to work when putting it in my main class file. Was there a specific spot to put this code?

     

    You need to make an event handler and register it in your main class file. Then you put that in the event handler. Regarding all of your other errors, delete that code Boonie gave you. He gave you 1.7.10 code when this is for 1.8.

  5. Seriously? How can your IDE even let you do something stupid like this???

     

     if(this.gethealth = 1000<0) 

     

    Here is whats happening:

     

    Mini Java Guy Inside Your Computer: Okay! I'm gonna do an if statement now!

    Mini Java Girl Inside Your Computer: Sweet! I haven't done one of those in a while. Ill help you out.

    Mini Java Guy Inside Your Computer: Gonna get this entity's health....

    Mini Java Girl Inside Your Computer: Okay, I'll set it to false...

    Mini Java Guy Inside Your Computer: Wait... you can't SET a variable by using a GETTER METHOD.

    Mini Java Guy Inside Your Computer: *Highlights this statement with a red squiggly line*

    Mini Java Guy Inside Your Computer: if(this.gethealth = 1000<0){

    Mini Java Boss Inside Your Computer: You're both fired!

    Console:

    java.lang.Error: Unresolved compilation problem: The left-hand side of an assignment must be a variable

     

     

    You are trying to set the health. You need

     if (this.getHealth() <= 1000){ 

     

    EDIT: Woops, totally scrolled past SuperJedi224's post.

  6. Everyone who posted here tried to help you. We are giving you suggestions to try, and you aren't even replying saying if the System.err.println() worked or not, and if it is being run clientside. We are normal people with jobs, and school, etc. We take the time to try and help you, and you dismiss it, and then make another post 5 minutes later asking us to spoon feed you code. So before you come here and tell us that no one tried to help you, read what we have said and do it.

  7. I don't think so.. I have a onUpdate method that constantly spawns the particles, and you can see the results of spawning one of them just fine.

     

    Like so:

    	if(equipped == stack){
    		world.spawnParticle("witchMagic", player.posX - 0.2, player.posY - 2, player.posZ - .5, 0f, 0f, 0f);
    

    and yes I know that I am spawning the particle 5 blocks into the ground, but it doesn't make a difference to not do that plus, the lava particles are huge so it will be very noticeable.

     

    I believe you want:

    if (equipped.equals(stack){
    } 

     

    == won't always do what you expect.

  8. Hey man, just an opinion passing by. I've been here for a while and I remember, when I started, that I was all about mod/source security.

    I even tried obfuscating source or trimming it from server classes (2nd I still have leftovers).

     

    There is just NO POINT in doing it. Seriously. Release beta, if they spread it - what's the big deal?

    I mean, there is no real way of providing 100% "safety". Not possible.

     

    As to problem - it's really easy if you step outside Java and GitHub.

    Get hosting, place php script, set keys in secured file. Make http request/response. Literally 1h of work.

    If you really want to key-checking systems like that I don't think GitHub is right place to do it (opinion).

     

    ... but why? :o

     

    Honestly, thanks for the opinion. I used to be like that with my source too. I'm not concerned about my source being released, I'm concerned about a tester releasing a ridiculously buggy mod to the public. And in reality, I could just send them unique download links and count downloads on them, but well, I tend to overcomplicate things sometimes. Just wanting to screw around with file sending really.

  9. I think you misunderstand. My beta testers cannot commit to my github. They get access to my beta builds, and report problems to my issues page. I dont want them spreading around the download link, so I'd like my mod to communicate with a file in my github repo and tell me if one of my testers is spreading around the link.

     

    (Also I need this for future use in my mod)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.