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

Revamp tools #688

Merged
merged 56 commits into from
Jan 4, 2024
Merged

Revamp tools #688

merged 56 commits into from
Jan 4, 2024

Conversation

screret
Copy link
Member

@screret screret commented Jan 4, 2024

What

Revamps most of everything related to tools & how they are handled.

Implementation Details

mostly same as how 1.12 handles it. Which is still how MC handles it.

Outcome

Makes tool logic more modular and changeable, as well as easier to update in future versions.

Additional Information

haha funi pink crowbar

Potential Compatibility Issues

might break some addons expecting the old tool table in GTItems, and definitely breaks all existing tools.

megacommit moment
- adds all classes for custom tools
- fabric parity for forge extension methods, minus extra weird ones
- custom behaviours
- et cetera, contains lots of skill issues
CURRENT ISSUES:
- torch place behavior voids your tool.
- fabric doesn't have the capabilities attaching yet.
@screret screret requested a review from a team as a code owner January 4, 2024 13:55
CHANGELOG.md Outdated Show resolved Hide resolved
if (player.level().isClientSide) return false;
getToolStats().getBehaviors().forEach(behavior -> behavior.onBlockStartBreak(stack, pos, player));

if (!player.isCrouching()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend using several early returns in this method to reduce the nesting level

Comment on lines +152 to +165
public final int column, row, layer;

private AoESymmetrical() {
this.column = 0;
this.row = 0;
this.layer = 0;
}

private AoESymmetrical(int column, int row, int layer) {
this.column = column;
this.row = row;
this.layer = layer;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to move this to the top of the class imo

Comment on lines +48 to +50
tag.putInt(ToolHelper.AOE_COLUMN_KEY, column);
tag.putInt(ToolHelper.AOE_ROW_KEY, row);
tag.putInt(ToolHelper.AOE_LAYER_KEY, layer);
Copy link
Member

@mikerooni mikerooni Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to write things back into the tag?

If yes, I'd suggest renaming the method to reflect that. Could be something similar to computeIfAbsent() on maps maybe?

import java.util.List;
import java.util.Set;

public class WaxOffBehavior implements IToolBehavior {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion to rename this to BlockUnwaxBehavior

screret and others added 3 commits January 4, 2024 22:56
Copy link
Member

@mikerooni mikerooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funi pink crowbar go brrr

@mikerooni mikerooni merged commit 702ca30 into 1.20.1 Jan 4, 2024
@mikerooni mikerooni deleted the sc/revamp-tools branch January 4, 2024 21:22
screret added a commit that referenced this pull request Jan 5, 2024
* aa why u crash

* aa why u crash

* holy shit this is worse than I thought...

* god this is annoying to do
megacommit moment

* update muh codes

* it runs.

* feat: megacommit moment
- adds all classes for custom tools
- fabric parity for forge extension methods, minus extra weird ones
- custom behaviours
- et cetera, contains lots of skill issues

* fix: use better, not as hardcoded AOE behaviour

* fix: behaviours now use UseOnContext instead of a lot of parameters

* fix: ShapedEnergyTransferRecipe crashes REI because .matches() is never called

* fix: fill creative tabs & recipes with correctly-NBT'd items

* fix: some more AOE fixes

* fix: better valid drop tier handling

* fix: misc fixes

* feat: tooltips

* fix: move tintColor to IGTTool

* fix: make tool types use correct constructors

* feat: allow autofilling recipes with items that have different NBT

* fix: spades now exist.

* fix: mining tool tags.

* chore: datagen & some minor touchups
CURRENT ISSUES:
- torch place behavior voids your tool.
- fabric doesn't have the capabilities attaching yet.

* feat: remake how tool types are passed to IToolable etc. and how IToolable is called.

* fix: better tool break handling when entity == null

* fix: plunger now voids fluids.

* fix: hoe behaviour works.

* "fix": disable torch place behavior for initial release as I can't figure out a fix.

* fix: log strip behaviour quirks

* feat: custom wrench block rotating actions

* fix: rail rotating with crowbar only works with normal rails

* feat: forge overrides for all tool actions that have them, onBlockStartBreak for fabric

* fix: tree felling might've worked with any tool

* fix: bad nullability everywhere

* fix: scythe had the wrong tool class, GTHoeItem extends ShovelItem instead of HoeItem

* fix: plunger only voids 1/81 on fabric

* fix: make constructors protected for tool classes

* feat: make GTItems.TOOL_ITEMS be a table of <Material, Type, IGTTool> instead of a <Tier, Type, ToolItem>

* fix: fix up tint colors in preparation for 2-color tool textures

* feat: fallback to vanilla logic in case someone calls IGTToolImpl.definition$isCorrectToolForDrops with a non-GT tool

* fix: plunger recipes set the max durability of the tool when crafting

* fix: update jade plugin to use new tool item map

* fix: oops.

* fix: for some reason NBTToJsonConverter always converts numbers to doubles which ends up in larger numbers having rounding errors.

* feat: colored tool handles

* fix: reorder tint indexes on tool models

* Revert "fix: reorder tint indexes on tool models"

This reverts commit fa2cbdf.

* fix: this is a better way to do the same thing.

* feat: implement getDefaultInstance on all tool type classes

* remove now useless mixin, add nbt output to fabric because it seemed to be missing.

* Revert "fix: for some reason NBTToJsonConverter always converts numbers to doubles which ends up in larger numbers having rounding errors."

This reverts commit 7140db5.

* fix: heading comma in tool class tooltip

* fix: fabric now has the ability to have electric tools

* chore: changelog & version

* chore: datagen

* emphasize tool breakage

Co-authored-by: Mikerooni <[email protected]>

* fix weird import

Co-authored-by: Mikerooni <[email protected]>

* Update common/src/main/java/com/gregtechceu/gtceu/api/item/tool/aoe/AoESymmetrical.java

Co-authored-by: Mikerooni <[email protected]>

---------

Co-authored-by: Mikerooni <[email protected]>
mikerooni added a commit that referenced this pull request Jan 5, 2024
* Revamp tools (#688)

* aa why u crash

* aa why u crash

* holy shit this is worse than I thought...

* god this is annoying to do
megacommit moment

* update muh codes

* it runs.

* feat: megacommit moment
- adds all classes for custom tools
- fabric parity for forge extension methods, minus extra weird ones
- custom behaviours
- et cetera, contains lots of skill issues

* fix: use better, not as hardcoded AOE behaviour

* fix: behaviours now use UseOnContext instead of a lot of parameters

* fix: ShapedEnergyTransferRecipe crashes REI because .matches() is never called

* fix: fill creative tabs & recipes with correctly-NBT'd items

* fix: some more AOE fixes

* fix: better valid drop tier handling

* fix: misc fixes

* feat: tooltips

* fix: move tintColor to IGTTool

* fix: make tool types use correct constructors

* feat: allow autofilling recipes with items that have different NBT

* fix: spades now exist.

* fix: mining tool tags.

* chore: datagen & some minor touchups
CURRENT ISSUES:
- torch place behavior voids your tool.
- fabric doesn't have the capabilities attaching yet.

* feat: remake how tool types are passed to IToolable etc. and how IToolable is called.

* fix: better tool break handling when entity == null

* fix: plunger now voids fluids.

* fix: hoe behaviour works.

* "fix": disable torch place behavior for initial release as I can't figure out a fix.

* fix: log strip behaviour quirks

* feat: custom wrench block rotating actions

* fix: rail rotating with crowbar only works with normal rails

* feat: forge overrides for all tool actions that have them, onBlockStartBreak for fabric

* fix: tree felling might've worked with any tool

* fix: bad nullability everywhere

* fix: scythe had the wrong tool class, GTHoeItem extends ShovelItem instead of HoeItem

* fix: plunger only voids 1/81 on fabric

* fix: make constructors protected for tool classes

* feat: make GTItems.TOOL_ITEMS be a table of <Material, Type, IGTTool> instead of a <Tier, Type, ToolItem>

* fix: fix up tint colors in preparation for 2-color tool textures

* feat: fallback to vanilla logic in case someone calls IGTToolImpl.definition$isCorrectToolForDrops with a non-GT tool

* fix: plunger recipes set the max durability of the tool when crafting

* fix: update jade plugin to use new tool item map

* fix: oops.

* fix: for some reason NBTToJsonConverter always converts numbers to doubles which ends up in larger numbers having rounding errors.

* feat: colored tool handles

* fix: reorder tint indexes on tool models

* Revert "fix: reorder tint indexes on tool models"

This reverts commit fa2cbdf.

* fix: this is a better way to do the same thing.

* feat: implement getDefaultInstance on all tool type classes

* remove now useless mixin, add nbt output to fabric because it seemed to be missing.

* Revert "fix: for some reason NBTToJsonConverter always converts numbers to doubles which ends up in larger numbers having rounding errors."

This reverts commit 7140db5.

* fix: heading comma in tool class tooltip

* fix: fabric now has the ability to have electric tools

* chore: changelog & version

* chore: datagen

* emphasize tool breakage

Co-authored-by: Mikerooni <[email protected]>

* fix weird import

Co-authored-by: Mikerooni <[email protected]>

* Update common/src/main/java/com/gregtechceu/gtceu/api/item/tool/aoe/AoESymmetrical.java

Co-authored-by: Mikerooni <[email protected]>

---------

Co-authored-by: Mikerooni <[email protected]>

* fix errors

---------

Co-authored-by: Mikerooni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants