Jump to content

[SOLVED ]Developing custom crafting recipes things


Whompy

Recommended Posts

I have two blocks that I am trying to use to craft items from my mod. The first block when right clicked, is supposed to check for an item above it in this case a glass block, then check for a ball of magma cream and a modded item I made in the first two slots of the container. However, nothing is happening when the block is right clicked so I assume one of the if statements is faulty.

 

 

Here's my onblockactivated method (idk why indents are weird in eclipse they look fine):

 

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    
    
	if(!playerIn.isSneaking()) {
		if(worldIn.getBlockState(pos.down(1)) == ModBlocks.Magic_Sponge.getDefaultState()) {		
            List<EntityItem> entities = worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1,pos.getY() + 1, pos.getZ()+1));
            for (EntityItem entity : entities) {
                if(entity.getItem().getItem() == glass.getItem()) {
                    TileEntityMagicSponge tileentity = (TileEntityMagicSponge)worldIn.getTileEntity(pos.down());
                    Item Magma_cream = tileentity.getStackInSlot(1).getItem();
                    Item Magic_Caytalist = tileentity.getStackInSlot(2).getItem();
                    ItemStack stack = entity.getItem();
                    if(Magma_cream == Items.MAGMA_CREAM.getItemById(378) && Magic_Caytalist == ModItems.CAYTALIST.getItemById(4110)) {
	                	if(!worldIn.isRemote) {
	                        while (stack.getCount() > 0) {
	                        	EntityItem item = new EntityItem(worldIn, pos.getX()+0.5F, pos.getY(), pos.getZ()+0.5F, Magic_orb);
	                			worldIn.spawnEntity(item);
	                    		stack.shrink(1);
	                    		tileentity.removeStackFromSlot(0);
	                    		tileentity.removeStackFromSlot(1);
	                    		worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_FIREWORK_LAUNCH, entity.getSoundCategory(), 0.8F, 0.8F + entity.world.rand.nextFloat() * 0.4F);
                        		}
                        	}
                        }
                	}  
        		}
            }
		}
	return enableStats;
	}
}

 

 

 

 

Edited by Whompy
bad spelling
Link to comment
Share on other sites

6 minutes ago, Whompy said:

new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1,pos.getY() + 1, pos.getZ()+1)

This AABB only contains the full 1x1x1 volume that your block occupies. If you want the space above it you need to offset the Y by more than 1 unit (and you can offset the bottom by +1 to avoid needlessly checking the volume your block fills).

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

3 hours ago, Draco18s said:

This AABB only contains the full 1x1x1 volume that your block occupies. If you want the space above it you need to offset the Y by more than 1 unit (and you can offset the bottom by +1 to avoid needlessly checking the volume your block fills).

I am aware of this my block is about the size of a slab so it's fine

Link to comment
Share on other sites

On 12/29/2019 at 10:07 AM, loordgek said:

dont use getItemById

 

where does enableStats come from?

 

entity.getItem().getItem() == glass.getItem()

what is glass

 

can you post your code on github so we can see everything

I am too lazy to make a github, sorry for not responding earlier btw

 

Here's the variables I forgot to put in the thread

 

when I created the public Boolean, enablestats was what appeared in the autogenerated return statement. I honestly don't know what it does nor have I looked into it

 

	ItemStack glass = new ItemStack(Blocks.GLASS);
	ItemStack Magic_orb = new ItemStack(ModItems.ORB_OF_CHANNELING);
	Item sponge = Item.getItemFromBlock(Blocks.SPONGE);

 

Edited by Whompy
Link to comment
Share on other sites

There's no reason to create a glass stack if you're just going to call getItem() on it.

 

entity.getItem().getItem() == Items.GLASS

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

8 hours ago, Ugdhar said:

Not doing so makes it harder to debug your issue, and a lot of people are "too lazy" to debug partial code.

ok fine, my question why do u need to see more of my code?

 

Is there more code relating to the right click function that I should take a look at?

Edited by Whompy
Link to comment
Share on other sites

Because we can't run it. If we can't run it we can't use a debugger. If we can't use a debugger all we can do is guess.

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.



×
×
  • Create New...

Important Information

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