diff --git a/base/src/main/java/dev/nathanpb/dml/mixin/LivingEntityMixin.java b/base/src/main/java/dev/nathanpb/dml/mixin/LivingEntityMixin.java index 494427f8..98c8acaf 100644 --- a/base/src/main/java/dev/nathanpb/dml/mixin/LivingEntityMixin.java +++ b/base/src/main/java/dev/nathanpb/dml/mixin/LivingEntityMixin.java @@ -78,12 +78,4 @@ public void setDmlRefInReiScreen(boolean flag) { dmlRefIsInREIScreen = flag; } - - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;playEquipSound(Lnet/minecraft/item/ItemStack;)V"), method = "onEquipStack", cancellable = true) - public void onEquip(EquipmentSlot slot, ItemStack oldStack, ItemStack newStack, CallbackInfo ci) { - if (isDmlRefIsInReiScreen()) { - ci.cancel(); - } - } - } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/entity/FakePlayerEntity.kt b/base/src/main/java/dev/nathanpb/dml/mixin/LootTableInvoker.java similarity index 57% rename from base/src/main/kotlin/dev/nathanpb/dml/entity/FakePlayerEntity.kt rename to base/src/main/java/dev/nathanpb/dml/mixin/LootTableInvoker.java index 0cfa859f..b0ba16db 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/entity/FakePlayerEntity.kt +++ b/base/src/main/java/dev/nathanpb/dml/mixin/LootTableInvoker.java @@ -1,3 +1,5 @@ +package dev.nathanpb.dml.mixin; + /* * Copyright (C) 2020 Nathan P. Bombana, IterationFunk * @@ -17,25 +19,16 @@ * along with Deep Mob Learning: Refabricated. If not, see . */ -package dev.nathanpb.dml.entity - -import com.mojang.authlib.GameProfile -import dev.nathanpb.dml.MOD_ID -import net.minecraft.network.encryption.PlayerPublicKey -import net.minecraft.server.network.ServerPlayerEntity -import net.minecraft.server.world.ServerWorld -import java.util.* +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.context.LootContext; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; -class FakePlayerEntity(world: ServerWorld, publicKey: PlayerPublicKey?) : ServerPlayerEntity( - world.server, - world, - GameProfile(UUID, "${MOD_ID}_fake_player"), - publicKey -) { - companion object { - val UUID: UUID = java.util.UUID.randomUUID() - } +@Mixin(LootTable.class) +public interface LootTableInvoker { - override fun isSpectator() = true - override fun isCreative() = true + @Invoker("generateLoot") + ObjectArrayList invokeGenerateLoot(LootContext context); } diff --git a/base/src/main/java/dev/nathanpb/dml/mixin/ServerWorldMixin.java b/base/src/main/java/dev/nathanpb/dml/mixin/ServerWorldMixin.java index 9072b7b5..77ed355c 100644 --- a/base/src/main/java/dev/nathanpb/dml/mixin/ServerWorldMixin.java +++ b/base/src/main/java/dev/nathanpb/dml/mixin/ServerWorldMixin.java @@ -51,18 +51,18 @@ public void explode( double z, float power, boolean createFire, - Explosion.DestructionType destructionType, + World.ExplosionSourceType explosionSource, CallbackInfoReturnable ci ) { if (power > 0F) { World world = (World) (Object) this; - BlockPos pos = new BlockPos(Math.floor(x), Math.floor(y), Math.floor(z)); + BlockPos pos = new BlockPos((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)); ActionResult result = VanillaEvents.INSTANCE.getWorldExplosionEvent() .invoker() - .invoke(world, entity, damageSource, behavior, pos, power, createFire, destructionType); + .invoke(world, entity, damageSource, behavior, pos, power, createFire, explosionSource); if (result == ActionResult.FAIL) { - Explosion explosion = new Explosion(world, entity, damageSource, behavior, x, y, z, power, createFire, Explosion.DestructionType.NONE); + Explosion explosion = new Explosion(world, entity, damageSource, behavior, x, y, z, power, createFire, Explosion.DestructionType.KEEP); ci.setReturnValue(explosion); ci.cancel(); } diff --git a/base/src/main/java/dev/nathanpb/dml/mixin/ShapelessRecipeAccessor.java b/base/src/main/java/dev/nathanpb/dml/mixin/ShapelessRecipeAccessor.java new file mode 100644 index 00000000..43f727b9 --- /dev/null +++ b/base/src/main/java/dev/nathanpb/dml/mixin/ShapelessRecipeAccessor.java @@ -0,0 +1,16 @@ +package dev.nathanpb.dml.mixin; + +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.ShapelessRecipe; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ShapelessRecipe.class) +public interface ShapelessRecipeAccessor { + + @Final + @Accessor("output") + ItemStack getOutput(); + +} diff --git a/base/src/main/java/dev/nathanpb/dml/mixin/SlotMixin.java b/base/src/main/java/dev/nathanpb/dml/mixin/SlotMixin.java index 8e9ce8b2..23e6e2aa 100644 --- a/base/src/main/java/dev/nathanpb/dml/mixin/SlotMixin.java +++ b/base/src/main/java/dev/nathanpb/dml/mixin/SlotMixin.java @@ -44,7 +44,7 @@ public void onTake(int amount, CallbackInfoReturnable ci) { if ((Object) this instanceof CraftingResultSlot dis) { PlayerEntity player = ((ICraftingResultSlotMixin)dis).dmlRefGetPlayer(); - if (!player.world.isClient) { + if (!player.getWorld().isClient) { TrialKeyData oldData = TrialKeyDataKt.getTrialKeyData(stack); if (oldData != null && oldData.getAffixes().isEmpty()) { TrialKeyData newData = new TrialKeyData(stack); diff --git a/base/src/main/java/dev/nathanpb/dml/mixin/SmithingTemplateItemAccessor.java b/base/src/main/java/dev/nathanpb/dml/mixin/SmithingTemplateItemAccessor.java new file mode 100644 index 00000000..33c07b06 --- /dev/null +++ b/base/src/main/java/dev/nathanpb/dml/mixin/SmithingTemplateItemAccessor.java @@ -0,0 +1,22 @@ +package dev.nathanpb.dml.mixin; + +import net.minecraft.item.SmithingTemplateItem; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.List; + +@Mixin(SmithingTemplateItem.class) +public interface SmithingTemplateItemAccessor { + + @Invoker("getArmorTrimEmptyBaseSlotTextures") + static List dml_getArmorTrimEmptyBaseSlotTextures() { + throw new AssertionError(); + } + + @Invoker("getNetheriteUpgradeEmptyAdditionsSlotTextures") + static List dml_getNetheriteUpgradeEmptyAdditionsSlotTextures() { + throw new AssertionError(); + } +} diff --git a/base/src/main/kotlin/dev/nathanpb/dml/DeepMobLearning.kt b/base/src/main/kotlin/dev/nathanpb/dml/DeepMobLearning.kt index fc0be6ea..a012e6a4 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/DeepMobLearning.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/DeepMobLearning.kt @@ -27,7 +27,9 @@ import dev.nathanpb.dml.command.DMLCommand import dev.nathanpb.dml.entity.registerEntityRenderer import dev.nathanpb.dml.entity.registerEntityTypes import dev.nathanpb.dml.event.VanillaEvents +import dev.nathanpb.dml.item.ITEM_DML import dev.nathanpb.dml.item.registerItems +import dev.nathanpb.dml.itemgroup.registerItemGroup import dev.nathanpb.dml.listener.CrushingRecipeListener import dev.nathanpb.dml.listener.DataCollectListener import dev.nathanpb.dml.recipe.registerRecipeSerializers @@ -40,7 +42,13 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback import net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents import net.fabricmc.fabric.api.event.player.AttackBlockCallback import net.fabricmc.fabric.api.event.player.UseBlockCallback +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup import net.fabricmc.loader.api.FabricLoader +import net.minecraft.item.ItemGroup +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.text.Text import net.minecraft.util.Identifier import org.slf4j.LoggerFactory import java.io.File @@ -86,6 +94,7 @@ val config: ModConfig by lazy { fun init() { registerItems() registerBlocks() + registerItemGroup() registerBlockEntityTypes() registerRecipeSerializers() registerRecipeTypes() diff --git a/base/src/main/kotlin/dev/nathanpb/dml/ModConfig.kt b/base/src/main/kotlin/dev/nathanpb/dml/ModConfig.kt index 22054539..fcfe214b 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/ModConfig.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/ModConfig.kt @@ -55,6 +55,13 @@ class Trial { var trialKeyConsume = true var trialKeyReturnIfSucceed = true + + + var faultyGlitchUpgradeOdds = .0 + var basicGlitchUpgradeOdds = .0 + var advancedGlitchUpgradeOdds = .15 + var superiorGlitchUpgradeOdds = .65 + var selfAwareGlitchUpgradeOdds = 1.0 } class TrialAffix { diff --git a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockCafeteria.kt b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockCafeteria.kt index cd04f5b4..7d7bd7a2 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockCafeteria.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockCafeteria.kt @@ -38,10 +38,11 @@ import net.minecraft.world.BlockView import net.minecraft.world.World class BlockCafeteria : HorizontalFacingBlock( - FabricBlockSettings.of(Material.STONE) + FabricBlockSettings.create() .hardness(1F) .resistance(.5F) .nonOpaque() + .mapColor(MapColor.YELLOW) ) { init { defaultState = stateManager.defaultState.with(Properties.HORIZONTAL_FACING, Direction.NORTH) @@ -63,8 +64,16 @@ class BlockCafeteria : HorizontalFacingBlock( builder?.add(Properties.HORIZONTAL_FACING) } - override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? { - return defaultState.with(FACING, ctx?.playerFacing?.opposite) + override fun getPlacementState(ctx: ItemPlacementContext): BlockState { + var blockState = defaultState + + for(direction in ctx.placementDirections) { + if(direction.axis.isHorizontal) { + blockState = blockState.with(FACING, direction.opposite) + if(blockState.canPlaceAt(ctx.world, ctx.blockPos)) return blockState + } + } + return blockState.with(FACING, Direction.NORTH) } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockLootFabricator.kt b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockLootFabricator.kt index c2631371..c1dce4f4 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockLootFabricator.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockLootFabricator.kt @@ -43,7 +43,7 @@ import net.minecraft.world.World import net.minecraft.world.WorldAccess class BlockLootFabricator : HorizontalFacingBlock ( - FabricBlockSettings.of(Material.STONE) + FabricBlockSettings.create() .hardness(4F) .resistance(3000F) ), InventoryProvider, BlockEntityProvider { @@ -83,8 +83,16 @@ class BlockLootFabricator : HorizontalFacingBlock ( builder?.add(Properties.HORIZONTAL_FACING) } - override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? { - return defaultState.with(FACING, ctx?.playerFacing?.opposite) + override fun getPlacementState(ctx: ItemPlacementContext): BlockState { + var blockState = defaultState + + for(direction in ctx.placementDirections) { + if(direction.axis.isHorizontal) { + blockState = blockState.with(FACING, direction.opposite) + if(blockState.canPlaceAt(ctx.world, ctx.blockPos)) return blockState + } + } + return blockState.with(FACING, Direction.NORTH) } override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = BlockEntityLootFabricator(pos, state) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockTrialKeystone.kt b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockTrialKeystone.kt index a27e7227..85022a96 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/block/BlockTrialKeystone.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/block/BlockTrialKeystone.kt @@ -49,7 +49,7 @@ import net.minecraft.world.BlockView import net.minecraft.world.World class BlockTrialKeystone : Block( - FabricBlockSettings.of(Material.STONE) + FabricBlockSettings.create() .hardness(4F) .resistance(3000F) ), BlockEntityProvider { diff --git a/base/src/main/kotlin/dev/nathanpb/dml/block/Blocks.kt b/base/src/main/kotlin/dev/nathanpb/dml/block/Blocks.kt index f3c6fd4c..4e154d14 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/block/Blocks.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/block/Blocks.kt @@ -20,23 +20,52 @@ package dev.nathanpb.dml.block import dev.nathanpb.dml.identifier -import dev.nathanpb.dml.item.settings +import dev.nathanpb.dml.item.ITEM_GLITCH_INGOT +import dev.nathanpb.dml.item.ITEM_PHYSICALLY_CONDENSED_MATRIX_FRAGMENT +import dev.nathanpb.dml.item.ITEM_PRISTINE_MATTER_OVERWORLD +import dev.nathanpb.dml.item.ITEM_TRIAL_KEY +import dev.nathanpb.dml.itemgroup.ITEMS +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY +import dev.nathanpb.dml.utils.RarityTuple +import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents +import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings +import net.minecraft.block.AbstractBlock +import net.minecraft.block.Blocks +import net.minecraft.block.SkullBlock +import net.minecraft.block.WallSkullBlock +import net.minecraft.block.enums.Instrument +import net.minecraft.block.piston.PistonBehavior import net.minecraft.item.BlockItem +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.util.Rarity -import net.minecraft.util.registry.Registry val BLOCK_TRIAL_KEYSTONE = BlockTrialKeystone() val BLOCK_LOOT_FABRICATOR = BlockLootFabricator() +/*val SYSTEM_GLITCH_HEAD = SkullBlock(SkullBlock.Type.CREEPER, FabricBlockSettings.create().instrument(Instrument.CREEPER).strength(1.0f).pistonBehavior(PistonBehavior.DESTROY)) +val SYSTEM_GLITCH_WALL_HEAD = WallSkullBlock(SkullBlock.Type.CREEPER, FabricBlockSettings.create().strength(1.0f).dropsLike(SYSTEM_GLITCH_HEAD).pistonBehavior(PistonBehavior.DESTROY))*/ val BLOCK_CAFETERIA = BlockCafeteria() fun registerBlocks() { - hashMapOf( - BLOCK_TRIAL_KEYSTONE to "trial_keystone", - BLOCK_LOOT_FABRICATOR to "loot_fabricator", - BLOCK_CAFETERIA to "cafeteria" - ).forEach { (block, id) -> - val identifier = identifier(id) - Registry.register(Registry.BLOCK, identifier, block) - Registry.register(Registry.ITEM, identifier, BlockItem(block, settings().rarity(if(block == BLOCK_CAFETERIA) Rarity.EPIC else Rarity.UNCOMMON))) // This is a bad way to do it, but it's fine for now + linkedMapOf( + BLOCK_TRIAL_KEYSTONE to RarityTuple("trial_keystone", Rarity.UNCOMMON), + BLOCK_LOOT_FABRICATOR to RarityTuple("loot_fabricator", Rarity.UNCOMMON), + /*SYSTEM_GLITCH_HEAD to RarityTuple("system_glitch_head", Rarity.EPIC), + SYSTEM_GLITCH_WALL_HEAD to RarityTuple("system_glitch_wall_head", Rarity.EPIC),*/ + BLOCK_CAFETERIA to RarityTuple("cafeteria", Rarity.EPIC) + ).forEach { (block, tuple) -> + val identifier = identifier(tuple.identifier) + Registry.register(Registries.BLOCK, identifier, block) + Registry.register(Registries.ITEM, identifier, BlockItem(block, FabricItemSettings().rarity(tuple.rarity))) + } + + + ITEMS.add(0, ItemStack(BLOCK_CAFETERIA)) + + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + it.addAfter(ItemStack(ITEM_TRIAL_KEY), BLOCK_TRIAL_KEYSTONE) + it.addBefore(ItemStack(ITEM_PRISTINE_MATTER_OVERWORLD), BLOCK_LOOT_FABRICATOR) } } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/BlockEntityLootFabricator.kt b/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/BlockEntityLootFabricator.kt index 0afad1eb..9694afbf 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/BlockEntityLootFabricator.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/BlockEntityLootFabricator.kt @@ -21,7 +21,6 @@ package dev.nathanpb.dml.blockEntity import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.config -import dev.nathanpb.dml.entity.FakePlayerEntity import dev.nathanpb.dml.enums.EntityCategory import dev.nathanpb.dml.inventory.LootFabricatorInventory import dev.nathanpb.dml.recipe.RECIPE_LOOT_FABRICATOR @@ -30,11 +29,12 @@ import dev.nathanpb.dml.utils.items import dev.nathanpb.dml.utils.setStacks import dev.nathanpb.dml.utils.simulateLootDroppedStacks import io.github.cottonmc.cotton.gui.PropertyDelegateHolder +import net.fabricmc.fabric.api.entity.FakePlayer import net.minecraft.block.BlockState import net.minecraft.block.InventoryProvider import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityTicker -import net.minecraft.entity.damage.DamageSource +import net.minecraft.entity.damage.DamageSources import net.minecraft.inventory.Inventories import net.minecraft.inventory.SidedInventory import net.minecraft.inventory.SimpleInventory @@ -42,12 +42,11 @@ import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound import net.minecraft.recipe.RecipeInputProvider import net.minecraft.recipe.RecipeMatcher +import net.minecraft.registry.Registries import net.minecraft.screen.ArrayPropertyDelegate import net.minecraft.server.world.ServerWorld import net.minecraft.util.collection.DefaultedList -import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry -import net.minecraft.world.WorldAccess +import net.minecraft.util.math.BlockPos import net.minecraft.world.WorldAccess class BlockEntityLootFabricator(pos: BlockPos, state: BlockState) : BlockEntity(BLOCKENTITY_LOOT_FABRICATOR, pos, state), @@ -111,10 +110,10 @@ class BlockEntityLootFabricator(pos: BlockPos, state: BlockState) : } private fun generateLoot(world: ServerWorld, category: EntityCategory): List { - val entityList = Registry.ENTITY_TYPE.iterateEntries(category.tagKey).filter{true} + val entityList = Registries.ENTITY_TYPE.iterateEntries(category.tagKey).filter{true} return (0 until category.exchangeRatio).map { entityList.random().value() - .simulateLootDroppedStacks(world, FakePlayerEntity(world, null), DamageSource.GENERIC) + .simulateLootDroppedStacks(world, FakePlayer.get(world), world.damageSources.generic()) }.flatten().let { stacks -> SimpleInventory(stacks.size).also { tempInventory -> stacks.forEach { tempInventory.addStack(it) } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/blockEntityTypes.kt b/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/blockEntityTypes.kt index 42d93cba..4a6af2de 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/blockEntityTypes.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/blockEntity/blockEntityTypes.kt @@ -25,15 +25,16 @@ import net.minecraft.block.Block import net.minecraft.block.BlockState import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityType +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry lateinit var BLOCKENTITY_TRIAL_KEYSTONE: BlockEntityType lateinit var BLOCKENTITY_LOOT_FABRICATOR: BlockEntityType private fun register(block: B, builder: (BlockPos, BlockState)->E) = Registry.register( - Registry.BLOCK_ENTITY_TYPE, - Registry.BLOCK.getId(block), + Registries.BLOCK_ENTITY_TYPE, + Registries.BLOCK.getId(block), BlockEntityType.Builder.create(builder, block).build(null) ) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/ReiPlugin.kt b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/ReiPlugin.kt index cedb9476..84fc236c 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/ReiPlugin.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/ReiPlugin.kt @@ -30,6 +30,7 @@ import dev.nathanpb.dml.compat.rei.display.TrialRecipeDisplay import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.ITEM_DML import dev.nathanpb.dml.item.ITEM_EMERITUS_HAT +import dev.nathanpb.dml.item.ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE import dev.nathanpb.dml.recipe.CrushingRecipe import dev.nathanpb.dml.recipe.LootFabricatorRecipe import dev.nathanpb.dml.recipe.TrialKeystoneRecipe @@ -41,6 +42,7 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier import me.shedaniel.rei.api.common.plugins.PluginManager import me.shedaniel.rei.api.common.registry.ReloadStage import me.shedaniel.rei.api.common.util.EntryStacks +import net.fabricmc.loader.api.FabricLoader @Suppress("unused") @@ -84,6 +86,11 @@ class ReiPlugin : REIClientPlugin { EntryRegistry.getInstance().removeEntryIf { it.itemStack().item in hiddenItems } + + // Glitch Upgrade Smithing Template is only used for Glitch Armor - hide if not present + EntryRegistry.getInstance().removeEntryIf { + it.itemStack().isOf(ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE) && !FabricLoader.getInstance().isModLoaded("dml-refabricated-modular-armor") + } } } \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/LootFabricatorDisplayCategory.kt b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/LootFabricatorDisplayCategory.kt index 89be2b60..17917a2e 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/LootFabricatorDisplayCategory.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/LootFabricatorDisplayCategory.kt @@ -36,10 +36,10 @@ import net.minecraft.client.MinecraftClient import net.minecraft.entity.EntityType import net.minecraft.entity.LivingEntity import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries import net.minecraft.text.MutableText import net.minecraft.text.Text import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry class LootFabricatorDisplayCategory: DisplayCategory { @@ -57,7 +57,7 @@ class LootFabricatorDisplayCategory: DisplayCategory> = arrayListOf() - Registry.ENTITY_TYPE.iterateEntries(recipeDisplay.recipe.category.tagKey).forEach { + Registries.ENTITY_TYPE.iterateEntries(recipeDisplay.recipe.category.tagKey).forEach { entities.add(it.value()) } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/TrialDisplayCategory.kt b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/TrialDisplayCategory.kt index 0435d556..1b00166f 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/TrialDisplayCategory.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/category/TrialDisplayCategory.kt @@ -66,7 +66,7 @@ class TrialDisplayCategory: DisplayCategory { val keySlot = Widgets.createSlot(Point(centerX, centerY - 24)).entries(input) val keystoneSlot = Widgets.createSlot(Point(centerX, centerY - 8)) - .entries(mutableListOf(EntryStacks.of(BLOCK_TRIAL_KEYSTONE.asItem()))) + .entries(listOf(EntryStacks.of(BLOCK_TRIAL_KEYSTONE.asItem()))) .apply { isBackgroundEnabled = false } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/display/TrialRecipeDisplay.kt b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/display/TrialRecipeDisplay.kt index 62e1b4f2..312888ad 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/display/TrialRecipeDisplay.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/display/TrialRecipeDisplay.kt @@ -21,14 +21,17 @@ package dev.nathanpb.dml.compat.rei.display import dev.nathanpb.dml.compat.rei.ReiPlugin import dev.nathanpb.dml.data.TrialKeyData +import dev.nathanpb.dml.item.ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE import dev.nathanpb.dml.item.ITEM_TRIAL_KEY import dev.nathanpb.dml.recipe.TrialKeystoneRecipe +import dev.nathanpb.dml.utils.RenderUtils import me.shedaniel.rei.api.common.category.CategoryIdentifier import me.shedaniel.rei.api.common.display.Display import me.shedaniel.rei.api.common.entry.EntryIngredient import me.shedaniel.rei.api.common.util.EntryIngredients import me.shedaniel.rei.api.common.util.EntryStacks import net.minecraft.item.ItemStack +import net.minecraft.text.Text class TrialRecipeDisplay ( private val recipe: TrialKeystoneRecipe @@ -47,8 +50,19 @@ class TrialRecipeDisplay ( ) ) - override fun getOutputEntries() = recipe.copyRewards() - .map(EntryStacks::of) - .map(EntryIngredient::of) + override fun getOutputEntries(): List { + val rewards = recipe.copyRewards(true).map(EntryStacks::of) + + rewards.find { + stack -> stack.value.isOf(ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE) + }?.tooltip((recipe.tier.glitchUpgradeOddsText).styled { RenderUtils.STYLE }) + + // TODO System Glitch Head + /*rewards.find { + stack -> stack.value.isOf(SYSTEM_GLITCH_HEAD.asItem()) + }?.tooltip(Text.literal("15%").styled { RenderUtils.STYLE })*/ + + return rewards.map(EntryIngredient::of) + } } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/widgets/EntityDisplayWidget.kt b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/widgets/EntityDisplayWidget.kt index 41ef88d0..45ad6226 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/widgets/EntityDisplayWidget.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/compat/rei/widgets/EntityDisplayWidget.kt @@ -20,10 +20,10 @@ package dev.nathanpb.dml.compat.rei.widgets import dev.nathanpb.dml.compat.rei.isInReiScreen +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.Drawable import net.minecraft.client.gui.Element import net.minecraft.client.gui.screen.ingame.InventoryScreen -import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.LivingEntity import net.minecraft.item.ItemStack import net.minecraft.util.Hand @@ -41,7 +41,7 @@ class EntityDisplayWidget( private var tickCount = 0 - override fun render(matrices: MatrixStack?, mX: Int, mY: Int, delta: Float) { + override fun render(ctx: DrawContext, mX: Int, mY: Int, delta: Float) { tickCount++ val entity = entities[(tickCount / 60) % entities.size] entity.isInReiScreen = true @@ -52,7 +52,7 @@ class EntityDisplayWidget( } preRender.invoke(entity) - InventoryScreen.drawEntity(x, y, size, mouseX, mouseY, entity) + InventoryScreen.drawEntity(ctx, x, y, size, mouseX, mouseY, entity) if (stackInMainHand != null) { entity.setStackInHand(Hand.MAIN_HAND, initialStackMainHand) @@ -60,4 +60,12 @@ class EntityDisplayWidget( entity.isInReiScreen = false } + override fun setFocused(focused: Boolean) { + throw IllegalStateException("don't?") + } + + override fun isFocused(): Boolean { + return true + } + } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/entity/EntityTypes.kt b/base/src/main/kotlin/dev/nathanpb/dml/entity/EntityTypes.kt index 2484a331..ea3699dc 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/entity/EntityTypes.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/entity/EntityTypes.kt @@ -28,7 +28,8 @@ import net.minecraft.client.render.entity.model.EntityModelLayers import net.minecraft.entity.EntityDimensions import net.minecraft.entity.EntityType import net.minecraft.entity.SpawnGroup -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry lateinit var SYSTEM_GLITCH_ENTITY_TYPE: EntityType @@ -38,7 +39,7 @@ private fun registerAttributes() { fun registerEntityTypes() { SYSTEM_GLITCH_ENTITY_TYPE = Registry.register( - Registry.ENTITY_TYPE, + Registries.ENTITY_TYPE, identifier("system_glitch"), FabricEntityTypeBuilder .create(SpawnGroup.MISC, ::SystemGlitchEntity) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/entity/SystemGlitchEntity.kt b/base/src/main/kotlin/dev/nathanpb/dml/entity/SystemGlitchEntity.kt index 112935b3..b9ba0940 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/entity/SystemGlitchEntity.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/entity/SystemGlitchEntity.kt @@ -112,8 +112,8 @@ class SystemGlitchEntity(type: EntityType, world: World) : Ho targetSelector.add(2, ActiveTargetGoal(this, PlayerEntity::class.java, true)) targetSelector.add(3, RevengeGoal(this)) - // rage attacks - // ranged attack + // TODO rage attacks + // TODO ranged attack } /** @@ -179,8 +179,8 @@ class SystemGlitchEntity(type: EntityType, world: World) : Ho } } - override fun applyDamage(source: DamageSource?, amount: Float) { - if (source?.isOutOfWorld == false && config.systemGlitch.damageLimiter > 0) { + override fun applyDamage(source: DamageSource, amount: Float) { + if (source != world.damageSources.outOfWorld() && config.systemGlitch.damageLimiter > 0) { super.applyDamage(source, min(amount, config.systemGlitch.damageLimiter)) } else { super.applyDamage(source, amount) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/enums/DataModelTier.kt b/base/src/main/kotlin/dev/nathanpb/dml/enums/DataModelTier.kt index c44a26dd..0e90e8ec 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/enums/DataModelTier.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/enums/DataModelTier.kt @@ -26,12 +26,12 @@ import net.minecraft.text.Text import kotlin.math.ceil import kotlin.math.max -enum class DataModelTier(textEntry: String, private val dataAmountSupplier: ()->Int) { - FAULTY("tier.${MOD_ID}.faulty", { 0 }), - BASIC("tier.${MOD_ID}.basic", config.dataModel::basicDataRequired), - ADVANCED("tier.${MOD_ID}.advanced", config.dataModel::advancedDataRequired), - SUPERIOR("tier.${MOD_ID}.superior", config.dataModel::superiorDataRequired), - SELF_AWARE("tier.${MOD_ID}.self_aware", config.dataModel::selfAwareDataRequired); +enum class DataModelTier(textEntry: String, private val dataAmountSupplier: ()->Int, val glitchUpgradeOdds: Double) { + FAULTY("tier.${MOD_ID}.faulty", { 0 }, config.trial.faultyGlitchUpgradeOdds), + BASIC("tier.${MOD_ID}.basic", config.dataModel::basicDataRequired, config.trial.basicGlitchUpgradeOdds), + ADVANCED("tier.${MOD_ID}.advanced", config.dataModel::advancedDataRequired, config.trial.advancedGlitchUpgradeOdds), + SUPERIOR("tier.${MOD_ID}.superior", config.dataModel::superiorDataRequired, config.trial.superiorGlitchUpgradeOdds), + SELF_AWARE("tier.${MOD_ID}.self_aware", config.dataModel::selfAwareDataRequired, config.trial.selfAwareGlitchUpgradeOdds); val dataAmount: Int get() = dataAmountSupplier() @@ -49,6 +49,7 @@ enum class DataModelTier(textEntry: String, private val dataAmountSupplier: ()-> } val text = Text.translatable(textEntry) + val glitchUpgradeOddsText = Text.literal("${(glitchUpgradeOdds * 100).toInt()}%") fun isMaxTier() = this == values().last() fun nextTierOrCurrent() = if (isMaxTier()) SELF_AWARE else values()[ordinal+1] val defaultWaveEntityCount = ceil((ordinal + 1) * 1.5).toInt() @@ -56,4 +57,4 @@ enum class DataModelTier(textEntry: String, private val dataAmountSupplier: ()-> val defaultWaveRespawnTimeout by lazy { (values().size - ordinal) * 5 * 20 } -} +} \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/enums/EntityCategory.kt b/base/src/main/kotlin/dev/nathanpb/dml/enums/EntityCategory.kt index a2ba3623..ba334fbe 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/enums/EntityCategory.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/enums/EntityCategory.kt @@ -25,22 +25,22 @@ import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.* import net.minecraft.entity.EntityType import net.minecraft.item.Item -import net.minecraft.tag.TagKey +import net.minecraft.registry.RegistryKeys +import net.minecraft.registry.tag.TagKey import net.minecraft.text.Text -import net.minecraft.util.registry.Registry enum class EntityCategory(val tagKey: TagKey>, var exchangeRatio: Int, private val itemForRendering: ()->Item = ::ITEM_DATA_MODEL) { - OVERWORLD(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("overworld_mobs")), config.lootFabricator.overworldExchangeRatio, ::ITEM_DATA_MODEL_OVERWORLD), - ZOMBIE(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("zombie_mobs")), config.lootFabricator.zombieExchangeRatio, ::ITEM_DATA_MODEL_ZOMBIE), - SKELETON(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("skeleton_mobs")), config.lootFabricator.skeletonExchangeRatio, ::ITEM_DATA_MODEL_SKELETON), - SLIMY(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("slimy_mobs")), config.lootFabricator.slimyExchangeRatio, ::ITEM_DATA_MODEL_SLIMY), - ILLAGER(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("illager_mobs")), config.lootFabricator.illagerExchangeRatio, ::ITEM_DATA_MODEL_ILLAGER), - OCEAN(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("ocean_mobs")), config.lootFabricator.oceanExchangeRatio, ::ITEM_DATA_MODEL_OCEAN), - GHOST(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("ghost_mobs")), config.lootFabricator.ghostExchangeRatio, ::ITEM_DATA_MODEL_GHOST), - NETHER(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("nether_mobs")), config.lootFabricator.netherExchangeRatio, ::ITEM_DATA_MODEL_NETHER), - END(TagKey.of(Registry.ENTITY_TYPE_KEY, identifier("end_mobs")), config.lootFabricator.endExchangeRatio, ::ITEM_DATA_MODEL_END); + OVERWORLD(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("overworld_mobs")), config.lootFabricator.overworldExchangeRatio, ::ITEM_DATA_MODEL_OVERWORLD), + ZOMBIE(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("zombie_mobs")), config.lootFabricator.zombieExchangeRatio, ::ITEM_DATA_MODEL_ZOMBIE), + SKELETON(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("skeleton_mobs")), config.lootFabricator.skeletonExchangeRatio, ::ITEM_DATA_MODEL_SKELETON), + SLIMY(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("slimy_mobs")), config.lootFabricator.slimyExchangeRatio, ::ITEM_DATA_MODEL_SLIMY), + ILLAGER(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("illager_mobs")), config.lootFabricator.illagerExchangeRatio, ::ITEM_DATA_MODEL_ILLAGER), + OCEAN(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("ocean_mobs")), config.lootFabricator.oceanExchangeRatio, ::ITEM_DATA_MODEL_OCEAN), + GHOST(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("ghost_mobs")), config.lootFabricator.ghostExchangeRatio, ::ITEM_DATA_MODEL_GHOST), + NETHER(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("nether_mobs")), config.lootFabricator.netherExchangeRatio, ::ITEM_DATA_MODEL_NETHER), + END(TagKey.of(RegistryKeys.ENTITY_TYPE, identifier("end_mobs")), config.lootFabricator.endExchangeRatio, ::ITEM_DATA_MODEL_END); val displayName = Text.translatable("mobcategory.${MOD_ID}.${tagKey.id.path}") diff --git a/base/src/main/kotlin/dev/nathanpb/dml/event/VanillaEvents.kt b/base/src/main/kotlin/dev/nathanpb/dml/event/VanillaEvents.kt index 8baead87..6d5494e2 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/event/VanillaEvents.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/event/VanillaEvents.kt @@ -74,7 +74,7 @@ object VanillaEvents { } } - val WorldExplosionEvent = event<(World, Entity?, DamageSource?, behavior: ExplosionBehavior?, pos: BlockPos, power: Float, createFire: Boolean, Explosion.DestructionType)-> ActionResult> { listeners -> + val WorldExplosionEvent = event<(World, Entity?, DamageSource?, behavior: ExplosionBehavior?, pos: BlockPos, power: Float, createFire: Boolean, World.ExplosionSourceType)-> ActionResult> { listeners -> { world, entity, damageSource, behavior, pos, power, createFire, destructionType -> val shouldFail = listeners.any { it.invoke(world, entity, damageSource, behavior, pos, power, createFire, destructionType) == ActionResult.FAIL diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDataModel.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDataModel.kt index 095cbc2e..b82954df 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDataModel.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDataModel.kt @@ -24,6 +24,7 @@ import dev.nathanpb.dml.data.dataModel import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.enums.EntityCategory import dev.nathanpb.dml.utils.RenderUtils +import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.client.MinecraftClient import net.minecraft.client.item.TooltipContext import net.minecraft.entity.player.PlayerEntity @@ -35,7 +36,7 @@ import net.minecraft.util.Hand import net.minecraft.util.TypedActionResult import net.minecraft.world.World -class ItemDataModel(val category: EntityCategory? = null) : Item(settings().maxCount(1).fireproof()) { +class ItemDataModel(val category: EntityCategory? = null) : Item(FabricItemSettings().maxCount(1).fireproof()) { override fun appendTooltip( stack: ItemStack?, world: World?, diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDeepLearner.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDeepLearner.kt index e389214d..301c7361 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDeepLearner.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemDeepLearner.kt @@ -20,6 +20,7 @@ package dev.nathanpb.dml.item import dev.nathanpb.dml.screen.handler.DeepLearnerScreenHandlerFactory +import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.Item import net.minecraft.item.ItemStack @@ -28,7 +29,7 @@ import net.minecraft.util.Hand import net.minecraft.util.TypedActionResult import net.minecraft.world.World -class ItemDeepLearner : Item(settings().maxCount(1).fireproof()) { +class ItemDeepLearner : Item(FabricItemSettings().maxCount(1).fireproof()) { override fun use(world: World?, player: PlayerEntity?, hand: Hand): TypedActionResult { (player as? ServerPlayerEntity)?.let { diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemEmeritusHat.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemEmeritusHat.kt index b7496fd3..9949506e 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemEmeritusHat.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemEmeritusHat.kt @@ -19,13 +19,32 @@ package dev.nathanpb.dml.item +import net.minecraft.entity.EquipmentSlot +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.item.Equipment import net.minecraft.item.Item import net.minecraft.item.ItemStack -import net.minecraft.item.Wearable +import net.minecraft.sound.SoundEvent +import net.minecraft.sound.SoundEvents +import net.minecraft.util.Hand import net.minecraft.util.Rarity +import net.minecraft.util.TypedActionResult +import net.minecraft.world.World -class ItemEmeritusHat : Item(Settings().maxCount(1).fireproof()), Wearable { +class ItemEmeritusHat : Item(Settings().maxCount(1).fireproof()), Equipment { - override fun getRarity(stack: ItemStack?) = Rarity.EPIC + override fun use(world: World, user: PlayerEntity, hand: Hand): TypedActionResult { + return equipAndSwap(this, world, user, hand) + } -} + override fun getSlotType(): EquipmentSlot { + return EquipmentSlot.HEAD + } + + override fun getEquipSound(): SoundEvent { + return SoundEvents.ITEM_ARMOR_EQUIP_LEATHER + } + + override fun getRarity(stack: ItemStack) = Rarity.EPIC + +} \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemPristineMatter.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemPristineMatter.kt index e1d241bf..984f1919 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemPristineMatter.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemPristineMatter.kt @@ -19,11 +19,12 @@ package dev.nathanpb.dml.item +import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.item.Item import net.minecraft.item.ItemStack import net.minecraft.util.Rarity -class ItemPristineMatter : Item(settings().fireproof()) { +class ItemPristineMatter : Item(FabricItemSettings().fireproof()) { override fun hasGlint(stack: ItemStack?) = true override fun getRarity(stack: ItemStack?) = Rarity.UNCOMMON diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemTrialKey.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemTrialKey.kt index c6ac345e..f2287c3d 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/ItemTrialKey.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/ItemTrialKey.kt @@ -22,6 +22,7 @@ package dev.nathanpb.dml.item import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.data.trialKeyData import dev.nathanpb.dml.utils.RenderUtils +import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.client.item.TooltipContext import net.minecraft.item.Item import net.minecraft.item.ItemStack @@ -29,7 +30,7 @@ import net.minecraft.text.Text import net.minecraft.util.Formatting import net.minecraft.world.World -class ItemTrialKey : Item(settings().maxCount(1).fireproof()) { +class ItemTrialKey : Item(FabricItemSettings().maxCount(1).fireproof()) { override fun appendTooltip( stack: ItemStack?, world: World?, diff --git a/base/src/main/kotlin/dev/nathanpb/dml/item/Items.kt b/base/src/main/kotlin/dev/nathanpb/dml/item/Items.kt index 39b0c606..32029737 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/item/Items.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/item/Items.kt @@ -22,20 +22,18 @@ package dev.nathanpb.dml.item import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.enums.EntityCategory import dev.nathanpb.dml.identifier -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder +import dev.nathanpb.dml.itemgroup.ITEMS +import dev.nathanpb.dml.mixin.SmithingTemplateItemAccessor +import dev.nathanpb.dml.utils.ItemTuple +import net.fabricmc.fabric.api.item.v1.FabricItemSettings import net.minecraft.item.Item -import net.minecraft.item.ItemGroup import net.minecraft.item.ItemStack +import net.minecraft.item.SmithingTemplateItem +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.text.Text +import net.minecraft.util.Formatting import net.minecraft.util.Rarity -import net.minecraft.util.registry.Registry - -val ITEM_GROUP: ItemGroup = FabricItemGroupBuilder.build(identifier("tab_${MOD_ID}")) { - ItemStack(ITEM_DML) -} - -fun settings(baseSettings: Item.Settings = Item.Settings()) = baseSettings.apply { - group(ITEM_GROUP) -} //val ITEM_GUIDE_TABLET = ItemGuideTablet() val ITEM_DML = Item(Item.Settings()) @@ -63,48 +61,59 @@ val ITEM_PRISTINE_MATTER_GHOST = ItemPristineMatter() val ITEM_PRISTINE_MATTER_ILLAGER = ItemPristineMatter() val ITEM_PRISTINE_MATTER_OCEAN = ItemPristineMatter() -val ITEM_SOOT_REDSTONE = Item(settings()) -val ITEM_SOOT_PLATE = Item(settings()) -val ITEM_SOOT_MACHINE_CASE = Item(settings()) +val ITEM_SOOT_REDSTONE = Item(FabricItemSettings()) +val ITEM_SOOT_PLATE = Item(FabricItemSettings()) +val ITEM_SOOT_MACHINE_CASE = Item(FabricItemSettings()) val ITEM_EMERITUS_HAT = ItemEmeritusHat() -val ITEM_PHYSICALLY_CONDENSED_MATRIX_FRAGMENT = Item(settings().fireproof().rarity(Rarity.RARE)) -val ITEM_GLITCH_INGOT = Item(settings().fireproof().rarity(Rarity.RARE)) - +val ITEM_PHYSICALLY_CONDENSED_MATRIX_FRAGMENT = Item(FabricItemSettings().fireproof().rarity(Rarity.RARE)) +val ITEM_GLITCH_INGOT = Item(FabricItemSettings().fireproof().rarity(Rarity.RARE)) +val ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE = SmithingTemplateItem( + Text.translatable("item.${MOD_ID}.glitch_upgrade_smithing_template.applies_to").formatted(Formatting.BLUE), + Text.translatable("item.${MOD_ID}.glitch_upgrade_smithing_template.ingredients").formatted(Formatting.BLUE), + Text.translatable("upgrade.${MOD_ID}.glitch_upgrade").formatted(Formatting.GRAY), + Text.translatable("item.${MOD_ID}.glitch_upgrade_smithing_template.base_slot_description"), + Text.translatable("item.${MOD_ID}.glitch_upgrade_smithing_template.additions_slot_description"), + SmithingTemplateItemAccessor.dml_getArmorTrimEmptyBaseSlotTextures(), + SmithingTemplateItemAccessor.dml_getNetheriteUpgradeEmptyAdditionsSlotTextures() +) fun registerItems() { - mapOf( - //ITEM_GUIDE_TABLET to "guide_tablet", - ITEM_DML to MOD_ID, - ITEM_DEEP_LEARNER to "deep_learner", - ITEM_TRIAL_KEY to "trial_key", - ITEM_DATA_MODEL to "data_model", - ITEM_DATA_MODEL_NETHER to "data_model_nether", - ITEM_DATA_MODEL_SLIMY to "data_model_slimy", - ITEM_DATA_MODEL_OVERWORLD to "data_model_overworld", - ITEM_DATA_MODEL_ZOMBIE to "data_model_zombie", - ITEM_DATA_MODEL_SKELETON to "data_model_skeleton", - ITEM_DATA_MODEL_END to "data_model_end", - ITEM_DATA_MODEL_GHOST to "data_model_ghost", - ITEM_DATA_MODEL_ILLAGER to "data_model_illager", - ITEM_DATA_MODEL_OCEAN to "data_model_ocean", - ITEM_SOOT_REDSTONE to "soot_redstone", - ITEM_SOOT_PLATE to "soot_plate", - ITEM_SOOT_MACHINE_CASE to "machine_casing", - ITEM_PRISTINE_MATTER_NETHER to "pristine_matter_nether", - ITEM_PRISTINE_MATTER_SLIMY to "pristine_matter_slimy", - ITEM_PRISTINE_MATTER_OVERWORLD to "pristine_matter_overworld", - ITEM_PRISTINE_MATTER_ZOMBIE to "pristine_matter_zombie", - ITEM_PRISTINE_MATTER_SKELETON to "pristine_matter_skeleton", - ITEM_PRISTINE_MATTER_END to "pristine_matter_end", - ITEM_PRISTINE_MATTER_GHOST to "pristine_matter_ghost", - ITEM_PRISTINE_MATTER_ILLAGER to "pristine_matter_illager", - ITEM_PRISTINE_MATTER_OCEAN to "pristine_matter_ocean", - ITEM_EMERITUS_HAT to "emeritus_hat", - ITEM_PHYSICALLY_CONDENSED_MATRIX_FRAGMENT to "physically_condensed_matrix_fragment", - ITEM_GLITCH_INGOT to "glitch_ingot" - ).forEach { (item, id) -> - Registry.register(Registry.ITEM, identifier(id), item) + linkedMapOf( + //ITEM_GUIDE_TABLET to ItemTuple("guide_tablet"), + ITEM_DML to ItemTuple(MOD_ID, false), + ITEM_DEEP_LEARNER to ItemTuple("deep_learner"), + ITEM_DATA_MODEL to ItemTuple("data_model"), + ITEM_DATA_MODEL_OVERWORLD to ItemTuple("data_model_overworld"), + ITEM_DATA_MODEL_ZOMBIE to ItemTuple("data_model_zombie"), + ITEM_DATA_MODEL_SKELETON to ItemTuple("data_model_skeleton"), + ITEM_DATA_MODEL_SLIMY to ItemTuple("data_model_slimy"), + ITEM_DATA_MODEL_ILLAGER to ItemTuple("data_model_illager"), + ITEM_DATA_MODEL_OCEAN to ItemTuple("data_model_ocean"), + ITEM_DATA_MODEL_GHOST to ItemTuple("data_model_ghost"), + ITEM_DATA_MODEL_NETHER to ItemTuple("data_model_nether"), + ITEM_DATA_MODEL_END to ItemTuple("data_model_end"), + ITEM_TRIAL_KEY to ItemTuple("trial_key"), + ITEM_PRISTINE_MATTER_OVERWORLD to ItemTuple("pristine_matter_overworld"), + ITEM_PRISTINE_MATTER_ZOMBIE to ItemTuple("pristine_matter_zombie"), + ITEM_PRISTINE_MATTER_SKELETON to ItemTuple("pristine_matter_skeleton"), + ITEM_PRISTINE_MATTER_SLIMY to ItemTuple("pristine_matter_slimy"), + ITEM_PRISTINE_MATTER_ILLAGER to ItemTuple("pristine_matter_illager"), + ITEM_PRISTINE_MATTER_OCEAN to ItemTuple("pristine_matter_ocean"), + ITEM_PRISTINE_MATTER_GHOST to ItemTuple("pristine_matter_ghost"), + ITEM_PRISTINE_MATTER_NETHER to ItemTuple("pristine_matter_nether"), + ITEM_PRISTINE_MATTER_END to ItemTuple("pristine_matter_end"), + ITEM_EMERITUS_HAT to ItemTuple("emeritus_hat", false), + ITEM_SOOT_REDSTONE to ItemTuple("soot_redstone"), + ITEM_SOOT_PLATE to ItemTuple("soot_plate"), + ITEM_SOOT_MACHINE_CASE to ItemTuple("machine_casing"), + ITEM_PHYSICALLY_CONDENSED_MATRIX_FRAGMENT to ItemTuple("physically_condensed_matrix_fragment"), + ITEM_GLITCH_INGOT to ItemTuple("glitch_ingot"), + ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE to ItemTuple("glitch_upgrade_smithing_template", false) + ).forEach { (item, tuple) -> + Registry.register(Registries.ITEM, identifier(tuple.identifier), item) + if(tuple.shown) ITEMS.add(ItemStack(item)) } -} + +} \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/itemgroup/ItemGroup.kt b/base/src/main/kotlin/dev/nathanpb/dml/itemgroup/ItemGroup.kt new file mode 100644 index 00000000..af2c8970 --- /dev/null +++ b/base/src/main/kotlin/dev/nathanpb/dml/itemgroup/ItemGroup.kt @@ -0,0 +1,28 @@ +package dev.nathanpb.dml.itemgroup + +import dev.nathanpb.dml.MOD_ID +import dev.nathanpb.dml.identifier +import dev.nathanpb.dml.item.ITEM_DML +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup +import net.minecraft.item.ItemConvertible +import net.minecraft.item.ItemGroup +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry +import net.minecraft.registry.RegistryKey +import net.minecraft.registry.RegistryKeys +import net.minecraft.text.Text + + +val ITEM_GROUP_KEY: RegistryKey = RegistryKey.of(RegistryKeys.ITEM_GROUP, identifier("tab_${MOD_ID}")) +val ITEMS = ArrayList() + +fun registerItemGroup() { + Registry.register(Registries.ITEM_GROUP, ITEM_GROUP_KEY, FabricItemGroup.builder() + .displayName(Text.translatable("itemGroup.$MOD_ID.tab_$MOD_ID")) + .icon { ItemStack(ITEM_DML) } + .entries { _: ItemGroup.DisplayContext, entries: ItemGroup.Entries -> + entries.addAll(ITEMS) + } + .build()) +} \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/listener/CrushingRecipeListener.kt b/base/src/main/kotlin/dev/nathanpb/dml/listener/CrushingRecipeListener.kt index f8ea5380..2e0c2880 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/listener/CrushingRecipeListener.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/listener/CrushingRecipeListener.kt @@ -29,7 +29,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.world.World -class CrushingRecipeListener : AttackBlockCallback { +class CrushingRecipeListener : AttackBlockCallback { // FIXME override fun interact( player: PlayerEntity, world: World, @@ -47,7 +47,7 @@ class CrushingRecipeListener : AttackBlockCallback { .firstOrNull { state.block == it.block && it.matches(inv, world) }?.apply { - player.inventory.offerOrDrop(craft(inv)) + player.inventory.offerOrDrop(craft(inv, world.registryManager)) return ActionResult.CONSUME } } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/CrushingRecipe.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/CrushingRecipe.kt index 377b2cfa..7c9548c4 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/CrushingRecipe.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/CrushingRecipe.kt @@ -29,25 +29,26 @@ import net.minecraft.recipe.Ingredient import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeSerializer import net.minecraft.recipe.ShapedRecipe +import net.minecraft.registry.DynamicRegistryManager +import net.minecraft.registry.Registries import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry import net.minecraft.world.World class CrushingRecipe ( private val id: Identifier, val input: Ingredient, val block: Block, - private val output: ItemStack + val output: ItemStack ) : Recipe { override fun getId() = id override fun getType() = RECIPE_CRUSHING override fun fits(width: Int, height: Int) = true override fun getSerializer() = CRUSHING_RECIPE_SERIALIZER - override fun getOutput() = output + override fun getOutput(registry: DynamicRegistryManager) = output - override fun craft(inv: SimpleInventory): ItemStack { - return getOutput().copy().also { + override fun craft(inv: SimpleInventory, registry: DynamicRegistryManager): ItemStack { + return getOutput(registry).copy().also { inv.items().firstOrNull { input.test(it) }?.decrement(1) @@ -61,7 +62,7 @@ class CrushingRecipe ( class Serializer : RecipeSerializer { override fun write(buf: PacketByteBuf, recipe: CrushingRecipe) { recipe.input.write(buf) - buf.writeIdentifier(Registry.BLOCK.getId(recipe.block)) + buf.writeIdentifier(Registries.BLOCK.getId(recipe.block)) buf.writeItemStack(recipe.output) } @@ -69,7 +70,7 @@ class CrushingRecipe ( return CrushingRecipe( id, Ingredient.fromPacket(buf), - Registry.BLOCK[buf.readIdentifier()], + Registries.BLOCK[buf.readIdentifier()], buf.readItemStack() ) } @@ -78,7 +79,7 @@ class CrushingRecipe ( return CrushingRecipe( id, Ingredient.fromJson(json.getAsJsonObject("input")), - Registry.BLOCK[Identifier(json.getAsJsonPrimitive("block").asString)], + Registries.BLOCK[Identifier(json.getAsJsonPrimitive("block").asString)], ShapedRecipe.outputFromJson(json.getAsJsonObject("output")) ) } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/LootFabricatorRecipe.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/LootFabricatorRecipe.kt index b59e5ed7..d452a64c 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/LootFabricatorRecipe.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/LootFabricatorRecipe.kt @@ -27,6 +27,7 @@ import net.minecraft.network.PacketByteBuf import net.minecraft.recipe.Ingredient import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeSerializer +import net.minecraft.registry.DynamicRegistryManager import net.minecraft.util.Identifier import net.minecraft.world.World @@ -43,9 +44,9 @@ class LootFabricatorRecipe ( override fun getType() = RECIPE_LOOT_FABRICATOR - override fun craft(inv: LootFabricatorInventory): ItemStack = ItemStack.EMPTY + override fun craft(inv: LootFabricatorInventory, registry: DynamicRegistryManager): ItemStack = ItemStack.EMPTY - override fun getOutput(): ItemStack = ItemStack.EMPTY + override fun getOutput(registry: DynamicRegistryManager): ItemStack = ItemStack.EMPTY override fun fits(width: Int, height: Int) = true diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeSerializers.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeSerializers.kt index 39bbf84c..35fc8008 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeSerializers.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeSerializers.kt @@ -22,7 +22,8 @@ package dev.nathanpb.dml.recipe import dev.nathanpb.dml.identifier import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeSerializer -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry lateinit var TRIAL_KEY_ATTUNEMENT_SERIALIZER: TrialKeyAttunementRecipeSerializer lateinit var TRIAL_KEYSTONE_RECIPE_SERIALIZER: TrialKeystoneRecipe.Serializer @@ -30,7 +31,7 @@ lateinit var CRUSHING_RECIPE_SERIALIZER: CrushingRecipe.Serializer lateinit var LOOT_FABRICATOR_SERIALIZER: LootFabricatorRecipe.Serializer private fun , T: Recipe<*>>register(id: String, serializer: S) = Registry.register( - Registry.RECIPE_SERIALIZER, + Registries.RECIPE_SERIALIZER, identifier(id).toString(), serializer ) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeTypes.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeTypes.kt index c0a3c1f0..ca62c7bf 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeTypes.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/RecipeTypes.kt @@ -22,8 +22,9 @@ package dev.nathanpb.dml.recipe import dev.nathanpb.dml.identifier import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeType +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry lateinit var RECIPE_TRIAL_KEY_ATTUNE: RecipeType lateinit var RECIPE_TRIAL_KEYSTONE: RecipeType @@ -31,7 +32,7 @@ lateinit var RECIPE_CRUSHING: RecipeType lateinit var RECIPE_LOOT_FABRICATOR: RecipeType private fun ?> register(id: Identifier) = Registry.register( - Registry.RECIPE_TYPE, + Registries.RECIPE_TYPE, id, object : RecipeType { override fun toString() = id.toString() diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipe.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipe.kt index 728923fa..128ada96 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipe.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipe.kt @@ -27,13 +27,15 @@ import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.ItemDataModel import dev.nathanpb.dml.item.ItemTrialKey import dev.nathanpb.dml.utils.items -import net.minecraft.inventory.CraftingInventory import net.minecraft.inventory.Inventory +import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.ItemStack import net.minecraft.recipe.CraftingRecipe import net.minecraft.recipe.Ingredient import net.minecraft.recipe.RecipeType import net.minecraft.recipe.ShapelessRecipe +import net.minecraft.recipe.book.CraftingRecipeCategory +import net.minecraft.registry.DynamicRegistryManager import net.minecraft.util.Identifier import net.minecraft.util.collection.DefaultedList import net.minecraft.world.World @@ -45,12 +47,13 @@ class TrialKeyAttuneRecipe ( ) : ShapelessRecipe( id, identifier("trial_key_attune").toString(), + CraftingRecipeCategory.MISC, output, inputs ) { - override fun craft(craftingInventory: CraftingInventory): ItemStack = getOutput().copy().apply { - findDataModel(craftingInventory)?.let { + override fun craft(recipeInputInventory: RecipeInputInventory, dynamicRegistryManager: DynamicRegistryManager): ItemStack = output.copy().apply { + findDataModel(recipeInputInventory)?.let { trialKeyData = TrialKeyData.fromDataModelData(it) } } @@ -63,9 +66,9 @@ class TrialKeyAttuneRecipe ( override fun getSerializer() = TRIAL_KEY_ATTUNEMENT_SERIALIZER - override fun getOutput(): ItemStack = output.copy() + override fun getOutput(dynamicRegistryManager: DynamicRegistryManager): ItemStack = output.copy() - override fun matches(craftingInventory: CraftingInventory, world: World): Boolean { + override fun matches(craftingInventory: RecipeInputInventory, world: World): Boolean { val dataModel = findDataModel(craftingInventory) return super.matches(craftingInventory, world) && dataModel != null diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipeSerializer.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipeSerializer.kt index b73de202..0b37978c 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipeSerializer.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeyAttunementRecipeSerializer.kt @@ -20,13 +20,14 @@ package dev.nathanpb.dml.recipe import com.google.gson.JsonObject +import dev.nathanpb.dml.mixin.ShapelessRecipeAccessor import net.minecraft.item.ItemStack import net.minecraft.network.PacketByteBuf import net.minecraft.recipe.Ingredient import net.minecraft.recipe.RecipeSerializer +import net.minecraft.registry.Registries import net.minecraft.util.Identifier import net.minecraft.util.collection.DefaultedList -import net.minecraft.util.registry.Registry class TrialKeyAttunementRecipeSerializer : RecipeSerializer { @@ -35,7 +36,7 @@ class TrialKeyAttunementRecipeSerializer : RecipeSerializer - val item = Registry.ITEM.getOrEmpty(Identifier(itemId)) + val item = Registries.ITEM.getOrEmpty(Identifier(itemId)) return@let if (item.isPresent) { ItemStack(item.get()) } else ItemStack.EMPTY diff --git a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeystoneRecipe.kt b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeystoneRecipe.kt index af7fff5b..69eb5982 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeystoneRecipe.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/recipe/TrialKeystoneRecipe.kt @@ -23,15 +23,19 @@ import com.google.gson.JsonObject import dev.nathanpb.dml.data.TrialKeyData import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.enums.EntityCategory +import dev.nathanpb.dml.item.ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE import dev.nathanpb.dml.utils.takeOrNull +import net.fabricmc.loader.api.FabricLoader import net.minecraft.inventory.SimpleInventory import net.minecraft.item.ItemStack import net.minecraft.network.PacketByteBuf import net.minecraft.recipe.Recipe import net.minecraft.recipe.RecipeSerializer import net.minecraft.recipe.ShapedRecipe +import net.minecraft.registry.DynamicRegistryManager import net.minecraft.util.Identifier import net.minecraft.world.World +import kotlin.random.Random class TrialKeystoneRecipe ( private val id: Identifier, @@ -52,13 +56,36 @@ class TrialKeystoneRecipe ( .firstOrNull { it.category == data.category && it.tier == data.tier() } } - fun copyRewards() = rewards.map(ItemStack::copy) + fun copyRewards(): MutableList { + return copyRewards(false) + } + + fun copyRewards(onREI: Boolean): MutableList { + val rewardsCopy = rewards.map(ItemStack::copy).toMutableList() + + // Glitch Upgrade + if(FabricLoader.getInstance().isModLoaded("dml-refabricated-modular-armor")) { // require modular-armor module + if(tier.glitchUpgradeOdds > 0 && (Random.nextDouble() < tier.glitchUpgradeOdds || onREI)) { + rewardsCopy.add(ItemStack(ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE)) + } + } + + // TODO System Glitch Head + /* + if(tier == DataModelTier.SELF_AWARE) { + if((Random.nextDouble() < 0.15 || onREI)) { + //rewardsCopy.add(ItemStack(SYSTEM_GLITCH_HEAD)) + } + }*/ + + return rewardsCopy + } @Deprecated("", ReplaceWith("copyRewards", "dev.nathanpb.dml.recipe")) - override fun craft(inv: SimpleInventory?): ItemStack = ItemStack.EMPTY + override fun craft(inv: SimpleInventory, registry: DynamicRegistryManager): ItemStack = ItemStack.EMPTY @Deprecated("", ReplaceWith("copyRewards", "dev.nathanpb.dml.recipe")) - override fun getOutput(): ItemStack = ItemStack.EMPTY + override fun getOutput(registry: DynamicRegistryManager): ItemStack = ItemStack.EMPTY override fun getId() = id diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/DeepLearnerScreenHandler.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/DeepLearnerScreenHandler.kt index 793e6d78..e9504cdb 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/DeepLearnerScreenHandler.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/DeepLearnerScreenHandler.kt @@ -26,7 +26,6 @@ import dev.nathanpb.dml.data.DeepLearnerData import dev.nathanpb.dml.data.dataModel import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.ItemDataModel -import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot import dev.nathanpb.dml.screen.handler.widget.WEntityShowcase import dev.nathanpb.dml.screen.handler.widget.WStylizedButton import dev.nathanpb.dml.utils.RenderUtils @@ -36,18 +35,22 @@ import dev.nathanpb.dml.utils.setStacks import io.github.cottonmc.cotton.gui.SyncedGuiDescription import io.github.cottonmc.cotton.gui.widget.* import io.github.cottonmc.cotton.gui.widget.data.Insets +import io.github.cottonmc.cotton.gui.widget.icon.Icon +import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon import net.fabricmc.api.EnvType import net.fabricmc.loader.api.FabricLoader +import net.minecraft.client.gui.DrawContext import net.minecraft.entity.EntityType import net.minecraft.entity.LivingEntity import net.minecraft.entity.player.PlayerInventory +import net.minecraft.inventory.Inventory import net.minecraft.inventory.SimpleInventory import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries import net.minecraft.screen.ArrayPropertyDelegate import net.minecraft.text.Text import net.minecraft.util.Formatting import net.minecraft.util.Hand -import net.minecraft.util.registry.Registry import kotlin.properties.Delegates @@ -165,7 +168,7 @@ class DeepLearnerScreenHandler ( } val showcaseEntities: MutableList> = arrayListOf() - Registry.ENTITY_TYPE.iterateEntries(currentDataModel?.category?.tagKey).forEach { + Registries.ENTITY_TYPE.iterateEntries(currentDataModel?.category?.tagKey).forEach { showcaseEntities.add(it.value()) } @@ -210,11 +213,7 @@ class DeepLearnerScreenHandler ( root.add(showcase, 0, 1*18, 3*18, 4*18) root.add( - WTooltippedItemSlot.of(blockInventory, 0, 2, 2, Text.translatable("gui.${MOD_ID}.data_model_only")).apply { - setFilter { stack -> - stack.item is ItemDataModel && stack.dataModel.category != null - } - + DataModelSlots(blockInventory).apply { addChangeListener { _, inventory, index, stack -> if (stack.isEmpty && index == currentSlot) { currentSlot = inventory.items().mapIndexedNotNull { slotIndex, itemStack -> @@ -222,6 +221,7 @@ class DeepLearnerScreenHandler ( }.closestValue(currentSlot) } } + }, 7*18, 1*18 ) @@ -243,7 +243,7 @@ class DeepLearnerScreenHandler ( update() } - root.add(this.createPlayerInventoryPanel(), 0, 5*18+6) + root.add(createPlayerInventoryPanel(), 0, 5*18+6) root.validate(this) update() } @@ -257,4 +257,25 @@ class DeepLearnerScreenHandler ( return RenderUtils.getDefaultTextColor(world) } -} + + private class DataModelSlots( + inventory: Inventory + ): WItemSlot(inventory, 0, 2, 2, false) { + + init { + setFilter { stack -> + stack.item is ItemDataModel && stack.dataModel.category != null + } + + icon = TextureIcon(identifier("textures/gui/slot_background/2x2_data_model_slot_background.png")) + } + + // Hacky way to render a TextureIcon on a 2x2 slot, ignore the on-screen warnings + override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { + backgroundPainter?.paintBackground(context, x, y, this) + + icon?.paint(context, x + 1, y + 1, 34) + } + + } +} \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt index ab52b81f..60ab7ed4 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt @@ -21,6 +21,7 @@ package dev.nathanpb.dml.screen.handler import dev.nathanpb.dml.MOD_ID +import dev.nathanpb.dml.identifier import dev.nathanpb.dml.recipe.LootFabricatorRecipe import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot import dev.nathanpb.dml.utils.RenderUtils @@ -29,6 +30,7 @@ import io.github.cottonmc.cotton.gui.widget.WBar import io.github.cottonmc.cotton.gui.widget.WGridPanel import io.github.cottonmc.cotton.gui.widget.WItemSlot import io.github.cottonmc.cotton.gui.widget.data.Insets +import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon import net.minecraft.entity.player.PlayerEntity import net.minecraft.entity.player.PlayerInventory import net.minecraft.inventory.SimpleInventory @@ -50,9 +52,13 @@ class LootFabricatorHandler( root.insets = Insets.ROOT_PANEL setRootPanel(root) - val inputSlot = WTooltippedItemSlot.of(blockInventory, 0, Text.translatable("gui.${MOD_ID}.pristine_matter_only")).setFilter { stack -> - world.recipeManager.values().filterIsInstance() - .any { it.input.test(stack) } + val inputSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply { + setFilter { stack -> + world.recipeManager.values().filterIsInstance() + .any { it.input.test(stack) } + } + + icon = TextureIcon(identifier("textures/gui/slot_background/pristine_matter_slot_background.png")) } root.add(inputSlot, 1, 2) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/slot/WTooltippedItemSlot.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/slot/WTooltippedItemSlot.kt index 22d304d2..948b1cc5 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/slot/WTooltippedItemSlot.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/slot/WTooltippedItemSlot.kt @@ -2,7 +2,7 @@ package dev.nathanpb.dml.screen.handler.slot import io.github.cottonmc.cotton.gui.widget.WItemSlot import net.minecraft.client.MinecraftClient -import net.minecraft.client.util.math.MatrixStack +import net.minecraft.client.gui.DrawContext import net.minecraft.inventory.Inventory import net.minecraft.text.Text @@ -17,28 +17,28 @@ open class WTooltippedItemSlot( private val startIndex: Int = 0, private val slotsWide: Int = 1, private val slotsHigh: Int = 1, - big: Boolean = false + big: Boolean ) : WItemSlot(inventory, startIndex, slotsWide, slotsHigh, big) { - override fun renderTooltip(matrices: MatrixStack?, x: Int, y: Int, tX: Int, tY: Int) { + override fun renderTooltip(ctx: DrawContext, x: Int, y: Int, tX: Int, tY: Int) { val slots = startIndex until startIndex + (slotsHigh * slotsWide) if (emptyTooltip.size != 0 && slots.all { inventory.getStack(it).isEmpty }) { - val screen = MinecraftClient.getInstance().currentScreen - screen?.renderTooltip(matrices, emptyTooltip, tX + x, tY + y) + ctx.drawTooltip(MinecraftClient.getInstance().textRenderer, emptyTooltip, tX + x, tY + y) } } companion object { - fun of(inventory: Inventory, index: Int, vararg emptyTooltip: Text): WTooltippedItemSlot = - WTooltippedItemSlot(emptyTooltip.toMutableList(), inventory, index) + fun of(inventory: Inventory, index: Int, big: Boolean, vararg emptyTooltip: Text): WTooltippedItemSlot = + WTooltippedItemSlot(emptyTooltip.toMutableList(), inventory, index, 1, 1, big) fun of( inventory: Inventory, startIndex: Int, slotsWide: Int, slotsHigh: Int, + big: Boolean, vararg emptyTooltip: Text - ): WTooltippedItemSlot = WTooltippedItemSlot(emptyTooltip.toMutableList(), inventory, startIndex, slotsWide, slotsHigh) + ): WTooltippedItemSlot = WTooltippedItemSlot(emptyTooltip.toMutableList(), inventory, startIndex, slotsWide, slotsHigh, big) } } \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WEntityShowcase.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WEntityShowcase.kt index cd62d754..c05a74dd 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WEntityShowcase.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WEntityShowcase.kt @@ -25,7 +25,7 @@ import dev.nathanpb.dml.utils.drawEntity import io.github.cottonmc.cotton.gui.SyncedGuiDescription import io.github.cottonmc.cotton.gui.widget.WWidget import net.minecraft.client.MinecraftClient -import net.minecraft.client.util.math.MatrixStack +import net.minecraft.client.gui.DrawContext import net.minecraft.entity.EntityType import net.minecraft.entity.LivingEntity import net.minecraft.village.VillagerData @@ -58,9 +58,8 @@ class WEntityShowcase( override fun canResize() = true - override fun paint(matrices: MatrixStack, x: Int, y: Int, mouseX: Int, mouseY: Int) { - super.paint(matrices, x, y, mouseX, mouseY) - matrices.push() + override fun paint(ctx: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { + super.paint(ctx, x, y, mouseX, mouseY) val entityType = entityType ?: return val world = MinecraftClient.getInstance().world ?: return @@ -83,7 +82,6 @@ class WEntityShowcase( 0, 180F, (tickCount % 360F) * 2F + 150F ) - matrices.pop() // only update at the exact tick the mob changes if(tickCount % 3 == 0) { diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WStylizedButton.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WStylizedButton.kt index ca2367ea..31fc9304 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WStylizedButton.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/widget/WStylizedButton.kt @@ -4,7 +4,7 @@ import io.github.cottonmc.cotton.gui.client.ScreenDrawing import io.github.cottonmc.cotton.gui.widget.WButton import net.fabricmc.api.EnvType import net.fabricmc.api.Environment -import net.minecraft.client.util.math.MatrixStack +import net.minecraft.client.gui.DrawContext import net.minecraft.text.Text import net.minecraft.util.Identifier @@ -19,7 +19,7 @@ class WStylizedButton( * Make sure to check it if anything breaks between versions! */ @Environment(EnvType.CLIENT) - override fun paint(matrices: MatrixStack?, x: Int, y: Int, mouseX: Int, mouseY: Int) { + override fun paint(ctx: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { val hovered = mouseX >= 0 && mouseY >= 0 && mouseX < getWidth() && mouseY < getHeight() var state = 1 // 1 = regular, 2 = hovered and 0 = disabled. if (!isEnabled) { @@ -36,7 +36,7 @@ class WStylizedButton( val buttonHeight = 20 * px val buttonEndLeft = (200 - getWidth() / 2) * px ScreenDrawing.texturedRect( - matrices, + ctx, x, y, getWidth() / 2, @@ -49,7 +49,7 @@ class WStylizedButton( -0x1 ) ScreenDrawing.texturedRect( - matrices, + ctx, x + getWidth() / 2, y, getWidth() / 2, @@ -68,7 +68,7 @@ class WStylizedButton( } ScreenDrawing.drawStringWithShadow( - matrices, + ctx, textLabel.asOrderedText(), alignment, x, diff --git a/base/src/main/kotlin/dev/nathanpb/dml/trial/Trial.kt b/base/src/main/kotlin/dev/nathanpb/dml/trial/Trial.kt index 32f51a2d..325133d2 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/trial/Trial.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/trial/Trial.kt @@ -36,6 +36,7 @@ import net.minecraft.entity.boss.BossBar import net.minecraft.entity.boss.ServerBossBar import net.minecraft.entity.mob.HostileEntity import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.server.world.ServerWorld import net.minecraft.sound.SoundCategory @@ -44,7 +45,6 @@ import net.minecraft.text.MutableText import net.minecraft.text.Text import net.minecraft.util.TypeFilter import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry import net.minecraft.world.World import java.util.* import kotlin.random.Random @@ -167,21 +167,21 @@ class Trial ( state = TrialState.RUNNING ModEvents.TrialStateChanged.invoker().invoke(this) spawnSystemGlitch() - world.getPlayersByUUID(players).forEach { - it.playSound( - SoundEvents.BLOCK_NOTE_BLOCK_BASS, - SoundCategory.BLOCKS, - 1F, 1F - ) - } + world.playSound( + null, + pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), + SoundEvents.BLOCK_NOTE_BLOCK_BASS, + SoundCategory.BLOCKS, + 1F, 1F, pos.asLong() + ) } else if (tickCount % 20 == 0) { - world.getPlayersByUUID(players).forEach { - it.playSound( - SoundEvents.BLOCK_NOTE_BLOCK_BASS, - SoundCategory.BLOCKS, - 1.5F, .75F - ) - } + world.playSound( + null, + pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), + SoundEvents.BLOCK_NOTE_BLOCK_BASS, + SoundCategory.BLOCKS, + 1.5F, .75F, pos.asLong() + ) } } else -> {} // Suppress non-exhaustive when @@ -241,7 +241,7 @@ class Trial ( private fun spawnSystemGlitch() { (world as? ServerWorld)?.let { world -> systemGlitch = SYSTEM_GLITCH_ENTITY_TYPE.spawn( - world, null, null, null, pos.add(0, 2, 0), SpawnReason.EVENT, false, false + world, null, null, pos.add(0, 2, 0), SpawnReason.EVENT, false, false )?.also { it.tier = recipe.tier it.health = loadedSystemGlitchHealth ?: it.maxHealth @@ -266,9 +266,9 @@ class Trial ( private fun spawnWave() { (world as? ServerWorld)?.let { world -> (0 until recipe.waveEntityCount).map { - val distributionTable = Registry.ENTITY_TYPE.iterateEntries(recipe.category.tagKey) + val distributionTable = Registries.ENTITY_TYPE.iterateEntries(recipe.category.tagKey) .associateWith { - val id = Registry.ENTITY_TYPE.getId(it.value()).toString() + val id = Registries.ENTITY_TYPE.getId(it.value()).toString() recipe.spawnRate.entries .last { (k) -> k.matches(id) } .value @@ -277,7 +277,7 @@ class Trial ( val entity = discreteDistribution(distributionTable).value() entity.spawn( world, - null, null, null, + null, null, pos.add(Random.nextInt(-2, 2), 5, Random.nextInt(-2, 2)), SpawnReason.SPAWNER, false, false diff --git a/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt b/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt index 29aefd6e..529b63cb 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt @@ -31,13 +31,13 @@ import net.minecraft.entity.Entity import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.mob.EndermanEntity import net.minecraft.entity.player.PlayerEntity +import net.minecraft.registry.Registries import net.minecraft.util.ActionResult import net.minecraft.util.Hand import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d -import net.minecraft.util.registry.Registry import net.minecraft.world.World import net.minecraft.world.explosion.Explosion import net.minecraft.world.explosion.ExplosionBehavior @@ -68,7 +68,7 @@ class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback { && world.getBlockState(pos)?.run { block !== Blocks.CHEST && block !== Blocks.TRAPPED_CHEST - && "grave" !in Registry.BLOCK.getId(block).path + && "grave" !in Registries.BLOCK.getId(block).path } != false ) { ActionResult.FAIL @@ -93,15 +93,15 @@ class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback { pos: BlockPos, power: Float, createFire: Boolean, - destructionType: Explosion.DestructionType? + destructionType: World.ExplosionSourceType ): ActionResult { if ( !world.isClient && config.trial.explosionGriefPrevention - && destructionType != Explosion.DestructionType.NONE + && destructionType != World.ExplosionSourceType.NONE && isBlockProtected(world, pos) ) { - world.createExplosion(entity, pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), power, createFire, Explosion.DestructionType.NONE) + world.createExplosion(entity, pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), power, createFire, World.ExplosionSourceType.NONE) return ActionResult.FAIL } return ActionResult.PASS diff --git a/base/src/main/kotlin/dev/nathanpb/dml/utils/EntityUtils.kt b/base/src/main/kotlin/dev/nathanpb/dml/utils/EntityUtils.kt index fad6acd8..0de2183c 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/utils/EntityUtils.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/utils/EntityUtils.kt @@ -20,31 +20,35 @@ package dev.nathanpb.dml.utils import dev.nathanpb.dml.config +import dev.nathanpb.dml.mixin.LootTableInvoker import net.minecraft.entity.EntityType import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemStack import net.minecraft.loot.context.LootContext +import net.minecraft.loot.context.LootContextParameterSet import net.minecraft.loot.context.LootContextParameters import net.minecraft.loot.context.LootContextTypes import net.minecraft.server.world.ServerWorld -fun EntityType<*>.simulateLootDroppedStacks(world: ServerWorld, player: PlayerEntity?, source: DamageSource): List { - val lootTable = world.server.lootManager?.getTable(lootTableId) +fun EntityType<*>.simulateLootDroppedStacks(world: ServerWorld, player: PlayerEntity, source: DamageSource): List { + val lootTable = world.server.lootManager.getLootTable(lootTableId) val entity = create(world) - val lootContext = LootContext.Builder(world).apply { - random(player?.random) - parameter(LootContextParameters.ORIGIN, entity?.pos) - parameter(LootContextParameters.THIS_ENTITY, entity) - parameter(LootContextParameters.DAMAGE_SOURCE, source) - - if (player != null) { - parameter(LootContextParameters.KILLER_ENTITY, player) - parameter(LootContextParameters.LAST_DAMAGE_PLAYER, player) - } + + val parameters = LootContextParameterSet.Builder(world).apply { + add(LootContextParameters.ORIGIN, entity?.pos) + add(LootContextParameters.THIS_ENTITY, entity) + add(LootContextParameters.DAMAGE_SOURCE, source) + + add(LootContextParameters.KILLER_ENTITY, player) + add(LootContextParameters.LAST_DAMAGE_PLAYER, player) }.build(LootContextTypes.ENTITY) - val lootList = lootTable?.generateLoot(lootContext) + val lootContext = LootContext.Builder(parameters).apply { + random(player.lootTableSeed) + }.build(null) + + val lootList = (lootTable as LootTableInvoker).invokeGenerateLoot(lootContext) lootList?.removeIf { stack: ItemStack -> !stack.isStackable && world.random.nextDouble() < config.lootFabricator.unstackableNullificationChance } return lootList ?: emptyList() diff --git a/base/src/main/kotlin/dev/nathanpb/dml/utils/ItemStackUtils.kt b/base/src/main/kotlin/dev/nathanpb/dml/utils/ItemStackUtils.kt index a0b50daf..8e735d9b 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/utils/ItemStackUtils.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/utils/ItemStackUtils.kt @@ -27,7 +27,7 @@ fun combineStacksIfPossible(source: ItemStack, target: ItemStack, maxInventoryCo return ( source.item === target.item && target.count < target.maxCount - && ItemStack.areNbtEqual(source, target) + && ItemStack.areEqual(source, target) ) } diff --git a/base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt b/base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt index 361c2eb6..34355078 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt @@ -32,7 +32,7 @@ import net.minecraft.entity.LivingEntity import net.minecraft.text.MutableText import net.minecraft.text.Style import net.minecraft.util.Identifier -import net.minecraft.util.math.Vec3f +import net.minecraft.util.math.RotationAxis import net.minecraft.world.World class RenderUtils { @@ -76,9 +76,9 @@ fun drawEntity( val matrixStack2 = MatrixStack() matrixStack2.translate(0.0, 0.0, 1000.0) matrixStack2.scale(size.toFloat(), size.toFloat(), size.toFloat()) - val quaternion = Vec3f.POSITIVE_Z.getDegreesQuaternion(rotationZ) - val quaternion2 = Vec3f.POSITIVE_Y.getDegreesQuaternion(rotationY) - quaternion.hamiltonProduct(quaternion2) + val quaternion = RotationAxis.POSITIVE_Z.rotationDegrees(rotationZ) + val quaternion2 = RotationAxis.POSITIVE_Y.rotationDegrees(rotationY) + quaternion.mul(quaternion2) matrixStack2.multiply(quaternion) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/utils/Tuples.kt b/base/src/main/kotlin/dev/nathanpb/dml/utils/Tuples.kt new file mode 100644 index 00000000..a2300b9b --- /dev/null +++ b/base/src/main/kotlin/dev/nathanpb/dml/utils/Tuples.kt @@ -0,0 +1,7 @@ +package dev.nathanpb.dml.utils + +import net.minecraft.util.Rarity + +data class ItemTuple(val identifier: String, val shown: Boolean = true) + +data class RarityTuple(val identifier: String, val rarity: Rarity = Rarity.COMMON) \ No newline at end of file diff --git a/base/src/main/resources/assets/dml-refabricated/lang/en_us.json b/base/src/main/resources/assets/dml-refabricated/lang/en_us.json index c1188b1a..0a09adeb 100644 --- a/base/src/main/resources/assets/dml-refabricated/lang/en_us.json +++ b/base/src/main/resources/assets/dml-refabricated/lang/en_us.json @@ -29,6 +29,14 @@ "item.dml-refabricated.emeritus_hat": "Emeritus Hat", "item.dml-refabricated.physically_condensed_matrix_fragment": "Physically-Condensed Matrix Fragment", "item.dml-refabricated.glitch_ingot": "Glitch Ingot", + + "item.dml-refabricated.glitch_upgrade_smithing_template": "Glitch Upgrade Smithing Template", + "upgrade.dml-refabricated.glitch_upgrade": "Glitch Upgrade", + "item.dml-refabricated.glitch_upgrade_smithing_template.applies_to": "Netherite Equipment", + "item.dml-refabricated.glitch_upgrade_smithing_template.ingredients": "Netherite Ingot", + "item.dml-refabricated.glitch_upgrade_smithing_template.base_slot_description": "Add netherite armor", + "item.dml-refabricated.glitch_upgrade_smithing_template.additions_slot_description": "Add Glitch Ingot", + "tooltip.dml-refabricated.guide_tablet": "§3§oDeep Mob Learning: Refabricated's high-tech guide!", "tooltip.dml-refabricated.data_model.bound_to.1": "Bound To: ", "tooltip.dml-refabricated.data_model.bound_to.2": "%d", diff --git a/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.bbmodel b/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.bbmodel index 3af3763c..7a266089 100644 --- a/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.bbmodel +++ b/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.bbmodel @@ -1 +1 @@ -{"meta":{"format_version":"3.6","model_format":"java_block","box_uv":false},"name":"emeritus_hat","parent":"","ambientocclusion":true,"front_gui_light":true,"visible_box":[1,1,0],"resolution":{"width":96,"height":32},"elements":[{"name":"mask","from":[0,0,0],"to":[16,16,1],"autouv":0,"color":7,"locked":false,"origin":[8,8,8],"faces":{"north":{"uv":[33.994020000000006,0,61.98797999999999,31.997],"texture":0},"east":{"uv":[0,0,0,0],"texture":0},"south":{"uv":[33.999,0,61.988,31.997],"texture":0},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"uuid":"009121cc-e968-7dd3-45e3-bd3708938fbf"},{"name":"right","from":[1,16,3],"to":[2,24,4],"autouv":0,"color":6,"locked":false,"origin":[9,24,11],"faces":{"north":{"uv":[6,10,9,32],"texture":1},"east":{"uv":[6,10,9,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[6,10,9,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[6,10,9,32],"texture":1}},"uuid":"63bca2d2-1ac3-a98b-2604-95a5c6a8605c"},{"name":"left","from":[14,16,3],"to":[15,24,4],"autouv":0,"color":3,"locked":false,"origin":[22,24,11],"faces":{"north":{"uv":[6,10,9,32],"texture":1},"east":{"uv":[6,10,9,32],"texture":1},"south":{"uv":[6,10,9,32],"texture":1},"west":{"uv":[6,10,9,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[6,10,9,32],"texture":1}},"uuid":"8385bced-0561-8828-2af2-c4d149cbd44a"},{"name":"right back","from":[0,16,4],"to":[1,21,9],"autouv":0,"color":2,"locked":false,"origin":[8,24,12],"faces":{"north":{"uv":[93,18,96,32],"texture":1},"east":{"uv":[0,10,15,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[81,10,96,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[81,10,96,32],"texture":1}},"uuid":"c6992637-aa6c-4227-e5b6-ba78db171038"},{"name":"left back","from":[15,16,4],"to":[16,21,9],"autouv":0,"color":5,"locked":false,"origin":[23,24,12],"faces":{"north":{"uv":[93,18,96,32],"texture":1},"east":{"uv":[0,10,15,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[81,10,96,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"uuid":"101e4842-2db6-7191-e921-72383491c3da"},{"name":"center back","from":[2,16,2],"to":[14,29,3],"autouv":0,"color":0,"locked":false,"origin":[20,24,10],"faces":{"north":{"uv":[6,0,90,32],"texture":1},"east":{"uv":[3,0,6,32],"texture":1},"south":{"uv":[6,0,90,31.997],"texture":1},"west":{"uv":[90,0,93,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"uuid":"d6edc127-aa99-6394-bc2f-cb0c567019bd"},{"name":"mask_side","from":[15,0,0],"to":[16,16,16],"autouv":0,"color":7,"locked":false,"origin":[23,8,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,33.999,31.997],"texture":0},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[60.999,0,95.991,31.997],"texture":0},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"uuid":"ffd855ce-4b04-c679-25aa-78fc3a521604"},{"name":"mask_top","from":[0,15,0],"to":[16,16,16],"autouv":0,"color":7,"locked":false,"origin":[8,23,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,0,0],"texture":null},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[10.997,0,13.992,2.991],"texture":0},"down":{"uv":[12,0,13.978,2.9800000000000004],"rotation":180,"texture":0}},"uuid":"5ae5fe5a-9239-2a53-2182-4a0447814b6c"},{"name":"mask_side","from":[0,0,0],"to":[1,16,16],"autouv":0,"color":7,"locked":false,"origin":[8,8,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,33.999,31.997],"texture":0},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[60.999,0,95.991,31.997],"texture":0},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"uuid":"fb5047cc-a7a5-9f12-63f4-5bd0638702ff"}],"outliner":["009121cc-e968-7dd3-45e3-bd3708938fbf",{"name":"hat","origin":[8,8,8],"uuid":"1a0f728a-222a-5730-aa54-3436a9330fdb","export":true,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["63bca2d2-1ac3-a98b-2604-95a5c6a8605c","8385bced-0561-8828-2af2-c4d149cbd44a","c6992637-aa6c-4227-e5b6-ba78db171038","101e4842-2db6-7191-e921-72383491c3da","d6edc127-aa99-6394-bc2f-cb0c567019bd"]},"ffd855ce-4b04-c679-25aa-78fc3a521604","fb5047cc-a7a5-9f12-63f4-5bd0638702ff","5ae5fe5a-9239-2a53-2182-4a0447814b6c"],"textures":[{"path":"/home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.png","name":"emeritus_mask.png","folder":"armor","namespace":"dml-refabricated","id":"0","particle":true,"visible":true,"mode":"bitmap","saved":false,"uuid":"a68abd7c-68ec-53a8-2d27-2a7d3b817d0d","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAgCAYAAADtwH1UAAABzklEQVRoQ+2aYXIDIQiF453c+x9gvZMdMjIlVjagrDpd8qfTDGLyPh7otuGle2Vd+GOjg/SbiwNLQgcgU1asqziwsa/D+BSlS8uuRTNh5NzPOQSrr8eW/fAGwwmsYIwILesKv1GDYEw1M03GCCEq4ZkA4HMqINyq0a3Jpe6YLb4AwDRdpm3EtYm8Qn3yYYLCCtpWJ4l3AA5g4JgjKbEvMe4Ab0EGZTSQwmfAgHgWSzkAdWvWGkW63lsQo2xrNkohaNY6AAUAcBwNR6Fb79Xu5OA5AAdg0cn7c1wN4atWwvV4TfspN+Kld6Glm5eWcvmsSCo0Gkk6fLFkHt+CYoz5PM8uC7VmgCbRcRyvlNLSIly6OYgFAOBnLwSN4DQWxIeXAygAqDhSGFoHoOh0LwfgAHpNbLMOZ0BdnZwLoOrrgUt/5877rfw+A8oMALFbAqHYtegSAPVaB8AYBu8BtUApJRuLlSwxxo986LDHH0PpRYycTEzFx2QIgba3xwNoXcboZQrazWgLQgD1fFgt/vsmfkupKZPWjyOujpc9Q5jL5wAIqJ4/zGjvAbQudhB/GweQFiH6HyKlwf6E7yL+dgAkD+f+k/hbArjLDTtVPS2iHyP1HzCEm21gAAAAAElFTkSuQmCC"},{"path":"/home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.png","name":"emeritus_hat.png","folder":"armor","namespace":"dml-refabricated","id":"1","particle":false,"visible":true,"mode":"bitmap","saved":false,"uuid":"872a2322-f02a-667b-ece7-f8166cb7a451","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAhCAYAAAC4JqlRAAABl0lEQVRYR9WXYQ6DIAyF5TIexcvocfQyHsXLsJTkLaVrS0GXZf5Z5oD3tdBHl6bBZ9/3zKdu25ZGlhqaJMUhPALxfwA553wch5rtdV2nlFJXUF2DufiyLBXEeZ7ley9EGIDESYCiJ/F5niuA67omgiAAPJFshAAgDgD65BAQRwY4WQuiCcDFRwBojgfhAkjxUQAPwgTQxO8AWBAqgCV+F0CD+ADwxJ8AkBAVQEv8KQAO8QboEffKUCtFzTZRGWEAbr9wQZgR+QA9cMMeiALQil6KSxdEhNyQIhCUhSaAJo6IZQboezdEpOQQIez3JwBSnKBkBvCuJwsp4nh8YX6iNQA5ll/TajVE/J4iwv5iEe065r/xOR5ElQHZ6Wj3vhaF905uh6yOAmC1WN8CAHDpnqwOl7vdU1ugngEPABBPHEJrmz4ygJ7OOg/wgJEy1La6AuANJYjvOGFrvXIrYgu0wR6EllKvOeXjeVCmEUmBntvQC0auGwagiYCI/i+IeMYQAK8OiLQs16yCVi9g7Z21YE/6yyH8NcALlCO4qAq8XvMAAAAASUVORK5CYII="}],"display":{"thirdperson_righthand":{"rotation":[50,0,-20],"translation":[0,-2,3.75],"scale":[0.5,0.5,0.5]},"thirdperson_lefthand":{"rotation":[50,0,-20],"translation":[0,-2,3.75],"scale":[0.5,0.5,0.5]},"firstperson_righthand":{"rotation":[0,120,0],"translation":[0.5,3.25,0],"scale":[0.5,0.5,0.5]},"firstperson_lefthand":{"rotation":[0,120,0],"translation":[0.5,3.25,0],"scale":[0.5,0.5,0.5]},"ground":{"scale":[0.5,0.5,0.5]},"gui":{"rotation":[0,-30,0],"translation":[-1.5,-2.5,0],"scale":[0.5,0.5,0.5]},"head":{"translation":[0,0,0.75]},"fixed":{"translation":[0,0,4.5]}}} \ No newline at end of file +{"meta":{"format_version":"4.5","model_format":"java_block","box_uv":false},"name":"emeritus_hat","parent":"","ambientocclusion":true,"front_gui_light":true,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":96,"height":32},"elements":[{"name":"mask","box_uv":false,"rescale":false,"locked":false,"from":[0,0,0],"to":[16,16,1],"autouv":0,"color":7,"origin":[8,8,8],"faces":{"north":{"uv":[33.994020000000006,0,61.98797999999999,31.997],"texture":0},"east":{"uv":[0,0,0,0],"texture":0},"south":{"uv":[33.999,0,61.988,31.997],"texture":0},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"009121cc-e968-7dd3-45e3-bd3708938fbf"},{"name":"right","box_uv":false,"rescale":false,"locked":false,"from":[1,16,3],"to":[2,24,4],"autouv":0,"color":6,"origin":[9,24,11],"faces":{"north":{"uv":[6,10,9,32],"texture":1},"east":{"uv":[6,10,9,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[6,10,9,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[6,10,9,32],"texture":1}},"type":"cube","uuid":"63bca2d2-1ac3-a98b-2604-95a5c6a8605c"},{"name":"left","box_uv":false,"rescale":false,"locked":false,"from":[14,16,3],"to":[15,24,4],"autouv":0,"color":3,"origin":[22,24,11],"faces":{"north":{"uv":[6,10,9,32],"texture":1},"east":{"uv":[6,10,9,32],"texture":1},"south":{"uv":[6,10,9,32],"texture":1},"west":{"uv":[6,10,9,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[6,10,9,32],"texture":1}},"type":"cube","uuid":"8385bced-0561-8828-2af2-c4d149cbd44a"},{"name":"right back","box_uv":false,"rescale":false,"locked":false,"from":[0,16,4],"to":[1,21,9],"autouv":0,"color":2,"origin":[8,24,12],"faces":{"north":{"uv":[93,18,96,32],"texture":1},"east":{"uv":[0,10,15,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[81,10,96,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[81,10,96,32],"texture":1}},"type":"cube","uuid":"c6992637-aa6c-4227-e5b6-ba78db171038"},{"name":"left back","box_uv":false,"rescale":false,"locked":false,"from":[15,16,4],"to":[16,21,9],"autouv":0,"color":5,"origin":[23,24,12],"faces":{"north":{"uv":[93,18,96,32],"texture":1},"east":{"uv":[0,10,15,32],"texture":1},"south":{"uv":[93,10,96,32],"texture":1},"west":{"uv":[81,10,96,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"101e4842-2db6-7191-e921-72383491c3da"},{"name":"center back","box_uv":false,"rescale":false,"locked":false,"from":[2,16,2],"to":[14,29,3],"autouv":0,"color":0,"origin":[20,24,10],"faces":{"north":{"uv":[6,0,90,32],"texture":1},"east":{"uv":[3,0,6,32],"texture":1},"south":{"uv":[6,0,90,31.997],"texture":1},"west":{"uv":[90,0,93,32],"texture":1},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"d6edc127-aa99-6394-bc2f-cb0c567019bd"},{"name":"mask_side","box_uv":false,"rescale":false,"locked":false,"from":[15,0,0],"to":[16,16,16],"autouv":0,"color":7,"origin":[23,8,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,33.999,31.997],"texture":0},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[60.999,0,95.991,31.997],"texture":0},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"ffd855ce-4b04-c679-25aa-78fc3a521604"},{"name":"mask_top","box_uv":false,"rescale":false,"locked":false,"from":[0,15,0],"to":[16,16,16],"autouv":0,"color":7,"origin":[8,23,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,0,0],"texture":null},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[0,0,0,0],"texture":null},"up":{"uv":[10.997,0,13.992,2.991],"texture":0},"down":{"uv":[12,0,13.978,2.9800000000000004],"rotation":180,"texture":0}},"type":"cube","uuid":"5ae5fe5a-9239-2a53-2182-4a0447814b6c"},{"name":"mask_side","box_uv":false,"rescale":false,"locked":false,"from":[0,0,0],"to":[1,16,16],"autouv":0,"color":7,"origin":[8,8,8],"faces":{"north":{"uv":[0,0,0,0],"texture":null},"east":{"uv":[0,0,33.999,31.997],"texture":0},"south":{"uv":[0,0,0,0],"texture":null},"west":{"uv":[60.999,0,95.991,31.997],"texture":0},"up":{"uv":[0,0,0,0],"texture":null},"down":{"uv":[0,0,0,0],"texture":null}},"type":"cube","uuid":"fb5047cc-a7a5-9f12-63f4-5bd0638702ff"}],"outliner":["009121cc-e968-7dd3-45e3-bd3708938fbf",{"name":"hat","origin":[8,8,8],"color":0,"uuid":"1a0f728a-222a-5730-aa54-3436a9330fdb","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["63bca2d2-1ac3-a98b-2604-95a5c6a8605c","8385bced-0561-8828-2af2-c4d149cbd44a","c6992637-aa6c-4227-e5b6-ba78db171038","101e4842-2db6-7191-e921-72383491c3da","d6edc127-aa99-6394-bc2f-cb0c567019bd"]},"ffd855ce-4b04-c679-25aa-78fc3a521604","fb5047cc-a7a5-9f12-63f4-5bd0638702ff","5ae5fe5a-9239-2a53-2182-4a0447814b6c"],"textures":[{"path":"/home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.png","name":"emeritus_mask.png","folder":"armor","namespace":"dml-refabricated","id":"0","particle":true,"render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"mode":"bitmap","saved":false,"uuid":"a68abd7c-68ec-53a8-2d27-2a7d3b817d0d","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAgCAYAAADtwH1UAAABzklEQVRoQ+2aYXIDIQiF453c+x9gvZMdMjIlVjagrDpd8qfTDGLyPh7otuGle2Vd+GOjg/SbiwNLQgcgU1asqziwsa/D+BSlS8uuRTNh5NzPOQSrr8eW/fAGwwmsYIwILesKv1GDYEw1M03GCCEq4ZkA4HMqINyq0a3Jpe6YLb4AwDRdpm3EtYm8Qn3yYYLCCtpWJ4l3AA5g4JgjKbEvMe4Ab0EGZTSQwmfAgHgWSzkAdWvWGkW63lsQo2xrNkohaNY6AAUAcBwNR6Fb79Xu5OA5AAdg0cn7c1wN4atWwvV4TfspN+Kld6Glm5eWcvmsSCo0Gkk6fLFkHt+CYoz5PM8uC7VmgCbRcRyvlNLSIly6OYgFAOBnLwSN4DQWxIeXAygAqDhSGFoHoOh0LwfgAHpNbLMOZ0BdnZwLoOrrgUt/5877rfw+A8oMALFbAqHYtegSAPVaB8AYBu8BtUApJRuLlSwxxo986LDHH0PpRYycTEzFx2QIgba3xwNoXcboZQrazWgLQgD1fFgt/vsmfkupKZPWjyOujpc9Q5jL5wAIqJ4/zGjvAbQudhB/GweQFiH6HyKlwf6E7yL+dgAkD+f+k/hbArjLDTtVPS2iHyP1HzCEm21gAAAAAElFTkSuQmCC","relative_path":"../../../../../../../../../../../../../home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.png"},{"path":"/home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.png","name":"emeritus_hat.png","folder":"armor","namespace":"dml-refabricated","id":"1","particle":false,"render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"mode":"bitmap","saved":false,"uuid":"872a2322-f02a-667b-ece7-f8166cb7a451","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAhCAYAAAC4JqlRAAABl0lEQVRYR9WXYQ6DIAyF5TIexcvocfQyHsXLsJTkLaVrS0GXZf5Z5oD3tdBHl6bBZ9/3zKdu25ZGlhqaJMUhPALxfwA553wch5rtdV2nlFJXUF2DufiyLBXEeZ7ley9EGIDESYCiJ/F5niuA67omgiAAPJFshAAgDgD65BAQRwY4WQuiCcDFRwBojgfhAkjxUQAPwgTQxO8AWBAqgCV+F0CD+ADwxJ8AkBAVQEv8KQAO8QboEffKUCtFzTZRGWEAbr9wQZgR+QA9cMMeiALQil6KSxdEhNyQIhCUhSaAJo6IZQboezdEpOQQIez3JwBSnKBkBvCuJwsp4nh8YX6iNQA5ll/TajVE/J4iwv5iEe065r/xOR5ElQHZ6Wj3vhaF905uh6yOAmC1WN8CAHDpnqwOl7vdU1ugngEPABBPHEJrmz4ygJ7OOg/wgJEy1La6AuANJYjvOGFrvXIrYgu0wR6EllKvOeXjeVCmEUmBntvQC0auGwagiYCI/i+IeMYQAK8OiLQs16yCVi9g7Z21YE/6yyH8NcALlCO4qAq8XvMAAAAASUVORK5CYII=","relative_path":"../../../../../../../../../../../../../home/nathan/Projects/DeepMobLearning-fabric/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.png"}],"display":{"thirdperson_righthand":{"translation":[0,-2,0.75],"scale":[0.25,0.25,0.25]},"thirdperson_lefthand":{"translation":[0,-2.75,2],"scale":[0.35,0.35,0.35]},"firstperson_righthand":{"rotation":[0,120,0],"translation":[0.5,3.25,0],"scale":[0.5,0.5,0.5]},"firstperson_lefthand":{"rotation":[0,120,0],"translation":[0.5,3.25,0],"scale":[0.5,0.5,0.5]},"ground":{"scale":[0.5,0.5,0.5]},"gui":{"rotation":[0,180,0],"translation":[0,-3.25,0],"scale":[0.5,0.5,0.5]},"head":{"translation":[0,0,0.75]},"fixed":{"translation":[0,0,4.5],"scale":[0.5,0.5,0.5]}}} \ No newline at end of file diff --git a/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.json b/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.json index d65b2eba..99139077 100644 --- a/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.json +++ b/base/src/main/resources/assets/dml-refabricated/models/item/emeritus_hat.json @@ -2,15 +2,16 @@ "credit": "Made with Blockbench", "texture_size": [96, 32], "textures": { - "0": "dml-refabricated:armor/emeritus_mask", - "1": "dml-refabricated:armor/emeritus_hat", - "particle": "dml-refabricated:armor/emeritus_mask" + "0": "dml-refabricated:item/armor/emeritus_mask", + "1": "dml-refabricated:item/armor/emeritus_hat", + "particle": "dml-refabricated:item/armor/emeritus_mask" }, "elements": [ { "name": "mask", "from": [0, 0, 0], "to": [16, 16, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "faces": { "north": {"uv": [5.66567, 0, 10.33133, 15.9985], "texture": "#0"}, "east": {"uv": [0, 0, 0, 0], "texture": "#0"}, @@ -94,6 +95,7 @@ "name": "mask_side", "from": [0, 0, 0], "to": [1, 16, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, "faces": { "east": {"uv": [0, 0, 5.6665, 15.9985], "texture": "#0"}, "west": {"uv": [10.1665, 0, 15.9985, 15.9985], "texture": "#0"} @@ -113,14 +115,12 @@ "gui_light": "front", "display": { "thirdperson_righthand": { - "rotation": [50, 0, -20], - "translation": [0, -2, 3.75], - "scale": [0.5, 0.5, 0.5] + "translation": [0, -2, 0.75], + "scale": [0.25, 0.25, 0.25] }, "thirdperson_lefthand": { - "rotation": [50, 0, -20], - "translation": [0, -2, 3.75], - "scale": [0.5, 0.5, 0.5] + "translation": [0, -2.75, 2], + "scale": [0.35, 0.35, 0.35] }, "firstperson_righthand": { "rotation": [0, 120, 0], @@ -136,21 +136,28 @@ "scale": [0.5, 0.5, 0.5] }, "gui": { - "rotation": [0, -30, 0], - "translation": [-1.5, -2.5, 0], + "rotation": [0, 180, 0], + "translation": [0, -3.25, 0], "scale": [0.5, 0.5, 0.5] }, "head": { "translation": [0, 0, 0.75] }, "fixed": { - "translation": [0, 0, 4.5] + "translation": [0, 0, 4.5], + "scale": [0.5, 0.5, 0.5] } }, - "groups": [0, + "groups": [ + 0, { "name": "hat", "origin": [8, 8, 8], + "color": 0, "children": [1, 2, 3, 4, 5] - }, 6, 7, 8] + }, + 6, + 7, + 8 + ] } \ No newline at end of file diff --git a/base/src/main/resources/assets/dml-refabricated/models/item/glitch_upgrade_smithing_template.json b/base/src/main/resources/assets/dml-refabricated/models/item/glitch_upgrade_smithing_template.json new file mode 100644 index 00000000..9acbbfb8 --- /dev/null +++ b/base/src/main/resources/assets/dml-refabricated/models/item/glitch_upgrade_smithing_template.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "dml-refabricated:item/glitch_upgrade_smithing_template" + } +} diff --git a/base/src/main/resources/assets/dml-refabricated/pack.mcmeta b/base/src/main/resources/assets/dml-refabricated/pack.mcmeta deleted file mode 100644 index 2f61bd04..00000000 --- a/base/src/main/resources/assets/dml-refabricated/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack":{ - "pack_format": 5, - "description": "Deep Mob Learning: Refabricated" - } -} diff --git a/base/src/main/resources/assets/dml-refabricated/textures/gui/entity_showcase_background.png b/base/src/main/resources/assets/dml-refabricated/textures/gui/entity_showcase_background.png index 901ec9e2..4c6423b0 100644 Binary files a/base/src/main/resources/assets/dml-refabricated/textures/gui/entity_showcase_background.png and b/base/src/main/resources/assets/dml-refabricated/textures/gui/entity_showcase_background.png differ diff --git a/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/2x2_data_model_slot_background.png b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/2x2_data_model_slot_background.png new file mode 100644 index 00000000..41bf30c2 Binary files /dev/null and b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/2x2_data_model_slot_background.png differ diff --git a/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/data_model_slot_background.png b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/data_model_slot_background.png new file mode 100644 index 00000000..38c1c03c Binary files /dev/null and b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/data_model_slot_background.png differ diff --git a/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/pristine_matter_slot_background.png b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/pristine_matter_slot_background.png new file mode 100644 index 00000000..9d39ec8c Binary files /dev/null and b/base/src/main/resources/assets/dml-refabricated/textures/gui/slot_background/pristine_matter_slot_background.png differ diff --git a/base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.png b/base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_hat.png similarity index 100% rename from base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.png rename to base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_hat.png diff --git a/base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.xcf b/base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_hat.xcf similarity index 100% rename from base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_hat.xcf rename to base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_hat.xcf diff --git a/base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.png b/base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_mask.png similarity index 100% rename from base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.png rename to base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_mask.png diff --git a/base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.xcf b/base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_mask.xcf similarity index 100% rename from base/src/main/resources/assets/dml-refabricated/textures/armor/emeritus_mask.xcf rename to base/src/main/resources/assets/dml-refabricated/textures/item/armor/emeritus_mask.xcf diff --git a/base/src/main/resources/assets/dml-refabricated/textures/item/glitch_upgrade_smithing_template.png b/base/src/main/resources/assets/dml-refabricated/textures/item/glitch_upgrade_smithing_template.png new file mode 100644 index 00000000..24a06b41 Binary files /dev/null and b/base/src/main/resources/assets/dml-refabricated/textures/item/glitch_upgrade_smithing_template.png differ diff --git a/base/src/main/resources/data/dml-refabricated/recipes/glitch_ingot.json b/base/src/main/resources/data/dml-refabricated/recipes/glitch_ingot.json index 7bd7c70b..3489b4e7 100644 --- a/base/src/main/resources/data/dml-refabricated/recipes/glitch_ingot.json +++ b/base/src/main/resources/data/dml-refabricated/recipes/glitch_ingot.json @@ -1,9 +1,9 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "FFF", + " F ", "FNF", - "FFF" + " F " ], "key": { "F": { diff --git a/base/src/main/resources/data/dml-refabricated/recipes/glitch_upgrade_smithing_template.json b/base/src/main/resources/data/dml-refabricated/recipes/glitch_upgrade_smithing_template.json new file mode 100644 index 00000000..a1be449c --- /dev/null +++ b/base/src/main/resources/data/dml-refabricated/recipes/glitch_upgrade_smithing_template.json @@ -0,0 +1,23 @@ +{ + "type": "minecraft:crafting_shaped", + "key": { + "#": { + "item": "minecraft:diamond" + }, + "S": { + "item": "dml-refabricated:soot_plate" + }, + "G": { + "item": "dml-refabricated:glitch_upgrade_smithing_template" + } + }, + "pattern": [ + "#G#", + "#S#", + "###" + ], + "result": { + "count": 2, + "item": "dml-refabricated:glitch_upgrade_smithing_template" + } +} \ No newline at end of file diff --git a/base/src/main/resources/mixins.dml-refabricated-base.json b/base/src/main/resources/mixins.dml-refabricated-base.json index 03ca21d7..69c91812 100644 --- a/base/src/main/resources/mixins.dml-refabricated-base.json +++ b/base/src/main/resources/mixins.dml-refabricated-base.json @@ -9,9 +9,12 @@ "HungerManagerMixin", "ICraftingResultSlotMixin", "LivingEntityMixin", + "LootTableInvoker", "PlayerEntityMixin", "ServerWorldMixin", + "ShapelessRecipeAccessor", "SlotMixin", + "SmithingTemplateItemAccessor", "WorldMixin" ], "client": [], diff --git a/build.gradle b/build.gradle index 39f832e9..a8825f3c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.2-SNAPSHOT' id 'maven-publish' - id "org.jetbrains.kotlin.jvm" version "1.6.0" - id "com.matthewprenger.cursegradle" version '1.4.0' - id "com.modrinth.minotaur" version '2.3.1' + id 'org.jetbrains.kotlin.jvm' version '1.8.22' + id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'com.modrinth.minotaur' version '2.3.1' } sourceCompatibility = JavaVersion.VERSION_17 @@ -49,7 +49,7 @@ allprojects { version = project.mod_version repositories { - maven { url = "https://jitpack.io/" } + maven { url = "https://maven.cafeteria.dev/releases/" } maven { url = "https://maven.cafeteria.dev/" } } @@ -60,8 +60,8 @@ allprojects { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" - modApi("com.github.CafeteriaGuild:KtDataTagLib:${project.ktdatataglib_version}") - include("com.github.CafeteriaGuild:KtDataTagLib:${project.ktdatataglib_version}") + modApi("dev.nathanpb:KtDataTagLib:${project.ktdatataglib_version}") + include("dev.nathanpb:KtDataTagLib:${project.ktdatataglib_version}") } jar { @@ -77,8 +77,15 @@ allprojects { expand "version": project.version } } + + configurations.configureEach { + resolutionStrategy.force("net.fabricmc:fabric-loader:${project.loader_version}") + } + } + + publishing { publications { mavenJava(MavenPublication) { @@ -100,18 +107,29 @@ publishing { } } +processResources { + inputs.property "version", project.version -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" + filesMatching("fabric.mod.json") { + expand "version": project.version + } } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +tasks.withType(JavaCompile).configureEach { + it.options.release = 17 +} + +java { + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } jar { - from "LICENSE" + from("LICENSE") { + rename { "${it}_${archivesBaseName}"} + } } curseforge { diff --git a/gradle.properties b/gradle.properties index 2fc1114a..ea85ccf7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,16 @@ kotlin.code.style=official org.gradle.jvmargs=-Xmx2G +fabric.loom.multiProjectOptimisation=true # Fabric Properties # Check these on https://modmuss50.me/fabric.html -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.28 -loader_version=0.14.10 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.14.22 #Fabric api -fabric_version=0.67.1+1.19.2 -loom_version=1.0 +fabric_version=0.86.1+1.20.1 +loom_version=1.3 # Mod Properties # !!! Do not change mod_version manually !!! @@ -20,16 +21,16 @@ curseforge_id=398614 modrinth_id=osuPHzT3 # Kotlin -kotlin_version=1.8.0 -fabric_kotlin_version=1.8.0+kotlin.1.7.0 +kotlin_version=1.8.22 +fabric_kotlin_version=1.9.5+kotlin.1.8.22 # Other Dependencies -ktdatataglib_version=1.6.6 -libguiVersion=6.3.0+1.19 -palVersion=1.6.0 -reiVersion=9.1.587 +ktdatataglib_version=1.6.7+1.20.1 +libguiVersion=8.0.0-beta.1+1.20-rc1 +palVersion=1.8.0 +reiVersion=12.0.625 energyVersion=2.3.0 -modmenuVersion=4.1.0 +modmenuVersion=7.0.0 mcdUsername=mcd mcdPassword=mcd diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c0..7454180f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 54e9a60b..fae08049 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c..c53aefaa 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/modular-armor/build.gradle.kts b/modular-armor/build.gradle.kts index 080173b6..7fbe00b0 100644 --- a/modular-armor/build.gradle.kts +++ b/modular-armor/build.gradle.kts @@ -4,7 +4,11 @@ val libguiVersion: String by project repositories { maven { name = "LadySnake" - url = uri("https://ladysnake.jfrog.io/artifactory/mods") + url = uri("https://maven.ladysnake.org/releases") + content { + includeGroup("io.github.ladysnake") + includeGroupByRegex("io\\.github\\.onyxstudios.*") + } } maven { name = "CottonMC" diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/BowItemMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/BowItemMixin.java index 3f5d7112..985ea596 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/BowItemMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/BowItemMixin.java @@ -26,18 +26,24 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(BowItem.class) public abstract class BowItemMixin { - @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BowItem;getPullProgress(I)F"), method = "onStoppedUsing") - public float proxyPullProgress(int useTicks, ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { + @Shadow + public abstract int getMaxUseTime(ItemStack stack); + + @ModifyVariable(at = @At(value = "LOAD"), method = "onStoppedUsing") + private float loadFloat(float value, ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { + int useTicks = this.getMaxUseTime(stack) - remainingUseTicks; + if (user instanceof PlayerEntity) { float modifier = ArcheryEffect.Companion.bowFastpullLevels((PlayerEntity) user) + 1; if (modifier > 1) { - float f = (float)useTicks / (20F / modifier); + float f = (float) useTicks / (20F / modifier); f = (f * f + f * 2.0F) / 3.0F; if (f > 1.0F) { f = 1.0F; @@ -46,6 +52,7 @@ public float proxyPullProgress(int useTicks, ItemStack stack, World world, Livin return f; } } - return BowItem.getPullProgress(useTicks); + + return value; } } diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/DamageSourceMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/DamageSourceMixin.java index cb6524a0..b3ef1422 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/DamageSourceMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/DamageSourceMixin.java @@ -27,6 +27,8 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.registry.tag.DamageTypeTags; +import net.minecraft.server.MinecraftServer; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -40,7 +42,8 @@ public class DamageSourceMixin { @Inject(at = @At("HEAD"), method = "getDeathMessage", cancellable = true) public void getDeathMessage(LivingEntity entity, CallbackInfoReturnable cir) { - if (entity instanceof PlayerEntity && this.equals(DamageSource.STARVE)) { // TODO Use class object, not mixin's class + DamageSource damageSource = ((DamageSource) (Object) this); + if (entity instanceof PlayerEntity && damageSource.isIn(DamageTypeTags.BYPASSES_EFFECTS)) { // this is the best way to check for starving atm, but could break on a later version Optional> effectOpt = ModularEffectRegistry.Companion .getINSTANCE() .getAll() diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/IArmorItemMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/IArmorItemMixin.java index 72bd776d..0b22e4a1 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/IArmorItemMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/IArmorItemMixin.java @@ -24,12 +24,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import java.util.EnumMap; import java.util.UUID; @Mixin(ArmorItem.class) public interface IArmorItemMixin { @Accessor("MODIFIERS") - static UUID[] dmlRefGetModifierUUIDs() { + static EnumMap dmlRefGetModifierUUIDs() { return null; } } diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/InGameHudMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/InGameHudMixin.java index e0b2a7d3..f2116afa 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/InGameHudMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/InGameHudMixin.java @@ -39,8 +39,8 @@ import dev.nathanpb.dml.modular_armor.hud.FlightBurnoutHud; import dev.nathanpb.dml.modular_armor.hud.UndyingCooldownHud; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -50,8 +50,8 @@ public class InGameHudMixin { @Inject(at = @At("RETURN"), method = "renderStatusBars") - public void renderStatusBar(MatrixStack matrices, CallbackInfo ci){ - FlightBurnoutHud.Companion.getINSTANCE().render(matrices); - UndyingCooldownHud.Companion.getINSTANCE().render(matrices); + public void renderStatusBar(DrawContext ctx, CallbackInfo ci){ + FlightBurnoutHud.Companion.getINSTANCE().render(ctx); + UndyingCooldownHud.Companion.getINSTANCE().render(ctx); } } diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/LivingEntityMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/LivingEntityMixin.java index b44461b4..3fb6bac6 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/LivingEntityMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/LivingEntityMixin.java @@ -19,7 +19,6 @@ * along with Deep Mob Learning: Refabricated. If not, see . */ -import com.mojang.datafixers.util.Pair; import dev.nathanpb.dml.item.ItemEmeritusHat; import dev.nathanpb.dml.modular_armor.EntityStatusEffectsKt; import dev.nathanpb.dml.modular_armor.ItemModularGlitchArmor; @@ -35,6 +34,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; +import com.mojang.datafixers.util.Pair; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -45,19 +45,26 @@ @Mixin(LivingEntity.class) public class LivingEntityMixin { + @ModifyVariable( - at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;onGround:Z"), + method = "travel", + at = @At( + target = "Lnet/minecraft/entity/LivingEntity;isOnGround()Z", + value = "INVOKE" + ), slice = @Slice( - from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getBaseMovementSpeedMultiplier()F", ordinal = 0), - to = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;onGround:Z", ordinal = 0) + from = @At( + target = "Lnet/minecraft/entity/LivingEntity;getBaseMovementSpeedMultiplier()F", + value = "INVOKE", + ordinal = 0 + ) ), - method = "travel", - ordinal = 2 + ordinal = 0 ) public float depthStriderEffectTravelPath(float value) { LivingEntity dis = (LivingEntity) (Object) this; if (dis.hasStatusEffect(EntityStatusEffectsKt.getDEPTH_STRIDER_EFFECT())) { - return value + dis.getStatusEffect(EntityStatusEffectsKt.getDEPTH_STRIDER_EFFECT()).getAmplifier(); + return value + (dis.getStatusEffect(EntityStatusEffectsKt.getDEPTH_STRIDER_EFFECT()).getAmplifier() * 0.25F); } return value; } @@ -91,8 +98,11 @@ public void canTarget(LivingEntity target, CallbackInfoReturnable cir) } @ModifyVariable( - at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/item/FoodComponent;getStatusEffects()Ljava/util/List;"), - method = "applyFoodEffects" + method = "applyFoodEffects", + at = @At( + target = "Lnet/minecraft/item/FoodComponent;getStatusEffects()Ljava/util/List;", + value = "STORE" + ) ) public List> applyFoodEffects(List> effects, ItemStack stack) { return RotResistanceEffect.Companion diff --git a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/StatusEffectUtilMixin.java b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/StatusEffectUtilMixin.java index 81bcf619..8b5666a4 100644 --- a/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/StatusEffectUtilMixin.java +++ b/modular-armor/src/main/java/dev/nathanpb/dml/modular_armor/mixin/StatusEffectUtilMixin.java @@ -23,7 +23,7 @@ import dev.nathanpb.dml.modular_armor.EntityStatusEffectsKt; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectUtil; -import net.minecraft.tag.FluidTags; +import net.minecraft.registry.tag.FluidTags; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockEntityMatterCondenser.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockEntityMatterCondenser.kt index 0780b01c..fcf513d5 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockEntityMatterCondenser.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockEntityMatterCondenser.kt @@ -35,10 +35,11 @@ import net.minecraft.block.entity.BlockEntityType import net.minecraft.inventory.Inventories import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.screen.ArrayPropertyDelegate import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry import net.minecraft.world.WorldAccess import kotlin.math.max import kotlin.math.min @@ -93,7 +94,7 @@ class BlockEntityMatterCondenser (pos: BlockPos, state: BlockState) : } val BLOCK_ENTITY_TYPE = Registry.register( - Registry.BLOCK_ENTITY_TYPE, + Registries.BLOCK_ENTITY_TYPE, BlockMatterCondenser.IDENTIFIER, BlockEntityType.Builder.create(::BlockEntityMatterCondenser, BlockMatterCondenser.BLOCK).build(null) ) diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockMatterCondenser.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockMatterCondenser.kt index a1306015..969f9e62 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockMatterCondenser.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/BlockMatterCondenser.kt @@ -20,10 +20,14 @@ package dev.nathanpb.dml.modular_armor +import dev.nathanpb.dml.block.BLOCK_LOOT_FABRICATOR import dev.nathanpb.dml.identifier -import dev.nathanpb.dml.item.settings +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY +import dev.nathanpb.dml.modular_armor.ItemModularGlitchArmor.Companion.GLITCH_BOOTS import dev.nathanpb.dml.modular_armor.screen.MatterCondenserScreenHandler import dev.nathanpb.dml.modular_armor.screen.MatterCondenserScreenHandlerFactory +import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings import net.minecraft.block.* import net.minecraft.block.entity.BlockEntity @@ -33,6 +37,9 @@ import net.minecraft.entity.player.PlayerEntity import net.minecraft.inventory.SidedInventory import net.minecraft.item.BlockItem import net.minecraft.item.ItemPlacementContext +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.screen.ScreenHandler import net.minecraft.state.StateManager import net.minecraft.state.property.Properties @@ -43,14 +50,13 @@ import net.minecraft.util.Rarity import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -import net.minecraft.util.registry.Registry import net.minecraft.util.shape.VoxelShape import net.minecraft.world.BlockView import net.minecraft.world.World import net.minecraft.world.WorldAccess class BlockMatterCondenser : HorizontalFacingBlock( - FabricBlockSettings.of(Material.STONE) + FabricBlockSettings.create() .hardness(4F) .resistance(3000F) ), InventoryProvider, BlockEntityProvider { @@ -60,8 +66,12 @@ class BlockMatterCondenser : HorizontalFacingBlock( val IDENTIFIER = identifier("matter_condenser") fun register() { - Registry.register(Registry.BLOCK, IDENTIFIER, BLOCK) - Registry.register(Registry.ITEM, IDENTIFIER, BlockItem(BLOCK, settings().rarity(Rarity.RARE))) + Registry.register(Registries.BLOCK, IDENTIFIER, BLOCK) + Registry.register(Registries.ITEM, IDENTIFIER, BlockItem(BLOCK, FabricItemSettings().rarity(Rarity.RARE))) + + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + it.addAfter(ItemStack(GLITCH_BOOTS), BLOCK) + } } } @@ -74,8 +84,16 @@ class BlockMatterCondenser : HorizontalFacingBlock( builder?.add(Properties.HORIZONTAL_FACING) } - override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? { - return defaultState.with(FACING, ctx?.playerFacing?.opposite) + override fun getPlacementState(ctx: ItemPlacementContext): BlockState { + var blockState = defaultState + + for(direction in ctx.placementDirections) { + if(direction.axis.isHorizontal) { + blockState = blockState.with(FACING, direction.opposite) + if(blockState.canPlaceAt(ctx.world, ctx.blockPos)) return blockState + } + } + return blockState.with(FACING, Direction.NORTH) } override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity?, hand: Hand, hit: BlockHitResult): ActionResult { diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/EntityStatusEffects.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/EntityStatusEffects.kt index 7c99055a..8b6a5106 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/EntityStatusEffects.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/EntityStatusEffects.kt @@ -22,7 +22,8 @@ package dev.nathanpb.dml.modular_armor import dev.nathanpb.dml.identifier import net.minecraft.entity.effect.StatusEffect import net.minecraft.entity.effect.StatusEffectCategory -import net.minecraft.util.registry.Registry +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry class UnderwaterHasteEffect : StatusEffect(StatusEffectCategory.BENEFICIAL, 0x46D99C) class DepthStriderEffect : StatusEffect(StatusEffectCategory.BENEFICIAL, 0x02A7D9) @@ -33,7 +34,7 @@ val DEPTH_STRIDER_EFFECT = register("depth_strider", DepthStriderEffect()) val SOUL_VISION_EFFECT = register("soul_vision", SoulVisionEffect()) private fun register(idPath: String, entry: StatusEffect): StatusEffect { - return Registry.register(Registry.STATUS_EFFECT, Registry.STATUS_EFFECT.toList().size, identifier(idPath).toString(), entry) + return Registry.register(Registries.STATUS_EFFECT, Registries.STATUS_EFFECT.toList().size, identifier(idPath).toString(), entry) } fun registerStatusEffects() { diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/GlitchArmorMaterial.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/GlitchArmorMaterial.kt index d8c671fd..2c1ab703 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/GlitchArmorMaterial.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/GlitchArmorMaterial.kt @@ -24,6 +24,7 @@ import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.item.ITEM_GLITCH_INGOT import dev.nathanpb.dml.utils.lerp import net.minecraft.entity.EquipmentSlot +import net.minecraft.item.ArmorItem import net.minecraft.item.ArmorMaterial import net.minecraft.recipe.Ingredient import net.minecraft.sound.SoundEvent @@ -40,7 +41,7 @@ class GlitchArmorMaterial : ArmorMaterial { override fun getEquipSound(): SoundEvent = SoundEvents.ITEM_ARMOR_EQUIP_GENERIC - override fun getDurability(slot: EquipmentSlot?) = 1 + override fun getDurability(type: ArmorItem.Type) = 1 override fun getName() = "glitch" @@ -48,7 +49,7 @@ class GlitchArmorMaterial : ArmorMaterial { override fun getKnockbackResistance() = 0F - override fun getProtectionAmount(slot: EquipmentSlot?) = 0 + override fun getProtection(type: ArmorItem.Type) = 0 override fun getToughness() = 0F diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/Init.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/Init.kt index f86f9d17..e189d399 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/Init.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/Init.kt @@ -20,11 +20,20 @@ package dev.nathanpb.dml.modular_armor +import dev.nathanpb.dml.block.BLOCK_LOOT_FABRICATOR import dev.nathanpb.dml.event.VanillaEvents +import dev.nathanpb.dml.identifier +import dev.nathanpb.dml.item.ITEM_GLITCH_INGOT +import dev.nathanpb.dml.item.ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY import dev.nathanpb.dml.modular_armor.core.ModularEffectRegistry import dev.nathanpb.dml.modular_armor.net.registerServerSidePackets import dev.nathanpb.dml.modular_armor.screen.MatterCondenserScreenHandler import dev.nathanpb.dml.modular_armor.screen.ModularArmorScreenHandler +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents +import net.fabricmc.loader.api.FabricLoader +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries @Suppress("unused") fun init() { @@ -41,4 +50,8 @@ fun init() { VanillaEvents.PlayerEntityTickEvent.register { it.flightBurnoutManager.tick() } + + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + it.addAfter(ItemStack(ITEM_GLITCH_INGOT), ITEM_GLITCH_UPGRADE_SMITHING_TEMPLATE) + } } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/ItemModularGlitchArmor.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/ItemModularGlitchArmor.kt index b9f1c5a6..5ea53569 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/ItemModularGlitchArmor.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/ItemModularGlitchArmor.kt @@ -26,12 +26,15 @@ import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.data.DataModelData import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.identifier -import dev.nathanpb.dml.item.settings +import dev.nathanpb.dml.item.ITEM_GLITCH_INGOT +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY import dev.nathanpb.dml.modular_armor.core.ModularEffectRegistry import dev.nathanpb.dml.modular_armor.data.ModularArmorData import dev.nathanpb.dml.modular_armor.mixin.IArmorItemMixin import dev.nathanpb.dml.modular_armor.screen.ModularArmorScreenHandlerFactory import dev.nathanpb.dml.utils.RenderUtils +import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents import net.minecraft.client.MinecraftClient import net.minecraft.client.item.TooltipContext import net.minecraft.entity.Entity @@ -43,32 +46,43 @@ import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ArmorItem import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.text.Text import net.minecraft.util.Formatting import net.minecraft.util.Hand import net.minecraft.util.Rarity import net.minecraft.util.TypedActionResult -import net.minecraft.util.registry.Registry import net.minecraft.world.World import kotlin.math.roundToInt -class ItemModularGlitchArmor(slot: EquipmentSlot, settings: Settings) : ArmorItem( + +class ItemModularGlitchArmor(type: Type, settings: Settings) : ArmorItem( GlitchArmorMaterial.INSTANCE, - slot, + type, settings.fireproof() ) { companion object { - val HELMET = ItemModularGlitchArmor(EquipmentSlot.HEAD, settings().fireproof()) - val CHESTPLATE = ItemModularGlitchArmor(EquipmentSlot.CHEST, settings().fireproof()) - val LEGGINGS = ItemModularGlitchArmor(EquipmentSlot.LEGS, settings().fireproof()) - val BOOTS = ItemModularGlitchArmor(EquipmentSlot.FEET, settings().fireproof()) + val GLITCH_HELMET = ItemModularGlitchArmor(Type.HELMET, FabricItemSettings().fireproof()) + val GLITCH_CHESTPLATE = ItemModularGlitchArmor(Type.CHESTPLATE, FabricItemSettings().fireproof()) + val GLITCH_LEGGINGS = ItemModularGlitchArmor(Type.LEGGINGS, FabricItemSettings().fireproof()) + val GLITCH_BOOTS = ItemModularGlitchArmor(Type.BOOTS, FabricItemSettings().fireproof()) fun register() { - Registry.register(Registry.ITEM, identifier("glitch_helmet"), HELMET) - Registry.register(Registry.ITEM, identifier("glitch_chestplate"), CHESTPLATE) - Registry.register(Registry.ITEM, identifier("glitch_leggings"), LEGGINGS) - Registry.register(Registry.ITEM, identifier("glitch_boots"), BOOTS) + linkedMapOf( + "glitch_boots" to GLITCH_BOOTS, + "glitch_leggings" to GLITCH_LEGGINGS, + "glitch_chestplate" to GLITCH_CHESTPLATE, + "glitch_helmet" to GLITCH_HELMET, + ).forEach { (id, item) -> + Registry.register(Registries.ITEM, identifier(id), item) + + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + it.addAfter(ItemStack(ITEM_GLITCH_INGOT), item) + } + } + } } @@ -117,10 +131,10 @@ class ItemModularGlitchArmor(slot: EquipmentSlot, settings: Settings) : ArmorIte .arrayListValues() .build() - if (slot != null && slot == this.slot) { + if (slot != null && slot == type.equipmentSlot) { (material as? GlitchArmorMaterial)?.let { material -> val data = ModularArmorData(stack) - val uuid = IArmorItemMixin.dmlRefGetModifierUUIDs()[slot.entitySlotId] + val uuid = IArmorItemMixin.dmlRefGetModifierUUIDs()[type] val protection = material.getProtectionAmount(slot, data.tier()).toDouble() val toughness = material.getToughness(data.tier()).toDouble() diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/core/ModularEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/core/ModularEffect.kt index 1d5ea250..d76d41ff 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/core/ModularEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/core/ModularEffect.kt @@ -29,11 +29,12 @@ import net.minecraft.entity.attribute.ClampedEntityAttribute import net.minecraft.entity.attribute.EntityAttribute import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.text.Text import net.minecraft.util.ActionResult import net.minecraft.util.Identifier import net.minecraft.util.TypedActionResult -import net.minecraft.util.registry.Registry import org.jetbrains.annotations.ApiStatus import kotlin.math.ceil import kotlin.math.floor @@ -94,7 +95,7 @@ abstract class ModularEffect( @ApiStatus.Internal fun registerEntityAttribute() { - entityAttribute = Registry.register(Registry.ATTRIBUTE, id, createEntityAttribute()) + entityAttribute = Registry.register(Registries.ATTRIBUTE, id, createEntityAttribute()) } protected open fun canApply(context: ModularEffectContext, payload: T): Boolean { diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/AutoExtinguishEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/AutoExtinguishEffect.kt index 7085e703..0974b073 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/AutoExtinguishEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/AutoExtinguishEffect.kt @@ -32,8 +32,10 @@ import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.player.PlayerEntity +import net.minecraft.registry.tag.DamageTypeTags import net.minecraft.sound.SoundEvents import net.minecraft.util.ActionResult +import net.minecraft.world.World class AutoExtinguishEffect : ProtectionLikeEffect( identifier("auto_extinguish"), @@ -56,7 +58,7 @@ class AutoExtinguishEffect : ProtectionLikeEffect( } } - override fun protectsAgainst(source: DamageSource) = source.isFire + override fun protectsAgainst(world: World, source: DamageSource) = source.isIn(DamageTypeTags.IS_FIRE) override fun acceptTier(tier: DataModelTier): Boolean { return tier.ordinal >= 2 diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FallImmunityEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FallImmunityEffect.kt index 9b8c662f..3fab803c 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FallImmunityEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FallImmunityEffect.kt @@ -27,6 +27,8 @@ import dev.nathanpb.dml.identifier import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.damage.DamageSource +import net.minecraft.registry.tag.DamageTypeTags +import net.minecraft.world.World class FallImmunityEffect : DamageImmunityLikeEffect( identifier("fall_immunity"), @@ -38,7 +40,7 @@ class FallImmunityEffect : DamageImmunityLikeEffect( return EntityAttributeModifier("dml_fall_immunity", 1.0, EntityAttributeModifier.Operation.MULTIPLY_BASE) } - override fun protectsAgainst(source: DamageSource) = source == DamageSource.FALL + override fun protectsAgainst(world: World, source: DamageSource) = source.isIn(DamageTypeTags.IS_FALL) override fun acceptTier(tier: DataModelTier): Boolean { return tier.isMaxTier() diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FeatherFallingEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FeatherFallingEffect.kt index c698bafb..1ff0be94 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FeatherFallingEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FeatherFallingEffect.kt @@ -25,7 +25,9 @@ import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.enums.EntityCategory import dev.nathanpb.dml.identifier import net.minecraft.entity.damage.DamageSource +import net.minecraft.registry.tag.DamageTypeTags import net.minecraft.text.Text +import net.minecraft.world.World class FeatherFallingEffect : ProtectionLikeEffect( identifier("feather_falling"), @@ -35,7 +37,7 @@ class FeatherFallingEffect : ProtectionLikeEffect( override val name = Text.translatable("enchantment.minecraft.feather_falling") - override fun protectsAgainst(source: DamageSource) = source == DamageSource.FALL + override fun protectsAgainst(world: World, source: DamageSource) = source.isIn(DamageTypeTags.IS_FALL) override fun acceptTier(tier: DataModelTier) = !tier.isMaxTier() } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireImmunityEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireImmunityEffect.kt index 18784876..d45f4684 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireImmunityEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireImmunityEffect.kt @@ -27,6 +27,8 @@ import dev.nathanpb.dml.identifier import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.damage.DamageSource +import net.minecraft.registry.tag.DamageTypeTags +import net.minecraft.world.World class FireImmunityEffect : DamageImmunityLikeEffect( identifier("fire_immunity"), @@ -34,7 +36,7 @@ class FireImmunityEffect : DamageImmunityLikeEffect( config.glitchArmor.costs::fireImmunity ) { - override fun protectsAgainst(source: DamageSource) = source.isFire + override fun protectsAgainst(world: World, source: DamageSource) = source.isIn(DamageTypeTags.IS_FIRE) override fun createEntityAttributeModifier(armor: ModularArmorData): EntityAttributeModifier { return EntityAttributeModifier(id.toString(), 1.0, EntityAttributeModifier.Operation.MULTIPLY_BASE) diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireProtectionEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireProtectionEffect.kt index 1c8db36a..7af3b89c 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireProtectionEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/FireProtectionEffect.kt @@ -25,7 +25,9 @@ import dev.nathanpb.dml.enums.DataModelTier import dev.nathanpb.dml.enums.EntityCategory import dev.nathanpb.dml.identifier import net.minecraft.entity.damage.DamageSource +import net.minecraft.registry.tag.DamageTypeTags import net.minecraft.text.Text +import net.minecraft.world.World class FireProtectionEffect : ProtectionLikeEffect( identifier("fire_protection"), @@ -35,7 +37,7 @@ class FireProtectionEffect : ProtectionLikeEffect( override val name = Text.translatable("enchantment.minecraft.fire_protection") - override fun protectsAgainst(source: DamageSource) = source.isFire + override fun protectsAgainst(world: World, source: DamageSource) = source.isIn(DamageTypeTags.IS_FIRE) override fun acceptTier(tier: DataModelTier) = !tier.isMaxTier() diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/PoseidonBlessEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/PoseidonBlessEffect.kt index c767ac60..4d4bfe09 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/PoseidonBlessEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/PoseidonBlessEffect.kt @@ -31,7 +31,7 @@ import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.effect.StatusEffectInstance import net.minecraft.entity.effect.StatusEffects -import net.minecraft.tag.FluidTags +import net.minecraft.registry.tag.FluidTags class PoseidonBlessEffect : StatusEffectLikeEffect( identifier("poseidon_bless"), diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ProtectionLikeEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ProtectionLikeEffect.kt index 3b3aedf2..5118e7e8 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ProtectionLikeEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ProtectionLikeEffect.kt @@ -32,6 +32,7 @@ import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.player.PlayerEntity import net.minecraft.util.ActionResult import net.minecraft.util.Identifier +import net.minecraft.world.World abstract class ProtectionLikeEffect( id: Identifier, @@ -60,10 +61,10 @@ abstract class ProtectionLikeEffect( return DamageUtil.getInflictedDamage(event.damage, armorValues.toFloat()) } - abstract fun protectsAgainst(source: DamageSource): Boolean + abstract fun protectsAgainst(world: World, source: DamageSource): Boolean override fun canApply(context: ModularEffectContext, payload: WrappedEffectTriggerPayload): Boolean { - return super.canApply(context, payload) && protectsAgainst(payload.value.source) + return super.canApply(context, payload) && protectsAgainst(context.player.world, payload.value.source) } } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ResistanceEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ResistanceEffect.kt index b0539e86..e5ef1c31 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ResistanceEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/ResistanceEffect.kt @@ -28,6 +28,8 @@ import dev.nathanpb.dml.identifier import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.damage.DamageSource +import net.minecraft.registry.tag.DamageTypeTags +import net.minecraft.world.World import kotlin.math.min class ResistanceEffect : ProtectionLikeEffect( @@ -36,8 +38,8 @@ class ResistanceEffect : ProtectionLikeEffect( config.glitchArmor.costs::resistance ) { - override fun protectsAgainst(source: DamageSource): Boolean { - return !source.isUnblockable && !source.isMagic + override fun protectsAgainst(world: World, source: DamageSource): Boolean { + return !source.isIn(DamageTypeTags.BYPASSES_ARMOR) && !source.isIn(DamageTypeTags.WITCH_RESISTANT_TO) } override fun acceptTier(tier: DataModelTier) = true diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/UnderwaterHasteEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/UnderwaterHasteEffect.kt index a6756e74..bbc3eb2e 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/UnderwaterHasteEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/UnderwaterHasteEffect.kt @@ -30,7 +30,7 @@ import dev.nathanpb.dml.modular_armor.core.EffectStackOption import dev.nathanpb.dml.modular_armor.core.ModularEffectContext import dev.nathanpb.dml.modular_armor.core.ModularEffectTriggerPayload import net.minecraft.entity.effect.StatusEffectInstance -import net.minecraft.tag.FluidTags +import net.minecraft.registry.tag.FluidTags import net.minecraft.text.Text class UnderwaterHasteEffect : StatusEffectLikeEffect( diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/WaterBreathingEffect.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/WaterBreathingEffect.kt index 2caebae7..2b1f8d4f 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/WaterBreathingEffect.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/effects/WaterBreathingEffect.kt @@ -31,7 +31,7 @@ import dev.nathanpb.dml.modular_armor.data.ModularArmorData import net.minecraft.entity.attribute.EntityAttributeModifier import net.minecraft.entity.effect.StatusEffectInstance import net.minecraft.entity.effect.StatusEffects -import net.minecraft.tag.FluidTags +import net.minecraft.registry.tag.FluidTags import net.minecraft.text.Text class WaterBreathingEffect : StatusEffectLikeEffect( diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/FlightBurnoutHud.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/FlightBurnoutHud.kt index 31b80941..900e501b 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/FlightBurnoutHud.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/FlightBurnoutHud.kt @@ -22,8 +22,7 @@ package dev.nathanpb.dml.modular_armor.hud import dev.nathanpb.dml.identifier import dev.nathanpb.dml.utils.lerp import net.minecraft.client.MinecraftClient -import net.minecraft.client.gui.DrawableHelper -import net.minecraft.client.util.math.MatrixStack +import net.minecraft.client.gui.DrawContext import kotlin.math.roundToInt class FlightBurnoutHud { @@ -40,7 +39,7 @@ class FlightBurnoutHud { var maxBurnoutTicks = 0 var canFly = true - fun render(matrices: MatrixStack) { + fun render(ctx: DrawContext) { val player = client.player ?: return if (maxBurnoutTicks <= 0 || (canFly && !player.abilities.flying)) { return @@ -50,11 +49,10 @@ class FlightBurnoutHud { val levelAmount = ((maxBurnoutTicks - burnoutTicks) / maxBurnoutTicks.toDouble()).lerp(0.0, 10.0).roundToInt() if (levelAmount > 0) { - matrices.push() - client.textureManager.bindTexture(if(canFly) TEXTURE else TEXTURE_FIRE) + ctx.matrices.push() (0 until levelAmount).forEach { index -> - DrawableHelper.drawTexture( - matrices, + ctx.drawTexture( + if(canFly) TEXTURE else TEXTURE_FIRE, centerX + 8 + index * 8, client.window.scaledHeight - 48, 0F, 0F, @@ -62,7 +60,7 @@ class FlightBurnoutHud { 8, 8 ) } - matrices.pop() + ctx.matrices.pop() } } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/UndyingCooldownHud.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/UndyingCooldownHud.kt index 35cf04ad..494a3a73 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/UndyingCooldownHud.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/hud/UndyingCooldownHud.kt @@ -21,10 +21,10 @@ package dev.nathanpb.dml.modular_armor.hud import dev.nathanpb.dml.identifier import net.minecraft.client.MinecraftClient -import net.minecraft.client.gui.DrawableHelper +import net.minecraft.client.gui.DrawContext import net.minecraft.client.util.math.MatrixStack -class UndyingCooldownHud : DrawableHelper() { +class UndyingCooldownHud { companion object { val INSTANCE = UndyingCooldownHud() @@ -36,7 +36,7 @@ class UndyingCooldownHud : DrawableHelper() { var cooldownTime = 0 var maxCooldownTime = 0 - fun render(matrices: MatrixStack) { + fun render(ctx: DrawContext) { if (cooldownTime == 0 || maxCooldownTime == 0) { return } @@ -46,17 +46,16 @@ class UndyingCooldownHud : DrawableHelper() { val width = client.window.scaledWidth val height = client.window.scaledHeight - matrices.push() - client.textureManager.bindTexture(TEXTURE) - drawTexture( - matrices, + ctx.matrices.push() + ctx.drawTexture( + TEXTURE, width - 64, height - 18, 0F, 0F, 16, 16, 16, 16 ) - matrices.pop() + ctx.matrices.pop() } } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt index 5b2b7811..98b77a3d 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt @@ -21,6 +21,7 @@ package dev.nathanpb.dml.modular_armor.screen import dev.nathanpb.dml.MOD_ID +import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.ItemPristineMatter import dev.nathanpb.dml.modular_armor.BlockMatterCondenser import dev.nathanpb.dml.modular_armor.ItemModularGlitchArmor @@ -30,8 +31,10 @@ import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot import dev.nathanpb.dml.utils.RenderUtils import io.github.cottonmc.cotton.gui.SyncedGuiDescription import io.github.cottonmc.cotton.gui.widget.WBar +import io.github.cottonmc.cotton.gui.widget.WItemSlot import io.github.cottonmc.cotton.gui.widget.WPlainPanel import io.github.cottonmc.cotton.gui.widget.data.Insets +import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon import net.minecraft.entity.player.PlayerInventory import net.minecraft.inventory.SimpleInventory import net.minecraft.screen.ScreenHandlerContext @@ -61,15 +64,21 @@ class MatterCondenserScreenHandler( root.insets = Insets.ROOT_PANEL val slots = WPlainPanel() - val armorSlot = WTooltippedItemSlot.of(blockInventory, 0, Text.translatable("gui.${MOD_ID}.glitch_armor_only")).setFilter { - it.item is ItemModularGlitchArmor && !ModularArmorData(it).tier().isMaxTier() + val armorSlot = WTooltippedItemSlot.of(blockInventory, 0, true, Text.translatable("gui.${MOD_ID}.glitch_armor_only")).apply { + setFilter { + it.item is ItemModularGlitchArmor && !ModularArmorData(it).tier().isMaxTier() + } } slots.add(armorSlot, 2*18, 2*18) val matterSlots = (1..6).map { - WTooltippedItemSlot.of(blockInventory, it, Text.translatable("gui.${MOD_ID}.pristine_matter_only")).setFilter { stack -> - stack.item is ItemPristineMatter + WItemSlot(blockInventory, it, 1, 1, false).apply { + setFilter { stack -> + stack.item is ItemPristineMatter + } + + icon = TextureIcon(identifier("textures/gui/slot_background/pristine_matter_slot_background.png")) } } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt index 12d3701d..b539dc40 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt @@ -20,6 +20,7 @@ package dev.nathanpb.dml.modular_armor.screen +import com.sun.java.accessibility.util.SwingEventMonitor.addChangeListener import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.data.dataModel import dev.nathanpb.dml.identifier @@ -34,8 +35,10 @@ import dev.nathanpb.dml.utils.RenderUtils import dev.nathanpb.dml.utils.takeOrNull import io.github.cottonmc.cotton.gui.SyncedGuiDescription import io.github.cottonmc.cotton.gui.widget.WGridPanel +import io.github.cottonmc.cotton.gui.widget.WItemSlot import io.github.cottonmc.cotton.gui.widget.WListPanel import io.github.cottonmc.cotton.gui.widget.data.Insets +import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon import io.netty.buffer.Unpooled import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking import net.minecraft.entity.player.PlayerInventory @@ -98,7 +101,7 @@ class ModularArmorScreenHandler( lastEffectsList!!.validate(this) } - val dataModelSlot = WTooltippedItemSlot.of(blockInventory, 0, Text.translatable("gui.${MOD_ID}.data_model_only")).apply { + val dataModelSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply { setFilter { it.isEmpty || ( (it.item as? ItemDataModel)?.category != null @@ -106,6 +109,8 @@ class ModularArmorScreenHandler( ) } addChangeListener { _, _, _, _ -> updateEffectsList()} + + icon = TextureIcon(identifier("textures/gui/slot_background/data_model_slot_background.png")) } root.add(dataModelSlot, 0, 2) diff --git a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_boots.json b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_boots.json index 203b1000..0d27e9b4 100644 --- a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_boots.json +++ b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_boots.json @@ -1,11 +1,14 @@ { - "type": "minecraft:smithing", + "type": "minecraft:smithing_transform", "base": { "item": "minecraft:netherite_boots" }, "addition": { "item": "dml-refabricated:glitch_ingot" }, + "template": { + "item": "dml-refabricated:glitch_upgrade_smithing_template" + }, "result": { "item": "dml-refabricated:glitch_boots" } diff --git a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_chestplate.json b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_chestplate.json index 7234b5e6..e669bd61 100644 --- a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_chestplate.json +++ b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_chestplate.json @@ -1,11 +1,14 @@ { - "type": "minecraft:smithing", + "type": "minecraft:smithing_transform", "base": { "item": "minecraft:netherite_chestplate" }, "addition": { "item": "dml-refabricated:glitch_ingot" }, + "template": { + "item": "dml-refabricated:glitch_upgrade_smithing_template" + }, "result": { "item": "dml-refabricated:glitch_chestplate" } diff --git a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_helmet.json b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_helmet.json index ab6ffbae..24d71728 100644 --- a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_helmet.json +++ b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_helmet.json @@ -1,11 +1,14 @@ { - "type": "minecraft:smithing", + "type": "minecraft:smithing_transform", "base": { "item": "minecraft:netherite_helmet" }, "addition": { "item": "dml-refabricated:glitch_ingot" }, + "template": { + "item": "dml-refabricated:glitch_upgrade_smithing_template" + }, "result": { "item": "dml-refabricated:glitch_helmet" } diff --git a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_leggings.json b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_leggings.json index fe96558a..8d1726df 100644 --- a/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_leggings.json +++ b/modular-armor/src/main/resources/data/dml-refabricated/recipes/glitch_leggings.json @@ -1,11 +1,14 @@ { - "type": "minecraft:smithing", + "type": "minecraft:smithing_transform", "base": { "item": "minecraft:netherite_leggings" }, "addition": { "item": "dml-refabricated:glitch_ingot" }, + "template": { + "item": "dml-refabricated:glitch_upgrade_smithing_template" + }, "result": { "item": "dml-refabricated:glitch_leggings" } diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/Init.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/Init.kt index 5356972e..8af44bac 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/Init.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/Init.kt @@ -1,31 +1,36 @@ package dev.nathanpb.dml.simulacrum +import dev.nathanpb.dml.block.BLOCK_LOOT_FABRICATOR import dev.nathanpb.dml.config import dev.nathanpb.dml.identifier -import dev.nathanpb.dml.item.ITEM_GROUP +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY import dev.nathanpb.dml.simulacrum.block.chamber.BlockEntitySimulationChamber import dev.nathanpb.dml.simulacrum.block.chamber.BlockSimulationChamber import dev.nathanpb.dml.simulacrum.item.registerItems import dev.nathanpb.dml.simulacrum.screen.ScreenHandlerSimulationChamber import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents import net.fabricmc.fabric.api.`object`.builder.v1.block.entity.FabricBlockEntityTypeBuilder import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry +import net.fabricmc.loader.api.FabricLoader import net.minecraft.block.Block import net.minecraft.block.BlockState import net.minecraft.block.entity.BlockEntityType import net.minecraft.entity.player.PlayerInventory import net.minecraft.item.BlockItem +import net.minecraft.item.ItemStack import net.minecraft.network.PacketByteBuf +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry import net.minecraft.screen.ScreenHandlerType import net.minecraft.util.math.BlockPos -import net.minecraft.util.registry.Registry import team.reborn.energy.api.EnergyStorage val SIMULATION_CHAMBER: Block = BlockSimulationChamber() val SIMULATION_CHAMBER_ENTITY: BlockEntityType = Registry.register( - Registry.BLOCK_ENTITY_TYPE, identifier("simulation_chamber_entity"), FabricBlockEntityTypeBuilder.create( + Registries.BLOCK_ENTITY_TYPE, identifier("simulation_chamber_entity"), FabricBlockEntityTypeBuilder.create( { pos: BlockPos?, state: BlockState? -> BlockEntitySimulationChamber(pos, state) }, SIMULATION_CHAMBER).build()) @@ -56,8 +61,16 @@ var ENERGY_COST = hashMapOf( @Suppress("unused") fun init() { - Registry.register(Registry.BLOCK, identifier("simulation_chamber"), SIMULATION_CHAMBER) - Registry.register(Registry.ITEM, identifier("simulation_chamber"), BlockItem(SIMULATION_CHAMBER, FabricItemSettings().group(ITEM_GROUP))) + Registry.register(Registries.BLOCK, identifier("simulation_chamber"), SIMULATION_CHAMBER) + Registry.register(Registries.ITEM, identifier("simulation_chamber"), BlockItem(SIMULATION_CHAMBER, FabricItemSettings())) + + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + if(FabricLoader.getInstance().isModLoaded("dml-refabricated-modular-armor")) { + it.addAfter(ItemStack(Registries.BLOCK.get(identifier("matter_condenser"))), SIMULATION_CHAMBER) + } else { // no modular-armor module: + it.addAfter(ItemStack(BLOCK_LOOT_FABRICATOR), SIMULATION_CHAMBER) + } + } registerItems() diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockEntitySimulationChamber.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockEntitySimulationChamber.kt index e60e3a84..35da62ca 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockEntitySimulationChamber.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockEntitySimulationChamber.kt @@ -20,10 +20,11 @@ import net.minecraft.inventory.SidedInventory import net.minecraft.item.Item import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound -import net.minecraft.network.Packet import net.minecraft.network.PacketByteBuf import net.minecraft.network.listener.ClientPlayPacketListener +import net.minecraft.network.packet.Packet import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket +import net.minecraft.registry.Registries import net.minecraft.screen.PropertyDelegate import net.minecraft.screen.ScreenHandler import net.minecraft.server.network.ServerPlayerEntity @@ -32,7 +33,6 @@ import net.minecraft.text.Text import net.minecraft.util.collection.DefaultedList import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -import net.minecraft.util.registry.Registry import net.minecraft.world.World import team.reborn.energy.api.base.SimpleEnergyStorage import java.util.* @@ -248,12 +248,12 @@ class BlockEntitySimulationChamber(pos: BlockPos?, state: BlockState?) : BlockEn private fun dataModelMatchesOutput(stack: ItemStack, output: ItemStack): Boolean { val livingMatter: Item? = dataModel2MatterMap[DataModelUtil.getEntityCategory(stack).toString()]?.type?.matter - return Registry.ITEM.getId(livingMatter) == Registry.ITEM.getId(output.item) + return Registries.ITEM.getId(livingMatter) == Registries.ITEM.getId(output.item) } private fun dataModelMatchesPristine(stack: ItemStack, pristine: ItemStack): Boolean { val pristineMatter: ItemPristineMatter? = dataModel2MatterMap[DataModelUtil.getEntityCategory(stack).toString()]?.pristine - return Registry.ITEM.getId(pristineMatter) == Registry.ITEM.getId(pristine.item) + return Registries.ITEM.getId(pristineMatter) == Registries.ITEM.getId(pristine.item) } fun tick(world: World, pos: BlockPos?, state: BlockState?, blockEntity: BlockEntitySimulationChamber) { diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockSimulationChamber.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockSimulationChamber.kt index 6078a24e..d2ceb81b 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockSimulationChamber.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/block/chamber/BlockSimulationChamber.kt @@ -15,10 +15,11 @@ import net.minecraft.state.property.Properties import net.minecraft.util.* import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Direction import net.minecraft.world.World @Suppress("deprecated") -class BlockSimulationChamber : BlockWithEntity(FabricBlockSettings.of(Material.STONE).hardness(4F).resistance(3000F)) { +class BlockSimulationChamber : BlockWithEntity(FabricBlockSettings.create().hardness(4F).resistance(3000F)) { override fun onUse(state: BlockState, world: World, pos: BlockPos?, player: PlayerEntity, hand: Hand?, hit: BlockHitResult?): ActionResult { @@ -52,7 +53,15 @@ class BlockSimulationChamber : BlockWithEntity(FabricBlockSettings.of(Material.S } override fun getPlacementState(ctx: ItemPlacementContext): BlockState? { - return defaultState.with(facing, ctx.playerFacing.opposite) + var blockState = defaultState + + for(direction in ctx.placementDirections) { + if(direction.axis.isHorizontal) { + blockState = blockState.with(HorizontalFacingBlock.FACING, direction.opposite) + if(blockState.canPlaceAt(ctx.world, ctx.blockPos)) return blockState + } + } + return blockState.with(HorizontalFacingBlock.FACING, Direction.NORTH) } override fun onStateReplaced(state: BlockState, world: World, pos: BlockPos?, newState: BlockState, moved: Boolean) { diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/item/Items.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/item/Items.kt index 265c1794..3e96ca42 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/item/Items.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/item/Items.kt @@ -2,23 +2,30 @@ package dev.nathanpb.dml.simulacrum.item import dev.nathanpb.dml.config import dev.nathanpb.dml.identifier -import dev.nathanpb.dml.item.ITEM_GROUP +import dev.nathanpb.dml.itemgroup.ITEM_GROUP_KEY +import dev.nathanpb.dml.simulacrum.SIMULATION_CHAMBER import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents import net.minecraft.item.Item -import net.minecraft.util.registry.Registry +import net.minecraft.item.ItemStack +import net.minecraft.registry.Registries +import net.minecraft.registry.Registry -val POLYMER_CLAY = Item(FabricItemSettings().maxCount(64).group(ITEM_GROUP)) -val OVERWORLD_MATTER = ItemMatter(FabricItemSettings().maxCount(64).group(ITEM_GROUP), config.matterXP.overworldMatterXP) -val HELLISH_MATTER = ItemMatter(FabricItemSettings().maxCount(64).group(ITEM_GROUP), config.matterXP.hellishMatterXP) -val EXTRATERRESTRIAL_MATTER = ItemMatter(FabricItemSettings().maxCount(64).group(ITEM_GROUP), config.matterXP.extraterrestrialMatterXP) +val OVERWORLD_MATTER = ItemMatter(FabricItemSettings(), config.matterXP.overworldMatterXP) +val HELLISH_MATTER = ItemMatter(FabricItemSettings(), config.matterXP.hellishMatterXP) +val EXTRATERRESTRIAL_MATTER = ItemMatter(FabricItemSettings(), config.matterXP.extraterrestrialMatterXP) +val POLYMER_CLAY = Item(FabricItemSettings()) fun registerItems() { - mapOf( - POLYMER_CLAY to "polymer_clay", - OVERWORLD_MATTER to "overworld_matter", + linkedMapOf( + EXTRATERRESTRIAL_MATTER to "extraterrestrial_matter", HELLISH_MATTER to "hellish_matter", - EXTRATERRESTRIAL_MATTER to "extraterrestrial_matter" + OVERWORLD_MATTER to "overworld_matter", + POLYMER_CLAY to "polymer_clay" ).forEach { (item, id) -> - Registry.register(Registry.ITEM, identifier(id), item) + Registry.register(Registries.ITEM, identifier(id), item) + ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP_KEY).register { + it.addAfter(ItemStack(SIMULATION_CHAMBER), item) + } } } \ No newline at end of file diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenHandlerSimulationChamber.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenHandlerSimulationChamber.kt index 26865d7f..d043dd0e 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenHandlerSimulationChamber.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenHandlerSimulationChamber.kt @@ -82,7 +82,7 @@ class ScreenHandlerSimulationChamber(syncId: Int, playerInventory: PlayerInvento } } - override fun transferSlot(player: PlayerEntity, index: Int): ItemStack { + override fun quickMove(player: PlayerEntity, index: Int): ItemStack { var newStack = ItemStack.EMPTY if (!world.isClient) { val slot = slots[index] diff --git a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenSimulationChamber.kt b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenSimulationChamber.kt index c72a24f7..7bb87fd7 100644 --- a/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenSimulationChamber.kt +++ b/simulacrum/src/main/kotlin/dev/nathanpb/dml/simulacrum/screen/ScreenSimulationChamber.kt @@ -9,7 +9,7 @@ import dev.nathanpb.dml.simulacrum.util.Animation import dev.nathanpb.dml.simulacrum.util.DataModelUtil import net.minecraft.client.MinecraftClient import net.minecraft.client.font.TextRenderer -import net.minecraft.client.gui.DrawableHelper +import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.player.PlayerInventory @@ -41,22 +41,21 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve } - override fun drawBackground(matrices: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { + override fun drawBackground(ctx: DrawContext, delta: Float, mouseX: Int, mouseY: Int) { val f = DecimalFormat("0.#") val x: Int = this.x + 8 val spacing = 12 val yStart: Int = y - 3 //Main Chamber GUI - RenderSystem.setShaderTexture(0, gui) RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f) - drawTexture(matrices, x, y, 0, 0, 216, 141) - drawTexture(matrices, x, y + 145, 0, 141, 18, 18) + ctx.drawTexture(gui, x, y, 0, 0, 216, 141) + ctx.drawTexture(gui, x, y + 145, 0, 141, 18, 18) //Energy Bar Rendering val energyBarHeight: Int = (handler!!.syncedEnergy / (maxEnergy - 64) * 87).toInt().coerceAtLeast(0).coerceAtMost(87) val energyBarOffset: Int = 87 - energyBarHeight - drawTexture(matrices, x + 203, (y + 48) + energyBarOffset, 25, 141, 7, energyBarHeight) + ctx.drawTexture(gui, x + 203, (y + 48) + energyBarOffset, 25, 141, 7, energyBarHeight) val lines: Array @@ -64,20 +63,20 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve lines = arrayOf("text.dml-refabricated.simulation_chamber.insert_data_model.1", "text.dml-refabricated.simulation_chamber.insert_data_model.2") val a1 = getAnimation("pleaseInsert1") val a2 = getAnimation("pleaseInsert2") - animateString(matrices, lines[0], a1, null, 1, false, x + 10, yStart + spacing, 0xFFFFFF) - animateString(matrices, lines[1], a2, a1, 1, false, x + 10, yStart + spacing * 2, 0xFFFFFF) + animateString(ctx, lines[0], a1, null, 1, false, x + 10, yStart + spacing, 0xFFFFFF) + animateString(ctx, lines[1], a2, a1, 1, false, x + 10, yStart + spacing * 2, 0xFFFFFF) } else if (DataModelUtil.getTier(blockEntity.dataModel) == DataModelTier.FAULTY) { lines = arrayOf("text.dml-refabricated.simulation_chamber.insuficiente_data.1", "text.dml-refabricated.simulation_chamber.insuficiente_data.2", "text.dml-refabricated.simulation_chamber.insuficiente_data.3") val insufData = getAnimation("insufData1") val insufData2 = getAnimation("insufData2") val insufData3 = getAnimation("insufData3") - animateString(matrices, lines[0], insufData, null, 1, false, x + 10, yStart + spacing, 0xFFFFFF) - animateString(matrices, lines[1], insufData2, insufData, 1, false, x + 10, yStart + spacing * 2, 0xFFFFFF) - animateString(matrices, lines[2], insufData3, insufData2, 1, false, x + 10, yStart + spacing * 3, 0xFFFFFF) + animateString(ctx, lines[0], insufData, null, 1, false, x + 10, yStart + spacing, 0xFFFFFF) + animateString(ctx, lines[1], insufData2, insufData, 1, false, x + 10, yStart + spacing * 2, 0xFFFFFF) + animateString(ctx, lines[2], insufData3, insufData2, 1, false, x + 10, yStart + spacing * 3, 0xFFFFFF) } else { // Draw current data model data if (DataModelUtil.getTier(blockEntity.dataModel) == DataModelTier.SELF_AWARE) { - drawTexture(matrices, x + 6, y + 48, 18, 141, 7, 87) + ctx.drawTexture(gui, x + 6, y + 48, 18, 141, 7, 87) } else { val collectedData = DataModelUtil.getTierCount(blockEntity.dataModel) - (DataModelUtil.getTier(blockEntity.dataModel)?.dataAmount ?: 0) @@ -85,29 +84,28 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve (DataModelUtil.getTier(blockEntity.dataModel)?.dataAmount ?: 0) val experienceBarHeight = (collectedData.toFloat() / tierRoof * 87).toInt() val experienceBarOffset = 87 - experienceBarHeight - drawTexture(matrices, x + 6, y + 48 + experienceBarOffset, 18, 141, 7, experienceBarHeight) + ctx.drawTexture(gui, x + 6, y + 48 + experienceBarOffset, 18, 141, 7, experienceBarHeight) } - DrawableHelper.drawTextWithShadow( - matrices, renderer, Text.translatable("tooltip.dml-refabricated.data_model.3").copy().append( + ctx.drawText( + renderer, Text.translatable("tooltip.dml-refabricated.data_model.3").copy().append( DataModelUtil.textTier(blockEntity.dataModel) - ), x + 10, yStart + spacing, 0xFFFFFF + ), x + 10, yStart + spacing, 0xFFFFFF, true ) - DrawableHelper.drawTextWithShadow( - matrices, renderer, Text.translatable("text.dml-refabricated.simulation_chamber.iterations", f.format( + ctx.drawText( + renderer, Text.translatable("text.dml-refabricated.simulation_chamber.iterations", f.format( DataModelUtil.getSimulationCount(blockEntity.dataModel).toLong()) - ), x + 10, yStart + spacing * 2, 0xFFFFFF + ), x + 10, yStart + spacing * 2, 0xFFFFFF, true ) - DrawableHelper.drawTextWithShadow( - matrices, renderer, Text.translatable("text.dml-refabricated.simulation_chamber.pristine_chance", + ctx.drawText( + renderer, Text.translatable("text.dml-refabricated.simulation_chamber.pristine_chance", PRISTINE_CHANCE[DataModelUtil.getTier(blockEntity.dataModel).toString()] - ).append("%"), x + 10, yStart + spacing * 3, 0xFFFFFF + ).append("%"), x + 10, yStart + spacing * 3, 0xFFFFFF, true ) } - RenderSystem.setShaderTexture(0, defaultGui) - drawTexture(matrices, x + 20, y + 145, 0, 0, 176, 90) + ctx.drawTexture(defaultGui, x + 20, y + 145, 0, 0, 176, 90) - drawConsoleText(matrices, x, y, spacing) + drawConsoleText(ctx, x, y, spacing) if(blockEntity.isCrafting) updateSimulationText() if((!blockEntity.isCrafting && blockEntity.canStartSimulation()) || hasDataModelChanged() || blockEntity.percentDone == 100) { resetAnimations() @@ -119,7 +117,7 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve simulationText = HashMap() } - override fun drawForeground(matrices: MatrixStack?, mouseX: Int, mouseY: Int) { + override fun drawForeground(ctx: DrawContext, mouseX: Int, mouseY: Int) { val x: Int = mouseX - this.x val y: Int = mouseY - this.y val f = NumberFormat.getNumberInstance(Locale.ENGLISH) @@ -146,19 +144,19 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve } else { tooltip.add(Text.translatable("text.dml-refabricated.simulation_chamber.missing_data_model")) } - renderTooltip(matrices, tooltip, x + 2, y + 2) + ctx.drawTooltip(textRenderer, tooltip, x + 2, y + 2) } else if (x in 211..219) { // Tooltip for energy tooltip.add(Text.of(f.format(handler!!.syncedEnergy.toLong()) + "/" + f.format(maxEnergy) + " E")) - renderTooltip(matrices, tooltip, x - 90, y - 16) + ctx.drawTooltip(textRenderer, tooltip, x - 90, y - 16) } } } - override fun render(matrices: MatrixStack?, mouseX: Int, mouseY: Int, delta: Float) { - renderBackground(matrices) - super.render(matrices, mouseX, mouseY, delta) - drawMouseoverTooltip(matrices, mouseX, mouseY) + override fun render(ctx: DrawContext, mouseX: Int, mouseY: Int, delta: Float) { + renderBackground(ctx) + super.render(ctx, mouseX, mouseY, delta) + drawMouseoverTooltip(ctx, mouseX, mouseY) } private fun getAnimation(key: String): Animation? { @@ -168,17 +166,27 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve return simulationAnimations[key] } - private fun animateString(matrices: MatrixStack, string: String, anim: Animation?, precedingAnim: Animation?, delay: Int, loop: Boolean, x: Int, y: Int, color: Int) { + private fun animateString(ctx: DrawContext, string: String, anim: Animation?, precedingAnim: Animation?, delay: Int, loop: Boolean, x: Int, y: Int, color: Int) { if (precedingAnim != null) { if (precedingAnim.hasFinished()) { val result = anim!!.animate(string, delay, world!!.levelProperties.time, loop) - DrawableHelper.drawStringWithShadow(matrices, renderer, result, x, y, color) + ctx.drawText( + renderer, + result, + x, y, + color, true + ) } else { return } } val result = anim!!.animate(string, delay, world!!.levelProperties.time, loop) - DrawableHelper.drawStringWithShadow(matrices, renderer, result, x, y, color) + ctx.drawText( + renderer, + result, + x, y, + color, true + ) } private fun animate(string: String, anim: Animation?, precedingAnim: Animation?, delayInTicks: Int, loop: Boolean): String { @@ -195,97 +203,97 @@ open class ScreenSimulationChamber(handler: ScreenHandlerSimulationChamber, inve } else anim!!.animate(string, delayInTicks, world!!.levelProperties.time, loop, intArg) } - private fun drawConsoleText(matrices: MatrixStack, x: Int, y: Int, spacing: Int) { + private fun drawConsoleText(ctx: DrawContext, x: Int, y: Int, spacing: Int) { val lines: Array if (!blockEntity.hasDataModel() || DataModelUtil.getTier(blockEntity.dataModel) == DataModelTier.FAULTY) { - animateString(matrices, "_", getAnimation("blinkingUnderline"), null, 16, true, x + 21, y + 49, 0xFFFFFF) + animateString(ctx, "_", getAnimation("blinkingUnderline"), null, 16, true, x + 21, y + 49, 0xFFFFFF) } else if (!blockEntity.hasPolymerClay() && !blockEntity.isCrafting) { lines = arrayOf("text.dml-refabricated.simulation_chamber.cant_begin", "text.dml-refabricated.simulation_chamber.missing_polymer", "_") val a1 = getAnimation("inputSlotEmpty1") val a2 = getAnimation("inputSlotEmpty2") val a3 = getAnimation("blinkingUnderline1") - animateString(matrices, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) - animateString(matrices, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) - animateString(matrices, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) + animateString(ctx, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) + animateString(ctx, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) + animateString(ctx, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) } else if (!hasEnergy() && !blockEntity.isCrafting) { lines = arrayOf("text.dml-refabricated.simulation_chamber.cant_begin", "text.dml-refabricated.simulation_chamber.missing_energy", "_") val a1 = getAnimation("lowEnergy1") val a2 = getAnimation("lowEnergy2") val a3 = getAnimation("blinkingUnderline2") - animateString(matrices, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) - animateString(matrices, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) - animateString(matrices, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) + animateString(ctx, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) + animateString(ctx, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) + animateString(ctx, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) } else if (blockEntity.outputIsFull() || blockEntity.pristineIsFull()) { lines = arrayOf("text.dml-refabricated.simulation_chamber.cant_begin", "text.dml-refabricated.simulation_chamber.output_full", "_") val a1 = getAnimation("outputSlotFilled1") val a2 = getAnimation("outputSlotFilled2") val a3 = getAnimation("blinkingUnderline3") - animateString(matrices, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) - animateString(matrices, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) - animateString(matrices, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) + animateString(ctx, lines[0], a1, null, 1, false, x + 21, y + 51, 0xFFFFFF) + animateString(ctx, lines[1], a2, a1, 1, false, x + 21, y + 51 + spacing, 0xFFFFFF) + animateString(ctx, lines[2], a3, a2, 16, true, x + 21, y + 51 + spacing * 2, 0xFFFFFF) } else if (blockEntity.isCrafting) { - DrawableHelper.drawStringWithShadow( - matrices, + ctx.drawText( renderer, blockEntity.percentDone.toString() + "%", x + 176, y + 123, - 0x62D8FF + 0x62D8FF, + true ) - DrawableHelper.drawStringWithShadow( - matrices, + ctx.drawText( renderer, getSimulationText("simulationProgressLine1"), x + 21, y + 51, - 0xFFFFFF + 0xFFFFFF, + true ) - DrawableHelper.drawStringWithShadow( - matrices, + ctx.drawText( renderer, getSimulationText("simulationProgressLine1Version"), x + 124, y + 51, - 0xFFFFFF + 0xFFFFFF, + true ) - DrawableHelper.drawStringWithShadow( - matrices, + ctx.drawText( renderer, getSimulationText("simulationProgressLine2"), x + 21, y + 51 + spacing, - 0xFFFFFF + 0xFFFFFF, + true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine3"), x + 21, - y + 51 + spacing * 2, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine3"), x + 21, + y + 51 + spacing * 2, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine4"), x + 21, - y + 51 + spacing * 3, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine4"), x + 21, + y + 51 + spacing * 3, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine5"), x + 21, - y + 51 + spacing * 4, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine5"), x + 21, + y + 51 + spacing * 4, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine6"), x + 21, - y + 51 + spacing * 5, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine6"), x + 21, + y + 51 + spacing * 5, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine6Result"), x + 140, - y + 51 + spacing * 5, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine6Result"), x + 140, + y + 51 + spacing * 5, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("simulationProgressLine7"), x + 21, - y + 51 + spacing * 6, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("simulationProgressLine7"), x + 21, + y + 51 + spacing * 6, 0xFFFFFF, true ) - DrawableHelper.drawStringWithShadow( - matrices, renderer, getSimulationText("blinkingDots1"), x + 128, - y + 51 + spacing * 6, 0xFFFFFF + ctx.drawText( + renderer, getSimulationText("blinkingDots1"), x + 128, + y + 51 + spacing * 6, 0xFFFFFF, true ) } else { - animateString(matrices, "_", getAnimation("blinkingUnderline"), null, 16, true, x + 21, y + 49, 0xFFFFFF) + animateString(ctx, "_", getAnimation("blinkingUnderline"), null, 16, true, x + 21, y + 49, 0xFFFFFF) } } diff --git a/simulacrum/src/main/resources/fabric.mod.json b/simulacrum/src/main/resources/fabric.mod.json index 43f5bd4a..3b1c527b 100644 --- a/simulacrum/src/main/resources/fabric.mod.json +++ b/simulacrum/src/main/resources/fabric.mod.json @@ -22,11 +22,7 @@ ] }, "depends": { - "fabricloader": ">=0.11.3", - "fabric": ">=0.43.1", - "minecraft": "1.19.x", - "dml-refabricated": "*", - "dml-refabricated-base": "*" + "dml-refabricated": "*" }, "custom": { "modmenu": { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4ba4caed..f05efc63 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,7 +19,7 @@ "fabricloader": ">=0.11.3", "fabric": "*", "fabric-language-kotlin": "*", - "minecraft": "1.19.x", + "minecraft": "1.20.x", "ktdatataglib": "*" }, "suggests": {