Jump to content

How do i meke the redstone ore glow for exact 4 secconds (80 ticks) after been activated?


Recommended Posts

Posted (edited)

It's not deactivating because you never do anything in your overridden tick method. Deactivate it there.

Override onBlockClicked for activating when it's clicked.

Edited by imacatlolol

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Posted (edited)

I have this all.

 

tick is alright from the vanilla redstone ore.

 

It activates , if i walk on it or right click it.

But not if i run against it´s vertical side or leftvlick it with a weapon or tool.

 

And i notice, it activates, if an arrow hit´s it´s vertical side, but not if it hit´s it´s top.

and stays activated forever.

 

It activates correctly at:

-walking on it

-rightclick it

 

It scould activate, too at

-leftclicking it with a sword(in creative for not braking it) or something else in survival (while the braking-process)

-walking against a vertical wall out of theese blocks.

-jump under such a block in a two block high gap

-shooting projectiles at it (no matter if side or top)

Edited by Drachenbauer
Posted

I'll say it again, this time with a little more clarity, override onBlockClicked to activate it when it's left clicked.

There's no built-in feature for detecting side collisions in the way you want. Maybe you could have it detect nearby entities and activate that way. Use something like World#getEntitiesWithinAABBExcludingEntity for that.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Posted (edited)

And i sayd, i already use onBlockClicked

 

Quote

There's no built-in feature for detecting side collisions in the way you want. Maybe you could have it detect nearby entities and activate that way. Use something like

I saw, the cactus uses onEntityCollision to deal damage.

So i thaught, this one can use it to activate.

Edited by Drachenbauer
Posted
3 minutes ago, Drachenbauer said:

And i sayd, i already use onBlockClicked

Show your code.

4 minutes ago, Drachenbauer said:

I saw, the cactus uses onEntityCollision to deal damage.

So i thaught, this one can use it to activate.

That's a good idea, but I'm pretty sure onEntityCollision only triggers when an entity is inside of a block's space. Since your block is a full block, I don't believe that code will ever run.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Posted
22 minutes ago, imacatlolol said:

It's not deactivating because you never do anything in your overridden tick method. Deactivate it there.

If you look at his most recent code. He doesn't override the tick method at all and it goes back into the super classes tick method which is RedstoneOreBlock::tick

5 minutes ago, Drachenbauer said:

I saw, the cactus uses onEntityCollision to deal damage.

So i thaught, this one can use it to activate.

The Cactus blocks Collision is slightly bigger than what is visual and thus allows the player to move ever so slightly inside of it and that is what is considered a collision. Take a look at CactusBlock for how it does that.

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.

Posted
1 minute ago, Animefan8888 said:

If you look at his most recent code. He doesn't override the tick method at all and it goes back into the super classes tick method which is RedstoneOreBlock::tick

The Cactus blocks Collision is slightly bigger than what is visual and thus allows the player to move ever so slightly inside of it and that is what is considered a collision. Take a look at CactusBlock for how it does that.

Oh, I didn't know. Thank you for the clarity!

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

Posted
8 minutes ago, Drachenbauer said:

About the cactus, do you mean, that the getShape and the getCollisionShape are slightly different cuboidshape values?

That is what I originally meant. Or something along those lines, However it seems that may have been changed, or it was never like that and I'm crazy. It seems an entity calls Block::onEntityCollision if the Entity's bounding box exists within the BlockPos(block space) of a block. IE if I stand next to a flower pot I'm considered colliding with that block.

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.

Posted (edited)

Now i created a collision-shape (applyed in getCollisionShape), that i slightly inside the block at the sides and botom.

 

Now the thing with the collision works.

 

Arrows at vertical side and from below work correctly, too.

but the arrows, sticking in the side or bottom of the block, turn black, if the block switches off.

And i cannot more place objects like torches and redstone wire at the block.

It seems like it has not more all required properties of a solid block now.

 

How can i keep it as a solid block and have onEntityCollision work?

 

And i still wonder why leftclick with a sword and arrows, wich hit the top of the block, do not activate it.

Edited by Drachenbauer
Posted (edited)

Entities stop, if their collision-box touch the one of a block.

As a player you notice it at walking against a wall.

I wonder, where this is coded.

Maybe i can hook my code there for switching the RedstoneOre on at walking against it or jumping or flying under it until automatic stopping.

 

And still:

Why the RedstoneOre does not switch on, if i leftclick it with a weapon (sword, trident) or hit its top with an arrow or thrown trident?

Edited by Drachenbauer

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.