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

Replace missed NBTKeys + Add paint to paint recipe #320

Merged
merged 1 commit into from
Jul 20, 2023
Merged
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 @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down Expand Up @@ -59,8 +59,8 @@
"ops": [
{
"op": "replace",
"source": "paint2",
"target": "BlockEntityTag.paint"
"source": "Paint2",
"target": "BlockEntityTag.Paint2"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ops": [
{
"op": "replace",
"source": "paint",
"target": "BlockEntityTag.paint"
"source": "Paint",
"target": "BlockEntityTag.Paint"
}
],
"source": "block_entity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_crafting_table"
},
"output": "enderio:painted_crafting_table"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_fence"
},
"output": "enderio:painted_fence"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_fence_gate"
},
"output": "enderio:painted_fence_gate"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_glowstone"
},
"output": "enderio:painted_glowstone"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_redstone_block"
},
"output": "enderio:painted_redstone_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_sand"
},
"output": "enderio:painted_sand"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_slab"
},
"output": "enderio:painted_slab"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_stairs"
},
"output": "enderio:painted_stairs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_trapdoor"
},
"output": "enderio:painted_trapdoor"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "enderio:painting",
"input": {
"item": "enderio:painted_wooden_pressure_plate"
},
"output": "enderio:painted_wooden_pressure_plate"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,26 @@ protected void buildRecipes(Consumer<FinishedRecipe> 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<FinishedRecipe> 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<FinishedRecipe> recipeConsumer) {
recipeConsumer.accept(new FinishedPaintingRecipe(EnderIO.loc("painting/" + ForgeRegistries.ITEMS.getKey(output.asItem()).getPath() + suffix), input, output.asItem()));
}

protected static class FinishedPaintingRecipe extends EnderFinishedRecipe {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/enderio/base/data/loot/DecorLootTable.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,20 +20,20 @@ public static <T extends Block> 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 <T extends Block> void paintedSlab(RegistrateBlockLootTables loot, T block) {
loot.add(block, LootTable
.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)))))));
}
Expand Down
Loading