Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Sep 29, 2024
2 parents ecdfde4 + c58dc21 commit 5a4900d
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 2 deletions.
Binary file added docs/assets/visibleSpectators.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ Optimize dragon respawn method. Ported from carpet AMS addition.
- Default value: `false`
- Categories: `OPTIMIZATION`, `VULPEUS`

### visibleSpectators

Makes spectators visible to non-spectator players. Ported from totos carpet tweaks.

![visibleSpectators](assets/visibleSpectators.png)

- Type: `boolean`
- Default value: `false`
- Categories: `SURVIVAL`, `VULPEUS`

## Command

### custom-load
Expand Down
10 changes: 10 additions & 0 deletions docs/ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ StackOverflowError によるサーバーのクラッシュの無効化。
- 既定値: `false`
- 分類: `OPTIMIZATION`, `VULPEUS`

### visibleSpectators

スペクテーターのプレイヤーをスペクテーターではないプレイヤーから見えるようにする。totots carpet tweaks からの移植。

![visibleSpectators](assets/visibleSpectators.png)

- 型式: `boolean`
- 既定値: `false`
- 分類: `SURVIVAL`, `VULPEUS`

## コマンド

### custom-load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ public class VulpeusCarpetSettings {
@Rule(categories = {OPTIMIZATION, VULPEUS})
public static boolean optimizedDragonRespawn = false;

@Rule(categories = {SURVIVAL, VULPEUS})
public static boolean visibleSpectators = false;

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* This file is part of the VulpeusCarpet project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 VulpeusServer and contributors
*
* VulpeusCarpet is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VulpeusCarpet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VulpeusCarpet. If not, see <https://www.gnu.org/licenses/>.
*/

package com.vulpeus.vulpeus_carpet.mixins.logEntityCount;

import net.minecraft.entity.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of the VulpeusCarpet project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 VulpeusServer and contributors
*
* VulpeusCarpet is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VulpeusCarpet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with VulpeusCarpet. If not, see <https://www.gnu.org/licenses/>.
*/

package com.vulpeus.vulpeus_carpet.mixins.visibleSpectators;

import com.mojang.authlib.GameProfile;
import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.CallbackInfoReturnable;

@Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity extends PlayerEntity {

public MixinServerPlayerEntity(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(world, pos, yaw, gameProfile);
}

@Shadow
public abstract Entity getCameraEntity();
@Shadow
public abstract boolean isSpectator();

@Inject(method = "updatePotionVisibility", at = @At("HEAD"), cancellable = true)
private void noInvisibleSpectators(CallbackInfo ci) {
if (VulpeusCarpetSettings.visibleSpectators) {
if (isSpectator()) clearPotionSwirls();
else super.updatePotionVisibility();
ci.cancel();
}
}

@Inject(method = "canBeSpectated", at = @At("HEAD"), cancellable = true)
private void allowSpectatorsToBeSpectated(ServerPlayerEntity spectator, CallbackInfoReturnable<Boolean> cir) {
if (VulpeusCarpetSettings.visibleSpectators) {
if (spectator.isSpectator()) cir.setReturnValue(getCameraEntity() == this);
else cir.setReturnValue(super.canBeSpectated(spectator));
}
}
}
5 changes: 4 additions & 1 deletion src/main/resources/assets/vulpeus_carpet/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ carpet:
desc: fixed MC-254100

optimizedDragonRespawn:
desc: Optimize dragon respawn method. Ported from carpet AMS addition.
desc: Optimize dragon respawn method. Ported from carpet AMS addition.

visibleSpectators:
desc: Makes spectators visible to non-spectator players. Ported from totos carpet tweaks.
3 changes: 2 additions & 1 deletion src/main/resources/vulpeus_carpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"optimizedDragonRespawn.IMixinBlockPatternTestTransform",
"optimizedDragonRespawn.MixinEnderDragonFight",
"playerActions.PlayerCommandMixin",
"playerActions.ServerPlayerEntityMixin"
"playerActions.ServerPlayerEntityMixin",
"visibleSpectators.MixinServerPlayerEntity"
],
"client": [
],
Expand Down

0 comments on commit 5a4900d

Please sign in to comment.