Skip to content

Commit

Permalink
Add support for Minecraft 1.20.6
Browse files Browse the repository at this point in the history
Adds armadillos, wolf variants, new attributes, sounds, particles, materials, potion effects, hide flags, etc

API Changes:
* SCUTE item has been renamed to TURTLE_SCUTE
* In potion item meta, the potion array under the "base" key was replaced by a "potiontype" string
* In enchantment item meta, the arrays under the "enchants" key have had the "etype" key removed
  • Loading branch information
PseudoKnight committed May 3, 2024
1 parent dbb0e39 commit 84f1af4
Show file tree
Hide file tree
Showing 75 changed files with 1,540 additions and 614 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@
<!-- GPL -->
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
</dependency>

<!-- Used for storing and retreiving Constructs in a storage transparent medium: JSONs -->
Expand Down Expand Up @@ -513,7 +513,6 @@
<arg>-XDignore.symbol.file</arg>
<arg>-parameters</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>

Expand All @@ -533,6 +532,7 @@
<!--<mainClass>com.laytonsmith.core.MainSandbox</mainClass>-->
</manifest>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
<Class-Path>../bukkit.jar CommandHelper/bukkit.jar</Class-Path>
</manifestEntries>
</archive>
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/com/laytonsmith/abstraction/Convertor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.laytonsmith.abstraction.enums.MCAttribute;
import com.laytonsmith.abstraction.enums.MCDyeColor;
import com.laytonsmith.abstraction.enums.MCEquipmentSlot;
import com.laytonsmith.abstraction.enums.MCEquipmentSlotGroup;
import com.laytonsmith.abstraction.enums.MCPatternShape;
import com.laytonsmith.abstraction.enums.MCPotionType;
import com.laytonsmith.abstraction.enums.MCRecipeType;
Expand All @@ -32,17 +33,6 @@ public interface Convertor {

Class GetServerEventMixin();

MCEnchantment[] GetEnchantmentValues();

/**
* Returns the enchantment, given an enchantment name (or a string'd number). Returns null if no such enchantment
* exists.
*
* @param name
* @return
*/
MCEnchantment GetEnchantmentByName(String name);

MCServer GetServer();

MCItemStack GetItemStack(MCMaterial type, int qty);
Expand All @@ -53,6 +43,8 @@ public interface Convertor {

MCAttributeModifier GetAttributeModifier(MCAttribute attr, UUID id, String name, double amt, MCAttributeModifier.Operation op, MCEquipmentSlot slot);

MCAttributeModifier GetAttributeModifier(MCAttribute attr, UUID id, String name, double amt, MCAttributeModifier.Operation op, MCEquipmentSlotGroup slot);

void Startup(CommandHelperPlugin chp);

MCMaterial[] GetMaterialValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.laytonsmith.abstraction.enums.MCAttribute;
import com.laytonsmith.abstraction.enums.MCEquipmentSlot;
import com.laytonsmith.abstraction.enums.MCEquipmentSlotGroup;
import com.laytonsmith.annotations.MEnum;

import java.util.UUID;
Expand All @@ -10,6 +11,7 @@ public interface MCAttributeModifier extends AbstractionObject {
String getAttributeName();
MCAttribute getAttribute();
MCEquipmentSlot getEquipmentSlot();
MCEquipmentSlotGroup getEquipmentSlotGroup();
Operation getOperation();
double getAmount();
UUID getUniqueId();
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/laytonsmith/abstraction/MCEnchantment.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.laytonsmith.abstraction;

import com.laytonsmith.abstraction.enums.MCEnchantment;

public interface MCEnchantmentOffer {
MCEnchantment getEnchantment();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.laytonsmith.abstraction;

import com.laytonsmith.abstraction.enums.MCEnchantment;

import java.util.Map;

public interface MCEnchantmentStorageMeta extends MCItemMeta {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/laytonsmith/abstraction/MCEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public interface MCEntity extends MCMetadatable {

void setFireTicks(int ticks);

void setLastDamageCause(MCEntityDamageEvent event);

boolean setPassenger(MCEntity passenger);

void setTicksLived(int value);
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCItemMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.laytonsmith.abstraction.blocks.MCBlockData;
import com.laytonsmith.abstraction.blocks.MCMaterial;
import com.laytonsmith.abstraction.enums.MCEnchantment;
import com.laytonsmith.abstraction.enums.MCItemFlag;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -113,6 +114,12 @@ public interface MCItemMeta extends AbstractionObject {

void setDamage(int damage);

boolean hasMaxDamage();

int getMaxDamage();

void setMaxDamage(int damage);

MCBlockData getBlockData(MCMaterial material);

boolean hasBlockData();
Expand All @@ -132,4 +139,30 @@ public interface MCItemMeta extends AbstractionObject {
boolean hasCustomTags();

MCTagContainer getCustomTags();

boolean hasItemName();

String getItemName();

void setItemName(String name);

boolean isHideTooltip();

void setHideTooltip(boolean hide);

boolean hasEnchantmentGlintOverride();

boolean getEnchantmentGlintOverride();

void setEnchantmentGlintOverride(boolean glint);

boolean isFireResistant();

void setFireResistant(boolean fireResistant);

boolean hasMaxStackSize();

int getMaxStackSize();

void setMaxStackSize(int size);
}
2 changes: 2 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCItemStack.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.laytonsmith.abstraction;

import com.laytonsmith.abstraction.blocks.MCMaterial;
import com.laytonsmith.abstraction.enums.MCEnchantment;

import java.util.Map;

public interface MCItemStack extends AbstractionObject {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCPotionMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.laytonsmith.abstraction.MCLivingEntity.MCEffect;
import com.laytonsmith.abstraction.enums.MCPotionEffectType;
import com.laytonsmith.abstraction.enums.MCPotionType;
import com.laytonsmith.core.constructs.Target;
import java.util.List;

Expand All @@ -11,6 +12,10 @@ public interface MCPotionMeta extends MCItemMeta {

void setBasePotionData(MCPotionData pd);

MCPotionType getBasePotionType();

void setBasePotionType(MCPotionType pt);

boolean addCustomEffect(MCPotionEffectType type, int strength, int ticks, boolean ambient, boolean particles, boolean icon, boolean force, Target t);

boolean clearCustomEffects();
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/laytonsmith/abstraction/StaticLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public static MCServer GetServer() {
return convertor.GetServer();
}

public static MCEnchantment GetEnchantmentByName(String name) {
return convertor.GetEnchantmentByName(name);
}

public static MCMaterial[] GetMaterialValues() {
return convertor.GetMaterialValues();
}
Expand All @@ -103,10 +99,6 @@ public static MCMaterial GetMaterial(String name) {
return convertor.GetMaterial(name);
}

public static MCEnchantment[] GetEnchantmentValues() {
return convertor.GetEnchantmentValues();
}

public static void Startup(CommandHelperPlugin chp) {
convertor.Startup(chp);
}
Expand Down
27 changes: 25 additions & 2 deletions src/main/java/com/laytonsmith/abstraction/blocks/MCMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ public enum MCVanillaMaterial {
STRUCTURE_BLOCK,
JIGSAW,
TURTLE_HELMET,
SCUTE,
SCUTE(MCVersion.MC1_13, MCVersion.MC1_20_4),
TURTLE_SCUTE(MCVersion.MC1_20_6), // changed from SCUTE
FLINT_AND_STEEL,
APPLE,
BOW,
Expand Down Expand Up @@ -1640,7 +1641,29 @@ public enum MCVanillaMaterial {
CHISELED_TUFF_BRICKS(MCVersion.MC1_20_4),
POLISHED_TUFF_SLAB(MCVersion.MC1_20_4),
POLISHED_TUFF_STAIRS(MCVersion.MC1_20_4),
POLISHED_TUFF_WALL(MCVersion.MC1_20_4);
POLISHED_TUFF_WALL(MCVersion.MC1_20_4),

// 1.20.5 additions
ARMADILLO_SCUTE(MCVersion.MC1_20_6),
ARMADILLO_SPAWN_EGG(MCVersion.MC1_20_6),
WOLF_ARMOR(MCVersion.MC1_20_6),

// 1.20.5 experimental additions for 1.21
BREEZE_ROD(MCVersion.MC1_20_6),
BOGGED_SPAWN_EGG(MCVersion.MC1_20_6),
HEAVY_CORE(MCVersion.MC1_20_6),
MACE(MCVersion.MC1_20_6),
OMINOUS_BOTTLE(MCVersion.MC1_20_6),
OMINOUS_TRIAL_KEY(MCVersion.MC1_20_6),
FLOW_BANNER_PATTERN(MCVersion.MC1_20_6),
GUSTER_BANNER_PATTERN(MCVersion.MC1_20_6),
FLOW_ARMOR_TRIM_SMITHING_TEMPLATE(MCVersion.MC1_20_6),
BOLT_ARMOR_TRIM_SMITHING_TEMPLATE(MCVersion.MC1_20_6),
FLOW_POTTERY_SHERD(MCVersion.MC1_20_6),
GUSTER_POTTERY_SHERD(MCVersion.MC1_20_6),
SCRAPE_POTTERY_SHERD(MCVersion.MC1_20_6),
VAULT(MCVersion.MC1_20_6),
WIND_CHARGE(MCVersion.MC1_20_6);

private final MCVersion since;
private final MCVersion until;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.laytonsmith.abstraction.MCColor;
import com.laytonsmith.abstraction.MCCommand;
import com.laytonsmith.abstraction.MCCommandSender;
import com.laytonsmith.abstraction.MCEnchantment;
import com.laytonsmith.abstraction.MCEntity;
import com.laytonsmith.abstraction.MCFireworkBuilder;
import com.laytonsmith.abstraction.MCInventory;
Expand Down Expand Up @@ -79,6 +78,7 @@
import com.laytonsmith.abstraction.enums.MCAttribute;
import com.laytonsmith.abstraction.enums.MCDyeColor;
import com.laytonsmith.abstraction.enums.MCEquipmentSlot;
import com.laytonsmith.abstraction.enums.MCEquipmentSlotGroup;
import com.laytonsmith.abstraction.enums.MCPatternShape;
import com.laytonsmith.abstraction.enums.MCPotionType;
import com.laytonsmith.abstraction.enums.MCRecipeType;
Expand All @@ -90,7 +90,6 @@
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCEquipmentSlot;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCLegacyMaterial;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCPatternShape;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCPotionType;
import com.laytonsmith.annotations.convert;
import com.laytonsmith.commandhelper.CommandHelperPlugin;
import com.laytonsmith.core.LogLevel;
Expand Down Expand Up @@ -129,7 +128,6 @@
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Breedable;
Expand All @@ -151,6 +149,7 @@
import org.bukkit.inventory.BlastingRecipe;
import org.bukkit.inventory.CampfireRecipe;
import org.bukkit.inventory.ComplexRecipe;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -183,7 +182,7 @@
import org.bukkit.inventory.meta.SuspiciousStewMeta;
import org.bukkit.inventory.meta.TropicalFishBucketMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import org.yaml.snakeyaml.Yaml;

import java.util.ArrayList;
Expand Down Expand Up @@ -220,29 +219,6 @@ public Class GetServerEventMixin() {
return BukkitAbstractEventMixin.class;
}

@Override
public MCEnchantment[] GetEnchantmentValues() {
MCEnchantment[] ea = new MCEnchantment[Enchantment.values().length];
Enchantment[] oea = Enchantment.values();
for(int i = 0; i < ea.length; i++) {
ea[i] = new BukkitMCEnchantment(oea[i]);
}
return ea;

}

@Override
public MCEnchantment GetEnchantmentByName(String name) {
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
if(enchant == null) {
enchant = Enchantment.getByName(name.toUpperCase());
if(enchant == null) {
return null;
}
}
return new BukkitMCEnchantment(enchant);
}

@Override
public MCServer GetServer() {
return BukkitMCServer.Get();
Expand Down Expand Up @@ -311,15 +287,20 @@ public MCItemStack GetItemStack(String type, int qty) {

@Override
public MCPotionData GetPotionData(MCPotionType type, boolean extended, boolean upgraded) {
return new BukkitMCPotionData(new PotionData(
BukkitMCPotionType.getConvertor().getConcreteEnum(type), extended, upgraded));
try {
Class clz = Class.forName("org.bukkit.potion.PotionData");
return new BukkitMCPotionData(ReflectionUtils.newInstance(clz,
new Class[]{PotionType.class, boolean.class, boolean.class},
new Object[]{type.getConcrete(), extended, upgraded}));
} catch (ClassNotFoundException ex) {
// probably before 1.20.5
// use PotionType instead
return null;
}
}

@Override
public MCAttributeModifier GetAttributeModifier(MCAttribute attr, UUID id, String name, double amt, MCAttributeModifier.Operation op, MCEquipmentSlot slot) {
if(name == null) {
name = " "; // Spigot does not allow an empty name even though Minecraft and Paper allow it
}
if(id == null) {
id = UUID.randomUUID();
}
Expand All @@ -329,6 +310,17 @@ public MCAttributeModifier GetAttributeModifier(MCAttribute attr, UUID id, Strin
return new BukkitMCAttributeModifier(BukkitMCAttribute.getConvertor().getConcreteEnum(attr), mod);
}

@Override
public MCAttributeModifier GetAttributeModifier(MCAttribute attr, UUID id, String name, double amt, MCAttributeModifier.Operation op, MCEquipmentSlotGroup slot) {
if(id == null) {
id = UUID.randomUUID();
}
AttributeModifier mod = new AttributeModifier(id, name, amt,
BukkitMCAttributeModifier.Operation.getConvertor().getConcreteEnum(op),
EquipmentSlotGroup.getByName(slot.name()));
return new BukkitMCAttributeModifier(BukkitMCAttribute.getConvertor().getConcreteEnum(attr), mod);
}

@Override
public MCMetadataValue GetMetadataValue(Object value, MCPlugin plugin) {
return new BukkitMCMetadataValue(new FixedMetadataValue(((BukkitMCPlugin) plugin).getHandle(), value));
Expand Down
Loading

0 comments on commit 84f1af4

Please sign in to comment.