Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.20/1.20.1, updated. #133

Open
wants to merge 3 commits into
base: 1.19.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -12,9 +12,9 @@ version = project.version + "-" + project.minecraft_version
repositories {
maven { url "https://maven.fabricmc.net/" }
maven { url 'https://jitpack.io' }
maven { url "https://server.bbkr.space/artifactory/libs-release" }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/"}
maven { url "https://maven.draylar.dev/releases" }
}

dependencies {
Expand All @@ -27,26 +27,25 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Magna (https://github.com/Draylar/magna) for hammers
include "com.github.Draylar:magna:${project.magna_version}"
modImplementation ("com.github.Draylar:magna:${project.magna_version}") {
include "dev.draylar:magna:${project.magna_version}"
modImplementation ("dev.draylar:magna:${project.magna_version}") {
exclude group: "net.fabricmc"
exclude group: "com.jamieswhiteshirt"
exclude group: "me.shedaniel.cloth"
}

modImplementation ("io.github.cottonmc:StaticData:1.1.2") {
exclude group: "net.fabricmc.fabric-api"
exclude module: "omega-config-base"
}

// Static Content (https://github.com/Draylar/static-content) for hammer loading and compat
include "com.github.Draylar:static-content:${project.static_content_version}"
modImplementation ("com.github.Draylar:static-content:${project.static_content_version}") {
exclude group: "com.github.Draylar"
exclude group: "net.fabricmc"
exclude module: "omega-config-base"
}

// Config solutions + Cloth Config for Magna
modImplementation "com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}"
include "com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}"
modImplementation "dev.draylar.omega-config:omega-config-base:${project.omega_config_version}"
include "dev.draylar.omega-config:omega-config-base:${project.omega_config_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
org.gradle.jvmargs=-Xmx1G

# Minecraft Properties
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.22
loader_version=0.14.9
fabric_version=0.63.0+1.19.2
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.24
fabric_version=0.90.7+1.20.1

# Metadata
modid=vanilla-hammers
version=3.5.0
version=3.5.0+gnifty3

# External Dependencies
magna_version=1.8.0-1.19.2
mod_menu_version=3.0.1
magna_version=1.10.0+1.20.1
mod_menu_version=7.2.2
libcd_version=3.0.3+1.16.3
static_content_version=1.0.2
maybe_data_version=1.3.0-1.18.2
omega_config_version=1.2.1-1.18.1
cloth_config_version=5.0.38
maybe_data_version=1.3.2-1.19
omega_config_version=1.4.0+1.20.1
cloth_config_version=11.1.106
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions src/main/java/draylar/vh/VanillaHammers.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
package draylar.vh;

import draylar.magna.api.optional.MagnaOptionals;
import dev.draylar.magna.api.optional.MagnaOptionals;
import draylar.omegaconfig.OmegaConfig;
import draylar.staticcontent.StaticContent;
import draylar.vh.config.VanillaHammersConfig;
import draylar.vh.data.HammerData;
import draylar.vh.item.ExtendedHammerItem;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
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;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class VanillaHammers implements ModInitializer {

public static String MODID = "vanilla-hammers";
public static VanillaHammersConfig CONFIG = OmegaConfig.register(VanillaHammersConfig.class);
public static final ItemGroup GROUP = FabricItemGroupBuilder.build(id("group"), () -> new ItemStack(Registry.ITEM.get(id("diamond_hammer"))));
private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, id("group"));

@Override
public void onInitialize() {
MagnaOptionals.optInForCurse();
StaticContent.load(id("hammers"), HammerData.class);
Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.vanilla-hammers.group"))
.icon(() -> new ItemStack(Registries.ITEM.get(id("diamond_hammer"))))
.entries((context, entries) -> entries.addAll(HammerData.ENTRY_SET))
.build()
);
registerCallbackHandlers();
}

Expand Down
33 changes: 11 additions & 22 deletions src/main/java/draylar/vh/data/HammerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import draylar.vh.VanillaHammers;
import draylar.vh.item.ExtendedHammerItem;
import draylar.vh.material.CustomToolMaterial;
import draylar.vh.mixin.ItemGroupAccessor;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.Set;

public class HammerData implements ContentData {

Expand All @@ -27,8 +28,8 @@ public class HammerData implements ContentData {
private final boolean isExtra;
private final int burnTime;
private final boolean hasExtraKnockback;
private final String group;
private transient ItemGroup cachedGroup;

public static final Set<ItemStack> ENTRY_SET = ItemStackSet.create();

public HammerData(String id, int miningLevel, int durability, float blockBreakSpeed, float attackDamage, float attackSpeed, int enchantability, Identifier repairIngredient, boolean isFireImmune, boolean smelts, int breakRadius, boolean isExtra, int burnTime, boolean hasExtraKnockback, String group) {
this.id = id;
Expand All @@ -45,7 +46,6 @@ public HammerData(String id, int miningLevel, int durability, float blockBreakSp
this.isExtra = isExtra;
this.burnTime = burnTime;
this.hasExtraKnockback = hasExtraKnockback;
this.group = group;
}

@Override
Expand All @@ -54,7 +54,7 @@ public void register(Identifier identifier) {
if (!isExtra() || isExtra() && VanillaHammers.CONFIG.enableExtraMaterials) {

// setup settings
Item.Settings settings = new Item.Settings().group(VanillaHammers.GROUP);
Item.Settings settings = new Item.Settings();
if (isFireImmune()) {
settings.fireproof();
}
Expand All @@ -78,22 +78,11 @@ public void register(Identifier identifier) {
// add hammer to tag
String path = getId() + "_hammer";
Identifier registryID = path.contains(":") ? new Identifier(path) : VanillaHammers.id(path);
Registry.register(Registry.ITEM, registryID, hammerItem);
}
}
Registry.register(Registries.ITEM, registryID, hammerItem);

public ItemGroup getGroup() {
// attempt to get group from string
if (cachedGroup == null && (group != null && !group.isEmpty())) {
for (ItemGroup itemGroup : ItemGroup.GROUPS) {
if (((ItemGroupAccessor) itemGroup).getId().equals(group)) {
cachedGroup = itemGroup;
break;
}
}
// add hammer to item group
ENTRY_SET.add(hammerItem.getDefaultStack());
}

return cachedGroup;
}

public boolean hasExtraKnockback() {
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/draylar/vh/item/ExtendedHammerItem.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package draylar.vh.item;

import dev.draylar.magna.api.BlockProcessor;
import dev.draylar.magna.item.HammerItem;
import draylar.vh.data.HammerData;
import draylar.magna.api.BlockProcessor;
import draylar.magna.item.HammerItem;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.RecipeType;
Expand All @@ -30,7 +29,7 @@ public HammerData getData() {

@Override
public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos pos, ItemStack heldStack) {
if(data.canSmelt()) {
if (data.canSmelt()) {
return (tool, input) -> {
Optional<SmeltingRecipe> cooked = world.getRecipeManager().getFirstMatch(
RecipeType.SMELTING,
Expand All @@ -39,7 +38,7 @@ public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos po
);

if (cooked.isPresent()) {
return cooked.get().getOutput().copy();
return cooked.get().getOutput(world.getRegistryManager()).copy();
}

return input;
Expand All @@ -48,9 +47,4 @@ public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos po
return super.getProcessor(world, player, pos, heldStack);
}
}

@Override
public boolean isIn(ItemGroup group) {
return super.isIn(group) || group.equals(data.getGroup());
}
}
16 changes: 8 additions & 8 deletions src/main/java/draylar/vh/material/CustomToolMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import draylar.vh.data.HammerData;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class CustomToolMaterial implements ToolMaterial {

private int enchantability;
private float miningSpeedMultiplier;
private int durability;
private float attackDamage;
private int miningLevel;
private Ingredient ingredient;
private final int enchantability;
private final float miningSpeedMultiplier;
private final int durability;
private final float attackDamage;
private final int miningLevel;
private final Ingredient ingredient;

public CustomToolMaterial(int enchantability, float miningSpeedMultiplier, int durability, float attackDamage, int miningLevel, Ingredient ingredient) {
this.enchantability = enchantability;
Expand All @@ -32,7 +32,7 @@ public static CustomToolMaterial from(HammerData data) {
(data.getDurability() == 0 ? 500 : data.getDurability()) * VanillaHammers.CONFIG.durabilityModifier,
data.getAttackDamage() == 0 ? 4 : data.getAttackDamage(),
data.getMiningLevel(),
Ingredient.ofItems(Registry.ITEM.get(data.getRepairIngredient() == null ? new Identifier("iron_ingot") : data.getRepairIngredient()))
Ingredient.ofItems(Registries.ITEM.get(data.getRepairIngredient() == null ? new Identifier("iron_ingot") : data.getRepairIngredient()))
);
}

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/draylar/vh/mixin/ItemGroupAccessor.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"type": "minecraft:smithing",
"type": "minecraft:smithing_transform",
"template": {
"item": "minecraft:netherite_upgrade_smithing_template"
},
"base": {
"item": "vanilla-hammers:diamond_hammer"
},
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/vanillahammers.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"HammerKnockbackMixin",
"ItemGroupAccessor",
"SilkTouchEnchantmentMixin"
],
"client": [
Expand Down