Skip to content

Commit 8f86748

Browse files
feat: port to 1.19.2
1 parent 33ab39b commit 8f86748

File tree

10 files changed

+42
-44
lines changed

10 files changed

+42
-44
lines changed

Diff for: CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Kube Utils Changelog
22

3-
## [0.1.3]
3+
## [1.0.0]
44

55
### Added
66

7-
- Released for 1.18.2
7+
- Ported 1.19.2

Diff for: build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ dependencies {
4848

4949
forge "net.minecraftforge:forge:${project.forge_version}"
5050

51-
modApi "dev.latvian.mods:kubejs-forge:1802.5.4-build.533"
52-
modApi "dev.latvian.mods:rhino-forge:1802.1.14-build.206"
51+
modApi "dev.latvian.mods:kubejs-forge:1902.6.0-build.140"
52+
modApi "dev.latvian.mods:rhino-forge:1902.2.2-build.264"
5353
}
5454

5555
processResources {

Diff for: gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
33

44
loom.platform=forge
55

6-
minecraft_version=1.18.2
7-
forge_version=1.18.2-40.1.54
6+
minecraft_version=1.19.2
7+
forge_version=1.19.2-43.2.3
88

9-
mod_version=0.1.3
9+
mod_version=1.0.0
1010
maven_group=pro.mikey.mods
1111
archives_base_name=kube-utils
1212
mod_id=kubeutils

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/KubeUtilsPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class KubeUtilsPlugin extends KubeJSPlugin {
77
@Override
8-
public void addBindings(BindingsEvent event) {
8+
public void registerBindings(BindingsEvent event) {
99
event.add("Ku", BaseBindings.class);
1010
}
1111
}

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/modules/Fluids.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public List<Fluid> getFluidsByNamespace(@Nullable String namespace) {
2727
}
2828

2929
return ForgeRegistries.FLUIDS.getValues().stream()
30-
.filter(e -> e.getRegistryName().getNamespace().equals(namespace))
30+
.filter(e -> ForgeRegistries.FLUIDS.getKey(e).getNamespace().equals(namespace))
3131
.filter(this::notEmpty)
3232
.toList();
3333
}
@@ -40,13 +40,13 @@ public List<Fluid> getFluidsByNamespace(@Nullable String namespace) {
4040
* @return a list of fluids that belong to that namespace
4141
*/
4242
@Nullable
43-
public List<Fluid> getFluidsByNamespaces(@Nullable ListJS namespaces) {
43+
public List<Fluid> getFluidsByNamespaces(@Nullable List<String> namespaces) {
4444
if (namespaces == null || namespaces.isEmpty()) {
4545
return List.of();
4646
}
4747

4848
return ForgeRegistries.FLUIDS.getValues().stream()
49-
.filter(e -> namespaces.stream().anyMatch(x -> e.getRegistryName().getNamespace().equals(x)))
49+
.filter(e -> namespaces.stream().anyMatch(x -> ForgeRegistries.FLUIDS.getKey(e).getNamespace().equals(x)))
5050
.filter(this::notEmpty)
5151
.toList();
5252
}

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/modules/LevelUtils.java

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package pro.mikey.kubeutils.kubejs.modules;
22

3-
import dev.latvian.mods.kubejs.level.ServerLevelJS;
43
import net.minecraft.core.BlockPos;
54
import net.minecraft.core.Registry;
65
import net.minecraft.core.Vec3i;
@@ -11,11 +10,12 @@
1110
import net.minecraft.world.entity.LivingEntity;
1211
import net.minecraft.world.level.block.Block;
1312
import net.minecraft.world.level.block.state.BlockState;
14-
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
1513
import net.minecraft.world.level.levelgen.structure.BoundingBox;
14+
import net.minecraft.world.level.levelgen.structure.Structure;
1615
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
1716
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
1817
import net.minecraft.world.phys.AABB;
18+
import net.minecraftforge.registries.ForgeRegistries;
1919
import pro.mikey.kubeutils.KubeUtils;
2020

2121
import javax.annotation.Nullable;
@@ -26,8 +26,8 @@ public class LevelUtils {
2626
private static final ResourceLocation UNKNOWN = new ResourceLocation(KubeUtils.getId(), "unknown");
2727
private final ServerLevel level;
2828

29-
public LevelUtils(ServerLevelJS level) {
30-
this.level = level.getMinecraftLevel();
29+
public LevelUtils(ServerLevel level) {
30+
this.level = level.getLevel();
3131
}
3232

3333
/**
@@ -62,7 +62,7 @@ public List<LivingEntity> findEntitiesWithinRadius(ResourceLocation entityId, Bl
6262
continue;
6363
}
6464

65-
ResourceLocation registryName = current.getType().getRegistryName();
65+
ResourceLocation registryName = ForgeRegistries.ENTITY_TYPES.getKey(current.getType());
6666
if (registryName == null || !registryName.equals(entityId)) {
6767
continue;
6868
}
@@ -178,29 +178,28 @@ public List<BlockPos> seekCollectionOfBlocks(BlockPos startingPos, int range, Pr
178178
* @return if the structure is there.
179179
*/
180180
public boolean isStructureAtLocation(BlockPos pos, ResourceLocation structureId) {
181-
ConfiguredStructureFeature<?, ?> configuredStructureFeature = level.getServer().registryAccess().registryOrThrow(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).get(structureId);
182-
if (configuredStructureFeature == null) {
181+
Structure structure = level.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).get(structureId);
182+
if (structure == null) {
183183
return false;
184184
}
185185

186-
return level.structureFeatureManager().getStructureAt(pos, configuredStructureFeature).isValid();
186+
return level.structureManager().getStructureAt(pos, structure).isValid();
187187
}
188188

189189
/**
190190
* Gets all the structures at a given block location
191191
*
192-
* @param pos the block location you want to check
193-
*
192+
* @param pos the block location you want to check
194193
* @return a list (set) of the structures at that location
195194
*/
196-
public Set<ConfiguredStructureFeature<?, ?>> getStructuresAtLocation(BlockPos pos) {
197-
return level.structureFeatureManager().getAllStructuresAt(pos).keySet();
195+
public Set<Structure> getStructuresAtLocation(BlockPos pos) {
196+
return level.structureManager().getAllStructuresAt(pos).keySet();
198197
}
199198

200199
/**
201200
* Gets all the structure ids at a given location, just like {@link #getRandomLocation(BlockPos, int, int)}
202201
*/
203202
public List<ResourceLocation> getStructureIdsAtLocation(BlockPos pos) {
204-
return getStructuresAtLocation(pos).stream().map(e -> e.feature.getRegistryName() == null ? UNKNOWN : e.feature.getRegistryName()).toList();
203+
return getStructuresAtLocation(pos).stream().map(e -> Registry.STRUCTURE_TYPES.getKey(e.type())).toList();
205204
}
206205
}

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/modules/ListActions.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
77

8+
import java.util.List;
9+
import java.util.Map;
10+
811
public class ListActions {
912
private static final Logger LOGGER = LoggerFactory.getLogger(ListActions.class);
1013

@@ -16,22 +19,23 @@ public ListActions() {
1619
* which is type cast to a double. This method will then use the weight to find a single item based on
1720
* a random selection that takes the items weight into consideration
1821
*
19-
* @param items {@link MapJS} of {@link Object} entry, and a {@link Object} weight
22+
* @param items List of Map<{weight: double, entry: any}>
2023
*
2124
* @return one of the items from the array
2225
*/
23-
public Object getEntryBasedOnWeight(ListJS items) {
26+
public Object getEntryBasedOnWeight(Object... items) {
2427
double totalWeight = 0.0;
25-
for (Object i : items) {
26-
totalWeight += ((Number) ((MapJS) i).get("weight")).doubleValue();
28+
var inputs = ListJS.orSelf(items).stream().map(MapJS::of).toList();
29+
for (Map<?, ?> input : inputs) {
30+
totalWeight += ((Number) input.get("weight")).doubleValue();
2731
}
2832

2933
int idx = 0;
30-
for (double r = Math.random() * totalWeight; idx < items.size() - 1; ++idx) {
31-
r -= ((Number) ((MapJS) items.get(idx)).get("weight")).doubleValue();
34+
for (double r = Math.random() * totalWeight; idx < inputs.size() - 1; ++idx) {
35+
r -= ((Number) inputs.get(idx).get("weight")).doubleValue();
3236
if (r <= 0.0) break;
3337
}
3438

35-
return ((MapJS) items.get(idx)).get("entry");
39+
return inputs.get(idx).get("entry");
3640
}
3741
}

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/modules/StreamsHelper.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package pro.mikey.kubeutils.kubejs.modules;
22

33
import dev.latvian.mods.kubejs.level.BlockContainerJS;
4-
import dev.latvian.mods.kubejs.level.ServerLevelJS;
54
import net.minecraft.core.BlockPos;
5+
import net.minecraft.server.level.ServerLevel;
66

77
import java.util.List;
88

@@ -18,7 +18,7 @@ public StreamsHelper() {
1818
*
1919
* @return List of {@link BlockContainerJS}
2020
*/
21-
public List<BlockContainerJS> mapToBlock(ServerLevelJS level, List<BlockPos> locations) {
22-
return locations.stream().map(level::getBlock).toList();
21+
public List<BlockContainerJS> mapToBlock(ServerLevel level, List<BlockPos> locations) {
22+
return locations.stream().map(level::kjs$getBlock).toList();
2323
}
2424
}

Diff for: src/main/java/pro/mikey/kubeutils/kubejs/modules/Utils.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package pro.mikey.kubeutils.kubejs.modules;
22

3-
import dev.latvian.mods.kubejs.entity.EntityJS;
43
import dev.latvian.mods.kubejs.item.ItemStackJS;
54
import dev.latvian.mods.kubejs.level.BlockContainerJS;
65
import dev.latvian.mods.rhino.Undefined;
76
import net.minecraft.resources.ResourceLocation;
8-
import net.minecraft.world.entity.Entity;
9-
import net.minecraft.world.entity.LivingEntity;
107
import net.minecraft.world.entity.item.ItemEntity;
118
import net.minecraft.world.item.Item;
129
import net.minecraft.world.item.ItemStack;
@@ -55,7 +52,7 @@ public boolean nullOrEmpty(Object entry) {
5552
return ((ItemEntity) entry).isRemoved() || ((ItemEntity) entry).getItem().isEmpty();
5653
}
5754

58-
return entry instanceof ItemStackJS && entry == ItemStackJS.EMPTY;
55+
return false;
5956
}
6057

6158
/**

Diff for: src/main/resources/META-INF/mods.toml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
modLoader = "javafml"
2-
loaderVersion = "[40,)"
2+
loaderVersion = "[43,)"
33
license = "GPL3"
44

55
[[mods]]
@@ -14,22 +14,20 @@ Provides extra methods and tools to the standard KubeJS mod
1414
[[dependencies.kubeutils]]
1515
modId = "forge"
1616
mandatory = true
17-
versionRange = "[40,)"
17+
versionRange = "[43,)"
1818
ordering = "NONE"
1919
side = "BOTH"
2020

2121
[[dependencies.kubeutils]]
2222
modId = "minecraft"
2323
mandatory = true
24-
versionRange = "[1.18.2,)"
24+
versionRange = "[1.19.2,)"
2525
ordering = "NONE"
2626
side = "BOTH"
2727

2828
[[dependencies.kubeutils]]
2929
modId = "kubejs"
3030
mandatory = true
31-
# See above for how to read this notation, this essentially means any
32-
# version of Minecraft from 1.18.2 (inclusive).
33-
versionRange = "[1802.5.4-build.533,)"
31+
versionRange = "[1902.6.0-build.140,)"
3432
ordering = "NONE"
3533
side = "BOTH"

0 commit comments

Comments
 (0)