Jump to content

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


Drachenbauer

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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