-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: 秋雨落 <[email protected]>
- Loading branch information
Showing
165 changed files
with
5,261 additions
and
713 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
.gradle/ | ||
/.settings/ | ||
build/ | ||
/bin/ | ||
bin/ | ||
/.project | ||
.idea | ||
*.log | ||
*.log | ||
run_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
.../main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/frog/TadpoleMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
package io.izzel.arclight.common.mixin.core.world.entity.animal.frog; | ||
|
||
import io.izzel.arclight.common.bridge.core.world.server.ServerWorldBridge; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.animal.frog.Frog; | ||
import net.minecraft.world.entity.animal.frog.Tadpole; | ||
import org.bukkit.craftbukkit.v.event.CraftEventFactory; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(Tadpole.class) | ||
public abstract class TadpoleMixin { | ||
|
||
// @formatter:off | ||
@Shadow protected abstract void setAge(int p_218711_); | ||
// @formatter:on | ||
|
||
@Inject(method = "ageUp()V", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/frog/Tadpole;playSound(Lnet/minecraft/sounds/SoundEvent;FF)V")) | ||
private void arclight$transform(CallbackInfo ci, ServerLevel serverLevel, Frog frog) { | ||
if (CraftEventFactory.callEntityTransformEvent((Tadpole) (Object) this, frog, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS).isCancelled()) { | ||
this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled | ||
ci.cancel(); | ||
} else { | ||
((ServerWorldBridge) serverLevel).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...n/java/io/izzel/arclight/common/mixin/vanilla/server/level/ServerEntityMixin_Vanilla.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package io.izzel.arclight.common.mixin.vanilla.server.level; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.mojang.datafixers.util.Pair; | ||
import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.game.*; | ||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.server.level.ServerEntity; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.Mob; | ||
import net.minecraft.world.entity.ai.attributes.AttributeInstance; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
@Mixin(ServerEntity.class) | ||
public abstract class ServerEntityMixin_Vanilla { | ||
|
||
// @formatter:off | ||
@Shadow @Final private Entity entity; | ||
@Shadow private int yHeadRotp; | ||
@Shadow @Nullable private List<SynchedEntityData.DataValue<?>> trackedDataValues; | ||
@Shadow @Final private boolean trackDelta; | ||
@Shadow private Vec3 ap; | ||
// @formatter:on | ||
|
||
/** | ||
* @author IzzelAliz | ||
* @reason | ||
*/ | ||
@Overwrite | ||
public void sendPairingData(ServerPlayer player, final Consumer<Packet<?>> consumer) { | ||
Mob entityinsentient; | ||
if (this.entity.isRemoved()) { | ||
return; | ||
} | ||
Packet<?> packet = this.entity.getAddEntityPacket(); | ||
this.yHeadRotp = Mth.floor(this.entity.getYHeadRot() * 256.0f / 360.0f); | ||
consumer.accept(packet); | ||
if (this.trackedDataValues != null) { | ||
consumer.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), this.trackedDataValues)); | ||
} | ||
boolean flag = this.trackDelta; | ||
if (this.entity instanceof LivingEntity livingEntity) { | ||
Collection<AttributeInstance> collection = livingEntity.getAttributes().getSyncableAttributes(); | ||
if (this.entity.getId() == player.getId()) { | ||
((ServerPlayerEntityBridge) this.entity).bridge$getBukkitEntity().injectScaledMaxHealth(collection, false); | ||
} | ||
if (!collection.isEmpty()) { | ||
consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), collection)); | ||
} | ||
if (livingEntity.isFallFlying()) { | ||
flag = true; | ||
} | ||
} | ||
this.ap = this.entity.getDeltaMovement(); | ||
if (flag && !(this.entity instanceof LivingEntity)) { | ||
consumer.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap)); | ||
} | ||
if (this.entity instanceof LivingEntity) { | ||
ArrayList<Pair<EquipmentSlot, ItemStack>> list = Lists.newArrayList(); | ||
for (EquipmentSlot enumitemslot : EquipmentSlot.values()) { | ||
ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot); | ||
if (itemstack.isEmpty()) continue; | ||
list.add(Pair.of(enumitemslot, itemstack.copy())); | ||
} | ||
if (!list.isEmpty()) { | ||
consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list)); | ||
} | ||
((LivingEntity) this.entity).detectEquipmentUpdates(); | ||
} | ||
// CraftBukkit start - MC-109346: Fix for nonsensical head yaw | ||
if (this.entity instanceof ServerPlayer) { | ||
consumer.accept(new ClientboundRotateHeadPacket(this.entity, (byte) Mth.floor(this.entity.getYHeadRot() * 256.0F / 360.0F))); | ||
} | ||
// CraftBukkit end | ||
if (!this.entity.getPassengers().isEmpty()) { | ||
consumer.accept(new ClientboundSetPassengersPacket(this.entity)); | ||
} | ||
if (this.entity.isPassenger()) { | ||
consumer.accept(new ClientboundSetPassengersPacket(this.entity.getVehicle())); | ||
} | ||
if (this.entity instanceof Mob && (entityinsentient = (Mob) this.entity).isLeashed()) { | ||
consumer.accept(new ClientboundSetEntityLinkPacket(entityinsentient, entityinsentient.getLeashHolder())); | ||
} | ||
} | ||
} |
Oops, something went wrong.