-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #975 from booky10/feat/1.21.2-update
1.21.2/1.21.3 update
- Loading branch information
Showing
173 changed files
with
204,436 additions
and
1,586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
api/src/main/java/com/github/retrooper/packetevents/protocol/attribute/StaticAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* This file is part of packetevents - https://github.com/retrooper/packetevents | ||
* Copyright (C) 2024 retrooper and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.retrooper.packetevents.protocol.attribute; | ||
|
||
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity; | ||
import com.github.retrooper.packetevents.protocol.player.ClientVersion; | ||
import com.github.retrooper.packetevents.resources.ResourceLocation; | ||
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class StaticAttribute extends AbstractMappedEntity implements Attribute { | ||
|
||
private final @Nullable ResourceLocation legacyName; | ||
private final double defaultValue; | ||
private final double minValue; | ||
private final double maxValue; | ||
|
||
StaticAttribute( | ||
TypesBuilderData data, String legacyPrefix, | ||
double defaultValue, double minValue, double maxValue | ||
) { | ||
super(data); | ||
this.defaultValue = defaultValue; | ||
this.minValue = minValue; | ||
this.maxValue = maxValue; | ||
this.legacyName = legacyPrefix == null ? null : new ResourceLocation( | ||
data.getName().getNamespace(), legacyPrefix + "." + data.getName().getKey()); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getName(ClientVersion version) { | ||
assert this.data != null; // not marked as nullable in ctor | ||
return version.isNewerThanOrEquals(ClientVersion.V_1_21_2) || this.legacyName == null | ||
? this.data.getName() : this.legacyName; | ||
} | ||
|
||
@Override | ||
public double getDefaultValue() { | ||
return this.defaultValue; | ||
} | ||
|
||
@Override | ||
public double getMinValue() { | ||
return this.minValue; | ||
} | ||
|
||
@Override | ||
public double getMaxValue() { | ||
return this.maxValue; | ||
} | ||
} |
Oops, something went wrong.