use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder in project endergetic by team-abnormals.
the class PlayerListMixin method removeBalloons.
@SuppressWarnings("deprecation")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/management/PlayerList;save(Lnet/minecraft/entity/player/ServerPlayerEntity;)V", shift = At.Shift.AFTER), method = "remove")
private void removeBalloons(ServerPlayerEntity player, CallbackInfo info) {
List<BolloomBalloonEntity> balloons = ((BalloonHolder) player).getBalloons();
if (!balloons.isEmpty()) {
ServerWorld serverWorld = (ServerWorld) player.level;
for (BolloomBalloonEntity balloon : balloons) {
serverWorld.despawn(balloon);
balloon.removed = true;
}
serverWorld.getChunk(player.xChunk, player.zChunk).markUnsaved();
}
}
use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder in project endergetic by team-abnormals.
the class EntityEvents method onPlayerSwing.
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void onPlayerSwing(InputEvent.ClickInputEvent event) {
if (event.isAttack()) {
ClientPlayerEntity player = ClientInfo.getClientPlayer();
if (player.xRot > -25.0F)
return;
Entity ridingEntity = player.getVehicle();
if (ridingEntity instanceof BoatEntity && BolloomBalloonItem.hasNoEntityTarget(player) && EntityUtil.rayTrace(player, BolloomBalloonItem.getPlayerReach(player), 1.0F).getType() == Type.MISS) {
List<BolloomBalloonEntity> balloons = ((BalloonHolder) ridingEntity).getBalloons();
if (!balloons.isEmpty()) {
Minecraft.getInstance().gameMode.attack(player, balloons.get(player.getRandom().nextInt(balloons.size())));
event.setSwingHand(true);
}
}
}
}
use of com.minecraftabnormals.endergetic.core.interfaces.BalloonHolder in project endergetic by team-abnormals.
the class S2CUpdateBalloonsMessage method handle.
public static void handle(S2CUpdateBalloonsMessage message, Supplier<NetworkEvent.Context> ctx) {
NetworkEvent.Context context = ctx.get();
if (context.getDirection().getReceptionSide() == LogicalSide.CLIENT) {
context.enqueueWork(() -> {
World world = ClientInfo.getClientPlayerWorld();
Entity entity = world.getEntity(message.entityId);
if (entity == null) {
EndergeticExpansion.LOGGER.warn("Received balloons for unknown entity!");
} else {
((BalloonHolder) entity).detachBalloons();
for (int id : message.balloonIds) {
Entity balloon = world.getEntity(id);
if (balloon instanceof BolloomBalloonEntity) {
((BolloomBalloonEntity) balloon).attachToEntity(entity);
}
}
}
});
}
context.setPacketHandled(true);
}
Aggregations