Jump to content

problems with onPlayerInteract (think)


monkeybee

Recommended Posts

hai there

 

im trying to make a item thats the only way to harvest bananas from the banana bunch but when u brake the banana bunch it brakes the block not return to age 0 (ive used parms harvest craft code for refrance)

so tryed to make the item do the same thing as right click harvest only on right clicking its doing nothing :(  anybody got a idea on to y the block brakes insted or turning back to age 0 OR y the banana picker is doing nothing on right click?

 

https://github.com/monkeybee11/monkeysmod/blob/master/src/main/java/com/monkeybee11/monkeysmod/item/ItemBananaPicker.java  banana pickers code 

 

https://github.com/monkeybee11/monkeysmod/blob/master/src/main/java/com/monkeybee11/monkeysmod/block/BlockBananaBunch.java banana bunch code 

Edited by monkeybee
forgot no 1 uses a lefthanded mouse ¬.¬
Link to comment
Share on other sites

56 minutes ago, monkeybee said:

on left clicking its doing nothing

Quote

PlayerInteractEvent.RightClickBlock event

I wonder why indeed... 

This is not what you use events for. Events are when you need to hook into existing behaviour, not when you need to create a completely new one. Just override Block#onBlockActivated, check if the item in the player's hand is your item and do what you need to do.

 

if (!(state.getValue(AGE) != 3)) {

		}

What is the purpose of this code? The condition will never be true and even if it was it does nothing.

 

56 minutes ago, monkeybee said:

y the block brakes insted or turning back to age 0

Well so far you've done absolutely nothing to change the default breaking behaviour, thus it breaks as all other blocks.

 

Link to comment
Share on other sites

29 minutes ago, V0idWa1k3r said:

I wonder why indeed... 

This is not what you use events for. Events are when you need to hook into existing behaviour, not when you need to create a completely new one. Just override Block#onBlockActivated, check if the item in the player's hand is your item and do what you need to do.

 


if (!(state.getValue(AGE) != 3)) {

		}

What is the purpose of this code? The condition will never be true and even if it was it does nothing.

 

Well so far you've done absolutely nothing to change the default breaking behaviour, thus it breaks as all other blocks.

 

MY BAD!!!! ive used a hard wired left handed mouse since ive used a pc so the buttions are swaped for me >.<
on right click then sry :P

im not 100% sure what the code dose was using parms code as a very close refraces bc befor had tryed to code it my self with only vanilla cocoa as refrance and it didt turn out well so something in parms mite have 3 ages insted of 2?

Edited by monkeybee
Link to comment
Share on other sites

11 minutes ago, monkeybee said:

im not 100% sure what the code dose was using parms code as a very close refraces bc befor had tryed to code it

Well you should then inspect your code and actually understand what it is doing. Programming without a clear understanding of what the code does is like trying to assemble a rocket without a manual or assembly markers.

 

What behaviour do you actually want? Afaik when you break a fruit in pam's it breaks like a normal block and doesn't revert to age 0. Pam's fruits are harvested by right-clicking.

Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

Well you should then inspect your code and actually understand what it is doing. Programming without a clear understanding of what the code does is like trying to assemble a rocket without a manual or assembly markers.

 

What behaviour do you actually want? Afaik when you break a fruit in pam's it breaks like a normal block and doesn't revert to age 0. Pam's fruits are harvested by right-clicking.

im lurning JAVA as im going along do better learning something by doing then sitting there watching/reading/taking lessens 

 

ive not used parms harvest craft since 1.5mc back then when the fruit was fully grown u punched it and it woud return to the 1st growth state (age 0) and drop its fruit

if u tryed to brake the fruit befor it was fully grown u woud still get a fruit BUT the "block" woud get destroyed

im trying to get something like that but 
1 it can only be harvested by the banana picker item
2 if u try to harvest it with anything else it will just not brake the block and send a message to the players chat (me know thats not even in my code im just trying to get part 1 working 1st) 

Link to comment
Share on other sites

Override Block#removedByPlayer, it fires when the block is broken by the player. Check whether the player is holding your picker item and if they aren't send your message and return false, otherwise invoke the base implementation(return super.removedByPlayer). That is if you want it harvested by breaking the block.

 

If you want to harvest the block with a right click then do what I've said earlier:

50 minutes ago, V0idWa1k3r said:

Just override Block#onBlockActivated, check if the item in the player's hand is your item and do what you need to do.

And by "do what you need to do" in this case I mean drop the item and set the block to air.

Link to comment
Share on other sites

2 hours ago, V0idWa1k3r said:

The condition will never be true

Yes it will, it's just ridiculous.

@monkeybee Just say value == 3

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

14 minutes ago, Animefan8888 said:

Yes it will, it's just ridiculous.

@monkeybee Just say value == 3

 

        if (!(state.getValue(AGE) !==3)) {


Syntax error on token "=", delete this token 
 

if ureplace the ! with a 1 it says the same error but on token "1"

Edited by monkeybee
Link to comment
Share on other sites

1 minute ago, monkeybee said:

Syntax error on token "=", delete this token 
 

I didn't say value !== 3

Did I?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

10 hours ago, monkeybee said:

im lurning JAVA as im going along do better learning something by doing then sitting there watching/reading/taking lessens 

Learning java through modding Minecraft is really painful, I suggest getting a basic understanding of java or at least OOP (Object Oriented Programming) in general first

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

8 hours ago, Cadiboo said:

Learning java through modding Minecraft is really painful, I suggest getting a basic understanding of java or at least OOP (Object Oriented Programming) in general first

the thing is as me said me learn stuff better by doing then learning minecraft is really the only thing vie got to "play about with" thats java ? 
the other stuff ive messed about with "coding" is
dont starve togeather modding (lua)
computercraft (lua)

nintendo labo (but thats more logic gate stuff so.....)

having a quick google on what OOP is .....guess nintendo labo coud be classed as that if not....mcreator did use that program befor giving up on how limmited it is to ppl who dont understand java and moving on to eclips

 

but HEY at leace ive got to the point of being able to add item blocks and custom 3d json models on my own now so baby steps XD

Link to comment
Share on other sites

56 minutes ago, monkeybee said:

but HEY at leace ive got to the point of being able to add item blocks and custom 3d json models on my own now so baby steps XD

Baby steps are the right way to go. However, instead of starting off with modding minecraft you could have started off with something like a calculator or a very simple game that will teach you the basics of Java itself instead of trying to make a modification to an already existing application via an external API.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

ok so the thing me want to happen still aint happerning ive removed all the cote from banana picker so its just a plain item and added 

 

	public boolean onBlockActivated(NonNullList<ItemStack> drops, IBlockAccess world, EntityPlayer playerIn, BlockPos pos, IBlockState state,int fortune) {
		ItemStack itm = playerIn.getHeldItemMainhand();
		if(!itm.equals(TutorialItems.BANANA_PICKER) == true)
			return true;
			drops.add(new ItemStack(TutorialItems.BASIC_ITEM, 6));
			
			if(!itm.equals(TutorialItems.BANANA_PICKER) == false); {
				playerIn.sendMessage(new TextComponentString("cant reach that from here if only there was a banana picker"));
			return false;
			}
		
	}

to banana bunch and // out the code for itemdrop but.....it dose nothing ?

right click is doing nothing

and braking the block is making the stem drop now ima confused monkey

https://github.com/monkeybee11/monkeysmod/blob/master/src/main/java/com/monkeybee11/monkeysmod/block/BlockBananaBunch.java

Link to comment
Share on other sites

2 hours ago, monkeybee said:

if(!itm.equals(TutorialItems.BANANA_PICKER) == true)

An ItemStack will never be equal to an item. Also that is not how you make a condition.

 

2 hours ago, monkeybee said:

drops.add(new ItemStack(TutorialItems.BASIC_ITEM, 6));

What is this mysterious drops object and how does it work?

 

2 hours ago, monkeybee said:

if(!itm.equals(TutorialItems.BANANA_PICKER) == false); { playerIn.sendMessage(new TextComponentString("cant reach that from here if only there was a banana picker")); return false; }

Again, this is a horrific way of making conditions. There is so much unnecessary stuff in it. Also you terminated whatever the condition was supposed to control with a ; meaning that the code in your brackets will get executed regardless.

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

An ItemStack will never be equal to an item. Also that is not how you make a condition.

 

What is this mysterious drops object and how does it work?

 

Again, this is a horrific way of making conditions. There is so much unnecessary stuff in it. Also you terminated whatever the condition was supposed to control with a ; meaning that the code in your brackets will get executed regardless.

1 ah ok

 

2....dont know makes the itemdrop?

 

3 ive got nothing to say just trying my best :s

Link to comment
Share on other sites

You should have a basic grasp of java before making a mod.

On 10/11/2018 at 1:39 AM, Animefan8888 said:

Baby steps are the right way to go. However, instead of starting off with modding minecraft you could have started off with something like a calculator or a very simple game that will teach you the basics of Java itself instead of trying to make a modification to an already existing application via an external API.

 

onBlockActivated(params...) {

  if(age==fully grown) {

    if (stack.getItem() == ModItems.BANANA_PICKER) {

      drops.add(new ItemStack(ModItems.BANANA));

    } else {

      //tell player they need to use a banana picker

    }

  }

}

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

14 hours ago, Cadiboo said:

You should have a basic grasp of java before making a mod.

now the confusing part of telling me this

ppl say that after u start but the  u have dw20 vaskii amadeus laxmanos?(think notsure) on the minecraft modded pannel at minecraft earth who say modding minecraft is a good place to start so im like.....who the heck do u baleave :s

Link to comment
Share on other sites

18 minutes ago, monkeybee said:

now the confusing part of telling me this

ppl say that after u start but the  u have dw20 vaskii amadeus laxmanos?(think notsure) on the minecraft modded pannel at minecraft earth who say modding minecraft is a good place to start so im like.....who the heck do u baleave :s

Do you understand the basic concepts of Object Oriented Programming? Do you understand basic java? Minecrafts code is badly and confusingly written and forge is complicated. You should have a good basic understanding of both before starting Modding. I’ve been programming for a few years and decided to learn java through modding and it was pretty (very) hard to just jump in and learn the basics, not to mention all the special stuff and intricacies of modding. It’s possible, but you need to be receptive and read a bunch of documentation and take baby steps. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

1 hour ago, monkeybee said:

say modding minecraft is a good place to start

Nobody is saying that modding is a good place to start if you know nothing about programming or the language. It really isn't. Modding expects you to know quite a lot about how java functions. Minecraft isn't a good place to learn how to code in java. It's too complicated for it's own good and in a lot of cases is plain bad as in it teaches you bad practices. It is a fine place to start if you have the basics nailed down. Or at least know other programming languages which feature OOP.

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

Nobody is saying that modding is a good place to start if you know nothing about programming or the language. It really isn't. Modding expects you to know quite a lot about how java functions. Minecraft isn't a good place to learn how to code in java. It's too complicated for it's own good and in a lot of cases is plain bad as in it teaches you bad practices. It is a fine place to start if you have the basics nailed down. Or at least know other programming languages which feature OOP.

dont want this to go off topic im just posting my sorce of ppl saying modding mc is a good place to start
and sry it wasent laxmanos it was king lemmin

 



 

Spoiler

 

but like me said dont want it to go of topic now ive posted the sorce of my info S:

 

 

image.png

Link to comment
Share on other sites

Just because it worked for one person does not mean that it's:

a) a good idea

b) going to work for you

 

