-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Added support for coloring backpacks in Decoration Table and …
…in the process made decoration table code more flexible
- Loading branch information
Showing
10 changed files
with
328 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
336 changes: 227 additions & 109 deletions
336
src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/DecorationTableBlockEntity.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/net/p3pp3rf1y/sophisticatedstorage/compat/jade/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Auto generated package-info by MCP | ||
|
||
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault | ||
package net.p3pp3rf1y.sophisticatedstorage.compat.jade; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
8 changes: 8 additions & 0 deletions
8
src/main/java/net/p3pp3rf1y/sophisticatedstorage/compat/quark/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Auto generated package-info by MCP | ||
|
||
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault | ||
package net.p3pp3rf1y.sophisticatedstorage.compat.quark; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
61 changes: 61 additions & 0 deletions
61
src/main/java/net/p3pp3rf1y/sophisticatedstorage/compat/sb/SBCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.p3pp3rf1y.sophisticatedstorage.compat.sb; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem; | ||
import net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackWrapper; | ||
import net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.IBackpackWrapper; | ||
import net.p3pp3rf1y.sophisticatedcore.compat.ICompat; | ||
import net.p3pp3rf1y.sophisticatedstorage.block.BarrelMaterial; | ||
import net.p3pp3rf1y.sophisticatedstorage.block.DecorationTableBlockEntity; | ||
import net.p3pp3rf1y.sophisticatedstorage.util.DecorationHelper; | ||
|
||
import java.util.Map; | ||
|
||
public class SBCompat implements ICompat { | ||
@Override | ||
public void setup() { | ||
DecorationTableBlockEntity.registerItemDecorator(BackpackItem.class, new DecorationTableBlockEntity.IItemDecorator() { | ||
@Override | ||
public boolean supportsMaterials(ItemStack input) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean supportsTints(ItemStack input) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean supportsTopInnerTrim(ItemStack input) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ItemStack decorateWithMaterials(ItemStack input, Map<BarrelMaterial, ResourceLocation> materialsToApply) { | ||
return ItemStack.EMPTY; | ||
} | ||
|
||
@Override | ||
public DecorationTableBlockEntity.TintDecorationResult decorateWithTints(ItemStack input, int mainColorToSet, int accentColorToSet) { | ||
if (colorsTransparentOrSameAs(input, mainColorToSet, accentColorToSet)) { | ||
return DecorationTableBlockEntity.TintDecorationResult.EMPTY; | ||
} | ||
|
||
ItemStack result = input.copyWithCount(1); | ||
|
||
IBackpackWrapper backpackWrapper = BackpackWrapper.fromStack(result); | ||
int originalMainColor = backpackWrapper.getMainColor(); | ||
int originalAccentColor = backpackWrapper.getAccentColor(); | ||
|
||
backpackWrapper.setColors(mainColorToSet, accentColorToSet); | ||
return new DecorationTableBlockEntity.TintDecorationResult(result, DecorationHelper.getDyePartsNeeded(mainColorToSet, accentColorToSet, originalMainColor, originalAccentColor, 20, 4)); | ||
} | ||
|
||
private boolean colorsTransparentOrSameAs(ItemStack backpack, int mainColorToSet, int accentColorToSet) { | ||
IBackpackWrapper backpackWrapper = BackpackWrapper.fromStack(backpack); | ||
return (mainColorToSet == -1 || mainColorToSet == backpackWrapper.getMainColor()) && (accentColorToSet == -1 || accentColorToSet == backpackWrapper.getAccentColor()); | ||
} | ||
}); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/net/p3pp3rf1y/sophisticatedstorage/compat/sb/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Auto generated package-info by MCP | ||
|
||
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault | ||
package net.p3pp3rf1y.sophisticatedstorage.compat.sb; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters