@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBoat.java
|
||||
+++ b/net/minecraft/world/item/ItemBoat.java
|
||||
@@ -58,6 +58,13 @@
|
||||
@@ -60,6 +60,13 @@
|
||||
}
|
||||
|
||||
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
@@ -11,10 +11,10 @@
|
||||
+ return InteractionResultWrapper.pass(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock);
|
||||
EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman);
|
||||
|
||||
entityboat.setVariant(this.type);
|
||||
@@ -66,7 +73,15 @@
|
||||
@@ -68,7 +75,15 @@
|
||||
return InteractionResultWrapper.fail(itemstack);
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
@@ -31,3 +31,12 @@
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation());
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
itemstack.shrink(1);
|
||||
@@ -86,7 +101,7 @@
|
||||
|
||||
private EntityBoat getBoat(World world, MovingObjectPosition movingobjectposition, ItemStack itemstack, EntityHuman entityhuman) {
|
||||
Vec3D vec3d = movingobjectposition.getLocation();
|
||||
- Object object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z);
|
||||
+ EntityBoat object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z); // CraftBukkit - decompile error
|
||||
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--- a/net/minecraft/world/item/ItemChorusFruit.java
|
||||
+++ b/net/minecraft/world/item/ItemChorusFruit.java
|
||||
@@ -39,7 +39,16 @@
|
||||
@@ -35,7 +35,16 @@
|
||||
|
||||
Vec3D vec3d = entityliving.position();
|
||||
|
||||
- if (entityliving.randomTeleport(d3, d4, d5, true)) {
|
||||
- if (entityliving.randomTeleport(d0, d1, d2, true)) {
|
||||
+ // CraftBukkit start - handle canceled status of teleport event
|
||||
+ java.util.Optional<Boolean> status = entityliving.randomTeleport(d3, d4, d5, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
|
||||
+ java.util.Optional<Boolean> status = entityliving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
|
||||
+
|
||||
+ if (!status.isPresent()) {
|
||||
+ // teleport event was canceled, no more tries
|
||||
@@ -16,5 +16,5 @@
|
||||
+ if (status.get()) {
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent(GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving));
|
||||
SoundEffect soundeffect = entityliving instanceof EntityFox ? SoundEffects.FOX_TELEPORT : SoundEffects.CHORUS_FRUIT_TELEPORT;
|
||||
|
||||
SoundEffect soundeffect;
|
||||
SoundCategory soundcategory;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemMinecart.java
|
||||
+++ b/net/minecraft/world/item/ItemMinecart.java
|
||||
@@ -18,6 +18,12 @@
|
||||
@@ -19,6 +19,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -13,17 +13,19 @@
|
||||
public class ItemMinecart extends Item {
|
||||
|
||||
private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -57,14 +63,43 @@
|
||||
@@ -58,10 +64,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type);
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type, itemstack, (EntityHuman) null);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type);
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
- itemstack.shrink(1);
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
@@ -46,31 +48,25 @@
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type);
|
||||
|
||||
if (itemstack.hasCustomHoverName()) {
|
||||
entityminecartabstract.setCustomName(itemstack.getHoverName());
|
||||
}
|
||||
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
- itemstack.shrink(1);
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type, itemstack1, (EntityHuman) null);
|
||||
+
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -106,7 +141,12 @@
|
||||
entityminecartabstract.setCustomName(itemstack.getHoverName());
|
||||
}
|
||||
@@ -100,7 +135,12 @@
|
||||
|
||||
- world.addFreshEntity(entityminecartabstract);
|
||||
EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.0625D + d0, (double) blockposition.getZ() + 0.5D, this.type, itemstack, itemactioncontext.getPlayer());
|
||||
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (!world.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
world.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), world.getBlockState(blockposition.below())));
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
worldserver.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below())));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
+++ b/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
@@ -185,7 +185,7 @@
|
||||
@@ -180,7 +180,7 @@
|
||||
return Optional.empty();
|
||||
} else {
|
||||
((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F);
|
||||
@@ -9,7 +9,7 @@
|
||||
if (itemstack.hasCustomHoverName()) {
|
||||
((EntityInsentient) object).setCustomName(itemstack.getHoverName());
|
||||
}
|
||||
@@ -194,7 +194,7 @@
|
||||
@@ -189,7 +189,7 @@
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -77,6 +77,43 @@
|
||||
@@ -81,6 +81,43 @@
|
||||
import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
public final class ItemStack {
|
||||
|
||||
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -152,11 +189,24 @@
|
||||
@@ -175,7 +212,18 @@
|
||||
this.item = null;
|
||||
}
|
||||
|
||||
@@ -64,14 +64,7 @@
|
||||
this.item = (Item) BuiltInRegistries.ITEM.get(new MinecraftKey(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
- this.tag = nbttagcompound.getCompound("tag");
|
||||
+ // CraftBukkit start - make defensive copy as this data may be coming from the save thread
|
||||
+ this.tag = nbttagcompound.getCompound("tag").copy();
|
||||
+ // CraftBukkit end
|
||||
this.getItem().verifyTagAfterLoad(this.tag);
|
||||
}
|
||||
|
||||
@@ -166,6 +216,11 @@
|
||||
@@ -189,6 +237,11 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -83,7 +76,7 @@
|
||||
public static ItemStack of(NBTTagCompound nbttagcompound) {
|
||||
try {
|
||||
return new ItemStack(nbttagcompound);
|
||||
@@ -243,11 +298,190 @@
|
||||
@@ -266,11 +319,190 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
Item item = this.getItem();
|
||||
@@ -212,7 +205,7 @@
|
||||
+ record.setCount(1);
|
||||
+ }
|
||||
+
|
||||
+ tileentityjukebox.setFirstItem(record);
|
||||
+ tileentityjukebox.setTheItem(record);
|
||||
+ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entityhuman, world.getBlockState(blockposition)));
|
||||
+ }
|
||||
+
|
||||
@@ -276,7 +269,7 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -328,6 +562,21 @@
|
||||
@@ -351,6 +583,21 @@
|
||||
}
|
||||
|
||||
i -= k;
|
||||
@@ -298,7 +291,7 @@
|
||||
if (i <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -349,6 +598,11 @@
|
||||
@@ -372,6 +619,11 @@
|
||||
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
|
||||
consumer.accept(t0);
|
||||
Item item = this.getItem();
|
||||
@@ -310,7 +303,7 @@
|
||||
|
||||
this.shrink(1);
|
||||
if (t0 instanceof EntityHuman) {
|
||||
@@ -497,6 +751,17 @@
|
||||
@@ -524,6 +776,17 @@
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
@@ -328,7 +321,7 @@
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
if (this.tag == null) {
|
||||
this.setTag(new NBTTagCompound());
|
||||
@@ -921,6 +1186,13 @@
|
||||
@@ -948,6 +1211,13 @@
|
||||
nbttaglist.add(nbttagcompound);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
|
||||
+ });
|
||||
+ entitythrowntrident.tridentItem = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
--- a/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
@@ -37,11 +37,13 @@
|
||||
@@ -34,11 +34,16 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
@@ -15,7 +18,7 @@
|
||||
private Map<MinecraftKey, RecipeHolder<?>> byName = ImmutableMap.of();
|
||||
private boolean hasErrors;
|
||||
|
||||
@@ -51,7 +53,12 @@
|
||||
@@ -48,7 +53,12 @@
|
||||
|
||||
protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.hasErrors = false;
|
||||
@@ -29,7 +32,7 @@
|
||||
Builder<MinecraftKey, RecipeHolder<?>> builder = ImmutableMap.builder();
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
|
||||
@@ -62,8 +69,10 @@
|
||||
@@ -59,8 +69,10 @@
|
||||
try {
|
||||
RecipeHolder<?> recipeholder = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
@@ -42,7 +45,7 @@
|
||||
})).put(minecraftkey, recipeholder);
|
||||
builder.put(minecraftkey, recipeholder);
|
||||
} catch (IllegalArgumentException | JsonParseException jsonparseexception) {
|
||||
@@ -72,20 +81,37 @@
|
||||
@@ -69,20 +81,37 @@
|
||||
}
|
||||
|
||||
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
||||
@@ -83,7 +86,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<Pair<MinecraftKey, RecipeHolder<T>>> getRecipeFor(Recipes<T> recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) {
|
||||
@@ -119,7 +145,7 @@
|
||||
@@ -116,7 +145,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
@@ -92,7 +95,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -166,12 +192,12 @@
|
||||
@@ -159,12 +188,12 @@
|
||||
|
||||
public void replaceRecipes(Iterable<RecipeHolder<?>> iterable) {
|
||||
this.hasErrors = false;
|
||||
@@ -107,14 +110,14 @@
|
||||
});
|
||||
MinecraftKey minecraftkey = recipeholder.id();
|
||||
RecipeHolder<?> recipeholder1 = (RecipeHolder) map1.put(minecraftkey, recipeholder);
|
||||
@@ -182,9 +208,29 @@
|
||||
@@ -175,9 +204,29 @@
|
||||
}
|
||||
});
|
||||
this.recipes = ImmutableMap.copyOf(map);
|
||||
- this.byName = builder.build();
|
||||
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(MinecraftKey mcKey) {
|
||||
+ for (Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>> recipes : recipes.values()) {
|
||||
@@ -122,8 +125,8 @@
|
||||
+ }
|
||||
+
|
||||
+ return byName.remove(mcKey) != null;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.recipes = Maps.newHashMap();
|
||||
+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -63,4 +63,6 @@
|
||||
@@ -67,4 +67,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -38,6 +38,7 @@
|
||||
@@ -35,6 +35,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
@@ -8,7 +8,7 @@
|
||||
public static final Codec<RecipeItemStack> CODEC = codec(true);
|
||||
public static final Codec<RecipeItemStack> CODEC_NONEMPTY = codec(false);
|
||||
|
||||
@@ -75,6 +76,15 @@
|
||||
@@ -72,6 +73,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -18,6 +18,14 @@
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -14,9 +14,9 @@
|
||||
+
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final int width;
|
||||
@@ -42,6 +50,68 @@
|
||||
this(s, craftingbookcategory, i, j, nonnulllist, itemstack, true);
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -30,6 +38,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -27,9 +27,9 @@
|
||||
+ recipe.setGroup(this.group);
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ switch (this.height) {
|
||||
+ switch (this.pattern.height()) {
|
||||
+ case 1:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a");
|
||||
+ break;
|
||||
@@ -42,7 +42,7 @@
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b");
|
||||
+ break;
|
||||
@@ -55,7 +55,7 @@
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b","c");
|
||||
+ break;
|
||||
@@ -69,7 +69,7 @@
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.recipeItems) {
|
||||
+ for (RecipeItemStack list : this.pattern.ingredients()) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
|
||||
Reference in New Issue
Block a user