Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 4deda9501f
commit 65bc2541a3
524 changed files with 7788 additions and 6181 deletions

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.attribute;
import com.google.common.base.Preconditions;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.ai.attributes.AttributeBase;
@@ -23,6 +24,10 @@ public class CraftAttribute {
return bukkit;
}
public static Attribute minecraftHolderToBukkit(Holder<AttributeBase> minecraft) {
return minecraftToBukkit(minecraft.value());
}
public static Attribute stringToBukkit(String bukkit) {
Preconditions.checkArgument(bukkit != null);
@@ -35,4 +40,17 @@ public class CraftAttribute {
return CraftRegistry.getMinecraftRegistry(Registries.ATTRIBUTE)
.getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow();
}
public static Holder<AttributeBase> bukkitToMinecraftHolder(Attribute bukkit) {
Preconditions.checkArgument(bukkit != null);
IRegistry<AttributeBase> registry = CraftRegistry.getMinecraftRegistry(Registries.ATTRIBUTE);
if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c<AttributeBase> holder) {
return holder;
}
throw new IllegalArgumentException("No Reference holder found for " + bukkit
+ ", this can happen if a plugin creates its own sound effect with out properly registering it.");
}
}

View File

@@ -63,7 +63,7 @@ public class CraftAttributeInstance implements AttributeInstance {
@Override
public double getDefaultValue() {
return handle.getAttribute().getDefaultValue();
return handle.getAttribute().value().getDefaultValue();
}
public static net.minecraft.world.entity.ai.attributes.AttributeModifier convert(AttributeModifier bukkit) {
@@ -71,10 +71,10 @@ public class CraftAttributeInstance implements AttributeInstance {
}
public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms) {
return new AttributeModifier(nms.getId(), nms.name, nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]);
return new AttributeModifier(nms.id(), nms.name, nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()]);
}
public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms, EquipmentSlot slot) {
return new AttributeModifier(nms.getId(), nms.name, nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()], slot);
return new AttributeModifier(nms.id(), nms.name, nms.amount(), AttributeModifier.Operation.values()[nms.operation().ordinal()], slot);
}
}

View File

@@ -17,7 +17,7 @@ public class CraftAttributeMap implements Attributable {
@Override
public AttributeInstance getAttribute(Attribute attribute) {
Preconditions.checkArgument(attribute != null, "attribute");
net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.getInstance(CraftAttribute.bukkitToMinecraft(attribute));
net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.getInstance(CraftAttribute.bukkitToMinecraftHolder(attribute));
return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
}