添加FastProjectile接口
This commit is contained in:
parent
52c18cb320
commit
0436765576
3 changed files with 20 additions and 6 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
|
|
||||||
|
public interface FastProjectile {
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "UnusedReturnValue", "SuspiciousNameCombination"})
|
@SuppressWarnings({"unused", "UnusedReturnValue", "SuspiciousNameCombination"})
|
||||||
public class ProjectileEntity extends Projectile implements IEntityAdditionalSpawnData, GeoEntity {
|
public class ProjectileEntity extends Projectile implements IEntityAdditionalSpawnData, GeoEntity, FastProjectile {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Float> COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Float> COLOR_G = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> COLOR_G = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT);
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package com.atsuishio.superbwarfare.mixins;
|
package com.atsuishio.superbwarfare.mixins;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.entity.projectile.FastProjectile;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -40,12 +44,18 @@ public class ClientboundSetEntityMotionPacketMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
private int za;
|
private int za;
|
||||||
|
|
||||||
@Inject(method = "Lnet/minecraft/network/protocol/game/ClientboundSetEntityMotionPacket;" +
|
// TODO 实现仅对 FastProjectile 对象的动量修改
|
||||||
"<init>(ILnet/minecraft/world/phys/Vec3;)V", at = @At(value = "RETURN"))
|
@Inject(method = "<init>(ILnet/minecraft/world/phys/Vec3;)V", at = @At(value = "RETURN"))
|
||||||
public void init(int entityId, Vec3 motion, CallbackInfo ci) {
|
public void init(int entityId, Vec3 motion, CallbackInfo ci) {
|
||||||
this.xa = (int) (motion.x * 8000.0D);
|
ClientLevel level = Minecraft.getInstance().level;
|
||||||
this.ya = (int) (motion.y * 8000.0D);
|
if (level != null) {
|
||||||
this.za = (int) (motion.z * 8000.0D);
|
Entity entity = level.getEntity(entityId);
|
||||||
|
if (entity instanceof FastProjectile) {
|
||||||
|
this.xa = (int) (motion.x * 8000.0D);
|
||||||
|
this.ya = (int) (motion.y * 8000.0D);
|
||||||
|
this.za = (int) (motion.z * 8000.0D);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V",
|
@Redirect(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V",
|
||||||
|
|
Loading…
Add table
Reference in a new issue