Skip to content

Commit

Permalink
Fix color applicator model orientation and allow switching colors by …
Browse files Browse the repository at this point in the history
…right-clicking. (#7742)
  • Loading branch information
shartte committed Mar 11, 2024
1 parent a41c7ad commit bd620dd
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion guidebook/items-blocks-machines/color_applicator.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Its energy can be recharged in a <ItemLink id="charger" />.
Color applicators act like [storage cells](storage_cells.md), and their paint storage can most easily be filled by sticking
the applicator in the storage cell slot in a <ItemLink id="chest" />

To use a color applicator, right click to apply, and shift-scroll to cycle through the stored paintballs and dyes.
Right-click a target to apply the selected color. To change colors, use your scroll wheel while hold shift, or right-click without a target.

## Upgrades

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parent": "minecraft:item/generated",
"parent": "minecraft:item/handheld",
"overrides": [
{
"model": "ae2:item/color_applicator_colored",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parent": "minecraft:item/generated",
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "ae2:item/color_applicator",
"layer1": "ae2:item/color_applicator_tip_dark",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ private void registerHandheld() {

// The color applicator uses a separate model when colored
var coloredColorApplicator = withExistingParent(AEItems.COLOR_APPLICATOR.id().getPath() + "_colored",
"item/generated")
"item/handheld")
.texture("layer0", makeId("item/color_applicator"))
.texture("layer1", makeId("item/color_applicator_tip_dark"))
.texture("layer2", makeId("item/color_applicator_tip_medium"))
.texture("layer3", makeId("item/color_applicator_tip_bright"));
withExistingParent(AEItems.COLOR_APPLICATOR.id().getPath(), "item/generated")
withExistingParent(AEItems.COLOR_APPLICATOR.id().getPath(), "item/handheld")
.texture("layer0", makeId("item/color_applicator"))
// Use different model when colored
.override()
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.animal.Sheep;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -135,6 +136,17 @@ public double getChargeRate(ItemStack stack) {
return 80d + 80d * Upgrades.getEnergyCardMultiplier(getUpgrades(stack));
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) {
var stack = player.getItemInHand(usedHand);

cycleColors(stack, getColor(stack), 1);
if (level.isClientSide) {
player.displayClientMessage(stack.getHoverName(), true);
}
return InteractionResultHolder.fail(stack);
}

@Override
public InteractionResult useOn(UseOnContext context) {
Level level = context.getLevel();
Expand Down Expand Up @@ -205,6 +217,10 @@ public InteractionResult useOn(UseOnContext context) {

if (p != null && InteractionUtil.isInAlternateUseMode(p)) {
this.cycleColors(is, paintBall, 1);
if (level.isClientSide) {
p.displayClientMessage(is.getHoverName(), true);
}
return InteractionResult.CONSUME;
}

return InteractionResult.FAIL;
Expand Down
Binary file modified src/main/resources/assets/ae2/textures/item/color_applicator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bd620dd

Please sign in to comment.