Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public ArmorModelData add(String key, SkinTypedValue<ModelLayerLocation> texture

@Nullable
public HumanoidModel<?> get(String key, LivingEntity entity, boolean hasConditions) {
// If the armor is openable, shouldn't it still use the key param? So we pass key instead of ArmorRendererConditions.BASE_TEXTURE
if (!hasConditions) {
var fallback = this.generatedByKey.get(ArmorRendererConditions.BASE_TEXTURE);
var fallback = this.generatedByKey.get(key);
return fallback != null ? fallback.get(entity) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.GsonHelper;
import net.threetag.palladium.Palladium;
import net.threetag.palladium.condition.Condition;
import net.threetag.palladium.condition.ConditionEnvironment;
import net.threetag.palladium.condition.ConditionSerializer;
Expand All @@ -27,16 +28,20 @@ public String getTexture(DataContext context, ArmorTextureData textures) {

var stack = context.getItem();
if (!stack.isEmpty() && stack.getItem() instanceof Openable openable) {
var max = openable.getOpeningTime(stack);
if (max <= 0 && openable.isOpen(stack)) {
key = OPENED_TEXTURE;
} else if (max > 0) {
key = OPENED_TEXTURE + "_" + openable.getOpeningProgress(context.getItem());

if (!textures.has(key)) {
if (openable.getOpeningProgress(stack) > 0) {
if (openable.getOpeningTime(stack) <= 0) {
key = OPENED_TEXTURE;
} else {
key = OPENED_TEXTURE + "_" + openable.getOpeningProgress(stack);

if (!textures.has(key)) {
key = OPENED_TEXTURE;
}
}
}
else if (openable.isOpen(stack)) {
key = OPENED_TEXTURE;
}
}

if (!textures.has(key)) {
Expand All @@ -55,16 +60,22 @@ public String getTexture(DataContext context, ArmorTextureData textures) {
public String getModelLayer(DataContext context, ArmorModelData models) {
String key = BASE_TEXTURE;

if (context.has(DataContextType.ITEM) && context.getItem().getItem() instanceof Openable openable && openable.getOpeningProgress(context.getItem()) > 0) {
if (openable.getOpeningTime(context.getItem()) <= 0) {
key = OPENED_TEXTURE;
} else {
key = OPENED_TEXTURE + "_" + openable.getOpeningProgress(context.getItem());

if (!models.has(key)) {
var stack = context.getItem();
if (context.has(DataContextType.ITEM) && stack.getItem() instanceof Openable openable) {
if (openable.getOpeningProgress(stack) > 0) {
if (openable.getOpeningTime(stack) <= 0) {
key = OPENED_TEXTURE;
} else {
key = OPENED_TEXTURE + "_" + openable.getOpeningProgress(stack);

if (!models.has(key)) {
key = OPENED_TEXTURE;
}
}
}
else if (openable.isOpen(stack)) {
key = OPENED_TEXTURE;
}
}

if (!models.has(key)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "palladium:armor",
"slot": "chest",
"armor_material": "test:dirt",
"creative_mode_tab": "test:test_tab",
"openable": true,
"opening_time": 16
}
3 changes: 2 additions & 1 deletion run/addonpacks/Test Pack/assets/test/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"accessory_slot.test.render_layer_switch_test": "Render Layer Switch Test",
"accessory.test.wood": "Oak Chestplate",
"accessory.test.birch": "Birch Chestplate",
"accessory_slot.test.accessory_variable_test": "Accessory Variable Test"
"accessory_slot.test.accessory_variable_test": "Accessory Variable Test",
"item.test.openable_test_chestplate": "Openable Test Chestplate"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "test:item/openable_test_chestplate"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"textures": {
"default": "test:textures/models/armor/dirt.png",
"open": {
"base": "test:textures/models/iron_man_suit.png",
"transformers": [
{
"type": "palladium:alpha_mask",
"mask": "test:textures/models/alpha_masks/iron_man_suit/transformation_#TIMER.png"
}
],
"variables": {
"TIMER": {
"type": "palladium:openable_equipment_progress"
}
},
"output": "test:textures/models/iron_man_suit_#TIMER.png"
}
},
"model_layers": {
"default": "test:player#thick_armor",
"open": "palladium:humanoid#suit"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.