Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Turret Shaft Not Extending to Full #170

Open
ComputerErika opened this issue Oct 2, 2021 · 3 comments
Open

[Bug] Turret Shaft Not Extending to Full #170

ComputerErika opened this issue Oct 2, 2021 · 3 comments
Labels

Comments

@ComputerErika
Copy link

Describe the bug
When using the Energy Turret, there is a function called exstendShaft() that gives the description of being able to extend 0 through 2, but when I input a value it only extends up to 0.5.

Is this on purpose and the desc function hasn't been updated?
Or am I just being dumb and missed something?
I have tried to install the movement upgrades but it doesn't seem to work.

I believe it should be able to move this high because setting the pitch with moveTo and in the wiki notes it says it can be set in the range -45 to 90 when assumedly fully extended.

In which environment did the Bug appear?
This appeared in my Singleplayer world

To Reproduce
Connect Energy Turret to Working OC Computer
type "lua" to get to the lua terminal
type "component.os_energyturret.powerOn()"
type "component.os_energyturret.extendShaft" to see desc of 0 through 2
type "component.os_energyturret.extendShaft(2)" (or any number larger than 0.5)
to see it only goes up to 0.5 in what it says in the return value.
Or type "component.os_energyturret.getShaftLength()" to see its only 0.5

Expected behavior
After typing "component.os_energyturret.extendShaft(2)", the rotary shaft of the turret should extend to 2, and by typing "component.os_energyturret.getShaftLength()" I should get 2.
This then gives the ability to set the turret pitch to the full range of -45 through 90

Minecraft:

  • OpenSecurity-1.12.2-1.0-83
  • 1.12.2
  • Forge 14.23.5.2855
  • OptiFine_1.12.2_HD_U_F5, with no shaders

Additional context
I saw in OpenSecurity/src/main/java/pcl/opensecurity/common/tileentity/logic/EnergyTurret.java
that maxShaftLengthForOneBlock = 0.5f and
getMaxAvailableShaftLength(float newExt) { newExt = Math.max(0, Math.min(newExt, 2)); return newExt <= maxShaftLengthForOneBlock /* && canExtendShaft() */ ? newExt : maxShaftLengthForOneBlock; }

which could be the cause or have something to do with it?

Tho for all I know I could be a complete dummy and there's a way to set shaft length to 2 and I am just doing it wrong xD, if so, then sorry on my part

@ben-mkiv
Copy link
Collaborator

ben-mkiv commented Oct 2, 2021

yea you are right, actually that code is limiting the shaft length to 0.5. There used to be a check if the above block is air, but this got somehow removed and i can't recall why that was done.

i can't give an ETA for a fix as the project currently doesn't have any regular active maintainer.

@ben-mkiv ben-mkiv added the bug label Oct 2, 2021
@ComputerErika
Copy link
Author

I made a fork and edited the code and changed

return newExt <= maxShaftLengthForOneBlock /* && canExtendShaft() */ ? newExt : maxShaftLengthForOneBlock;
to return canExtendShaft() ? newExt : maxShaftLengthForOneBlock;

it seems to work just fine, altho you can still place a block after extending to 2 which could be considered cheaty

Should I ask to merge this into the mod or would I have to implement a way to check if you place a block overhead to lower it down to 0.5?

@ben-mkiv
Copy link
Collaborator

ben-mkiv commented Nov 6, 2021

yea if you are familiar with minecraft code, there's a block event which gets called if the neighbour block gets changed, imho that check should be implemented before we make a official release that supports extending over a 2nd block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants