Skip to content

Commit d26609f

Browse files
committed
2.3.5 Release
1 parent bcbcc3a commit d26609f

File tree

8 files changed

+241
-91
lines changed

8 files changed

+241
-91
lines changed

changelog.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 2.3.4 MoLang Additions
1+
# 2.3.5 MoLang Additions
22

33
## Warning:
44

@@ -10,19 +10,12 @@
1010
## Added
1111

1212
* Added all the MoLang for:
13-
* Saddleable
14-
* Ownable
13+
* Attackable
14+
* Targeting
15+
* Leashable
1516

1617
## Changed
17-
18-
* Refactored some shared Entity Rendering code to reduce duplication.
19-
20-
### From Previous Beta's
21-
22-
* Added a TypeAdapter for the Animation Controllers.
23-
* Made the JSONMerger Static, so it can be used without instantiation.
24-
* Minor Cleanup in the EntityMoLang Registration.
25-
* And a lot of MoLang!!!!
18+
* Added a lot of readability improvements to the ArmorRenderer.
2619

2720
## Epilogue
2821

common/src/main/java/software/bluelib/BlueLibConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static <T> ServiceLoader<T> loadAll(@NotNull Class<T> pClazz) {
5959
public static final String MOD_NAME = "BlueLib";
6060

6161
@NotNull
62-
public static final String VERSION = "2.3.4";
62+
public static final String VERSION = "2.3.5";
6363

6464
@Nullable
6565
public static MinecraftServer server;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2024 BlueLib Contributors
3+
*
4+
* This Source Code Form is subject to the terms of the MIT License.
5+
* If a copy of the MIT License was not distributed with this file,
6+
* You can obtain one at https://opensource.org/licenses/MIT.
7+
*/
8+
package software.bluelib.api.molang.context.entity;
9+
10+
import java.util.function.Supplier;
11+
import net.minecraft.world.entity.Attackable;
12+
import org.jetbrains.annotations.NotNull;
13+
import software.bluelib.api.molang.context.BaseMoLangContext;
14+
15+
public class AttackableMoLang extends BaseMoLangContext {
16+
17+
public AttackableMoLang(@NotNull Supplier<Attackable> pAttackableSup) {
18+
Attackable attackableEntity = pAttackableSup.get();
19+
setVariable("get_last_attacker", attackableEntity.getLastAttacker());
20+
}
21+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (C) 2024 BlueLib Contributors
3+
*
4+
* This Source Code Form is subject to the terms of the MIT License.
5+
* If a copy of the MIT License was not distributed with this file,
6+
* You can obtain one at https://opensource.org/licenses/MIT.
7+
*/
8+
package software.bluelib.api.molang.context.entity;
9+
10+
import java.util.function.Supplier;
11+
import net.minecraft.nbt.CompoundTag;
12+
import net.minecraft.world.entity.Entity;
13+
import net.minecraft.world.entity.Leashable;
14+
import org.jetbrains.annotations.NotNull;
15+
import software.bluelib.api.molang.context.BaseMoLangContext;
16+
17+
public class LeashableMoLang extends BaseMoLangContext {
18+
19+
public LeashableMoLang(@NotNull Supplier<Leashable> pLeashableSup) {
20+
Leashable leashableEntity = pLeashableSup.get();
21+
setVariable("leash_tag", Leashable.LEASH_TAG);
22+
setVariable("leash_too_far_dist", Leashable.LEASH_TOO_FAR_DIST);
23+
setVariable("leash_elastic_dist", Leashable.LEASH_ELASTIC_DIST);
24+
setVariable("get_leash_data", leashableEntity.getLeashData());
25+
setVariable("is_leashed", leashableEntity.isLeashed());
26+
setVariable("can_have_a_leash_attached_to_it", leashableEntity.canHaveALeashAttachedToIt());
27+
setVariable("can_be_leashed", leashableEntity.canBeLeashed());
28+
setVariable("get_leash_holder", leashableEntity.getLeashHolder());
29+
30+
registerFunction("set_leash_data", (args, runtime) -> {
31+
if (args.size() != 1 || !(args.getFirst() instanceof Leashable.LeashData data)) {
32+
return leashableEntity.getLeashData();
33+
}
34+
leashableEntity.setLeashData(data);
35+
return leashableEntity.getLeashData();
36+
});
37+
38+
registerFunction("set_delayed_leash_holder_id", (args, runtime) -> {
39+
if (args.size() != 1 || !(args.getFirst() instanceof Integer data)) {
40+
return false;
41+
}
42+
leashableEntity.setDelayedLeashHolderId(data);
43+
return true;
44+
});
45+
46+
registerFunction("read_leash_data", (args, runtime) -> {
47+
if (args.size() != 1 || !(args.getFirst() instanceof CompoundTag data)) {
48+
return false;
49+
}
50+
return leashableEntity.readLeashData(data);
51+
});
52+
53+
registerFunction("write_leash_data", (args, runtime) -> {
54+
if (args.size() != 2 || (!(args.getFirst() instanceof CompoundTag) && !(args.get(1) instanceof Leashable.LeashData))) {
55+
return false;
56+
}
57+
CompoundTag data = (CompoundTag) args.getFirst();
58+
Leashable.LeashData leashData = (Leashable.LeashData) args.get(1);
59+
leashableEntity.writeLeashData(data, leashData);
60+
return leashableEntity.readLeashData(data);
61+
});
62+
63+
registerFunction("drop_leash", (args, runtime) -> {
64+
if (args.size() != 2 || (!(args.getFirst() instanceof Boolean) && !(args.get(1) instanceof Boolean))) {
65+
return false;
66+
}
67+
boolean sendPacket = (Boolean) args.getFirst();
68+
boolean dropItem = (Boolean) args.get(1);
69+
leashableEntity.dropLeash(sendPacket, dropItem);
70+
return true;
71+
});
72+
73+
registerFunction("handle_leash_at_distance", (args, runtime) -> {
74+
if (args.size() != 2 || (!(args.getFirst() instanceof Entity) && !(args.get(1) instanceof Number))) {
75+
return false;
76+
}
77+
Entity entity = (Entity) args.getFirst();
78+
float distance = ((Number) args.get(1)).floatValue();
79+
leashableEntity.handleLeashAtDistance(entity, distance);
80+
return true;
81+
});
82+
83+
registerFunction("leash_too_far_behaviour", (args, runtime) -> {
84+
leashableEntity.leashTooFarBehaviour();
85+
return true;
86+
});
87+
88+
registerFunction("close_range_leash_behaviour", (args, runtime) -> {
89+
if (args.size() != 1 || !(args.getFirst() instanceof Entity entity)) {
90+
return false;
91+
}
92+
leashableEntity.closeRangeLeashBehaviour(entity);
93+
return true;
94+
});
95+
96+
registerFunction("elastic_range_leash_behaviour", (args, runtime) -> {
97+
if (args.size() != 2 || (!(args.getFirst() instanceof Entity) && !(args.get(1) instanceof Number))) {
98+
return false;
99+
}
100+
Entity entity = (Entity) args.getFirst();
101+
float distance = ((Number) args.get(1)).floatValue();
102+
leashableEntity.elasticRangeLeashBehaviour(entity, distance);
103+
return true;
104+
});
105+
106+
registerFunction("set_leash_to", (args, runtime) -> {
107+
if (args.size() != 2 || (!(args.getFirst() instanceof Entity) && !(args.get(1) instanceof Boolean))) {
108+
return false;
109+
}
110+
Entity entity = (Entity) args.getFirst();
111+
boolean broadcast = (Boolean) args.get(1);
112+
leashableEntity.setLeashedTo(entity, broadcast);
113+
return true;
114+
});
115+
}
116+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) 2024 BlueLib Contributors
3+
*
4+
* This Source Code Form is subject to the terms of the MIT License.
5+
* If a copy of the MIT License was not distributed with this file,
6+
* You can obtain one at https://opensource.org/licenses/MIT.
7+
*/
8+
package software.bluelib.api.molang.context.entity;
9+
10+
import java.util.function.Supplier;
11+
import net.minecraft.world.entity.Targeting;
12+
import org.jetbrains.annotations.NotNull;
13+
import software.bluelib.api.molang.context.BaseMoLangContext;
14+
15+
public class TargetingMoLang extends BaseMoLangContext {
16+
17+
public TargetingMoLang(@NotNull Supplier<Targeting> pTargetingSup) {
18+
Targeting targetingEntity = pTargetingSup.get();
19+
setVariable("get_target", targetingEntity.getTarget());
20+
}
21+
}

common/src/main/java/software/bluelib/api/molang/registry/MoLangEntityRegistry.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public static void init() {
6464

6565
registerEntityContext(saddleableEntity -> saddleableEntity instanceof Saddleable ? new SaddleableMoLang(() -> (Saddleable) saddleableEntity) : null);
6666
registerEntityContext(ownableEntity -> ownableEntity instanceof OwnableEntity ? new OwnableMoLang(() -> (OwnableEntity) ownableEntity) : null);
67+
registerEntityContext(attackableEntity -> attackableEntity instanceof Attackable ? new AttackableMoLang(() -> (Attackable) attackableEntity) : null);
68+
registerEntityContext(targetingEntity -> targetingEntity instanceof Targeting ? new TargetingMoLang(() -> (Targeting) targetingEntity) : null);
69+
registerEntityContext(leashableEntity -> leashableEntity instanceof Leashable ? new LeashableMoLang(() -> (Leashable) leashableEntity) : null);
6770

6871
registerEntityContext(entity -> entity instanceof Entity ? new EntityMoLang(() -> entity) : null);
6972
}

0 commit comments

Comments
 (0)