Skip to content

Commit

Permalink
Updated for minecraft 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zabi94 committed Nov 19, 2024
1 parent 1c37935 commit ce129f7
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 64 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ archivesBaseName = project.archives_base_name+"-"+project.minecraft_version
version = project.mod_version
group = project.maven_group

loom {
accessWidenerPath = file("src/main/resources/extraalchemy.accesswidener")
}

repositories {
mavenLocal()
maven {
Expand Down
22 changes: 11 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
loader_version=0.16.2
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.9

fabric_version=0.100.8+1.20.6
fabric_version=0.102.0+1.21

#fabric_kotlin_version=1.10.8+kotlin.1.9.0

modmenu_version=10.0.0
clothconfig_version=14.0.129
rei_version=15.0.753
pehkui_version=3.8.2
trinkets_version=3.9.0
patchouli_version=1.20.6-87-FABRIC-SNAPSHOT
modmenu_version=11.0.2
clothconfig_version=15.0.140
rei_version=16.0.788
pehkui_version=3.8.3
trinkets_version=3.10.0
#patchouli_version=1.20.6-87-FABRIC-SNAPSHOT
#inventorio_version=5134138
cardinal_components_version=6.0.0
cardinal_components_version=6.1.1
#nbttt_version=3595757
#flk_version=3364215

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zabi.minecraft.extraalchemy.client.tooltip;

import net.minecraft.client.item.TooltipData;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipData;

public class PotionTooltipData implements TooltipData {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class PehkuiPotions {

public static int registerEffects() {
Log.i("Registering pehkui effects");
Identifier id_grow = new Identifier(LibMod.MOD_ID, "growing");
Identifier id_grow = LibMod.id("growing");
Registry.register(Registries.STATUS_EFFECT, id_grow, growing.onRegister());
Identifier id_shrink = new Identifier(LibMod.MOD_ID, "shrinking");
Identifier id_shrink = LibMod.id("shrinking");
Registry.register(Registries.STATUS_EFFECT, id_shrink, shrinking.onRegister());
return 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand All @@ -19,6 +18,7 @@
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.recipe.book.CraftingRecipeCategory;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -66,16 +66,18 @@ public PotionRingRecipe(Optional<Integer> level, int cost, int length, int renew
}

@Override
public boolean matches(RecipeInputInventory inv, World world) {
public boolean matches(CraftingRecipeInput input, World world) {
if (!ModConfig.INSTANCE.enableRings) { //Globally disabled and specifically disabled
return false;
}

boolean foundEffect = false;
boolean foundRing = false;

List<ItemStack> inv = input.getStacks();

for (int i = 0; i < inv.size(); i++) {
ItemStack is = inv.getStack(i);
ItemStack is = input.getStackInSlot(i);
Item s = is.getItem();
if (s.equals(Items.POTION)) {
if (foundEffect || !doesPotionMatch(PotionUtilities.getEffects(is))) {
Expand All @@ -97,8 +99,8 @@ public boolean matches(RecipeInputInventory inv, World world) {
}

@Override
public ItemStack craft(RecipeInputInventory inv, WrapperLookup wl) {
return getResult(wl);
public ItemStack craft(CraftingRecipeInput input, WrapperLookup lookup) {
return getResult(lookup);
}

@Override
Expand Down Expand Up @@ -157,7 +159,7 @@ public PotionRingRecipe decode(RegistryByteBuf buf) {
int renew = buf.readInt();
int level = buf.readInt();
String potion_name = buf.readString();
StatusEffect effect = Registries.STATUS_EFFECT.get(new Identifier(potion_name));
StatusEffect effect = Registries.STATUS_EFFECT.get(Identifier.of(potion_name));
return new PotionRingRecipe(Optional.of(level), cost, length, renew, Optional.of(effect), Optional.empty());
}

Expand All @@ -179,4 +181,5 @@ public MapCodec<PotionRingRecipe> codec() {
}

}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package zabi.minecraft.extraalchemy.crafting;

import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.SpecialCraftingRecipe;
import net.minecraft.recipe.book.CraftingRecipeCategory;
import net.minecraft.recipe.input.CraftingRecipeInput;
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
import net.minecraft.world.World;
import zabi.minecraft.extraalchemy.config.ModConfig;
Expand All @@ -20,16 +20,26 @@ public PotionVialRecipe(CraftingRecipeCategory category) {
}

@Override
public boolean matches(RecipeInputInventory inv, World world) {
public boolean fits(int width, int height) {
return width > 1 || height > 1;
}

@Override
public RecipeSerializer<?> getSerializer() {
return CraftingRecipes.FILL_VIAL_SERIALIZER;
}

@Override
public boolean matches(CraftingRecipeInput input, World world) {
if (!ModConfig.INSTANCE.enableVials) {
return false;
}

boolean splash = false;
boolean vial = false;

for (int i = 0; i < inv.size(); i++) {
Item s = inv.getStack(i).getItem();
for (int i = 0; i < input.getSize(); i++) {
Item s = input.getStackInSlot(i).getItem();
if (s.equals(Items.SPLASH_POTION)) {
if (splash) {
return false;
Expand All @@ -50,19 +60,9 @@ public boolean matches(RecipeInputInventory inv, World world) {
}

@Override
public boolean fits(int width, int height) {
return width > 1 || height > 1;
}

@Override
public RecipeSerializer<?> getSerializer() {
return CraftingRecipes.FILL_VIAL_SERIALIZER;
}

@Override
public ItemStack craft(RecipeInputInventory inv, WrapperLookup wl) {
for (int i = 0; i < inv.size(); i++) {
ItemStack is = inv.getStack(i);
public ItemStack craft(CraftingRecipeInput input, WrapperLookup lookup) {
for (int i = 0; i < input.getSize(); i++) {
ItemStack is = input.getStackInSlot(i);
if (is.getItem().equals(Items.SPLASH_POTION)) {
ItemStack result = new ItemStack(ModItems.POTION_VIAL);
PotionUtilities.cloneEffectsToStack(is, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.item.TooltipType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import zabi.minecraft.extraalchemy.config.ModConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.serialization.codecs.PrimitiveCodec;

import net.minecraft.component.DataComponentType;
import net.minecraft.component.ComponentType;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
Expand All @@ -11,17 +11,17 @@

public class ModComponents {

public static final DataComponentType<Boolean> DISABLED = DataComponentType.<Boolean>builder()
public static final ComponentType<Boolean> DISABLED = ComponentType.<Boolean>builder()
.codec(PrimitiveCodec.BOOL)
.packetCodec(PacketCodecs.BOOL)
.build();

public static final DataComponentType<PotionRingItem.PotionRingData> POTION_RING_DATA = DataComponentType.<PotionRingItem.PotionRingData>builder()
public static final ComponentType<PotionRingItem.PotionRingData> POTION_RING_DATA = ComponentType.<PotionRingItem.PotionRingData>builder()
.codec(PotionRingData.CODEC)
// .packetCodec(PacketCodecs.BOOL)
.build();

public static final DataComponentType<PotionBagItem.SelectionMode> SELECTION_MODE = DataComponentType.<PotionBagItem.SelectionMode>builder()
public static final ComponentType<PotionBagItem.SelectionMode> SELECTION_MODE = ComponentType.<PotionBagItem.SelectionMode>builder()
.codec(PotionBagItem.SelectionMode.CODEC)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.mojang.serialization.Codec;

import net.minecraft.client.item.TooltipType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.ContainerComponent;
import net.minecraft.component.type.DyedColorComponent;
Expand All @@ -16,6 +15,7 @@
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.potion.Potion;
import net.minecraft.registry.Registries;
import net.minecraft.registry.tag.TagKey;
Expand Down Expand Up @@ -170,10 +170,10 @@ public UseAction getUseAction(ItemStack stack) {
}

@Override
public int getMaxUseTime(ItemStack stack) {
public int getMaxUseTime(ItemStack stack, LivingEntity user) {
return 20;
}

@Override
public boolean hasGlint(ItemStack stack) {
return getSelectedPotion(stack).isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.client.item.TooltipData;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipData;
import zabi.minecraft.extraalchemy.client.tooltip.PotionTooltipData;
import zabi.minecraft.extraalchemy.client.tooltip.StatusEffectContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void registerAll() {
int registered = 0;
for (Field field:ModPotionRegistry.class.getDeclaredFields()) {
if (ModPotion.class.isAssignableFrom(field.getType())) {
Identifier id = new Identifier(LibMod.MOD_ID, field.getName());
Identifier id = LibMod.id(field.getName());
Log.d("Registering potion "+id);
registered += ((ModPotion) field.get(null)).registerTree(LibMod.MOD_ID, field.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void registerAll() {
int registered = 0;
for (Field field:ModEffectRegistry.class.getDeclaredFields()) {
if (ModStatusEffect.class.isAssignableFrom(field.getType())) {
Identifier id = new Identifier(LibMod.MOD_ID, field.getName());
Identifier id = LibMod.id(field.getName());
Registry.register(Registries.STATUS_EFFECT, id, ((ModStatusEffect) field.get(null)).onRegister());
Log.d("Registered potion "+id);
registered++;
Expand All @@ -75,7 +75,7 @@ public static class Utils {
public static StatusEffect magnetism_disabled = null;

public static void register() {
magnetism_disabled = Registry.register(Registries.STATUS_EFFECT, new Identifier(LibMod.MOD_ID, "magnetism_disabled"), new ModStatusEffect(StatusEffectCategory.BENEFICIAL, MAGNETISM_COLOR, magnetism.isInstant()).onRegister());
magnetism_disabled = Registry.register(Registries.STATUS_EFFECT, LibMod.id("magnetism_disabled"), new ModStatusEffect(StatusEffectCategory.BENEFICIAL, MAGNETISM_COLOR, magnetism.isInstant()).onRegister());
Log.i("Registered dummy effects");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zabi.minecraft.extraalchemy.statuseffect.effects;

import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -39,15 +38,16 @@ public boolean applyUpdateEffect(LivingEntity entity, int i) {
if (!pos.getWorldId().equals(entity.getEntityWorld().getRegistryKey().getValue())) {
if (i > 0) {
ServerWorld destinationWorld = (ServerWorld) pos.getWorld(entity.getServer());
ent = FabricDimensions.teleport(entity, destinationWorld, new TeleportTarget(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), Vec3d.ZERO, ent.getYaw(), ent.getPitch()));
TeleportTarget destination = new TeleportTarget(destinationWorld, new Vec3d(pos.getX(), pos.getY(), pos.getZ()), Vec3d.ZERO, ent.getYaw(), ent.getPitch(), TeleportTarget.NO_OP);
ent = (LivingEntity) entity.teleportTo(destination);
} else {
ent.damage(entity.getEntityWorld().getDamageSources().magic(), 1f);
if (ent instanceof PlayerEntity player) {
player.sendMessage(Text.translatable("message.extraalchemy.recall_damage"), true);
}
}
} else {
ent.teleport(pos.getX(), pos.getY(), pos.getZ());
ent.teleport(pos.getX(), pos.getY(), pos.getZ(), true);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package zabi.minecraft.extraalchemy.statuseffect.effects;

import java.util.Optional;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import zabi.minecraft.extraalchemy.config.ModConfig;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.TeleportTarget;
import zabi.minecraft.extraalchemy.statuseffect.ModStatusEffect;

public class ReturnStatusEffect extends ModStatusEffect {
Expand All @@ -18,13 +19,13 @@ public ReturnStatusEffect(StatusEffectCategory type, int color, boolean isInstan

@Override
public void applyInstantEffect(Entity source, Entity attacker, LivingEntity target, int amplifier, double d) {
if (target instanceof ServerPlayerEntity) {
ServerPlayerEntity player = (ServerPlayerEntity) target;
if (target instanceof ServerPlayerEntity player) {
BlockPos respawnPos = player.getSpawnPointPosition();
if (respawnPos != null) {
PlayerEntity.findRespawnPosition((ServerWorld) target.getEntityWorld(), respawnPos, player.getYaw(), player.isSpawnForced(), !ModConfig.INSTANCE.useAnchorChargesWithReturnPotion).ifPresent(v3d -> {
player.requestTeleport(v3d.x, v3d.y, v3d.z);
});
Optional<ServerPlayerEntity.RespawnPos> pos = ServerPlayerEntity.findRespawnPosition(player.getServerWorld(), respawnPos, 0, false, true);
if (pos.isPresent()) {
target.getWorldSpawnPos(player.getServerWorld(), respawnPos);
TeleportTarget teleportTarget = new TeleportTarget(player.getServerWorld(), Vec3d.of(respawnPos), Vec3d.ZERO, player.getYaw(), player.getPitch(), TeleportTarget.NO_OP);
player.teleportTo(teleportTarget);
}
}
}
Expand Down
Loading

0 comments on commit ce129f7

Please sign in to comment.