-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/main' into 1.20.4-f…
…abric
- Loading branch information
Showing
8 changed files
with
83 additions
and
45 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
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
37 changes: 37 additions & 0 deletions
37
...ntini/commander/impl/expression/extensions/convert/attributes/EntityAttributesStruct.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,37 @@ | ||
package me.melontini.commander.impl.expression.extensions.convert.attributes; | ||
|
||
import com.ezylang.evalex.data.EvaluationValue; | ||
import me.melontini.commander.impl.expression.extensions.ProxyMap; | ||
import net.minecraft.entity.attribute.AttributeContainer; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public class EntityAttributesStruct extends ProxyMap { | ||
|
||
private final AttributeContainer container; | ||
|
||
public EntityAttributesStruct(AttributeContainer container) { | ||
this.container = container; | ||
} | ||
|
||
@Override | ||
public boolean containsKey(Object key) { | ||
if (!(key instanceof String s)) return false; | ||
var attr = Registries.ATTRIBUTE.get(new Identifier(s)); | ||
if (attr == null) return false; | ||
return container.hasAttribute(attr); | ||
} | ||
|
||
@Override | ||
public EvaluationValue get(Object key) { | ||
if (!(key instanceof String s)) return EvaluationValue.nullValue(); | ||
return EvaluationValue.numberValue(BigDecimal.valueOf(container.getValue(Registries.ATTRIBUTE.get(new Identifier(s))))); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.valueOf(container.toNbt()); | ||
} | ||
} |
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