diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_crafting_table.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_crafting_table.json index e00e60eb13..bf6a26c914 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_crafting_table.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_crafting_table.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence.json index 493496ef4f..d16e798a40 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence_gate.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence_gate.json index df96286faf..86aadbb930 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence_gate.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_fence_gate.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_glowstone.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_glowstone.json index ff3aafc48b..60c8aedd03 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_glowstone.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_glowstone.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_redstone_block.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_redstone_block.json index 2fb4d0b8b2..fb89bec458 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_redstone_block.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_redstone_block.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_sand.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_sand.json index 82b7e787bf..b098e87d73 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_sand.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_sand.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_slab.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_slab.json index 17dfd694a2..1a735eea4d 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_slab.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_slab.json @@ -24,8 +24,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" @@ -59,8 +59,8 @@ "ops": [ { "op": "replace", - "source": "paint2", - "target": "BlockEntityTag.paint" + "source": "Paint2", + "target": "BlockEntityTag.Paint2" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_stairs.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_stairs.json index 0d6333c4cc..e9f2e36909 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_stairs.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_stairs.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_trapdoor.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_trapdoor.json index c9590f0e17..84e4b49f8b 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_trapdoor.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_trapdoor.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/loot_tables/blocks/painted_wooden_pressure_plate.json b/src/generated/resources/data/enderio/loot_tables/blocks/painted_wooden_pressure_plate.json index f15e9bf8c4..1d77c47bd1 100644 --- a/src/generated/resources/data/enderio/loot_tables/blocks/painted_wooden_pressure_plate.json +++ b/src/generated/resources/data/enderio/loot_tables/blocks/painted_wooden_pressure_plate.json @@ -12,8 +12,8 @@ "ops": [ { "op": "replace", - "source": "paint", - "target": "BlockEntityTag.paint" + "source": "Paint", + "target": "BlockEntityTag.Paint" } ], "source": "block_entity" diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_crafting_table_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_crafting_table_frompainted.json new file mode 100644 index 0000000000..14fc8aa90a --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_crafting_table_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_crafting_table" + }, + "output": "enderio:painted_crafting_table" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_fence_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_fence_frompainted.json new file mode 100644 index 0000000000..93e3be5519 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_fence_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_fence" + }, + "output": "enderio:painted_fence" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_fence_gate_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_fence_gate_frompainted.json new file mode 100644 index 0000000000..df2d5f5d53 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_fence_gate_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_fence_gate" + }, + "output": "enderio:painted_fence_gate" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_glowstone_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_glowstone_frompainted.json new file mode 100644 index 0000000000..2458fc77c4 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_glowstone_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_glowstone" + }, + "output": "enderio:painted_glowstone" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_redstone_block_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_redstone_block_frompainted.json new file mode 100644 index 0000000000..dbe0a8dc5c --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_redstone_block_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_redstone_block" + }, + "output": "enderio:painted_redstone_block" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_sand_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_sand_frompainted.json new file mode 100644 index 0000000000..b32cd8875b --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_sand_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_sand" + }, + "output": "enderio:painted_sand" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_slab_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_slab_frompainted.json new file mode 100644 index 0000000000..590b135ab6 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_slab_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_slab" + }, + "output": "enderio:painted_slab" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_stairs_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_stairs_frompainted.json new file mode 100644 index 0000000000..e351886c27 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_stairs_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_stairs" + }, + "output": "enderio:painted_stairs" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_trapdoor_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_trapdoor_frompainted.json new file mode 100644 index 0000000000..c85de1f394 --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_trapdoor_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_trapdoor" + }, + "output": "enderio:painted_trapdoor" +} \ No newline at end of file diff --git a/src/generated/resources/data/enderio/recipes/painting/painted_wooden_pressure_plate_frompainted.json b/src/generated/resources/data/enderio/recipes/painting/painted_wooden_pressure_plate_frompainted.json new file mode 100644 index 0000000000..d4008af19e --- /dev/null +++ b/src/generated/resources/data/enderio/recipes/painting/painted_wooden_pressure_plate_frompainted.json @@ -0,0 +1,7 @@ +{ + "type": "enderio:painting", + "input": { + "item": "enderio:painted_wooden_pressure_plate" + }, + "output": "enderio:painted_wooden_pressure_plate" +} \ No newline at end of file diff --git a/src/machines/java/com/enderio/machines/data/recipes/PaintingRecipeProvider.java b/src/machines/java/com/enderio/machines/data/recipes/PaintingRecipeProvider.java index 29cdb99b59..c55e22ef54 100644 --- a/src/machines/java/com/enderio/machines/data/recipes/PaintingRecipeProvider.java +++ b/src/machines/java/com/enderio/machines/data/recipes/PaintingRecipeProvider.java @@ -37,11 +37,26 @@ protected void buildRecipes(Consumer pFinishedRecipeConsumer) { build(EIOBlocks.PAINTED_WOODEN_PRESSURE_PLATE, Ingredient.of(ItemTags.WOODEN_PRESSURE_PLATES), pFinishedRecipeConsumer); build(EIOBlocks.PAINTED_SLAB, Ingredient.of(ItemTags.WOODEN_SLABS), pFinishedRecipeConsumer); build(EIOBlocks.PAINTED_GLOWSTONE, Ingredient.of(Items.GLOWSTONE), pFinishedRecipeConsumer); + //Painted block to painted block + build(EIOBlocks.PAINTED_FENCE, Ingredient.of(EIOBlocks.PAINTED_FENCE), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_FENCE_GATE, Ingredient.of(EIOBlocks.PAINTED_FENCE_GATE), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_SAND, Ingredient.of(EIOBlocks.PAINTED_SAND), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_STAIRS, Ingredient.of(EIOBlocks.PAINTED_STAIRS), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_CRAFTING_TABLE, Ingredient.of(EIOBlocks.PAINTED_CRAFTING_TABLE), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_REDSTONE_BLOCK, Ingredient.of(EIOBlocks.PAINTED_REDSTONE_BLOCK), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_TRAPDOOR, Ingredient.of(EIOBlocks.PAINTED_TRAPDOOR), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_WOODEN_PRESSURE_PLATE, Ingredient.of(EIOBlocks.PAINTED_WOODEN_PRESSURE_PLATE), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_SLAB, Ingredient.of(EIOBlocks.PAINTED_SLAB), "_frompainted", pFinishedRecipeConsumer); + build(EIOBlocks.PAINTED_GLOWSTONE, Ingredient.of(EIOBlocks.PAINTED_GLOWSTONE), "_frompainted", pFinishedRecipeConsumer); } protected void build(ItemLike output, Ingredient input, Consumer recipeConsumer) { - recipeConsumer.accept(new FinishedPaintingRecipe(EnderIO.loc("painting/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath()), input, output.asItem())); + build(output, input, "", recipeConsumer); + } + + protected void build(ItemLike output, Ingredient input, String suffix, Consumer recipeConsumer) { + recipeConsumer.accept(new FinishedPaintingRecipe(EnderIO.loc("painting/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath() + suffix), input, output.asItem())); } protected static class FinishedPaintingRecipe extends EnderFinishedRecipe { diff --git a/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java b/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java index 809cdc4b28..fa8a1436e2 100644 --- a/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java +++ b/src/main/java/com/enderio/base/client/renderer/PaintedBlockColor.java @@ -1,5 +1,6 @@ package com.enderio.base.client.renderer; +import com.enderio.base.EIONBTKeys; import com.enderio.base.common.block.painted.IPaintedBlock; import com.enderio.base.common.blockentity.DoublePaintedBlockEntity; import com.enderio.base.common.blockentity.IPaintableBlockEntity; @@ -65,10 +66,10 @@ public int getColor(BlockState state, @Nullable BlockAndTintGetter level, @Nulla @Override public int getColor(ItemStack itemStack, int tintIndex) { - if (itemStack.getTag() != null && itemStack.getTag().contains("BlockEntityTag")) { - CompoundTag blockEntityTag = itemStack.getTag().getCompound("BlockEntityTag"); - if (blockEntityTag.contains("paint")) { - Block paint = PaintUtils.getBlockFromRL(blockEntityTag.getString("paint")); + if (itemStack.getTag() != null && itemStack.getTag().contains(EIONBTKeys.BLOCK_ENTITY_TAG)) { + CompoundTag blockEntityTag = itemStack.getTag().getCompound(EIONBTKeys.BLOCK_ENTITY_TAG); + if (blockEntityTag.contains(EIONBTKeys.PAINT)) { + Block paint = PaintUtils.getBlockFromRL(blockEntityTag.getString(EIONBTKeys.PAINT)); if (paint == null) return 0; return Minecraft.getInstance().getItemColors().getColor(paint.asItem().getDefaultInstance(), tintIndex); diff --git a/src/main/java/com/enderio/base/common/block/painted/PaintedFenceBlock.java b/src/main/java/com/enderio/base/common/block/painted/PaintedFenceBlock.java index a31e3212b9..7afd17e156 100644 --- a/src/main/java/com/enderio/base/common/block/painted/PaintedFenceBlock.java +++ b/src/main/java/com/enderio/base/common/block/painted/PaintedFenceBlock.java @@ -26,13 +26,7 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { @Override public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, Player player) { - ItemStack stack = new ItemStack(this); - BlockEntity be = level.getBlockEntity(pos); - if (be != null) { - - stack.getOrCreateTag().put("BlockEntityTag", be.saveWithoutMetadata()); - } - return stack; + return getPaintedStack(level, pos, this); } } diff --git a/src/main/java/com/enderio/base/common/entity/PaintedSandEntity.java b/src/main/java/com/enderio/base/common/entity/PaintedSandEntity.java index 79f89fb71e..03db873825 100644 --- a/src/main/java/com/enderio/base/common/entity/PaintedSandEntity.java +++ b/src/main/java/com/enderio/base/common/entity/PaintedSandEntity.java @@ -77,7 +77,7 @@ public ItemEntity spawnAtLocation(ItemStack stack, float offsetY) { // Add block entity NBT to item stack if (!stack.isEmpty() && blockData != null) { CompoundTag itemNbt = new CompoundTag(); - itemNbt.put("BlockEntityTag", blockData); + itemNbt.put(EIONBTKeys.BLOCK_ENTITY_TAG, blockData); stack.setTag(itemNbt); } return super.spawnAtLocation(stack, offsetY); diff --git a/src/main/java/com/enderio/base/data/loot/DecorLootTable.java b/src/main/java/com/enderio/base/data/loot/DecorLootTable.java index 56a8e17359..cfc2212e2e 100644 --- a/src/main/java/com/enderio/base/data/loot/DecorLootTable.java +++ b/src/main/java/com/enderio/base/data/loot/DecorLootTable.java @@ -1,5 +1,6 @@ package com.enderio.base.data.loot; +import com.enderio.base.EIONBTKeys; import com.tterrag.registrate.providers.loot.RegistrateBlockLootTables; import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.world.level.block.Block; @@ -19,7 +20,7 @@ public static void withPaint(RegistrateBlockLootTables loot, T loot.add(block, LootTable .lootTable() .withPool(new LootPool.Builder().add( - LootItem.lootTableItem(block).apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("paint", "BlockEntityTag.paint"))))); + LootItem.lootTableItem(block).apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy(EIONBTKeys.PAINT, EIONBTKeys.BLOCK_ENTITY_TAG + "." + EIONBTKeys.PAINT))))); } public static void paintedSlab(RegistrateBlockLootTables loot, T block) { @@ -27,12 +28,12 @@ public static void paintedSlab(RegistrateBlockLootTables loot, .lootTable() .withPool(new LootPool.Builder().add(LootItem .lootTableItem(block) - .apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("paint", "BlockEntityTag.paint")) + .apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy(EIONBTKeys.PAINT, EIONBTKeys.BLOCK_ENTITY_TAG + "." + EIONBTKeys.PAINT)) .when(InvertedLootItemCondition.invert(new LootItemBlockStatePropertyCondition.Builder(block).setProperties( StatePropertiesPredicate.Builder.properties().hasProperty(SlabBlock.TYPE, SlabType.TOP)))))) .withPool(new LootPool.Builder().add(LootItem .lootTableItem(block) - .apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy("paint2", "BlockEntityTag.paint")) + .apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY).copy(EIONBTKeys.PAINT_2, EIONBTKeys.BLOCK_ENTITY_TAG + "." + EIONBTKeys.PAINT_2)) .when(InvertedLootItemCondition.invert(new LootItemBlockStatePropertyCondition.Builder(block).setProperties( StatePropertiesPredicate.Builder.properties().hasProperty(SlabBlock.TYPE, SlabType.BOTTOM))))))); }