diff --git a/RebornCore/src/main/java/reborncore/api/items/ItemStackModifiers.java b/RebornCore/src/main/java/reborncore/api/items/ItemStackModifiers.java deleted file mode 100644 index 2f238fdb7..000000000 --- a/RebornCore/src/main/java/reborncore/api/items/ItemStackModifiers.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.api.items; - -import com.google.common.collect.Multimap; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.item.ItemStack; - -public interface ItemStackModifiers { - - void getAttributeModifiers(EquipmentSlot slot, ItemStack stack, Multimap builder); - -} diff --git a/RebornCore/src/main/java/reborncore/common/recipes/ExtendedRecipeRemainder.java b/RebornCore/src/main/java/reborncore/common/recipes/ExtendedRecipeRemainder.java deleted file mode 100644 index f876357a1..000000000 --- a/RebornCore/src/main/java/reborncore/common/recipes/ExtendedRecipeRemainder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.common.recipes; - -import net.minecraft.item.ItemStack; - -public interface ExtendedRecipeRemainder { - - default ItemStack getRemainderStack(ItemStack stack) { - return stack.getItem().hasRecipeRemainder() ? new ItemStack(stack.getItem().getRecipeRemainder()) : ItemStack.EMPTY; - } - -} \ No newline at end of file diff --git a/RebornCore/src/main/java/reborncore/mixin/common/MixinCraftingResultSlot.java b/RebornCore/src/main/java/reborncore/mixin/common/MixinCraftingResultSlot.java index 2f2a06af1..1844215e9 100644 --- a/RebornCore/src/main/java/reborncore/mixin/common/MixinCraftingResultSlot.java +++ b/RebornCore/src/main/java/reborncore/mixin/common/MixinCraftingResultSlot.java @@ -28,16 +28,13 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.screen.slot.CraftingResultSlot; -import net.minecraft.util.collection.DefaultedList; 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 org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import reborncore.api.events.ItemCraftCallback; -import reborncore.common.recipes.ExtendedRecipeRemainder; @Mixin(CraftingResultSlot.class) public abstract class MixinCraftingResultSlot { @@ -50,20 +47,6 @@ public abstract class MixinCraftingResultSlot { @Final private PlayerEntity player; - @ModifyVariable(method = "onTakeItem", at = @At(value = "INVOKE"), index = 3) - private DefaultedList defaultedList(DefaultedList list) { - for (int i = 0; i < input.size(); i++) { - ItemStack invStack = input.getStack(i); - if (invStack.getItem() instanceof ExtendedRecipeRemainder) { - ItemStack remainder = ((ExtendedRecipeRemainder) invStack.getItem()).getRemainderStack(invStack.copy()); - if (!remainder.isEmpty()) { - list.set(i, remainder); - } - } - } - return list; - } - @Inject(method = "onCrafted(Lnet/minecraft/item/ItemStack;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;onCraft(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;I)V", shift = At.Shift.AFTER)) private void onCrafted(ItemStack itemStack, CallbackInfo info) { ItemCraftCallback.EVENT.invoker().onCraft(itemStack, input, player); diff --git a/RebornCore/src/main/java/reborncore/mixin/common/MixinItemStack.java b/RebornCore/src/main/java/reborncore/mixin/common/MixinItemStack.java deleted file mode 100644 index cee0d772f..000000000 --- a/RebornCore/src/main/java/reborncore/mixin/common/MixinItemStack.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.mixin.common; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import reborncore.api.items.ItemStackModifiers; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack { - - @Shadow - public abstract Item getItem(); - - @Inject(method = "getAttributeModifiers", at = @At("RETURN"), cancellable = true) - private void getAttributeModifiers(EquipmentSlot equipmentSlot, CallbackInfoReturnable> info) { - if (getItem() instanceof ItemStackModifiers item) { - Multimap modifierHashMap = ArrayListMultimap.create(info.getReturnValue()); - item.getAttributeModifiers(equipmentSlot, (ItemStack) (Object) this, modifierHashMap); - info.setReturnValue(ImmutableMultimap.copyOf(modifierHashMap)); - } - } - -} diff --git a/RebornCore/src/main/resources/fabric.mod.json b/RebornCore/src/main/resources/fabric.mod.json index c94aa6c8a..93fb9224e 100644 --- a/RebornCore/src/main/resources/fabric.mod.json +++ b/RebornCore/src/main/resources/fabric.mod.json @@ -26,7 +26,7 @@ ], "depends": { "fabricloader": ">=0.13.3", - "fabric": ">=0.40.0", + "fabric": ">=0.50.0", "team_reborn_energy": ">=2.2.0", "fabric-biome-api-v1": ">=3.0.0", "minecraft": "~1.18.2-beta.1" diff --git a/RebornCore/src/main/resources/reborncore.common.mixins.json b/RebornCore/src/main/resources/reborncore.common.mixins.json index e32577fc9..177583c81 100644 --- a/RebornCore/src/main/resources/reborncore.common.mixins.json +++ b/RebornCore/src/main/resources/reborncore.common.mixins.json @@ -11,7 +11,6 @@ "MixinBucketItem", "MixinCraftingResultSlot", "MixinItemEntity", - "MixinItemStack", "MixinLivingEntity", "MixinPlayerEntity", "MixinServerPlayerEntity" diff --git a/gradle.properties b/gradle.properties index becbf25bc..9f9981e1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,9 +7,9 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://modmuss50.me/fabric.html minecraft_version=1.18.2 - yarn_version=1.18.2+build.1 + yarn_version=1.18.2+build.3 loader_version=0.13.3 - fapi_version=0.47.8+1.18.2 + fapi_version=0.50.0+1.18.2 # Dependencies energy_version=2.2.0 diff --git a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java index ef00c10d6..dce067639 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/AutoCraftingTableBlockEntity.java @@ -48,7 +48,6 @@ import reborncore.common.screen.BuiltScreenHandler; import reborncore.client.screen.builder.ScreenHandlerBuilder; import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.powerSystem.PowerAcceptorBlockEntity; -import reborncore.common.recipes.ExtendedRecipeRemainder; import reborncore.common.util.ItemUtils; import reborncore.common.util.RebornInventory; import techreborn.config.TechRebornConfig; @@ -240,12 +239,10 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity } private ItemStack getRemainderItem(ItemStack stack) { - if (stack.getItem() instanceof ExtendedRecipeRemainder) { - return ((ExtendedRecipeRemainder) stack.getItem()).getRemainderStack(stack); - - } else if (stack.getItem().hasRecipeRemainder()) { + if (stack.getItem().hasRecipeRemainder()) { return new ItemStack(stack.getItem().getRecipeRemainder()); } + return ItemStack.EMPTY; } diff --git a/src/main/java/techreborn/items/armor/QuantumSuitItem.java b/src/main/java/techreborn/items/armor/QuantumSuitItem.java index 407c082cb..4533878f2 100644 --- a/src/main/java/techreborn/items/armor/QuantumSuitItem.java +++ b/src/main/java/techreborn/items/armor/QuantumSuitItem.java @@ -24,7 +24,9 @@ package techreborn.items.armor; +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.attribute.EntityAttribute; @@ -40,7 +42,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.collection.DefaultedList; import reborncore.api.items.ArmorBlockEntityTicker; import reborncore.api.items.ArmorRemoveHandler; -import reborncore.api.items.ItemStackModifiers; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; @@ -48,7 +49,7 @@ import techreborn.TechReborn; import techreborn.config.TechRebornConfig; import techreborn.utils.InitUtils; -public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, ArmorBlockEntityTicker, ArmorRemoveHandler, RcEnergyItem { +public class QuantumSuitItem extends TRArmourItem implements ArmorBlockEntityTicker, ArmorRemoveHandler, RcEnergyItem { public final long flyCost = TechRebornConfig.quantumSuitFlyingCost; public final long swimCost = TechRebornConfig.quantumSuitSwimmingCost; @@ -65,7 +66,9 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, } @Override - public void getAttributeModifiers(EquipmentSlot equipmentSlot, ItemStack stack, Multimap attributes) { + public Multimap getAttributeModifiers(ItemStack stack, EquipmentSlot equipmentSlot) { + var attributes = ArrayListMultimap.create(super.getAttributeModifiers(stack, slot)); + attributes.removeAll(EntityAttributes.GENERIC_MOVEMENT_SPEED); if (this.slot == EquipmentSlot.LEGS && equipmentSlot == EquipmentSlot.LEGS && enableSprint) { @@ -78,6 +81,8 @@ public class QuantumSuitItem extends TRArmourItem implements ItemStackModifiers, attributes.put(EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Armor modifier", 20, EntityAttributeModifier.Operation.ADDITION)); attributes.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(MODIFIERS[slot.getEntitySlotId()], "Knockback modifier", 2, EntityAttributeModifier.Operation.ADDITION)); } + + return ImmutableMultimap.copyOf(attributes); } @Override diff --git a/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java b/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java index d25de391b..bc9cb712b 100644 --- a/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java +++ b/src/main/java/techreborn/items/tool/industrial/NanosaberItem.java @@ -24,6 +24,8 @@ package techreborn.items.tool.industrial; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -47,7 +49,6 @@ import net.minecraft.util.TypedActionResult; import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import reborncore.api.items.ItemStackModifiers; import reborncore.common.powerSystem.RcEnergyItem; import reborncore.common.powerSystem.RcEnergyTier; import reborncore.common.util.ItemUtils; @@ -59,7 +60,7 @@ import techreborn.utils.MessageIDs; import java.util.List; -public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemStackModifiers { +public class NanosaberItem extends SwordItem implements RcEnergyItem { public static final int maxCharge = TechRebornConfig.nanosaberCharge; public int cost = TechRebornConfig.nanosaberCost; @@ -168,9 +169,10 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemStackM return ItemUtils.getColorForDurabilityBar(stack); } - // ItemStackModifiers @Override - public void getAttributeModifiers(EquipmentSlot slot, ItemStack stack, Multimap attributes) { + public Multimap getAttributeModifiers(ItemStack stack, EquipmentSlot slot) { + var attributes = ArrayListMultimap.create(super.getAttributeModifiers(stack, slot)); + attributes.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE); attributes.removeAll(EntityAttributes.GENERIC_ATTACK_SPEED); @@ -178,5 +180,7 @@ public class NanosaberItem extends SwordItem implements RcEnergyItem, ItemStackM attributes.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", TechRebornConfig.nanosaberDamage, EntityAttributeModifier.Operation.ADDITION)); attributes.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Weapon modifier", 3, EntityAttributeModifier.Operation.ADDITION)); } + + return ImmutableMultimap.copyOf(attributes); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 77ba43cd6..7a36309fb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,10 +21,7 @@ ], "rei": [ "techreborn.compat.rei.ReiPlugin" - ], - "autoswitch": [ - "techreborn.compat.autoswitch.AutoSwitchApiImpl" - ] + ] }, "custom": { "dashloader:customobject": [ @@ -34,7 +31,7 @@ }, "depends": { "fabricloader": ">=0.13.3", - "fabric": ">=0.46.1", + "fabric": ">=0.50.0", "reborncore": "*", "team_reborn_energy": ">=2.2.0", "fabric-biome-api-v1": ">=3.0.0",