aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch232
1 files changed, 232 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch
new file mode 100644
index 0000000000..839b0598c2
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/SpawnEggItem.java.patch
@@ -0,0 +1,232 @@
+--- 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;
+@@ -27,7 +27,7 @@
+ import net.minecraft.world.level.Spawner;
+ import net.minecraft.world.level.block.LiquidBlock;
+ import net.minecraft.world.level.block.entity.BlockEntity;
+-import net.minecraft.world.level.block.state.BlockState;
++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;
+@@ -40,51 +40,50 @@
+ private final int highlightColor;
+ private final EntityType<?> defaultType;
+
+- public SpawnEggItem(EntityType<? extends Mob> entitytype, int i, int j, Item.Properties item_properties) {
+- super(item_properties);
+- this.defaultType = entitytype;
+- this.backgroundColor = i;
+- this.highlightColor = j;
+- SpawnEggItem.BY_ID.put(entitytype, this);
++ public SpawnEggItem(EntityType<? extends Mob> defaultType, int backgroundColor, int highlightColor, Item.Properties properties) {
++ super(properties);
++ this.defaultType = defaultType;
++ this.backgroundColor = backgroundColor;
++ this.highlightColor = highlightColor;
++ SpawnEggItem.BY_ID.put(defaultType, this);
+ }
+
+ @Override
+- @Override
+- public InteractionResult useOn(UseOnContext useoncontext) {
+- Level level = useoncontext.getLevel();
++ public InteractionResult useOn(UseOnContext context) {
++ Level world = context.getLevel();
+
+- if (!(level instanceof ServerLevel)) {
++ if (!(world instanceof ServerLevel)) {
+ return InteractionResult.SUCCESS;
+ } else {
+- ItemStack itemstack = useoncontext.getItemInHand();
+- BlockPos blockpos = useoncontext.getClickedPos();
+- Direction direction = useoncontext.getClickedFace();
+- BlockState blockstate = level.getBlockState(blockpos);
+- BlockEntity blockentity = level.getBlockEntity(blockpos);
+- EntityType entitytype;
++ 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 (blockentity instanceof Spawner) {
+- Spawner spawner = (Spawner) blockentity;
++ if (tileentity instanceof Spawner) {
++ Spawner spawner = (Spawner) tileentity;
+
+- entitytype = this.getType(itemstack.getTag());
+- spawner.setEntityId(entitytype, level.getRandom());
+- level.sendBlockUpdated(blockpos, blockstate, blockstate, 3);
+- level.gameEvent((Entity) useoncontext.getPlayer(), GameEvent.BLOCK_CHANGE, blockpos);
++ 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 blockpos1;
++ BlockPos blockposition1;
+
+- if (blockstate.getCollisionShape(level, blockpos).isEmpty()) {
+- blockpos1 = blockpos;
++ if (iblockdata.getCollisionShape(world, blockposition).isEmpty()) {
++ blockposition1 = blockposition;
+ } else {
+- blockpos1 = blockpos.relative(direction);
++ blockposition1 = blockposition.relative(enumdirection);
+ }
+
+- entitytype = this.getType(itemstack.getTag());
+- if (entitytype.spawn((ServerLevel) level, itemstack, useoncontext.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) {
++ 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);
+- level.gameEvent((Entity) useoncontext.getPlayer(), GameEvent.ENTITY_PLACE, blockpos);
++ world.gameEvent((Entity) context.getPlayer(), GameEvent.ENTITY_PLACE, blockposition);
+ }
+
+ return InteractionResult.CONSUME;
+@@ -93,23 +92,22 @@
+ }
+
+ @Override
+- @Override
+- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionhand) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
+- BlockHitResult blockhitresult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
++ 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 (blockhitresult.getType() != HitResult.Type.BLOCK) {
++ if (movingobjectpositionblock.getType() != HitResult.EnumMovingObjectType.BLOCK) {
+ return InteractionResultHolder.pass(itemstack);
+ } else if (!(level instanceof ServerLevel)) {
+ return InteractionResultHolder.success(itemstack);
+ } else {
+- BlockPos blockpos = blockhitresult.getBlockPos();
++ BlockPos blockposition = movingobjectpositionblock.getBlockPos();
+
+- if (!(level.getBlockState(blockpos).getBlock() instanceof LiquidBlock)) {
++ if (!(level.getBlockState(blockposition).getBlock() instanceof LiquidBlock)) {
+ return InteractionResultHolder.pass(itemstack);
+- } else if (level.mayInteract(player, blockpos) && player.mayUseItemAt(blockpos, blockhitresult.getDirection(), itemstack)) {
+- EntityType<?> entitytype = this.getType(itemstack.getTag());
+- Entity entity = entitytype.spawn((ServerLevel) level, itemstack, player, blockpos, MobSpawnType.SPAWN_EGG, false, false);
++ } 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(itemstack);
+@@ -128,29 +126,29 @@
+ }
+ }
+
+- public boolean spawnsEntity(@Nullable CompoundTag compoundtag, EntityType<?> entitytype) {
+- return Objects.equals(this.getType(compoundtag), entitytype);
++ public boolean spawnsEntity(@Nullable CompoundTag nbt, EntityType<?> type) {
++ return Objects.equals(this.getType(nbt), type);
+ }
+
+- public int getColor(int i) {
+- return i == 0 ? this.backgroundColor : this.highlightColor;
++ public int getColor(int tintIndex) {
++ return tintIndex == 0 ? this.backgroundColor : this.highlightColor;
+ }
+
+ @Nullable
+- public static SpawnEggItem byId(@Nullable EntityType<?> entitytype) {
+- return (SpawnEggItem) SpawnEggItem.BY_ID.get(entitytype);
++ public static SpawnEggItem byId(@Nullable EntityType<?> type) {
++ return (SpawnEggItem) SpawnEggItem.BY_ID.get(type);
+ }
+
+ public static Iterable<SpawnEggItem> eggs() {
+ return Iterables.unmodifiableIterable(SpawnEggItem.BY_ID.values());
+ }
+
+- public EntityType<?> getType(@Nullable CompoundTag compoundtag) {
+- if (compoundtag != null && compoundtag.contains("EntityTag", 10)) {
+- CompoundTag compoundtag1 = compoundtag.getCompound("EntityTag");
++ public EntityType<?> getType(@Nullable CompoundTag nbt) {
++ if (nbt != null && nbt.contains("EntityTag", 10)) {
++ CompoundTag nbttagcompound1 = nbt.getCompound("EntityTag");
+
+- if (compoundtag1.contains("id", 8)) {
+- return (EntityType) EntityType.byString(compoundtag1.getString("id")).orElse(this.defaultType);
++ if (nbttagcompound1.contains("id", 8)) {
++ return (EntityType) EntityType.byString(nbttagcompound1.getString("id")).orElse(this.defaultType);
+ }
+ }
+
+@@ -158,21 +156,20 @@
+ }
+
+ @Override
+- @Override
+ public FeatureFlagSet requiredFeatures() {
+ return this.defaultType.requiredFeatures();
+ }
+
+- public Optional<Mob> spawnOffspringFromSpawnEgg(Player player, Mob mob, EntityType<? extends Mob> entitytype, ServerLevel serverlevel, Vec3 vec3, ItemStack itemstack) {
+- if (!this.spawnsEntity(itemstack.getTag(), entitytype)) {
++ 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 {
+ Object object;
+
+ if (mob instanceof AgeableMob) {
+- object = ((AgeableMob) mob).getBreedOffspring(serverlevel, (AgeableMob) mob);
++ object = ((AgeableMob) mob).getBreedOffspring(serverLevel, (AgeableMob) mob);
+ } else {
+- object = (Mob) entitytype.create(serverlevel);
++ object = (Mob) entityType.create(serverLevel);
+ }
+
+ if (object == null) {
+@@ -182,17 +179,17 @@
+ if (!((Mob) object).isBaby()) {
+ return Optional.empty();
+ } else {
+- ((Mob) object).moveTo(vec3.x(), vec3.y(), vec3.z(), 0.0F, 0.0F);
+- serverlevel.addFreshEntityWithPassengers((Entity) object);
+- if (itemstack.hasCustomHoverName()) {
+- ((Mob) object).setCustomName(itemstack.getHoverName());
++ ((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()) {
++ ((Mob) object).setCustomName(stack.getHoverName());
+ }
+
+ if (!player.getAbilities().instabuild) {
+- itemstack.shrink(1);
++ stack.shrink(1);
+ }
+
+- return Optional.of(object);
++ return Optional.of((Mob) object); // CraftBukkit - decompile error
+ }
+ }
+ }