Skip to content
Permalink
Browse files
Add support for Minecraft 1.16
  • Loading branch information
PseudoKnight committed Jun 25, 2020
1 parent bc3f00a commit 0fe660dbf2f72dfcdfaab1938ff697939bdaa009
Show file tree
Hide file tree
Showing 32 changed files with 480 additions and 105 deletions.
@@ -172,7 +172,7 @@
<!-- GPL -->
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
</dependency>

<!-- Used for storing and retreiving Constructs in a storage transparent medium: JSONs -->
@@ -0,0 +1,8 @@
package com.laytonsmith.abstraction;

import com.laytonsmith.abstraction.blocks.MCMaterial;

public interface MCSmithingRecipe extends MCRecipe {
MCMaterial[] getBase();
MCMaterial[] getAddition();
}
@@ -137,6 +137,7 @@
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.SmithingRecipe;
import org.bukkit.inventory.SmokingRecipe;
import org.bukkit.inventory.StonecuttingRecipe;
import org.bukkit.inventory.meta.BannerMeta;
@@ -694,6 +695,7 @@ public MCRecipe GetNewRecipe(String key, MCRecipeType type, MCItemStack result)
return new BukkitMCCookingRecipe(new SmokingRecipe(nskey, is, Material.AIR, 0.0F, 200), type);
case STONECUTTING:
return new BukkitMCStonecuttingRecipe(new StonecuttingRecipe(nskey, is, Material.AIR));
case SMITHING:
case COMPLEX:
throw new IllegalArgumentException("Unable to generate recipe type: " + type.name());
}
@@ -711,7 +713,8 @@ public MCRecipe GetRecipe(MCRecipe unspecific) {
}

