aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch
diff options
context:
space:
mode:
authorMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
committerMiniDigger | Martin <[email protected]>2024-01-14 11:04:49 +0100
commitbee74680e607c2e29b038329f62181238911cd83 (patch)
tree708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch
parent0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff)
downloadPaper-softspoon.tar.gz
Paper-softspoon.zip
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch241
1 files changed, 241 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch
new file mode 100644
index 0000000000..e55ed2d4a1
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/item/SpawnEggItem.java.patch
@@ -0,0 +1,241 @@
+--- a/net/minecraft/world/item/SpawnEggItem.java
++++ b/net/minecraft/world/item/SpawnEggItem.java
+@@ -11,14 +11,14 @@
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.server.level.ServerLevel;
+ import net.minecraft.stats.Stats;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.InteractionResultHolder;
+ import net.minecraft.world.entity.AgeableMob;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.EnumMobSpawn;
+ import net.minecraft.world.entity.Mob;
+-import net.minecraft.world.entity.MobSpawnType;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.flag.FeatureFlagSet;
+ import net.minecraft.world.item.context.UseOnContext;
+@@ -26,13 +26,15 @@
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.Spawner;
+ import net.minecraft.world.level.block.LiquidBlock;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.entity.BlockEntity;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.gameevent.GameEvent;
+ import net.minecraft.world.phys.BlockHitResult;
+ import net.minecraft.world.phys.HitResult;
+ import net.minecraft.world.phys.Vec3;
+
+ public class SpawnEggItem extends Item {
++
+ private static final Map<EntityType<? extends Mob>, SpawnEggItem> BY_ID = Maps.newIdentityHashMap();
+ private final int backgroundColor;
+ private final int highlightColor;
+@@ -43,47 +45,45 @@
+ this.defaultType = defaultType;
+ this.backgroundColor = backgroundColor;
+ this.highlightColor = highlightColor;
+- BY_ID.put(defaultType, this);
++ SpawnEggItem.BY_ID.put(defaultType, this);
+ }
+
+ @Override
+ public InteractionResult useOn(UseOnContext context) {
+- Level level = context.getLevel();
+- if (!(level instanceof ServerLevel)) {
++ Level world = context.getLevel();
++
++ if (!(world instanceof ServerLevel)) {
+ return InteractionResult.SUCCESS;
+ } else {
+- ItemStack itemInHand = context.getItemInHand();
+- BlockPos clickedPos = context.getClickedPos();
+- Direction clickedFace = context.getClickedFace();
+- BlockState blockState = level.getBlockState(clickedPos);
+- if (level.getBlockEntity(clickedPos) instanceof Spawner spawner) {
+- EntityType<?> type = this.getType(itemInHand.getTag());
+- spawner.setEntityId(type, level.getRandom());
+- level.sendBlockUpdated(clickedPos, blockState, blockState, 3);
+- level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos);
+- itemInHand.shrink(1);
++ ItemStack itemstack = context.getItemInHand();
++ BlockPos blockposition = context.getClickedPos();
++ Direction enumdirection = context.getClickedFace();
++ IBlockData iblockdata = world.getBlockState(blockposition);
++ BlockEntity tileentity = world.getBlockEntity(blockposition);
++ EntityType entitytypes;
++
++ if (tileentity instanceof Spawner) {
++ Spawner spawner = (Spawner) tileentity;
++
++ entitytypes = this.getType(itemstack.getTag());
++ spawner.setEntityId(entitytypes, world.getRandom());
++ world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
++ world.gameEvent((Entity) context.getPlayer(), GameEvent.BLOCK_CHANGE, blockposition);
++ itemstack.shrink(1);
+ return InteractionResult.CONSUME;
+ } else {
+- BlockPos blockPos;
+- if (blockState.getCollisionShape(level, clickedPos).isEmpty()) {
+- blockPos = clickedPos;
++ BlockPos blockposition1;
++
++ if (iblockdata.getCollisionShape(world, blockposition).isEmpty()) {
++ blockposition1 = blockposition;
+ } else {
+- blockPos = clickedPos.relative(clickedFace);
++ blockposition1 = blockposition.relative(enumdirection);
+ }
+
+- EntityType<?> type = this.getType(itemInHand.getTag());
+- if (type.spawn(
+- (ServerLevel)level,
+- itemInHand,
+- context.getPlayer(),
+- blockPos,
+- MobSpawnType.SPAWN_EGG,
+- true,
+- !Objects.equals(clickedPos, blockPos) && clickedFace == Direction.UP
+- )
+- != null) {
+- itemInHand.shrink(1);
+- level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, clickedPos);
++ entitytypes = this.getType(itemstack.getTag());
++ if (entitytypes.spawn((ServerLevel) world, itemstack, context.getPlayer(), blockposition1, EnumMobSpawn.SPAWN_EGG, true, !Objects.equals(blockposition, blockposition1) && enumdirection == Direction.UP) != null) {
++ itemstack.shrink(1);
++ world.gameEvent((Entity) context.getPlayer(), GameEvent.ENTITY_PLACE, blockposition);
+ }
+
+ return InteractionResult.CONSUME;
+@@ -92,33 +92,36 @@
+ }
+
+ @Override
+- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
+- ItemStack itemInHand = player.getItemInHand(hand);
+- BlockHitResult playerPOVHitResult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
+- if (playerPOVHitResult.getType() != HitResult.Type.BLOCK) {
+- return InteractionResultHolder.pass(itemInHand);
++ public InteractionResultHolder<ItemStack> use(Level level, Player player, EnumHand hand) {
++ ItemStack itemstack = player.getItemInHand(hand);
++ BlockHitResult movingobjectpositionblock = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
++
++ if (movingobjectpositionblock.getType() != HitResult.EnumMovingObjectType.BLOCK) {
++ return InteractionResultHolder.pass(itemstack);
+ } else if (!(level instanceof ServerLevel)) {
+- return InteractionResultHolder.success(itemInHand);
++ return InteractionResultHolder.success(itemstack);
+ } else {
+- BlockPos blockPos = playerPOVHitResult.getBlockPos();
+- if (!(level.getBlockState(blockPos).getBlock() instanceof LiquidBlock)) {
+- return InteractionResultHolder.pass(itemInHand);
+- } else if (level.mayInteract(player, blockPos) && player.mayUseItemAt(blockPos, playerPOVHitResult.getDirection(), itemInHand)) {
+- EntityType<?> type = this.getType(itemInHand.getTag());
+- Entity entity = type.spawn((ServerLevel)level, itemInHand, player, blockPos, MobSpawnType.SPAWN_EGG, false, false);
++ BlockPos blockposition = movingobjectpositionblock.getBlockPos();
++
++ if (!(level.getBlockState(blockposition).getBlock() instanceof LiquidBlock)) {
++ return InteractionResultHolder.pass(itemstack);
++ } else if (level.mayInteract(player, blockposition) && player.mayUseItemAt(blockposition, movingobjectpositionblock.getDirection(), itemstack)) {
++ EntityType<?> entitytypes = this.getType(itemstack.getTag());
++ Entity entity = entitytypes.spawn((ServerLevel) level, itemstack, player, blockposition, EnumMobSpawn.SPAWN_EGG, false, false);
++
+ if (entity == null) {
+- return InteractionResultHolder.pass(itemInHand);
++ return InteractionResultHolder.pass(itemstack);
+ } else {
+ if (!player.getAbilities().instabuild) {
+- itemInHand.shrink(1);
++ itemstack.shrink(1);
+ }
+
+ player.awardStat(Stats.ITEM_USED.get(this));
+- level.gameEvent(player, GameEvent.ENTITY_PLACE, entity.position());
+- return InteractionResultHolder.consume(itemInHand);
++ level.gameEvent((Entity) player, GameEvent.ENTITY_PLACE, entity.position());
++ return InteractionResultHolder.consume(itemstack);
+ }
+ } else {
+- return InteractionResultHolder.fail(itemInHand);
++ return InteractionResultHolder.fail(itemstack);
+ }
+ }
+ }
+@@ -133,18 +136,19 @@
+
+ @Nullable
+ public static SpawnEggItem byId(@Nullable EntityType<?> type) {
+- return BY_ID.get(type);
++ return (SpawnEggItem) SpawnEggItem.BY_ID.get(type);
+ }
+
+ public static Iterable<SpawnEggItem> eggs() {
+- return Iterables.unmodifiableIterable(BY_ID.values());
++ return Iterables.unmodifiableIterable(SpawnEggItem.BY_ID.values());
+ }
+
+ public EntityType<?> getType(@Nullable CompoundTag nbt) {
+ if (nbt != null && nbt.contains("EntityTag", 10)) {
+- CompoundTag compound = nbt.getCompound("EntityTag");
+- if (compound.contains("id", 8)) {
+- return EntityType.byString(compound.getString("id")).orElse(this.defaultType);
++ CompoundTag nbttagcompound1 = nbt.getCompound("EntityTag");
++
++ if (nbttagcompound1.contains("id", 8)) {
++ return (EntityType) EntityType.byString(nbttagcompound1.getString("id")).orElse(this.defaultType);
+ }
+ }
+
+@@ -156,37 +160,36 @@
+ return this.defaultType.requiredFeatures();
+ }
+
+- public Optional<Mob> spawnOffspringFromSpawnEgg(
+- Player player, Mob mob, EntityType<? extends Mob> entityType, ServerLevel serverLevel, Vec3 pos, ItemStack stack
+- ) {
++ public Optional<Mob> spawnOffspringFromSpawnEgg(Player player, Mob mob, EntityType<? extends Mob> entityType, ServerLevel serverLevel, Vec3 pos, ItemStack stack) {
+ if (!this.spawnsEntity(stack.getTag(), entityType)) {
+ return Optional.empty();
+ } else {
+- Mob breedOffspring;
++ Object object;
++
+ if (mob instanceof AgeableMob) {
+- breedOffspring = ((AgeableMob)mob).getBreedOffspring(serverLevel, (AgeableMob)mob);
++ object = ((AgeableMob) mob).getBreedOffspring(serverLevel, (AgeableMob) mob);
+ } else {
+- breedOffspring = entityType.create(serverLevel);
++ object = (Mob) entityType.create(serverLevel);
+ }
+
+- if (breedOffspring == null) {
++ if (object == null) {
+ return Optional.empty();
+ } else {
+- breedOffspring.setBaby(true);
+- if (!breedOffspring.isBaby()) {
++ ((Mob) object).setBaby(true);
++ if (!((Mob) object).isBaby()) {
+ return Optional.empty();
+ } else {
+- breedOffspring.moveTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F);
+- serverLevel.addFreshEntityWithPassengers(breedOffspring);
++ ((Mob) object).moveTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F);
++ serverLevel.addFreshEntityWithPassengers((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
+ if (stack.hasCustomHoverName()) {
+- breedOffspring.setCustomName(stack.getHoverName());
++ ((Mob) object).setCustomName(stack.getHoverName());
+ }
+
+ if (!player.getAbilities().instabuild) {
+ stack.shrink(1);
+ }
+
+- return Optional.of(breedOffspring);
++ return Optional.of((Mob) object); // CraftBukkit - decompile error
+ }
+ }
+ }