Port to 1.18.2 (#2824)

* Port to 1.18.2-pre1

* 1.18.2-pre3

* Fix build.

* Fixes and cleanup

* Build fix?

* Update REI
This commit is contained in:
modmuss50 2022-02-28 09:18:27 +00:00 committed by GitHub
parent 4465ffa1aa
commit f7d5139332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 406 additions and 393 deletions

View file

@ -24,16 +24,17 @@
package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
@ -41,7 +42,8 @@ import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.utils.InitUtils;
public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class DrillItem extends MiningToolItem implements RcEnergyItem {
public static final TagKey<Block> DRILL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/drill"));
public final int maxCharge;
public final int cost;
@ -52,7 +54,7 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
public DrillItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
// combat stats same as for diamond pickaxe. Fix for #2468
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(1, -2.8F, material, DRILL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.cost = cost;
this.poweredSpeed = poweredSpeed;
@ -161,13 +163,4 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
public long getEnergyMaxOutput() {
return 0;
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES) || tag.equals(FabricToolTags.SHOVELS)) {
return miningLevel;
}
return 0;
}
}

View file

@ -24,31 +24,25 @@
package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.init.TRToolMaterials;
import techreborn.utils.InitUtils;
import techreborn.utils.ToolsUtil;
import java.util.Random;
public class JackhammerItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class JackhammerItem extends PickaxeItem implements RcEnergyItem {
public final int maxCharge;
public final RcEnergyTier tier;
public final int cost;
@ -158,13 +152,4 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem, Dynamic
public int getItemBarColor(ItemStack stack) {
return ItemUtils.getColorForDurabilityBar(stack);
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES)) {
return MiningLevel.IRON.intLevel;
}
return 0;
}
}

View file

@ -32,7 +32,6 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.tag.BlockTags;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
@ -48,7 +47,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRToolMaterials;
import techreborn.items.tool.ChainsawItem;
import techreborn.utils.MessageIDs;
import techreborn.utils.TagUtils;
import techreborn.utils.ToolsUtil;
import java.util.ArrayList;
@ -75,10 +73,11 @@ public class IndustrialChainsawItem extends ChainsawItem {
BlockPos checkPos = pos.offset(facing);
if (!wood.contains(checkPos) && !leaves.contains(checkPos)) {
BlockState state = world.getBlockState(checkPos);
if (TagUtils.hasTag(state.getBlock(), BlockTags.LOGS)) {
if (state.isIn(BlockTags.LOGS)) {
wood.add(checkPos);
findWood(world, checkPos, wood, leaves);
} else if (TagUtils.hasTag(state.getBlock(), BlockTags.LEAVES)) {
} else if (state.isIn(BlockTags.LEAVES)) {
leaves.add(checkPos);
findWood(world, checkPos, wood, leaves);
}

View file

@ -26,8 +26,7 @@ package techreborn.items.tool.industrial;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n;
@ -35,20 +34,21 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
import reborncore.common.util.TorchHelper;
import reborncore.common.powerSystem.RcEnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
@ -58,7 +58,8 @@ import techreborn.utils.InitUtils;
import java.util.List;
public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
public static final TagKey<Block> OMNI_TOOL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/omni_tool"));
public final int maxCharge = TechRebornConfig.omniToolCharge;
public int cost = TechRebornConfig.omniToolCost;
@ -67,7 +68,7 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
// 4M FE max charge with 1k charge rate
public OmniToolItem() {
super(TRToolMaterials.OMNI_TOOL, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(3, 1, TRToolMaterials.OMNI_TOOL, OMNI_TOOL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.miningLevel = MiningLevel.DIAMOND.intLevel;
}
@ -169,13 +170,4 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
public RcEnergyTier getTier() {
return RcEnergyTier.EXTREME;
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES) || tag.equals(FabricToolTags.SHOVELS) || tag.equals(FabricToolTags.AXES) || tag.equals(FabricToolTags.SHEARS) || tag.equals(FabricToolTags.SWORDS)) {
return miningLevel;
}
return 0;
}
}