public static MCRecipe BukkitGetRecipe(Recipe r) {
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_14)) {
MCVersion version = Static.getServer().getMinecraftVersion();
if(version.gte(MCVersion.MC1_14)) {
if(r instanceof BlastingRecipe) {
return new BukkitMCCookingRecipe(r, MCRecipeType.BLASTING);
} else if(r instanceof CampfireRecipe) {
@@ -720,8 +723,12 @@ public static MCRecipe BukkitGetRecipe(Recipe r) {
return new BukkitMCCookingRecipe(r, MCRecipeType.SMOKING);
} else if(r instanceof StonecuttingRecipe) {
return new BukkitMCStonecuttingRecipe((StonecuttingRecipe) r);
} else if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_15) && r instanceof ComplexRecipe) {
return new BukkitMCComplexRecipe(r);
} else if(version.gte(MCVersion.MC1_15)) {
if(r instanceof ComplexRecipe) {
return new BukkitMCComplexRecipe(r);
} else if(version.gte(MCVersion.MC1_16) && r instanceof SmithingRecipe) {
return new BukkitMCSmithingRecipe((SmithingRecipe) r);
}
}
}
if(r instanceof ShapelessRecipe) {
@@ -0,0 +1,70 @@
package com.laytonsmith.abstraction.bukkit;

import com.laytonsmith.abstraction.MCItemStack;
import com.laytonsmith.abstraction.MCSmithingRecipe;
import com.laytonsmith.abstraction.blocks.MCMaterial;
import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCMaterial;
import com.laytonsmith.abstraction.enums.MCRecipeType;
import org.bukkit.Material;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.SmithingRecipe;

import java.util.List;

public class BukkitMCSmithingRecipe extends BukkitMCRecipe implements MCSmithingRecipe {

private final SmithingRecipe recipe;

public BukkitMCSmithingRecipe(SmithingRecipe recipe) {
super(recipe);
this.recipe = recipe;
}

@Override
public String getKey() {
return recipe.getKey().getKey();
}

@Override
public MCRecipeType getRecipeType() {
return MCRecipeType.SMITHING;
}

@Override
public String getGroup() {
return "";
}

@Override
public void setGroup(String group) {}

@Override
public MCItemStack getResult() {
return new BukkitMCItemStack(recipe.getResult());
}

@Override
public Object getHandle() {
return recipe;
}

@Override
public MCMaterial[] getBase() {
List<Material> choices = ((RecipeChoice.MaterialChoice) recipe.getBase()).getChoices();
MCMaterial[] ret = new MCMaterial[choices.size()];
for(int i = 0; i < choices.size(); i++) {
ret[i] = new BukkitMCMaterial(choices.get(i));
}
return ret;
}

@Override
public MCMaterial[] getAddition() {
List<Material> choices = ((RecipeChoice.MaterialChoice) recipe.getAddition()).getChoices();
MCMaterial[] ret = new MCMaterial[choices.size()];
for(int i = 0; i < choices.size(); i++) {
ret[i] = new BukkitMCMaterial(choices.get(i));
}
return ret;
}
}
@@ -11,7 +11,6 @@
import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.Team.OptionStatus;

import java.util.HashSet;
import java.util.Set;

public class BukkitMCTeam implements MCTeam {
@@ -55,9 +54,7 @@ public MCOptionStatus getOption(MCOption option) {

@Override
public Set<String> getEntries() {
Set<String> ret = new HashSet<>();
ret.addAll(t.getEntries());
return ret;
return t.getEntries();
}

@Override
@@ -0,0 +1,15 @@
package com.laytonsmith.abstraction.bukkit.entities;

import com.laytonsmith.abstraction.entities.MCStrider;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Strider;

public class BukkitMCStrider extends BukkitMCAgeable implements MCStrider {

Strider s;

public BukkitMCStrider(Entity be) {
super(be);
s = (Strider) be;
}
}
@@ -175,10 +175,7 @@ public Object _GetObject() {

@Override
public MCEntity getEntity() {
if(e.getEntity() != null) {
return BukkitConvertor.BukkitGetCorrectEntity(e.getEntity());
}
return null;
return BukkitConvertor.BukkitGetCorrectEntity(e.getEntity());
}

@Override
@@ -59,7 +59,6 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -277,20 +276,12 @@ public Map<Integer, MCItemStack> getNewItems() {

@Override
public Set<Integer> getRawSlots() {
Set<Integer> ret = new HashSet<>();
for(Integer rs : id.getRawSlots()) {
ret.add(rs);
}
return ret;
return id.getRawSlots();
}

@Override
public Set<Integer> getInventorySlots() {
Set<Integer> ret = new HashSet<>();
for(Integer is : id.getInventorySlots()) {
ret.add(is);
}
return ret;
return id.getInventorySlots();
}

@Override
@@ -39,9 +39,6 @@ public BukkitMCVehicleEntityCollideEvent(VehicleCollisionEvent event) {

@Override
public MCEntity getEntity() {
if(vec.getEntity() == null) {
return null;
}
return BukkitConvertor.BukkitGetCorrectEntity(vec.getEntity());
}

@@ -105,9 +102,6 @@ public BukkitMCVehicleEnterEvent(VehicleEnterEvent event) {

@Override
public MCEntity getEntity() {
if(vee.getEntered() == null) {
return null;
}
return BukkitConvertor.BukkitGetCorrectEntity(vee.getEntered());
}
}
@@ -124,9 +118,6 @@ public BukkitMCVehicleExitEvent(VehicleExitEvent event) {

@Override
public MCEntity getEntity() {
if(vee.getExited() == null) {
return null;
}
return BukkitConvertor.BukkitGetCorrectEntity(vee.getExited());
}
}
@@ -202,10 +193,7 @@ public BukkitMCVehicleEvent(VehicleEvent event) {

@Override
public MCEntity getVehicle() {
if(ve.getVehicle() instanceof org.bukkit.entity.Vehicle) {
return BukkitConvertor.BukkitGetCorrectEntity(ve.getVehicle());
}
return null;
return BukkitConvertor.BukkitGetCorrectEntity(ve.getVehicle());
}

@Override
@@ -0,0 +1,5 @@
package com.laytonsmith.abstraction.entities;

public interface MCStrider extends MCAgeable, MCVehicle {

}
@@ -7,6 +7,7 @@ public enum MCAttribute {
GENERIC_ARMOR,
GENERIC_ARMOR_TOUGHNESS,
GENERIC_ATTACK_DAMAGE,
GENERIC_ATTACK_KNOCKBACK,
GENERIC_ATTACK_SPEED,
GENERIC_FLYING_SPEED,
GENERIC_FOLLOW_RANGE,
@@ -2,7 +2,8 @@

import com.laytonsmith.PureUtilities.ClassLoading.DynamicEnum;
import com.laytonsmith.annotations.MDynamicEnum;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.MSLog;
import com.laytonsmith.core.constructs.Target;

import java.util.ArrayList;
import java.util.HashMap;
@@ -26,6 +27,12 @@ public MCBiomeType(MCVanillaBiomeType mcVanillaBiomeType, Concrete concrete) {
public static MCBiomeType valueOf(String test) throws IllegalArgumentException {
MCBiomeType ret = MAP.get(test);
if(ret == null) {
switch(test) {
case "NETHER":
MSLog.GetLogger().e(MSLog.Tags.GENERAL,
"NETHER biome type was renamed in 1.16. Converted to NETHER_WASTES.", Target.UNKNOWN);
return MAP.get("NETHER_WASTES");
}
throw new IllegalArgumentException("Unknown biome type: " + test);
}
return ret;
@@ -38,7 +45,9 @@ public static Set<String> types() {
if(NULL == null) { // docs mode
Set<String> dummy = new HashSet<>();
for(final MCVanillaBiomeType t : MCVanillaBiomeType.values()) {
dummy.add(t.name());
if(t.existsIn(MCVersion.CURRENT)) {
dummy.add(t.name());
}
}
return dummy;
}
@@ -52,6 +61,9 @@ public static List<MCBiomeType> values() {
if(NULL == null) { // docs mode
ArrayList<MCBiomeType> dummy = new ArrayList<>();
for(final MCVanillaBiomeType t : MCVanillaBiomeType.values()) {
if(!t.existsIn(MCVersion.CURRENT)) {
continue;
}
dummy.add(new MCBiomeType<Object>(t, null) {
@Override
public String name() {
@@ -78,7 +90,7 @@ public enum MCVanillaBiomeType {
TAIGA,
SWAMP,
RIVER,
NETHER,
NETHER(MCVersion.MC1_0, MCVersion.MC1_15_X), // renamed to NETHER_WASTES
THE_END,
FROZEN_OCEAN,
FROZEN_RIVER,
@@ -145,20 +157,31 @@ public enum MCVanillaBiomeType {
DEEP_FROZEN_OCEAN,
BAMBOO_JUNGLE(MCVersion.MC1_14),
BAMBOO_JUNGLE_HILLS(MCVersion.MC1_14),
NETHER_WASTES(MCVersion.MC1_16),
SOUL_SAND_VALLEY(MCVersion.MC1_16),
CRIMSON_FOREST(MCVersion.MC1_16),
WARPED_FOREST(MCVersion.MC1_16),
BASALT_DELTAS(MCVersion.MC1_16),
UNKNOWN(MCVersion.NEVER);

private final MCVersion since;
private final MCVersion until;

MCVanillaBiomeType() {
this(MCVersion.MC1_0);
}

MCVanillaBiomeType(MCVersion since) {
this(since, MCVersion.FUTURE);
}

MCVanillaBiomeType(MCVersion since, MCVersion until) {
this.since = since;
this.until = until;
}

public boolean existsInCurrent() {
return Static.getServer().getMinecraftVersion().gte(since);
public boolean existsIn(MCVersion version) {
return version.gte(since) && version.lte(until);
}
}
}
@@ -135,7 +135,7 @@ public static String stripColor(final String input) {
return null;
}

return input.replaceAll("(?i)\u00A7[0-9A-Fklmnor]", "");
return input.replaceAll("(?i)\u00A7[0-9A-Fklmnorx]", "");
}

static {
@@ -30,5 +30,20 @@ public enum MCEntityEffect {
IRON_GOLEM_SHEATH,
TOTEM_RESURRECT,
HURT_DROWN,
HURT_EXPLOSION
HURT_EXPLOSION,
DOLPHIN_FED,
RAVAGER_STUNNED,
CAT_TAME_FAIL,
CAT_TAME_SUCCESS,
VILLAGER_SPLASH,
PLAYER_BAD_OMEN_RAID,
HURT_BERRY_BUSH,
FOX_CHEW,
TELEPORT_ENDER,
BREAK_EQUIPMENT_MAIN_HAND,
BREAK_EQUIPMENT_OFF_HAND,
BREAK_EQUIPMENT_HELMET,
BREAK_EQUIPMENT_CHESTPLATE,
BREAK_EQUIPMENT_LEGGINGS,
BREAK_EQUIPMENT_BOOTS
}

0 comments on commit 0fe660d

Please sign in to comment.