diff --git a/src/main/java/net/ugi/sculk_depths/block/ModBlocks.java b/src/main/java/net/ugi/sculk_depths/block/ModBlocks.java index 65e56d07..02570238 100644 --- a/src/main/java/net/ugi/sculk_depths/block/ModBlocks.java +++ b/src/main/java/net/ugi/sculk_depths/block/ModBlocks.java @@ -43,6 +43,8 @@ public class ModBlocks { public static final Block SOUL_FIRE = registerBlockWithoutBlockItem("soul_fire", new SoulFireBlock(FabricBlockSettings.copyOf(Blocks.SOUL_FIRE)), ModItemGroup.SCULK_DEPTHS); + public static final Block AMALGAMITE = registerBlock("amalgamite", + new Block(FabricBlockSettings.copyOf(Blocks.DEEPSLATE).strength(5.0f,8f).requiresTool()), ModItemGroup.SCULK_DEPTHS); public static final Block LARGUTH = registerBlock("larguth", new Block(FabricBlockSettings.copyOf(Blocks.OBSIDIAN).strength(40.0f,1000f).requiresTool()), ModItemGroup.SCULK_DEPTHS); //umbrusk blockset diff --git a/src/main/java/net/ugi/sculk_depths/item/crystal/CrystalUpgrade.java b/src/main/java/net/ugi/sculk_depths/item/crystal/CrystalUpgrade.java index 6d4fd21c..aa393aa4 100644 --- a/src/main/java/net/ugi/sculk_depths/item/crystal/CrystalUpgrade.java +++ b/src/main/java/net/ugi/sculk_depths/item/crystal/CrystalUpgrade.java @@ -1,5 +1,6 @@ package net.ugi.sculk_depths.item.crystal; +import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.minecraft.entity.EquipmentSlot; @@ -9,12 +10,14 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; +import net.ugi.sculk_depths.SculkDepths; import net.ugi.sculk_depths.block.enums.CrystalType; import net.ugi.sculk_depths.item.ModItems; import net.ugi.sculk_depths.tags.ModTags; @@ -66,6 +69,8 @@ public static ActionResult createCrystalUpgrade(ItemStack stack, PlayerEntity pl public static void addAttributeToCrystalUpgrade(ItemStack stack, PlayerEntity player, CrystalType crystal) { EquipmentSlot slot = EquipmentSlot.MAINHAND; Multimap modifiers = stack.getAttributeModifiers(slot); + SculkDepths.LOGGER.info(modifiers.toString()); + Multimap modifiers2 = HashMultimap.create(); if(stack.getItem() == ModItems.QUAZARITH_SHOVEL){ if (crystal == CrystalType.WHITE){ @@ -98,7 +103,13 @@ public static void addAttributeToCrystalUpgrade(ItemStack stack, PlayerEntity pl if(stack.getItem() == ModItems.QUAZARITH_SWORD){ if (crystal == CrystalType.WHITE){ - modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier( "Attack Damage", 2,EntityAttributeModifier.Operation.ADDITION)); + modifiers2 = addAttribute(modifiers,modifiers2, EntityAttributes.GENERIC_ATTACK_DAMAGE, Item.ATTACK_DAMAGE_MODIFIER_ID,"Attack Damage", 20,EntityAttributeModifier.Operation.ADDITION); + modifiers2 = addAttribute(modifiers,modifiers2, EntityAttributes.GENERIC_ATTACK_SPEED, Item.ATTACK_SPEED_MODIFIER_ID,"Attack Speed", 2,EntityAttributeModifier.Operation.ADDITION); + modifiers2 = addAttribute(modifiers,modifiers2, EntityAttributes.GENERIC_MOVEMENT_SPEED, UUID.randomUUID(),"Movement Speed", 20,EntityAttributeModifier.Operation.ADDITION); + } + if (crystal == CrystalType.ORANGE){ + + modifiers2 = addAttribute(modifiers,modifiers2, EntityAttributes.GENERIC_MOVEMENT_SPEED, UUID.randomUUID(),"Movement Speed", 20,EntityAttributeModifier.Operation.ADDITION); } } @@ -126,15 +137,55 @@ public static void addAttributeToCrystalUpgrade(ItemStack stack, PlayerEntity pl if(stack.getItem() == ModItems.QUAZARITH_BOOTS){ if (crystal == CrystalType.WHITE){ - modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier( "Attack Damage", 2,EntityAttributeModifier.Operation.ADDITION)); + modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier( "Attack Damage", 2, EntityAttributeModifier.Operation.ADDITION)); } } + Multimap finalModifiers = modifiers2; + modifiers.forEach((entityAttribute, entityAttributeModifier) -> { + int check[] = {0}; + finalModifiers.forEach((entityAttribute2, entityAttributeModifier2) -> { + SculkDepths.LOGGER.info(entityAttribute.toString() + ", " + entityAttributeModifier.toString()); + if (entityAttributeModifier2.getId().equals(entityAttributeModifier.getId())) { + check[0] = 1; + } + + }); + if (check[0] == 0){ + finalModifiers.put(entityAttribute,entityAttributeModifier); + } + + + }); + + EquipmentSlot slot2 = getEquipmentSlot(stack.getItem()); + finalModifiers.forEach((entityAttribute, entityAttributeModifier) -> { + stack.addAttributeModifier(entityAttribute, new EntityAttributeModifier(entityAttributeModifier.getId(), entityAttributeModifier.getName(), entityAttributeModifier.getValue(), entityAttributeModifier.getOperation()) , slot2); + }); + } + + public static Multimap addAttribute(Multimap modifiers,Multimap modifiers2, EntityAttribute attribute, UUID uuid, String name, double value, EntityAttributeModifier.Operation operation){ + final int[] check = {0}; modifiers.forEach((entityAttribute, entityAttributeModifier) -> { - stack.addAttributeModifier(entityAttribute, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, entityAttributeModifier.getName(), entityAttributeModifier.getValue(), entityAttributeModifier.getOperation()) , slot2); + if (entityAttributeModifier.getId().equals(uuid)) { + check[0] = 1; + if (operation == EntityAttributeModifier.Operation.ADDITION){ + double originalValue = entityAttributeModifier.getValue(); + modifiers2.put(attribute, new EntityAttributeModifier(uuid,name, originalValue + value, operation)); + } + if (operation == EntityAttributeModifier.Operation.MULTIPLY_TOTAL){ + double originalValue = entityAttributeModifier.getValue(); + modifiers2.put(attribute, new EntityAttributeModifier(uuid,name, originalValue * value, operation)); + } + } + }); + if (check[0] == 0){ + modifiers2.put(attribute, new EntityAttributeModifier( uuid,name, value, operation)); + } + return modifiers2; } public static void addNbtToCrystalUpgrade(ItemStack stack, PlayerEntity player, CrystalType crystal) { diff --git a/src/main/java/net/ugi/sculk_depths/mixin/ItemAccessorMixin.java b/src/main/java/net/ugi/sculk_depths/mixin/ItemAccessorMixin.java new file mode 100644 index 00000000..56c3ab81 --- /dev/null +++ b/src/main/java/net/ugi/sculk_depths/mixin/ItemAccessorMixin.java @@ -0,0 +1,21 @@ +package net.ugi.sculk_depths.mixin; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.UUID; + +@Mixin(Item.class) +public interface ItemAccessorMixin { + @Accessor + static UUID getATTACK_DAMAGE_MODIFIER_ID() { + throw new AssertionError(); // never called + } + @Accessor + static UUID getATTACK_SPEED_MODIFIER_ID() { + throw new AssertionError(); // never called + } +} diff --git a/src/main/java/net/ugi/sculk_depths/mixin/ItemStackMixin.java b/src/main/java/net/ugi/sculk_depths/mixin/ItemStackMixin.java index 7ad22148..17d8635e 100644 --- a/src/main/java/net/ugi/sculk_depths/mixin/ItemStackMixin.java +++ b/src/main/java/net/ugi/sculk_depths/mixin/ItemStackMixin.java @@ -8,7 +8,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Uuids; import org.apache.logging.log4j.core.config.plugins.convert.TypeConverters; +import org.slf4j.Logger; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import java.util.UUID; @@ -16,22 +19,20 @@ @Mixin(ItemStack.class) public class ItemStackMixin{ + @Shadow @Final private static Logger LOGGER; + @ModifyExpressionValue( method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getId()Ljava/util/UUID;") ) private static UUID fixBug(UUID original){ - if (original.equals(Item.ATTACK_DAMAGE_MODIFIER_ID)) { - return Item.ATTACK_DAMAGE_MODIFIER_ID; + if (original.equals(ItemAccessorMixin.getATTACK_DAMAGE_MODIFIER_ID())) { + return ItemAccessorMixin.getATTACK_DAMAGE_MODIFIER_ID(); + } + if (original.equals(ItemAccessorMixin.getATTACK_SPEED_MODIFIER_ID())) { + return ItemAccessorMixin.getATTACK_SPEED_MODIFIER_ID(); } return original; } - -/* @ModifyExpressionValue( - method = "getTooltip", - at = @At(value = "HEAD", target = "Lnet/minecraft/item/Item;ATTACK_DAMAGE_MODIFIER_ID:Ljava/util/UUID") - - )*/ - } diff --git a/src/main/resources/assets/sculk_depths/blockstates/amalgamite.json b/src/main/resources/assets/sculk_depths/blockstates/amalgamite.json new file mode 100644 index 00000000..e1fe6ab2 --- /dev/null +++ b/src/main/resources/assets/sculk_depths/blockstates/amalgamite.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "sculk_depths:block/amalgamite" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/sculk_depths/models/block/amalgamite.json b/src/main/resources/assets/sculk_depths/models/block/amalgamite.json new file mode 100644 index 00000000..0172fa24 --- /dev/null +++ b/src/main/resources/assets/sculk_depths/models/block/amalgamite.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "sculk_depths:block/amalgamite" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/sculk_depths/models/item/amalgamite.json b/src/main/resources/assets/sculk_depths/models/item/amalgamite.json new file mode 100644 index 00000000..14e1953d --- /dev/null +++ b/src/main/resources/assets/sculk_depths/models/item/amalgamite.json @@ -0,0 +1,3 @@ +{ + "parent": "sculk_depths:block/amalgamite" +} \ No newline at end of file diff --git a/src/main/resources/assets/sculk_depths/textures/block/amalgamite.png b/src/main/resources/assets/sculk_depths/textures/block/amalgamite.png new file mode 100644 index 00000000..f108c74f Binary files /dev/null and b/src/main/resources/assets/sculk_depths/textures/block/amalgamite.png differ diff --git a/src/main/resources/data/sculk_depths/dimension/sculk_depths.json b/src/main/resources/data/sculk_depths/dimension/sculk_depths.json index 72421fcb..1efb9791 100644 --- a/src/main/resources/data/sculk_depths/dimension/sculk_depths.json +++ b/src/main/resources/data/sculk_depths/dimension/sculk_depths.json @@ -469,7 +469,7 @@ "type": "minecraft:condition", "if_true": { "type": "minecraft:vertical_gradient", - "random_name": "minecraft:deepslate", + "random_name": "sculk_depths:amalgamite", "true_at_and_below": { "absolute": 72 }, @@ -480,7 +480,7 @@ "then_run": { "type": "minecraft:block", "result_state": { - "Name": "minecraft:deepslate", + "Name": "sculk_depths:amalgamite", "Properties": { "axis": "y" } diff --git a/src/main/resources/data/sculk_depths/tags/blocks/sculk_veins_deepslate.json b/src/main/resources/data/sculk_depths/tags/blocks/sculk_veins_deepslate.json index 0012c241..ed63e4fa 100644 --- a/src/main/resources/data/sculk_depths/tags/blocks/sculk_veins_deepslate.json +++ b/src/main/resources/data/sculk_depths/tags/blocks/sculk_veins_deepslate.json @@ -1,5 +1,6 @@ { "values": [ - "minecraft:deepslate" + "minecraft:deepslate", + "sculk_depths:amalgamite" ] } \ No newline at end of file diff --git a/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_floor_deepslate.json b/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_floor_deepslate.json index f6359b89..a4d0b992 100644 --- a/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_floor_deepslate.json +++ b/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_floor_deepslate.json @@ -36,13 +36,13 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -51,49 +51,49 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -102,22 +102,22 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -129,40 +129,40 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -171,7 +171,7 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" } ] }, @@ -186,7 +186,7 @@ "can_place_on_ceiling": true, "can_place_on_wall": true, "can_be_placed_on": [ - "minecraft:deepslate" + "sculk_depths:amalgamite" ] } }, @@ -231,7 +231,7 @@ -1, 0 ], - "blocks": "minecraft:deepslate" + "blocks": "sculk_depths:amalgamite" } }, { diff --git a/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_roof_deepslate.json b/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_roof_deepslate.json index 2ac5324f..e9a40ea6 100644 --- a/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_roof_deepslate.json +++ b/src/main/resources/data/sculk_depths/worldgen/placed_feature/sculk_veins_roof_deepslate.json @@ -36,13 +36,13 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -51,49 +51,49 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -102,22 +102,22 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -129,40 +129,40 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" }, { "Name": "minecraft:sculk" @@ -171,7 +171,7 @@ "Name": "minecraft:sculk" }, { - "Name": "minecraft:deepslate" + "Name": "sculk_depths:amalgamite" } ] }, @@ -186,7 +186,7 @@ "can_place_on_ceiling": true, "can_place_on_wall": true, "can_be_placed_on": [ - "minecraft:deepslate" + "sculk_depths:amalgamite" ] } }, @@ -231,7 +231,7 @@ 1, 0 ], - "blocks": "minecraft:deepslate" + "blocks": "sculk_depths:amalgamite" } }, { diff --git a/src/main/resources/sculk_depths.mixins.json b/src/main/resources/sculk_depths.mixins.json index 73e4a0ff..64512036 100644 --- a/src/main/resources/sculk_depths.mixins.json +++ b/src/main/resources/sculk_depths.mixins.json @@ -9,6 +9,7 @@ "BlockMixin", "CropBlockMixin", "FarmLandBlockMixin", + "ItemAccessorMixin", "ItemStackMixin", "LivingEntityMixin", "NoiseChunkGeneratorMixin",