Fix cable recipes, advancements, loot tables, and face device drops

This commit is contained in:
Shadowfacts 2021-03-15 19:06:17 -04:00
parent bc50017b4a
commit ee6fb1e725
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
42 changed files with 703 additions and 56 deletions

View File

@ -4,6 +4,8 @@ import net.minecraft.block.Block
import net.minecraft.block.BlockState import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext import net.minecraft.block.ShapeContext
import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemPlacementContext
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.state.StateManager import net.minecraft.state.StateManager
import net.minecraft.state.property.EnumProperty import net.minecraft.state.property.EnumProperty
import net.minecraft.state.property.Properties import net.minecraft.state.property.Properties
@ -14,11 +16,11 @@ import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView import net.minecraft.world.BlockView
import net.minecraft.world.World
import net.minecraft.world.WorldAccess import net.minecraft.world.WorldAccess
import net.shadowfacts.phycon.api.Interface import net.shadowfacts.phycon.api.Interface
import net.shadowfacts.phycon.api.NetworkComponentBlock import net.shadowfacts.phycon.api.NetworkComponentBlock
import net.shadowfacts.phycon.block.cable.CableBlock import net.shadowfacts.phycon.block.cable.CableBlock
import net.shadowfacts.phycon.init.PhyItems
import java.util.* import java.util.*
@ -160,4 +162,11 @@ abstract class FaceDeviceBlock<T: DeviceBlockEntity>(settings: Settings): Device
override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, context: ShapeContext): VoxelShape { override fun getOutlineShape(state: BlockState, world: BlockView, pos: BlockPos, context: ShapeContext): VoxelShape {
return getShape(state[FACING], state[CABLE_CONNECTION]) return getShape(state[FACING], state[CABLE_CONNECTION])
} }
override fun onStacksDropped(state: BlockState, world: ServerWorld, pos: BlockPos, stack: ItemStack) {
super.onStacksDropped(state, world, pos, stack)
val cableStack = ItemStack(PhyItems.CABLES[state[COLOR]])
dropStack(world, pos, cableStack)
}
} }

View File

@ -82,7 +82,8 @@ class ScrewdriverItem: Item(Settings().maxCount(1)) {
val faceShape = block.faceShapes[state[FaceDeviceBlock.FACING]]!! val faceShape = block.faceShapes[state[FaceDeviceBlock.FACING]]!!
// if we hit the face part of block, leave the cable behind // if we hit the face part of block, leave the cable behind
if (faceShape.boundingBox.containsInclusive(hitInsideBlock)) { if (faceShape.boundingBox.containsInclusive(hitInsideBlock)) {
return (state.block as CableBlock).getInitialState(context.world, context.blockPos) val cableBlock = PhyBlocks.CABLES[state[FaceDeviceBlock.COLOR]]!!
return cableBlock.getInitialState(context.world, context.blockPos)
} else { } else {
if (!context.world.isClient) { if (!context.world.isClient) {
val cable = ItemEntity(context.world, context.blockPos.x.toDouble(), context.blockPos.y.toDouble(), context.blockPos.z.toDouble(), ItemStack(state.block)) val cable = ItemEntity(context.world, context.blockPos.x.toDouble(), context.blockPos.y.toDouble(), context.blockPos.z.toDouble(), ItemStack(state.block))

View File

@ -2,7 +2,7 @@
"parent": "phycon:root", "parent": "phycon:root",
"display": { "display": {
"icon": { "icon": {
"item": "phycon:cable" "item": "phycon:cable_blue"
}, },
"title": { "title": {
"translate": "advancements.phycon.cable.title" "translate": "advancements.phycon.cable.title"
@ -19,9 +19,8 @@
"cable": { "cable": {
"trigger": "minecraft:placed_block", "trigger": "minecraft:placed_block",
"conditions": { "conditions": {
"block": "phycon:cable",
"item": { "item": {
"item": "phycon:cable" "tag": "phycon:cable"
} }
} }
} }

View File

@ -2,7 +2,22 @@
"parent": "minecraft:recipes/root", "parent": "minecraft:recipes/root",
"rewards": { "rewards": {
"recipes": [ "recipes": [
"phycon:cable" "phycon:cable/white",
"phycon:cable/orange",
"phycon:cable/magenta",
"phycon:cable/light_blue",
"phycon:cable/yellow",
"phycon:cable/lime",
"phycon:cable/pink",
"phycon:cable/gray",
"phycon:cable/light_gray",
"phycon:cable/cyan",
"phycon:cable/purple",
"phycon:cable/blue",
"phycon:cable/brown",
"phycon:cable/green",
"phycon:cable/red",
"phycon:cable/black"
] ]
}, },
"criteria": { "criteria": {
@ -16,17 +31,122 @@
] ]
} }
}, },
"has_the_recipe": { "has_white_recipe": {
"trigger": "minecraft:recipe_unlocked", "trigger": "minecraft:recipe_unlocked",
"conditions": { "conditions": {
"recipe": "phycon:cable" "recipe": "phycon:cable/white"
}
},
"has_orange_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/orange"
}
},
"has_magenta_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/magenta"
}
},
"has_light_blue_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/light_blue"
}
},
"has_yellow_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/yellow"
}
},
"has_lime_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/lime"
}
},
"has_pink_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/pink"
}
},
"has_gray_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/gray"
}
},
"has_light_gray_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/light_gray"
}
},
"has_cyan_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/cyan"
}
},
"has_purple_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/purple"
}
},
"has_blue_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/blue"
}
},
"has_brown_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/brown"
}
},
"has_green_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/green"
}
},
"has_red_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/red"
}
},
"has_black_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "phycon:cable/black"
} }
} }
}, },
"requirements": [ "requirements": [
[ [
"has_twisted_pair", "has_twisted_pair",
"has_the_recipe" "has_white_recipe",
"has_orange_recipe",
"has_magenta_recipe",
"has_light_blue_recipe",
"has_yellow_recipe",
"has_lime_recipe",
"has_pink_recipe",
"has_gray_recipe",
"has_light_gray_recipe",
"has_cyan_recipe",
"has_purple_recipe",
"has_blue_recipe",
"has_brown_recipe",
"has_green_recipe",
"has_red_recipe",
"has_black_recipe"
] ]
] ]
} }

