Update to Minecraft 1.18-pre8

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-25 08:00:00 +11:00
parent 0d839e926c
commit 799bfc92e2
30 changed files with 206 additions and 758 deletions

View File

@@ -14,7 +14,7 @@
public class ItemBlock extends Item {
private static final String BLOCK_ENTITY_TAG = "BlockEntityTag";
@@ -68,6 +75,12 @@
@@ -69,6 +76,12 @@
return EnumInteractionResult.FAIL;
} else {
IBlockData iblockdata = this.getPlacementState(blockactioncontext1);
@@ -27,7 +27,7 @@
if (iblockdata == null) {
return EnumInteractionResult.FAIL;
@@ -84,6 +97,19 @@
@@ -85,6 +98,19 @@
iblockdata1 = this.updateBlockStateFromTag(blockposition, world, itemstack, iblockdata1);
this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1);
iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack);
@@ -47,7 +47,7 @@
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack);
}
@@ -91,9 +117,9 @@
@@ -92,9 +118,9 @@
SoundEffectType soundeffecttype = iblockdata1.getSoundType();
@@ -59,7 +59,7 @@
itemstack.shrink(1);
}
@@ -129,6 +155,21 @@
@@ -130,6 +156,21 @@
if (nbttagcompound != null) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag");
@@ -81,7 +81,7 @@
BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStateDefinition();
Iterator iterator = nbttagcompound1.getAllKeys().iterator();
@@ -143,11 +184,6 @@
@@ -144,11 +185,6 @@
}
}
}
@@ -93,7 +93,7 @@
return iblockdata1;
}
@@ -160,8 +196,15 @@
@@ -161,8 +197,15 @@
protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) {
EntityHuman entityhuman = blockactioncontext.getPlayer();
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman);
@@ -110,7 +110,7 @@
}
protected boolean mustSurvive() {
@@ -244,7 +287,7 @@
@@ -245,7 +288,7 @@
if (nbttagcompound != null && nbttagcompound.contains("Items", 9)) {
NBTTagList nbttaglist = nbttagcompound.getList("Items", 10);

View File

@@ -41,7 +41,7 @@
public final class ItemStack {
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
@@ -139,16 +173,30 @@
@@ -140,16 +174,30 @@
this.updateEmptyCacheFlag();
}
@@ -74,7 +74,7 @@
this.getItem().verifyTagAfterLoad(this.tag);
}
@@ -156,6 +204,11 @@
@@ -157,6 +205,11 @@
this.setDamageValue(this.getDamageValue());
}
@@ -86,7 +86,7 @@
this.updateEmptyCacheFlag();
}
@@ -193,7 +246,7 @@
@@ -194,7 +247,7 @@
return this.getItem() == item;
}
@@ -95,7 +95,7 @@
EntityHuman entityhuman = itemactioncontext.getPlayer();
BlockPosition blockposition = itemactioncontext.getClickedPos();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false);
@@ -201,12 +254,157 @@
@@ -202,12 +255,157 @@
if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().getTagManager(), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
@@ -254,7 +254,7 @@
return enuminteractionresult;
}
@@ -287,6 +485,21 @@
@@ -288,6 +486,21 @@
}
i -= k;
@@ -276,7 +276,7 @@
if (i <= 0) {
return false;
}
@@ -308,6 +521,11 @@
@@ -309,6 +522,11 @@
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
consumer.accept(t0);
Item item = this.getItem();
@@ -288,7 +288,7 @@
this.shrink(1);
if (t0 instanceof EntityHuman) {
@@ -463,6 +681,17 @@
@@ -464,6 +682,17 @@
return this.tag;
}
@@ -306,7 +306,7 @@
public NBTTagCompound getOrCreateTag() {
if (this.tag == null) {
this.setTag(new NBTTagCompound());
@@ -843,6 +1072,12 @@
@@ -844,6 +1073,12 @@
}
public void setRepairCost(int i) {
@@ -319,7 +319,7 @@
this.getOrCreateTag().putInt("RepairCost", i);
}
@@ -892,6 +1127,13 @@
@@ -893,6 +1128,13 @@
nbttaglist.add(nbttagcompound);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/crafting/CraftingManager.java
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
@@ -34,11 +34,13 @@
@@ -33,11 +33,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,9 +12,9 @@
private static final Logger LOGGER = LogManager.getLogger();
- public Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of();
+ public Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of(); // CraftBukkit
private Map<MinecraftKey, IRecipe<?>> byName = ImmutableMap.of();
private boolean hasErrors;
public CraftingManager() {
@@ -47,7 +49,12 @@
protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
@@ -26,10 +26,10 @@
+ map1.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
+ }
+ // CraftBukkit end
Builder<MinecraftKey, IRecipe<?>> builder = ImmutableMap.builder();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
@@ -57,8 +64,10 @@
@@ -58,8 +65,10 @@
try {
IRecipe<?> irecipe = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element"));
@@ -40,15 +40,17 @@
+ return new Object2ObjectLinkedOpenHashMap<>();
+ // CraftBukkit end
})).put(minecraftkey, irecipe);
builder.put(minecraftkey, irecipe);
} catch (IllegalArgumentException | JsonParseException jsonparseexception) {
CraftingManager.LOGGER.error("Parsing error loading recipe {}", minecraftkey, jsonparseexception);
@@ -66,19 +75,35 @@
@@ -68,20 +77,37 @@
}
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
- return ((Builder) entry1.getValue()).build();
+ return (entry1.getValue()); // CraftBukkit
}));
- this.byName = builder.build();
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
CraftingManager.LOGGER.info("Loaded {} recipes", map1.size());
}
@@ -56,10 +58,11 @@
+ public void addRecipe(IRecipe<?> irecipe) {
+ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.getType()); // CraftBukkit
+
+ if (map.containsKey(irecipe.getId())) {
+ if (byName.containsKey(irecipe.getId()) || map.containsKey(irecipe.getId())) {
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getId());
+ } else {
+ map.putAndMoveToFirst(irecipe.getId(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority
+ byName.put(irecipe.getId(), irecipe);
+ }
+ }
+ // CraftBukkit end
@@ -80,7 +83,7 @@
}
public <C extends IInventory, T extends IRecipe<C>> List<T> getAllRecipesFor(Recipes<T> recipes) {
@@ -96,7 +121,7 @@
@@ -99,7 +125,7 @@
}
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> byType(Recipes<T> recipes) {
@@ -89,33 +92,37 @@
}
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
@@ -117,7 +142,7 @@
public Optional<? extends IRecipe<?>> byKey(MinecraftKey minecraftkey) {
return this.recipes.values().stream().map((map) -> {
- return (IRecipe) map.get(minecraftkey);
+ return map.get(minecraftkey); // CraftBukkit - decompile error
}).filter(Objects::nonNull).findFirst();
@@ -119,7 +145,7 @@
}
@@ -143,11 +168,11 @@
public Optional<? extends IRecipe<?>> byKey(MinecraftKey minecraftkey) {
- return Optional.ofNullable((IRecipe) this.byName.get(minecraftkey));
+ return Optional.ofNullable(this.byName.get(minecraftkey)); // CraftBukkit - decompile error
}
public Collection<IRecipe<?>> getRecipes() {
@@ -144,12 +170,12 @@
public void replaceRecipes(Iterable<IRecipe<?>> iterable) {
this.hasErrors = false;
- Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap();
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap(); // CraftBukkit
Builder<MinecraftKey, IRecipe<?>> builder = ImmutableMap.builder();
iterable.forEach((irecipe) -> {
Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
- return Maps.newHashMap();
+ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
});
IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getId(), irecipe);
@@ -157,4 +182,14 @@
MinecraftKey minecraftkey = irecipe.getId();
IRecipe<?> irecipe1 = (IRecipe) map1.put(minecraftkey, irecipe);
@@ -160,6 +186,18 @@
}
});
this.recipes = ImmutableMap.copyOf(map);
}
- this.byName = builder.build();
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
+ }
+
+ // CraftBukkit start
+ public void clearRecipes() {
@@ -124,6 +131,8 @@
+ for (Recipes<?> recipeType : IRegistry.RECIPE_TYPE) {
+ this.recipes.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
+ }
+ }
+
+ this.byName = Maps.newHashMap();
}
+ // CraftBukkit end
}