use of net.minecraft.server.network.ServerPlayerEntity in project MCDoom by AzureDoom.
the class ChaingunBulletEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.arrow(this, this);
} else {
damageSource2 = DamageSource.arrow(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, projectiledamage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.remove(Entity.RemovalReason.DISCARDED);
}
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.server.network.ServerPlayerEntity in project MCDoom by AzureDoom.
the class ShotgunShellEntity method onEntityHit.
@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
Entity entity = entityHitResult.getEntity();
if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
Entity entity2 = this.getOwner();
DamageSource damageSource2;
if (entity2 == null) {
damageSource2 = DamageSource.arrow(this, this);
} else {
damageSource2 = DamageSource.arrow(this, entity2);
if (entity2 instanceof LivingEntity) {
((LivingEntity) entity2).onAttacking(entity);
}
}
if (entity.damage(damageSource2, shelldamage)) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!this.world.isClient && entity2 instanceof LivingEntity) {
EnchantmentHelper.onUserDamaged(livingEntity, entity2);
EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
this.remove(Entity.RemovalReason.DISCARDED);
}
this.onHit(livingEntity);
if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
}
}
} else {
if (!this.world.isClient) {
this.remove(Entity.RemovalReason.DISCARDED);
}
}
}
use of net.minecraft.server.network.ServerPlayerEntity in project SpeedRunIGT by RedLime.
the class TimerPacketHandler method sendInitS2C.
public static void sendInitS2C(List<ServerPlayerEntity> players, long startTime, RunCategory category) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeLong(startTime);
passedData.writeString(category.getID());
CustomPayloadS2CPacket s2CPacket = new CustomPayloadS2CPacket(PACKET_TIMER_INIT_ID, passedData);
for (ServerPlayerEntity player : players) {
player.networkHandler.sendPacket(s2CPacket);
}
}
use of net.minecraft.server.network.ServerPlayerEntity in project SpeedRunIGT by RedLime.
the class TimerPacketHandler method sendCompleteS2C.
public static void sendCompleteS2C(List<ServerPlayerEntity> players, long endTime) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeLong(endTime);
CustomPayloadS2CPacket s2CPacket = new CustomPayloadS2CPacket(PACKET_TIMER_COMPLETE_ID, passedData);
for (ServerPlayerEntity player : players) {
player.networkHandler.sendPacket(s2CPacket);
}
}
use of net.minecraft.server.network.ServerPlayerEntity in project Rug by RubixDev.
the class FrameCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> command = CommandManager.literal("frame").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandFrame)).then(CommandManager.literal("hide").executes((context) -> {
ServerCommandSource playerSource = context.getSource();
ServerCommandSource source = playerSource.getServer().getCommandSource();
ServerPlayerEntity playerEntity = playerSource.getPlayer();
CommandManager manager = playerSource.getServer().getCommandManager();
String playerName = playerEntity.getName().getString();
manager.execute(source, "execute at " + playerName + " run tag @e[type=minecraft:item_frame,distance=..5] remove hasItem");
manager.execute(source, "execute at " + playerName + " run tag @e[type=minecraft:item_frame,distance=..5,nbt={Item:{}}] add hasItem");
manager.execute(source, "execute at " + playerName + " as @e[type=item_frame,distance=..5,tag=hasItem,limit=1,sort=nearest,nbt={Fixed:0b,Invisible:0b}]" + " run data merge entity @s {Invisible:1b,Fixed:1b}");
manager.execute(source, "execute at " + playerName + " run tag @e[type=minecraft:item_frame,distance=..5] remove hasItem");
return 1;
})).then(CommandManager.literal("show").executes((context -> {
ServerCommandSource playerSource = context.getSource();
ServerCommandSource source = playerSource.getServer().getCommandSource();
ServerPlayerEntity playerEntity = playerSource.getPlayer();
CommandManager manager = playerSource.getServer().getCommandManager();
String playerName = playerEntity.getName().getString();
manager.execute(source, "execute at " + playerName + " as @e[type=item_frame,distance=..5,limit=1,sort=nearest,nbt={Fixed:1b,Invisible:1b}]" + " run data merge entity @s {Invisible:0b,Fixed:0b}");
return 1;
})));
dispatcher.register(command);
}
Aggregations