Jump to content

Recommended Posts

Posted

I have an Item that places blocks when you right click and it almost works' except that it is placing the blocks like you could place a torch. Ex: when you right click right under you it will place the block, then the block will push you out of the way.  I am having a hard time finding the method that is for block placement and not item placement.    If anyone could point me in the right direction I'd be grateful. 

Posted

if i understand correctly, you want it to work like a normal block? meaning, instead of it placing the block down and pushing you out, it shouldn't be placed at all unless you move out of the way?

 

anyway, just take a look at ItemBlock.class. you'll probably find what you want there

Posted

I've looked in that class And I see the onItemUse Method , the description says it's for items and not for blocks.  And I see the canPlaceItemBlockOnSide method and that one isn't quite working... It's checking for for a player that is one block lower than the player is. I'll try adding some +1s some where to seed if I can get it to work.  Thanks for your help.

Posted

I figured it out.. when I was checking where to place the block I was increment the (x,y,z) location twice.  I end up using a combination of the onItemUse and the canPlaceItemBlockAt method.  There is probably some easier way to do it, but it works so I wont touch it for a while.

 

When In doubt print all the vars!

Posted

if you actually read and understood the code, you'd know it's for blocks. almost all the vanilla blocks use that class. if you wanna make sure what you made is clean and if you wanna understand better how vanilla mc places its blocks down, here are some things you can do:

 

if you're patient and thorough enough, start at clickMouse(int par1) in Minecraft.class. follow and understand the code until you reach the point where it tries to use an item (or place a block down). it might take a while, but you'd get a pretty good understanding of how blocks are placed after you do that.

 

or you can try making a new block for testing. just a plain basic one and then create your own item for it that extends ItemBlock (doesn't have to be a subclass of ItemBlock if you know what you're doing). then play around with both your item class and your block class to see how they work together. canPlaceItemBlockAt is probably not working for you because you're probably already doing something else that's messing it up. which is why i suggest making a new block for testing (something clean).

 

of course you can just stick with what you have since you say it's working already, but then i doubt you really understand why it's working. it could help loads in the future if you really understand what's happening

Posted

if you actually read and understood the code, you'd know it's for blocks. almost all the vanilla blocks use that class. ...

I know that that class is for blocks, that is why i used it. I have an Item that places blocks when you right click on a surface.  I know why it wasn't working. 

 

 

... if you're patient and thorough enough, start at clickMouse(int par1) in Minecraft.class. follow and understand the code until you reach the point where it tries to use an item (or place a block down). it might take a while, but you'd get a pretty good understanding of how blocks are placed after you do that. ...

 

I didn't know where clicks where initially handled thanks for pointing that out.

 

 

 

 

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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