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:
parent
4465ffa1aa
commit
f7d5139332
34 changed files with 406 additions and 393 deletions
|
@ -26,7 +26,6 @@ package techreborn.init;
|
|||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tag.TagFactory;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -35,9 +34,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.item.Items;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.math.intprovider.UniformIntProvider;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import reborncore.api.blockentity.IUpgrade;
|
||||
|
@ -397,7 +398,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> ORES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ores"));
|
||||
public static final TagKey<Item> ORES_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ores"));
|
||||
|
||||
private final static Map<Ores, Ores> deepslateMap = new HashMap<>();
|
||||
|
||||
|
@ -437,7 +438,7 @@ public class TRContent {
|
|||
public final String name;
|
||||
public final Block block;
|
||||
public final OreDistribution distribution;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -449,7 +450,7 @@ public class TRContent {
|
|||
distribution != null ? distribution.experienceDropped : experienceDroppedFallback
|
||||
);
|
||||
InitUtils.setup(block, name + "_ore");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c",
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c",
|
||||
(name.startsWith("deepslate_") ? name.substring(name.indexOf('_')+1): name) + "_ores"));
|
||||
this.distribution = distribution;
|
||||
}
|
||||
|
@ -470,7 +471,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -495,7 +496,7 @@ public class TRContent {
|
|||
*/
|
||||
public static final String CHROME_TAG_NAME_BASE = "chromium";
|
||||
|
||||
public static final Tag.Identified<Item> STORAGE_BLOCK_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "storage_blocks"));
|
||||
public static final TagKey<Item> STORAGE_BLOCK_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "storage_blocks"));
|
||||
|
||||
public enum StorageBlocks implements ItemConvertible, TagConvertible<Item> {
|
||||
ADVANCED_ALLOY(5f, 6f),
|
||||
|
@ -536,13 +537,13 @@ public class TRContent {
|
|||
private final StairsBlock stairsBlock;
|
||||
private final SlabBlock slabBlock;
|
||||
private final WallBlock wallBlock;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
StorageBlocks(boolean isHot, float hardness, float resistance, String tagNameBase) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
block = new BlockStorage(isHot, hardness, resistance);
|
||||
InitUtils.setup(block, name + "_storage_block");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks"));
|
||||
|
||||
stairsBlock = new TechRebornStairsBlock(block.getDefaultState(), FabricBlockSettings.copyOf(block));
|
||||
InitUtils.setup(stairsBlock, name + "_storage_block_stairs");
|
||||
|
@ -572,7 +573,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -718,7 +719,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "dusts"));
|
||||
public static final TagKey<Item> DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "dusts"));
|
||||
|
||||
public enum Dusts implements ItemConvertible, TagConvertible<Item> {
|
||||
ALMANDINE, ALUMINUM, AMETHYST, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME(CHROME_TAG_NAME_BASE),
|
||||
|
@ -729,13 +730,13 @@ public class TRContent {
|
|||
|
||||
private final String name;
|
||||
private final Item item;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Dusts(String tagNameBase) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
|
||||
InitUtils.setup(item, name + "_dust");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_dusts"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_dusts"));
|
||||
}
|
||||
|
||||
Dusts() {
|
||||
|
@ -756,12 +757,12 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> RAW_METALS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "raw_metals"));
|
||||
public static final TagKey<Item> RAW_METALS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "raw_metals"));
|
||||
|
||||
public enum RawMetals implements ItemConvertible, TagConvertible<Item> {
|
||||
IRIDIUM, LEAD, SILVER, TIN, TUNGSTEN;
|
||||
|
@ -769,7 +770,7 @@ public class TRContent {
|
|||
private final String name;
|
||||
private final Item item;
|
||||
private final ItemConvertible storageBlock;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
RawMetals() {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -783,7 +784,7 @@ public class TRContent {
|
|||
}
|
||||
storageBlock = blockVariant;
|
||||
InitUtils.setup(item, "raw_" + name);
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", "raw_" + name + "_ores"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "raw_" + name + "_ores"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -792,7 +793,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -813,7 +814,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> SMALL_DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "small_dusts"));
|
||||
public static final TagKey<Item> SMALL_DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "small_dusts"));
|
||||
|
||||
public enum SmallDusts implements ItemConvertible, TagConvertible<Item> {
|
||||
ALMANDINE, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, CALCITE, CHARCOAL, CHROME(CHROME_TAG_NAME_BASE),
|
||||
|
@ -826,7 +827,7 @@ public class TRContent {
|
|||
private final String name;
|
||||
private final Item item;
|
||||
private final ItemConvertible dust;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
SmallDusts(String tagNameBase, ItemConvertible dustVariant) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -840,7 +841,7 @@ public class TRContent {
|
|||
}
|
||||
dust = dustVariant;
|
||||
InitUtils.setup(item, name + "_small_dust");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts"));
|
||||
}
|
||||
|
||||
SmallDusts(String tagNameBase) {
|
||||
|
@ -869,7 +870,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -893,7 +894,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> GEMS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "gems"));
|
||||
public static final TagKey<Item> GEMS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "gems"));
|
||||
|
||||
public enum Gems implements ItemConvertible, TagConvertible<Item> {
|
||||
PERIDOT, RED_GARNET, RUBY("rubies"), SAPPHIRE("sapphires"), YELLOW_GARNET;
|
||||
|
@ -901,7 +902,7 @@ public class TRContent {
|
|||
private final String name;
|
||||
private final Item item;
|
||||
private final ItemConvertible storageBlock;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Gems(String tagPlural) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -915,7 +916,7 @@ public class TRContent {
|
|||
}
|
||||
storageBlock = blockVariant;
|
||||
InitUtils.setup(item, name + "_gem");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural));
|
||||
}
|
||||
|
||||
Gems() {
|
||||
|
@ -936,7 +937,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -957,7 +958,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> INGOTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ingots"));
|
||||
public static final TagKey<Item> INGOTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ingots"));
|
||||
|
||||
public enum Ingots implements ItemConvertible, TagConvertible<Item> {
|
||||
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CHROME(CHROME_TAG_NAME_BASE), ELECTRUM, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM_ALLOY, IRIDIUM,
|
||||
|
@ -966,7 +967,7 @@ public class TRContent {
|
|||
private final String name;
|
||||
private final Item item;
|
||||
private final ItemConvertible storageBlock;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Ingots(String tagNameBase) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -980,7 +981,7 @@ public class TRContent {
|
|||
}
|
||||
storageBlock = blockVariant;
|
||||
InitUtils.setup(item, name + "_ingot");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots"));
|
||||
}
|
||||
|
||||
Ingots() {
|
||||
|
@ -1001,7 +1002,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1023,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> NUGGETS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "nuggets"));
|
||||
public static final TagKey<Item> NUGGETS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "nuggets"));
|
||||
|
||||
public enum Nuggets implements ItemConvertible, TagConvertible<Item> {
|
||||
ALUMINUM, BRASS, BRONZE, CHROME(CHROME_TAG_NAME_BASE), COPPER(Items.COPPER_INGOT, false), DIAMOND(Items.DIAMOND, true),
|
||||
|
@ -1033,7 +1034,7 @@ public class TRContent {
|
|||
private final Item item;
|
||||
private final ItemConvertible ingot;
|
||||
private final boolean ofGem;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Nuggets(String tagNameBase, ItemConvertible ingotVariant, boolean ofGem) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
|
@ -1048,7 +1049,7 @@ public class TRContent {
|
|||
ingot = ingotVariant;
|
||||
this.ofGem = ofGem;
|
||||
InitUtils.setup(item, name + "_nugget");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets"));
|
||||
}
|
||||
|
||||
Nuggets(ItemConvertible ingotVariant, boolean ofGem) {
|
||||
|
@ -1077,7 +1078,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -1179,7 +1180,7 @@ public class TRContent {
|
|||
}
|
||||
}
|
||||
|
||||
public static final Tag.Identified<Item> PLATES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "plates"));
|
||||
public static final TagKey<Item> PLATES_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "plates"));
|
||||
|
||||
public enum Plates implements ItemConvertible, TagConvertible<Item> {
|
||||
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CARBON, CHROME(CHROME_TAG_NAME_BASE), COAL, COPPER, DIAMOND, ELECTRUM, EMERALD, GOLD, INVAR,
|
||||
|
@ -1189,13 +1190,13 @@ public class TRContent {
|
|||
|
||||
private final String name;
|
||||
private final Item item;
|
||||
private final Tag.Identified<Item> tag;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
Plates(String tagNameBase) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
|
||||
InitUtils.setup(item, name + "_plate");
|
||||
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_plates"));
|
||||
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_plates"));
|
||||
}
|
||||
|
||||
Plates() {
|
||||
|
@ -1216,7 +1217,7 @@ public class TRContent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Tag.Identified<Item> asTag() {
|
||||
public TagKey<Item> asTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2020 TechReborn
|
||||
*
|
||||
* 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 techreborn.utils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.tag.TagGroup;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TagUtils {
|
||||
|
||||
public static <T> boolean hasTag(T type, Tag<T> tag) {
|
||||
return tag.contains(type);
|
||||
}
|
||||
|
||||
public static TagGroup<Block> getAllBlockTags(World world) {
|
||||
return world.getTagManager().getOrCreateTagGroup(Registry.BLOCK_KEY);
|
||||
}
|
||||
|
||||
public static TagGroup<Item> getAllItemTags(World world) {
|
||||
return world.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY);
|
||||
}
|
||||
|
||||
public static TagGroup<Fluid> getAllFluidTags(World world) {
|
||||
return world.getTagManager().getOrCreateTagGroup(Registry.FLUID_KEY);
|
||||
}
|
||||
}
|
|
@ -31,10 +31,11 @@ import net.minecraft.structure.rule.RuleTest;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.gen.YOffset;
|
||||
import net.minecraft.world.gen.decorator.*;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
import net.minecraft.world.gen.placementmodifier.*;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -59,7 +60,7 @@ public class OreFeature {
|
|||
case END -> createSimpleFeatureConfig(new BlockStateMatchRuleTest(Blocks.END_STONE.getDefaultState()));
|
||||
};
|
||||
|
||||
ConfiguredFeature<?, ?> configuredFeature = Feature.ORE.configure(oreFeatureConfig);
|
||||
ConfiguredFeature<?, ?> configuredFeature = new ConfiguredFeature<>(Feature.ORE, oreFeatureConfig);
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, getId(), configuredFeature);
|
||||
return configuredFeature;
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ public class OreFeature {
|
|||
}
|
||||
|
||||
private PlacedFeature configureAndRegisterPlacedFeature() {
|
||||
PlacedFeature placedFeature = configuredFeature.withPlacement(getPlacementModifiers());
|
||||
PlacedFeature placedFeature = new PlacedFeature(WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, configuredFeature), getPlacementModifiers());
|
||||
Registry.register(BuiltinRegistries.PLACED_FEATURE, getId(), placedFeature);
|
||||
return placedFeature;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
package techreborn.world;
|
||||
|
||||
import net.minecraft.block.sapling.SaplingGenerator;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.TreeFeatureConfig;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -34,7 +35,7 @@ import java.util.Random;
|
|||
public class RubberSaplingGenerator extends SaplingGenerator {
|
||||
@Nullable
|
||||
@Override
|
||||
protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random random, boolean bl) {
|
||||
return WorldGenerator.RUBBER_TREE_FEATURE;
|
||||
protected RegistryEntry<? extends ConfiguredFeature<?, ?>> getTreeFeature(Random random, boolean bees) {
|
||||
return WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, WorldGenerator.RUBBER_TREE_FEATURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,16 @@ import net.minecraft.util.math.Direction;
|
|||
import net.minecraft.util.math.intprovider.ConstantIntProvider;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.decorator.BiomePlacementModifier;
|
||||
import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier;
|
||||
import net.minecraft.world.gen.decorator.SquarePlacementModifier;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize;
|
||||
import net.minecraft.world.gen.foliage.BlobFoliagePlacer;
|
||||
import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier;
|
||||
import net.minecraft.world.gen.placementmodifier.RarityFilterPlacementModifier;
|
||||
import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier;
|
||||
import net.minecraft.world.gen.stateprovider.BlockStateProvider;
|
||||
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;
|
||||
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
|
||||
|
@ -100,25 +101,29 @@ public class WorldGenerator {
|
|||
Identifier patchId = new Identifier("techreborn", "rubber_tree_patch");
|
||||
|
||||
RUBBER_TREE_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, treeId,
|
||||
Feature.TREE.configure(rubber().build())
|
||||
new ConfiguredFeature<>(Feature.TREE, rubber().build())
|
||||
);
|
||||
RUBBER_TREE_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, treeId,
|
||||
RUBBER_TREE_FEATURE.withWouldSurviveFilter(TRContent.RUBBER_SAPLING)
|
||||
new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_FEATURE), List.of(
|
||||
PlacedFeatures.wouldSurvive(TRContent.RUBBER_SAPLING)
|
||||
))
|
||||
);
|
||||
|
||||
RUBBER_TREE_PATCH_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, patchId,
|
||||
Feature.RANDOM_PATCH.configure(
|
||||
ConfiguredFeatures.createRandomPatchFeatureConfig(6, RUBBER_TREE_PLACED_FEATURE)
|
||||
new ConfiguredFeature<>(Feature.RANDOM_PATCH,
|
||||
ConfiguredFeatures.createRandomPatchFeatureConfig(
|
||||
6, getEntry(BuiltinRegistries.PLACED_FEATURE, RUBBER_TREE_PLACED_FEATURE)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
RUBBER_TREE_PATCH_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, patchId,
|
||||
RUBBER_TREE_PATCH_FEATURE.withPlacement(
|
||||
RarityFilterPlacementModifier.of(3),
|
||||
SquarePlacementModifier.of(),
|
||||
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
|
||||
BiomePlacementModifier.of()
|
||||
)
|
||||
new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_PATCH_FEATURE), List.of(
|
||||
RarityFilterPlacementModifier.of(3),
|
||||
SquarePlacementModifier.of(),
|
||||
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
|
||||
BiomePlacementModifier.of())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -163,4 +168,8 @@ public class WorldGenerator {
|
|||
new RubberTreeSpikeDecorator(4, BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState()))
|
||||
));
|
||||
}
|
||||
|
||||
public static <T> RegistryEntry<T> getEntry(Registry<T> registry, T value) {
|
||||
return registry.getEntry(registry.getKey(value).orElseThrow()).orElseThrow();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue