Fixed team color using client method (#965)

This commit is contained in:
replaceitem authored and GitHub committed 2021-06-28 22:52:40 -03:00
1 parent cd50919a90
commit 83afa95d98
3 files changed
+16 -1

No files matched your search

@@ -0,0 +1,13 @@
package carpet.mixins;
import net.minecraft.scoreboard.Team;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(Team.class)
public interface Team_scarpetMixin
{
@Accessor("color")
Formatting getColor();
}
@@ -2,6 +2,7 @@ package carpet.script.api;
import carpet.mixins.ScoreboardObjective_scarpetMixin;
import carpet.mixins.Scoreboard_scarpetMixin;
import carpet.mixins.Team_scarpetMixin;
import carpet.script.CarpetContext;
import carpet.script.Expression;
import carpet.script.LazyValue;
@@ -337,7 +338,7 @@ public class Scoreboards {
team.setCollisionRule(collisionRule);
break;
case "color":
if(!modifying) return new StringValue(team.getColor().getName());
if(!modifying) return new StringValue(((Team_scarpetMixin) team).getColor().getName());
if(!(settingVal instanceof StringValue)) throw new InternalExpressionException("'team_property' requires a string as the third argument for the property " + propertyVal.getString());
Formatting color = Formatting.byName(settingVal.getString().toUpperCase());
if(color == null || !color.isColor()) throw new InternalExpressionException("Unknown value for property " + propertyVal.getString() + ": " + settingVal.getString());