Jump to content

[1.12.2] Outputting redstone signal to intended side of block after getStateForPlacement()


kyleposey

Recommended Posts

I have a block in which I want to emit a redstone signal from one side. 

This block also has :

@Override
    public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
        EnumFacing face = placer.getHorizontalFacing();
        return this.getDefaultState().withProperty(BlockHorizontal.FACING, face);
    }

 

 

I'm currently trying to use...

@Override
    public boolean canProvidePower(IBlockState state) {
        return true;
    }
    public int getWeakPower(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
        return side == EnumFacing.NORTH ? 15 : 0;
    }

 

...to output to the desired side, but since since the block gets placed based on where the player faces, it will always output from the side in relation to Minecraft's NORTH, not the desired block side.  What would be a good way of actually having it output the way I need it to?

 

 

 

 

Edited by kyleposey
Link to comment
Share on other sites

You have to compare the state's facing to the side passed in. 

9 hours ago, kyleposey said:

face_signal

Where is this coming from? 

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

1 hour ago, Draco18s said:

You have to compare the state's facing to the side passed in. 

Where is this coming from? 

That's a static variable I declared at the top of the class.

public static EnumFacing face_signal;

I'm new to Forge and didn't realize this is not ok. After some research and finding that out I removed it, I'm still struggling with getting this working in a proper way now. Dis regarding this issue I'm struggling with having it take a redstone input using onNeightborChange() also.

 

Pastebin of the class:

https://pastebin.com/QR4tNnbt

Link to comment
Share on other sites

53 minutes ago, kyleposey said:

public static EnumFacing face_signal;

You can't do this. How many of your block do you intend to place into the world? More than one? What if they face different directions?

 

DO NOT STORE DATA STATICALLY OR IN A BLOCK/ITEM CLASS.

 

53 minutes ago, kyleposey said:

I'm new to Forge and didn't realize this is not ok. After some research and finding that out I removed it

private boolean isOn;

*Cough*

Just because you removed one thing and put something else in its place doesn't mean its fixed. Its still broken and in the same way.  All you exchanged was storing the block's facing in the class to storing whether or not the block emits a signal in the class.

 

You must query the block state in getWeakPower().

 

if (side == (EnumFacing.NORTH) && isOn == true)

 

Oh for christ's sake. You still aren't checking if side == facing. You're checking "is the side that wants power coming from the north?"

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

20 hours ago, Draco18s said:

You can't do this. How many of your block do you intend to place into the world? More than one? What if they face different directions?

 

DO NOT STORE DATA STATICALLY OR IN A BLOCK/ITEM CLASS.

 

private boolean isOn;

*Cough*

Just because you removed one thing and put something else in its place doesn't mean its fixed. Its still broken and in the same way.  All you exchanged was storing the block's facing in the class to storing whether or not the block emits a signal in the class.

 

You must query the block state in getWeakPower().

 

if (side == (EnumFacing.NORTH) && isOn == true)

 

Oh for christ's sake. You still aren't checking if side == facing. You're checking "is the side that wants power coming from the north?"

I meant I removed all the unproper variables ?. And thank you I understand why that wasn't working now. ('You're checking "is the side that wants power coming from the north?"'), really helped me shift my thinking, I appreciate it!

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



×
×
  • Create New...

Important Information

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