Jump to content

Recommended Posts

Posted

Hello,

 

i have made water finite in my mod and now water bottles are the only item was not suck a water source like the bucket. Now i try to catch all blockstates that water can be have:

 

At the moment i catch this with:

 

BlockPos pos = new BlockPos(event.getHitVec());
IBlockState state = event.getWorld().getBlockState(pos);

if (state != null && state.getBlock() == Blocks.WATER)

 

But it seems that fluid are not so easy catchable. Some States of the Water Block can i not catch. Only direct water blocks with an solid block under can i catch. No water blocks under water and so on.

 

How catch the Minecraft Bucket Fluid Blocks like Water?

 

Has anybody a solution?

 

Thx

Posted

Hello,

 

i mean the Vanilla Bucket suck up Water Sources when i take water with the bucket, with finite water fluid. Means Water Bottles suck up no Water Source and make the finite water fluid sensless.

 

The Bucket does this all very good right. He trigger all BlockStates from Water:

 

I trigger with this:

state.getBlock() == Blocks.WATER

only the water source when a block is under this water source.

 

I think the problem is that the WaterBlock does not are solid and slight transparency, i think. When i trigger solid blocks it functioned perfectly.

 

I have many situations where the Vanilla-WaterBottle-NoWaterSource will be triggered, as an example when i try to suck up wit water bottle deep water sources.

 

And therefore i must find a BlockState where i can excactly trigger water like the Vanilla Bucket, or another workaround that i can suck up water sources exactly like the Vanilla Bucket.

 

 

Posted

Yes exactly.

 

My only for Solid Blocks 100% functioned Solution is:

 

BlockPos pos = new BlockPos(event.getHitVec());
IBlockState state = event.getWorld().getBlockState(pos);

if (state != null && state.getBlock() == Blocks.WATER)
{
	event.getWorld().setBlockToAir(pos);
	event.getWorld().playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F);
	event.getEntityPlayer().setHeldItem(event.getHand(), giveBottleBack(event.getItemStack(), event.getEntityPlayer(), new ItemStack(Items.POTIONITEM,1,(byte)0)));
}

 

And this don't functioned like the Vanilla Bucket. The Vanilla Bucket make it better :) . The Vanilla Bucket trigger the Block Water (Water Source) perfectly.

Posted

Yeah cool i study the code. Very intresting for me. I Only want a open source mod convert to 1.11.2 from 1.10.2. The original Mod has the same problems i have.

 

i study:

http://book2s.com/java/src/package/net/minecraft/item/itemglassbottle.html

and

http://book2s.com/java/src/package/net/minecraft/item/itembucket.html

 

seems old.

 

How i can see, i trigger 2 BlockStates first my own and second the vanilla glassbottle. Hu Yeah my first Day after decades of non JAVA Prorgamming ;) (php,python and so on but today i have say i want this mod for 1.11.2 and this must i made myself :) ).

 

Sorry but i think in my very old brain that i can easy overwrite Objects in Java:

 

@Override
public class ItemGlassBottle extends Item {}

 

And then complete rewrite the ItemGlassBottle. Fuhhhh :) .

 

Knows anybody a newer Site with the source code from 1.11.2?

Posted

I have no IDE for Java, i'm a WebDeveloper :) , i have converted the original mod from 1.10.2 to 1.11.2 and must seen that the original mod don't functioned. Same Issues on 1.10.2 and now i am here with my notepad++ and gradle pure :) .

 

The Mod is functioned like the 1.10.2 i should be happy with the buggy original functions on 1.11.2. With the study of the orignal code from GlassBottle and Bucket i know now whats the problem, but with no solution.

 

Also it gives no Website with the newest decompiled code? Only decompile with MCP-Packet?

 

So its look like i must deactivate the original WaterBottle, coding a new WaterBottle and implement the Bucket-Code.

 

Has noboby another Solution, how i easier can implement an new method for sucking up water with the GlassBottle?

The only problem is the original trigger from OrignalClass ItemGlassBottle, the code from the Bucket are useless when 2 Objects trigger the same Blockstate, my Object and the OrignalObject.

 

Why has Mojang the GlassBottle not simple made with an BlockToAir :):):):):):):):):) ?

Posted

I think that his problem is the following:

He made all water in the world finite and is now trying to achieve correct item behaviour.

Water buckets behave just fine as they remove the water block they are used on.

However glass bottles don't. They just fill up with water and the block is not removed.

Right now he is using one of events to remove the water block the bottle is filled from.

It however only functions with water blocks that have a solid block directly under them as the event he uses only fires when the block with a collision bounding box is clicked. At least this is the way I am understanding the issue.

CyberPunkBln if that is your issue you can use forge's PlayerInteraction events. There are 2 - when a solid block is clicked and when a player performs right click with an iten without targeting a block. Then you can raytrace the block the player is looking at and remove it.

Posted

@diesieben07

Thx a good tip for me. Now i have the fresh 1.11.2 code for inspect and study.

 

@V0idWa1k3r

Yes this is, i think,  the way.

Do you have an code-example or an site with an good explanation, or is the orignal code with:

 

public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)

 

the right place for me to show?

 

When i use this 2 event-handlers, what is with the original eventHandler in ItemGlassBottle?

Posted (edited)

Depends on how you want to achieve it.

If you are using forge then the events are:

PlayerInteractEvent.RightClickBlock fires when the player clicks on a solid block in the world.

PlayerInteractEvent.RightClickItem fires when the player presses the right mouse button with an item in his/hers hand and there is no block with a collision box that is being targeted by the player.

For both events you can get the world, use the World::rayTraceBlocks(Vec3d start, Vec3d end, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) to get the block the player is effectively looking at. If it is the desired water block fill your glass bottle with water and remove the water block. Both events are cancelable so you can prevent vanilla behaviour.

As @Jay Avery said you can look at the way buckets handle their raytracing of water to understand how to do it correctly.

Edited by V0idWa1k3r
Posted
1 hour ago, CyberPunkBln said:

and now i am here with my notepad++ and gradle pure :) .

Oh jesus. Get Eclipse. It's freaking free.

Or IntelliJ.

 

You wouldn't use Notepad++ to edit a website, so why are you doing it for Java?

  • Like 1

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.

Posted

@Draco18s

For WebDevelopment is use Notepad++ for years :) . I think it is why iam an old man :) . Yes Eclipse i use, too.

 

How i say i have converted a little Mod wit Name ThirstyBottles from 1.10.2 to 1.11.2. And then i must see that this mod has many Bugs in it and not functioned 100% for my needs.

 

@V0idWa1k3r

I think i give up with this.

 

This is what i understand, but should old code:

 

@SubscribeEvent
	public void onItemUsed(RightClickBlock event)
	{
	if (!event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof ItemGlassBottle) {

			BlockPos pos = new BlockPos(event.getHitVec());
	...
	}

 

But this is where i need to much time to Dive Into Java4MinecraftForge :) :

 

 public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
   
   RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, flag);
   
   ...

 

I have thinked that it cannot be so a hard dive into this materia when i want to make GlassBottles interact like a Bucket on water :) .

 

But Thx for the Help at all.

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



×
×
  • Create New...

Important Information

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