(Thinking otherwise is called Survivorship Bias)

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • C:\Minecraft Server>java -Xmx4096M -Xms1024M -jar server.jar nogui Starting net.minecraft.server.Main ERROR StatusConsoleListener Unable to delete file C:\Minecraft Server\logs\latest.log: java.nio.file.FileSystemException C:\Minecraft Server\logs\latest.log: The process cannot access the file because it is being used by another process ^CTerminate batch job (Y/N)?
    • Oke i tried to download a different mod and try that out on my server and i get the same error. Now i know for a fact that my port forwarding and server is working properly, because i can join them without adding any mods into the server file, but then i dont know what i am doing wrong 
    • Salutation to you ladies and gentlemen, i must confidently say a very big thanks to Fastfundrecovery8 AT GMAIL COM for their tremendous action taken over my case immediately brought to their table, i saw how the whole process was going, and i wisperred to myself and said indeed i am previlledge to know such a legitimate recovery company who is very understable and do not stress their client over recovery software tools, Fastfunds Recovery are good in keeping to time, punctuality, I was scammed last year December 18, i realized that my long investment which i inteded to withdraw has long been a scam, got so frustrated, hired 4 recovery hackers which ended up taking money from me and i couldn't contact them anymore, i went through emotional pains and betrayer, wasn't easy for me at that moment, am very greatful for FastFunds Recovery, who was referred to me by a civil engineer who i was opportuned to share part of my story with and he was like i have a cyber friend do reach and say i'm from Pato's, that's how i got in touch with fastfundsrecovery8(@)gmail(.)com, do inform FastFunds recovery for any cyber issues. Fastfundsrecovery8 AT GMAIL WILL ALWAYS HELP GET BACK YOUR FUNDS.
    • Hello everyone i have made a server with forge and have added pixelmon into the server. But for some reason i keep getting "Internal Exception: io.netty.handles.codec.DecoderException: Not enough bytes in buffer, expected 105, byt got 48". I tried upping the ram of the server to 2GB but it didnt solve anything. I have 16 GB of ram on my pc (where i host the server), but i cant seem to get it to work. Pixelmon does work when i try to go into singleplayer, but for some reason just doesnt work online   Edit: server logs sais nothing aswell [18:55:49] [ServerMain/INFO]: Environment: Environment[accountsHost=https://api.mojang.com, sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD] [18:55:50] [ServerMain/INFO]: Loaded 7 recipes [18:55:51] [ServerMain/INFO]: Loaded 1271 advancements [18:55:51] [Server thread/INFO]: Starting minecraft server version 1.20.2 [18:55:51] [Server thread/INFO]: Loading properties [18:55:51] [Server thread/INFO]: Default game type: SURVIVAL [18:55:51] [Server thread/INFO]: Generating keypair [18:55:51] [Server thread/INFO]: Starting Minecraft server on *:xxxx [18:55:51] [Server thread/INFO]: Using default channel type [18:55:51] [Server thread/INFO]: Preparing level "world" [18:55:52] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld [18:55:53] [Worker-Main-8/INFO]: Preparing spawn area: 0% [18:55:53] [Worker-Main-8/INFO]: Preparing spawn area: 0% [18:55:53] [Worker-Main-8/INFO]: Preparing spawn area: 0% [18:55:53] [Worker-Main-12/INFO]: Preparing spawn area: 0% [18:55:54] [Worker-Main-11/INFO]: Preparing spawn area: 31% [18:55:54] [Server thread/INFO]: Time elapsed: 2344 ms [18:55:54] [Server thread/INFO]: Done (2.865s)! For help, type "help" [18:55:56] [User Authenticator #1/INFO]: UUID of player kemal007023 is 9a2a1dff-fa06-4e29-b57d-b1e6afb2db87 [18:55:56] [Server thread/INFO]: kemal007023[/xxxx] logged in with entity id 271 at (9.497695306619189, 68.0, 10.973182362716573) [18:55:56] [Server thread/INFO]: kemal007023 joined the game [18:55:56] [Server thread/INFO]: kemal007023 lost connection: Disconnected [18:55:56] [Server thread/INFO]: kemal007023 left the game [18:56:00] [User Authenticator #2/INFO]: UUID of player kemal007023 is 9a2a1dff-fa06-4e29-b57d-b1e6afb2db87 [18:56:00] [Server thread/INFO]: kemal007023[xxxx] logged in with entity id 272 at (9.497695306619189, 68.0, 10.973182362716573) [18:56:00] [Server thread/INFO]: kemal007023 joined the game [18:56:00] [Server thread/INFO]: kemal007023 lost connection: Disconnected [18:56:00] [Server thread/INFO]: kemal007023 left the game  
    • Hi, im making a BlockEntity that can contain fluids, and render them in the GUI, only one fluid works perfectly, I can fill or drain it, sync it to the client, and render it. The problem comes when i try to have two fluids in the same GUI, depending on what I delete or leave, the fluids act differently; for example, deleting both of them from "saveAdditional" and "load" methods makes that the fluids cannot render. Also, it can only render one fluid alone, or again, render one fluid, but twice (copies one fluid to the other one). FYI the left one is water, the right one is a red custom fluid. How can I fix this? BoilerBlockEntity: https://pastebin.com/e6b2U3sD BoilerMenu: https://pastebin.com/D375yCNr BoilerScreen: https://pastebin.com/WMrK83Du 
  • Topics

×
×
  • Create New...

Important Information

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