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 Fabric #41

Closed
wants to merge 6 commits into from
Closed
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
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.14
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22

# Mod Properties
mod_version=1.27
mod_version=1.28
maven_group=dev.cammiescorner
archives_base_name=hookshot

# Dependencies
fabric_version=0.75.1+1.19.3
midnightlib_version=1.1.0-fabric
modmenu_version=5.0.2
fabric_version=0.88.1+1.20.1
midnightlib_version=1.4.1-fabric
modmenu_version=7.2.1
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [HOOKSHOT](https://modrinth.com/mod/hookshot)

## Description

adds hookshot to Minecraft, This is an attempt to update to 1.20.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import dev.cammiescorner.hookshot.Hookshot;
import dev.cammiescorner.hookshot.common.item.HookshotItem;
import dev.cammiescorner.hookshot.core.integration.HookshotConfig;
import dev.cammiescorner.hookshot.core.registry.ModDamageSource;
import dev.cammiescorner.hookshot.core.registry.ModDamageTypes;
//import dev.cammiescorner.hookshot.core.registry.ModDamageSource;
import dev.cammiescorner.hookshot.core.registry.ModEntities;
import dev.cammiescorner.hookshot.core.registry.ModSoundEvents;
import dev.cammiescorner.hookshot.core.util.PlayerProperties;
Expand All @@ -13,6 +14,7 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.boss.dragon.EnderDragonPart;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
Expand Down Expand Up @@ -40,6 +42,7 @@ public class HookshotEntity extends PersistentProjectileEntity {
private Entity hookedEntity;
private ItemStack stack;

World world = this.getWorld();
public HookshotEntity(EntityType<? extends PersistentProjectileEntity> type, PlayerEntity owner, World world) {
super(type, owner, world);
this.setNoGravity(true);
Expand Down Expand Up @@ -83,7 +86,8 @@ public void tick() {
}
else {
if(UpgradesHelper.hasBleedUpgrade(stack) && age % 20 == 0)
hookedEntity.damage(ModDamageSource.bleed(this, owner), 1);
hookedEntity.damage(ModDamageTypes.of(world, ModDamageTypes.HOOKBLEEDING), 1.0f);
//hookedEntity.damage(ModDamageSource.bleed(this, owner), 1);

this.updatePosition(this.hookedEntity.getX(), this.hookedEntity.getBodyY(0.8D), this.hookedEntity.getZ());
}
Expand Down Expand Up @@ -222,7 +226,8 @@ protected void onEntityHit(EntityHitResult entityHitResult) {
}

if(hookedEntity != null && UpgradesHelper.hasBleedUpgrade(stack))
hookedEntity.damage(ModDamageSource.bleed(this, owner), 1);
hookedEntity.damage(ModDamageTypes.of(world, ModDamageTypes.HOOKBLEEDING), 1.0f);
// hookedEntity.damage(ModDamageSource.bleed(this, owner), 1);

if(UpgradesHelper.hasEndericUpgrade(stack)) {
owner.requestTeleport(getX(), getY(), getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.SmithingRecipe;
import net.minecraft.recipe.SmithingTransformRecipe;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(SmithingRecipe.class)
@Mixin(SmithingTransformRecipe.class)
public interface SmithingRecipeAccessor {

@Accessor("template")
Ingredient testTemplate();

@Accessor("base")
Ingredient getBase();
Ingredient testBase();

@Accessor("addition")
Ingredient getAddition();
Ingredient testAddition();

@Accessor("result")
ItemStack getResult();
ItemStack getOutput();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.cammiescorner.hookshot.core.registry;

import dev.cammiescorner.hookshot.*;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;

public interface ModDamageTypes
{
public static final RegistryKey<DamageType> HOOKBLEEDING = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, new Identifier(Hookshot.MOD_ID, "hookbleeding"));

public static DamageSource of(World world, RegistryKey<DamageType> key) {
return new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import dev.cammiescorner.hookshot.common.item.HookshotItem;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
Expand All @@ -13,6 +13,7 @@
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.recipe.ShapelessRecipe;
import net.minecraft.recipe.book.CraftingRecipeCategory;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
Expand All @@ -23,8 +24,8 @@ public HookshotShapelessRecipe(Identifier id, String group, CraftingRecipeCatego
}

@Override
public ItemStack craft(CraftingInventory inv) {
ItemStack stack = this.getOutput().copy();
public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager dynamicRegistryManager){
ItemStack stack = this.getOutput(dynamicRegistryManager).copy();
NbtCompound tag = null;

for(int i = 0; i < inv.size(); ++i) {
Expand All @@ -35,8 +36,8 @@ public ItemStack craft(CraftingInventory inv) {
}

if(tag != null && stack.hasNbt())
tag.copyFrom(tag);

stack.getOrCreateNbt().copyFrom(tag);
return stack;
}

Expand All @@ -58,7 +59,6 @@ private static DefaultedList<Ingredient> getIngredients(JsonArray json) {
public HookshotShapelessRecipe read(Identifier identifier, JsonObject jsonObject) {
String string = JsonHelper.getString(jsonObject, "group", "");
DefaultedList<Ingredient> defaultedList = getIngredients(JsonHelper.getArray(jsonObject, "ingredients"));

if(defaultedList.isEmpty()) {
throw new JsonParseException("No ingredients for shapeless recipe");
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public void write(PacketByteBuf packetByteBuf, HookshotShapelessRecipe shapeless
for(Ingredient ingredient : shapelessRecipe.getIngredients())
ingredient.write(packetByteBuf);

packetByteBuf.writeItemStack(shapelessRecipe.getOutput());
packetByteBuf.writeItemStack(shapelessRecipe.getOutput(null));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SmithingRecipe;
import net.minecraft.recipe.SmithingTransformRecipe;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;

public class HookshotSmithingRecipe extends SmithingRecipe {
public HookshotSmithingRecipe(Identifier id, Ingredient base, Ingredient addition, ItemStack result) {
super(id, base, addition, result);
public class HookshotSmithingRecipe extends SmithingTransformRecipe {
public HookshotSmithingRecipe(Identifier id,Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
super(id,template, base, addition, result);
}

// I don't know why, I don't want to know why, I shouldn't
// have to wonder why, but for whatever reason this stupid
// NBT data won't add new tags unless we do this terribleness.
@Override
public ItemStack craft(Inventory inv) {
ItemStack stack = ((SmithingRecipeAccessor) this).getResult().copy();
NbtCompound tag = inv.getStack(0).getNbt();
public ItemStack craft(Inventory inv, DynamicRegistryManager registryManager) {
ItemStack stack = ((SmithingRecipeAccessor) this).getOutput().copy();
NbtCompound tag = inv.getStack(1).getNbt();

if(tag != null)
stack.getOrCreateNbt().copyFrom(tag);

{
stack.getOrCreateNbt().copyFrom(tag).copy();
}
return stack;
}

Expand All @@ -57,27 +59,30 @@ public static ItemStack getItemStack(JsonObject json) {
public static class Serializer implements RecipeSerializer<HookshotSmithingRecipe> {
@Override
public HookshotSmithingRecipe read(Identifier identifier, JsonObject jsonObject) {
Ingredient template = Ingredient.fromJson(JsonHelper.getObject(jsonObject, "template"));
Ingredient base = Ingredient.fromJson(JsonHelper.getObject(jsonObject, "base"));
Ingredient addition = Ingredient.fromJson(JsonHelper.getObject(jsonObject, "addition"));
ItemStack result = HookshotSmithingRecipe.getItemStack(JsonHelper.getObject(jsonObject, "result"));

return new HookshotSmithingRecipe(identifier, base, addition, result);
return new HookshotSmithingRecipe(identifier,template, base, addition, result);
}

@Override
public HookshotSmithingRecipe read(Identifier identifier, PacketByteBuf packetByteBuf) {
Ingredient template = Ingredient.fromPacket(packetByteBuf);
Ingredient base = Ingredient.fromPacket(packetByteBuf);
Ingredient addition = Ingredient.fromPacket(packetByteBuf);
ItemStack result = packetByteBuf.readItemStack();

return new HookshotSmithingRecipe(identifier, base, addition, result);
return new HookshotSmithingRecipe(identifier,template, base, addition, result);
}

@Override
public void write(PacketByteBuf packetByteBuf, HookshotSmithingRecipe smithingRecipe) {
((SmithingRecipeAccessor) smithingRecipe).getBase().write(packetByteBuf);
((SmithingRecipeAccessor) smithingRecipe).getAddition().write(packetByteBuf);
packetByteBuf.writeItemStack(((SmithingRecipeAccessor) smithingRecipe).getResult());
((SmithingRecipeAccessor) smithingRecipe).testTemplate().write(packetByteBuf);
((SmithingRecipeAccessor) smithingRecipe).testBase().write(packetByteBuf);
((SmithingRecipeAccessor) smithingRecipe).testAddition().write(packetByteBuf);
packetByteBuf.writeItemStack(((SmithingRecipeAccessor) smithingRecipe).getOutput());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"exhaustion": 0.1,
"message_id": "hookshot",
"scaling": "when_caused_by_living_non_player"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:black_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:blue_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:blue_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:blue_hookshot"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": "hookshot:smithing",
"template":
{
"item": "minecraft:iron_ingot"
},
"base":
{
"item": "hookshot:blue_hookshot"
Expand Down
Loading