Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run/
build/
.gradle/
gradle/
remappedSrc/

# IDE-related
.idea/
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'fabric-loom' version "${loom_version}"
id 'maven-publish'
}

Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.5
yarn_mappings=1.21.5+build.1
loader_version=0.16.13
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
loader_version=0.16.14
loom_version=1.11-SNAPSHOT
# Mod Properties
mod_version=1.1
maven_group=D7lan
archives_base_name=minecartsloadchunks
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.120.0+1.21.5
fabric_version=0.130.0+1.21.8
9 changes: 4 additions & 5 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/main/java/D7lan/minecartsloadchunks/MinecartsLoadChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.ChestMinecartEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkPos;
Expand Down Expand Up @@ -37,6 +38,15 @@ private void onServerTick(MinecraftServer server) {

for (EntityType<?> type : MINECART_TYPES) {
for (AbstractMinecartEntity minecart : world.getEntitiesByType((EntityType<AbstractMinecartEntity>) type, e -> true)) {
if (minecart instanceof ChestMinecartEntity chest) {
if (chest.getCommandTags().contains("minecartsloadchunks_ignore"))
continue;

if (chest.getLootTable() != null) {
chest.addCommandTag("minecartsloadchunks_ignore");
}
}

if (!getConfig().alwaysLoad) {
boolean isMoving = minecart.getVelocity().lengthSquared() > 1e-6;
if (isMoving) MINECART_LAST_MOVED.put(minecart.getUuid(), currentTick);
Expand Down