View File

@ -11,7 +11,7 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"item": "phycon:cable" "tag": "phycon:cable"
} }
] ]
} }

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_black"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_blue"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_brown"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_cyan"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_gray"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_green"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_light_blue"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_light_gray"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_lime"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_magenta"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_orange"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_pink"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_purple"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -6,7 +6,7 @@
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
"name": "phycon:cable" "name": "phycon:cable_red"
} }
], ],
"conditions": [ "conditions": [

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_white"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable_yellow"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -14,20 +14,6 @@
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
] ]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
} }
] ]
} }

View File

@ -14,20 +14,6 @@
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
] ]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
} }
] ]
} }

View File

@ -14,20 +14,6 @@
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
] ]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "phycon:cable"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
} }
] ]
} }

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:black_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_black",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:blue_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_blue",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:brown_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_brown",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:cyan_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_cyan",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:gray_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_gray",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:green_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_green",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:light_blue_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_light_blue",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:light_gray_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_light_gray",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:lime_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_lime",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:orange_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_orange",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:orange_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_orange",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:pink_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_pink",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:purple_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_purple",
"count": 3
}
}

View File

@ -6,12 +6,12 @@
"CCC" "CCC"
], ],
"key": { "key": {
"C": {"tag": "minecraft:carpets"}, "C": {"item": "minecraft:red_carpet"},
"T": {"item": "phycon:twisted_pair"}, "T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"} "R": {"item": "minecraft:redstone"}
}, },
"result": { "result": {
"item": "phycon:cable", "item": "phycon:cable_red",
"count": 3 "count": 3
} }
} }

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:white_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_white",
"count": 3
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"CCC",
"TRT",
"CCC"
],
"key": {
"C": {"item": "minecraft:yellow_carpet"},
"T": {"item": "phycon:twisted_pair"},
"R": {"item": "minecraft:redstone"}
},
"result": {
"item": "phycon:cable_yellow",
"count": 3
}
}

View File

@ -7,7 +7,7 @@
], ],
"key": { "key": {
"S": {"item": "phycon:silicon_wafer"}, "S": {"item": "phycon:silicon_wafer"},
"C": {"item": "phycon:cable"}, "C": {"tag": "phycon:cable"},
"I": {"tag": "c:iron_ingots"} "I": {"tag": "c:iron_ingots"}
}, },
"result": { "result": {

View File

@ -0,0 +1,20 @@
{
"values": [
"phycon:cable_white",
"phycon:cable_orange",
"phycon:cable_magenta",
"phycon:cable_light_blue",
"phycon:cable_yellow",
"phycon:cable_lime",
"phycon:cable_pink",
"phycon:cable_gray",
"phycon:cable_light_gray",
"phycon:cable_cyan",
"phycon:cable_purple",
"phycon:cable_blue",
"phycon:cable_brown",
"phycon:cable_green",
"phycon:cable_red",
"phycon:cable_black"
]
}