|
1 | 1 | --- a/net/minecraft/world/entity/EntityType.java
|
2 | 2 | +++ b/net/minecraft/world/entity/EntityType.java
|
3 |
| -@@ -1070,6 +_,10 @@ |
| 3 | +@@ -1070,6 +_,11 @@ |
4 | 4 | private final float spawnDimensionsScale;
|
5 | 5 | private final FeatureFlagSet requiredFeatures;
|
6 | 6 |
|
7 | 7 | + private final java.util.function.Predicate<EntityType<?>> trackDeltasSupplier;
|
8 | 8 | + private final java.util.function.ToIntFunction<EntityType<?>> trackingRangeSupplier;
|
9 | 9 | + private final java.util.function.ToIntFunction<EntityType<?>> updateIntervalSupplier;
|
| 10 | ++ private final boolean onlyOpCanSetNbt; |
10 | 11 | +
|
11 | 12 | private static <T extends Entity> EntityType<T> register(ResourceKey<EntityType<?>> p_368669_, EntityType.Builder<T> p_368714_) {
|
12 | 13 | return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_368669_, p_368714_.build(p_368669_));
|
13 | 14 | }
|
14 |
| -@@ -1106,6 +_,28 @@ |
| 15 | +@@ -1106,6 +_,29 @@ |
15 | 16 | Optional<ResourceKey<LootTable>> p_368696_,
|
16 | 17 | FeatureFlagSet p_273518_
|
17 | 18 | ) {
|
18 |
| -+ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_368582_, p_368696_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier); |
| 19 | ++ this(p_273268_, p_272918_, p_273417_, p_273389_, p_273556_, p_272654_, p_273631_, p_272946_, p_338404_, p_272895_, p_273451_, p_368582_, p_368696_, p_273518_, EntityType::defaultTrackDeltasSupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, false); |
19 | 20 | + }
|
20 | 21 | +
|
21 | 22 | + public EntityType(
|
|
35 | 36 | + FeatureFlagSet p_273518_,
|
36 | 37 | + final java.util.function.Predicate<EntityType<?>> trackDeltasSupplier,
|
37 | 38 | + final java.util.function.ToIntFunction<EntityType<?>> trackingRangeSupplier,
|
38 |
| -+ final java.util.function.ToIntFunction<EntityType<?>> updateIntervalSupplier |
| 39 | ++ final java.util.function.ToIntFunction<EntityType<?>> updateIntervalSupplier, |
| 40 | ++ boolean onlyOpCanSetNbt |
39 | 41 | + ) {
|
40 | 42 | this.factory = p_273268_;
|
41 | 43 | this.category = p_272918_;
|
42 | 44 | this.canSpawnFarFromPlayer = p_272654_;
|
43 |
| -@@ -1120,6 +_,9 @@ |
| 45 | +@@ -1120,6 +_,10 @@ |
44 | 46 | this.descriptionId = p_368582_;
|
45 | 47 | this.lootTable = p_368696_;
|
46 | 48 | this.requiredFeatures = p_273518_;
|
47 | 49 | + this.trackDeltasSupplier = trackDeltasSupplier;
|
48 | 50 | + this.trackingRangeSupplier = trackingRangeSupplier;
|
49 | 51 | + this.updateIntervalSupplier = updateIntervalSupplier;
|
| 52 | ++ this.onlyOpCanSetNbt = onlyOpCanSetNbt; |
50 | 53 | }
|
51 | 54 |
|
52 | 55 | @Nullable
|
|
88 | 91 | return this != PLAYER
|
89 | 92 | && this != LLAMA_SPIT
|
90 | 93 | && this != WITHER
|
91 |
| -@@ -1462,6 +_,8 @@ |
| 94 | +@@ -1459,9 +_,12 @@ |
| 95 | + } |
| 96 | + |
| 97 | + public boolean onlyOpCanSetNbt() { |
| 98 | ++ if (onlyOpCanSetNbt) return true; |
92 | 99 | return OP_ONLY_CUSTOM_DATA.contains(this);
|
93 | 100 | }
|
94 | 101 |
|
|
97 | 104 | public static class Builder<T extends Entity> {
|
98 | 105 | private final EntityType.EntityFactory<T> factory;
|
99 | 106 | private final MobCategory category;
|
100 |
| -@@ -1481,6 +_,10 @@ |
| 107 | +@@ -1481,6 +_,11 @@ |
101 | 108 | );
|
102 | 109 | private DependantName<EntityType<?>, String> descriptionId = p_367918_ -> Util.makeDescriptionId("entity", p_367918_.location());
|
103 | 110 |
|
104 | 111 | + private java.util.function.Predicate<EntityType<?>> velocityUpdateSupplier = EntityType::defaultTrackDeltasSupplier;
|
105 | 112 | + private java.util.function.ToIntFunction<EntityType<?>> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier;
|
106 | 113 | + private java.util.function.ToIntFunction<EntityType<?>> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier;
|
| 114 | ++ private boolean onlyOpCanSetNbt = false; |
107 | 115 | +
|
108 | 116 | private Builder(EntityType.EntityFactory<T> p_20696_, MobCategory p_20697_) {
|
109 | 117 | this.factory = p_20696_;
|
110 | 118 | this.category = p_20697_;
|
111 |
| -@@ -1593,6 +_,21 @@ |
| 119 | +@@ -1593,6 +_,26 @@ |
112 | 120 | return this;
|
113 | 121 | }
|
114 | 122 |
|
|
126 | 134 | + this.velocityUpdateSupplier = t->value;
|
127 | 135 | + return this;
|
128 | 136 | + }
|
| 137 | ++ |
| 138 | ++ public EntityType.Builder<T> setOnlyOpCanSetNbt(boolean onlyOpCanSetNbt) { |
| 139 | ++ this.onlyOpCanSetNbt = onlyOpCanSetNbt; |
| 140 | ++ return this; |
| 141 | ++ } |
129 | 142 | +
|
130 | 143 | public EntityType<T> build(ResourceKey<EntityType<?>> p_368626_) {
|
131 | 144 | if (this.serialize) {
|
132 | 145 | Util.fetchChoiceType(References.ENTITY_TREE, p_368626_.location().toString());
|
133 |
| -@@ -1612,7 +_,10 @@ |
| 146 | +@@ -1612,7 +_,11 @@ |
134 | 147 | this.updateInterval,
|
135 | 148 | this.descriptionId.get(p_368626_),
|
136 | 149 | this.lootTable.get(p_368626_),
|
137 | 150 | - this.requiredFeatures
|
138 | 151 | + this.requiredFeatures,
|
139 |
| -+ velocityUpdateSupplier, |
140 |
| -+ trackingRangeSupplier, |
141 |
| -+ updateIntervalSupplier |
| 152 | ++ this.velocityUpdateSupplier, |
| 153 | ++ this.trackingRangeSupplier, |
| 154 | ++ this.updateIntervalSupplier, |
| 155 | ++ this.onlyOpCanSetNbt |
142 | 156 | );
|
143 | 157 | }
|
144 | 158 | }
|
0 commit comments