Updates for global registry
This commit is contained in:
parent
12b59ed785
commit
cb85689ea9
@ -6,7 +6,9 @@ import com.google.common.collect.Streams
|
||||
import net.minecraft.advancements.CriteriaTriggers
|
||||
import net.minecraft.client.renderer.item.ItemProperties
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.core.Registry
|
||||
import net.minecraft.core.cauldron.CauldronInteraction
|
||||
import net.minecraft.core.component.DataComponents
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.core.registries.Registries
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
@ -15,9 +17,10 @@ import net.minecraft.world.entity.ai.village.poi.PoiType
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiTypes
|
||||
import net.minecraft.world.item.BlockItem
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.DyeableArmorItem
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ShieldItem
|
||||
import net.minecraft.world.item.component.CustomData
|
||||
import net.minecraft.world.item.component.DyedItemColor
|
||||
import net.minecraft.world.level.BlockGetter
|
||||
import net.minecraft.world.level.block.*
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour
|
||||
@ -143,7 +146,7 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
|
||||
val TRITANIUM_STAIRS = DecorativeBlock(MNames.TRITANIUM_STAIRS) {
|
||||
StairBlock(
|
||||
{ TRITANIUM_BLOCK.allBlocks[it]!!.defaultBlockState() },
|
||||
TRITANIUM_BLOCK.allBlocks[it]!!.defaultBlockState(),
|
||||
BlockBehaviour.Properties.ofFullCopy(TRITANIUM_BLOCK.allBlocks[it]!!)
|
||||
)
|
||||
}.also { decorativeBlocks.add(it) }
|
||||
@ -186,13 +189,13 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
|
||||
val FLOOR_TILES_STAIRS = ColoredDecorativeBlock(MNames.FLOOR_TILES_STAIRS) {
|
||||
StairBlock(
|
||||
{ FLOOR_TILES.blocks[it]!!.defaultBlockState() },
|
||||
BlockBehaviour.Properties.copy(FLOOR_TILES.blocks[it]!!)
|
||||
FLOOR_TILES.blocks[it]!!.defaultBlockState(),
|
||||
BlockBehaviour.Properties.ofLegacyCopy(FLOOR_TILES.blocks[it]!!)
|
||||
)
|
||||
}.also { decorativeBlocks.add(it) }
|
||||
|
||||
val FLOOR_TILES_SLAB = ColoredDecorativeBlock(MNames.FLOOR_TILES_SLAB) {
|
||||
SlabBlock(BlockBehaviour.Properties.copy(FLOOR_TILES.blocks[it]!!))
|
||||
SlabBlock(BlockBehaviour.Properties.ofLegacyCopy(FLOOR_TILES.blocks[it]!!))
|
||||
}.also { decorativeBlocks.add(it) }
|
||||
|
||||
val UNREFINED_FLOOR_TILES = ColoredDecorativeBlock.simple(MNames.UNREFINED_FLOOR_TILES) {
|
||||
@ -221,7 +224,7 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
return@DecorativeBlock StainedGlassBlock(color, properties)
|
||||
}
|
||||
|
||||
return@DecorativeBlock GlassBlock(properties)
|
||||
return@DecorativeBlock TransparentBlock(properties)
|
||||
}.also { decorativeBlocks.add(it) }
|
||||
|
||||
val INDUSTRIAL_GLASS_PANE = DecorativeBlock(MNames.INDUSTRIAL_GLASS_PANE) { color ->
|
||||
@ -266,7 +269,7 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
// mojang moment
|
||||
|
||||
if (event.registryKey == Registries.POINT_OF_INTEREST_TYPE) {
|
||||
val reg = event.getVanillaRegistry<PoiType>() ?: throw IllegalStateException("POI registry is not a vanilla registry")
|
||||
val reg = event.registry as Registry<PoiType>
|
||||
|
||||
event.register(Registries.POINT_OF_INTEREST_TYPE, PoiTypes.BUTCHER.location()) {
|
||||
val old = reg[PoiTypes.BUTCHER] ?: throw IllegalStateException("POI with type ${PoiTypes.ARMORER} does not exist")
|
||||
@ -353,7 +356,7 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
|
||||
for (item in MItems.ESSENCE_STORAGE.values) {
|
||||
ItemProperties.register(item, ResourceLocation(OverdriveThatMatters.MOD_ID, "is_filled")) { stack, _, _, _ ->
|
||||
val tag = (stack.tag?.get(BlockItem.BLOCK_ENTITY_TAG) as? CompoundTag)?: return@register 0f
|
||||
val tag = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).unsafe ?: return@register 0f
|
||||
|
||||
if (tag.contains("experienceStored") && tag.getLong("experienceStored") > 0.0) {
|
||||
1f
|
||||
@ -366,14 +369,16 @@ object MRegistry : IBlockItemRegistryAcceptor {
|
||||
}
|
||||
|
||||
private fun registerCauldronHandlers() {
|
||||
MItems.TRITANIUM_ARMOR.forEach { CauldronInteraction.WATER[it] = CauldronInteraction.DYED_ITEM }
|
||||
MItems.TRITANIUM_ARMOR.forEach { CauldronInteraction.WATER.map()[it] = CauldronInteraction.DYED_ITEM }
|
||||
}
|
||||
|
||||
private fun registerItemColorHandlers(event: RegisterColorHandlersEvent.Item) {
|
||||
event.register(DynamicFluidContainerModel.Colors(), MItems.FLUID_CAPSULE)
|
||||
event.register({ stack, layer -> if (layer == 0) (stack.item as DyeableArmorItem).getColor(stack) else -1 },
|
||||
|
||||
event.register({ stack, layer -> if (layer == 0) DyedItemColor.getOrDefault(stack, -1) else -1 },
|
||||
*MItems.TRITANIUM_ARMOR.toTypedArray()
|
||||
)
|
||||
|
||||
event.register({ _, layer -> if (layer == 1) RGBAColor.AQUA.toBGRA() else -1 },
|
||||
*MItems.MachineUpgrades.Creative.LIST.toTypedArray())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user