Skip to content
Open

Fabric #1128

Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ plugins {
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
id 'net.neoforged.moddev' version '2.0.49-beta' apply false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -655,23 +655,23 @@ public void setColorString(String colorString) {
this.colorString = colorString;
}

//@OnlyIn(Dist.CLIENT)
//
private BlockColor colorMultiplier;

//@OnlyIn(Dist.CLIENT)
//
public int treeFallColorMultiplier(BlockState state, BlockAndTintGetter level, BlockPos pos) {
return this.foliageColorMultiplier(state, level, pos);
}

//@OnlyIn(Dist.CLIENT)
//
public int foliageColorMultiplier(BlockState state, BlockAndTintGetter level, BlockPos pos) {
if (colorMultiplier == null) {
return 0x00FF00FF; //purple if broken
}
return colorMultiplier.getColor(state, level, pos, -1);
}

// @OnlyIn(Dist.CLIENT)
//
private void processColor() {
int color = -1;
if (this.colorNumber != null) {
Expand Down Expand Up @@ -700,7 +700,7 @@ private void processColor() {
this.colorMultiplier = (s, w, p, t) -> c == -1 ? Minecraft.getInstance().getBlockColors().getColor(getPrimitiveLeaves(), w, p, 0) : c;
}

//@OnlyIn(Dist.CLIENT)
//
public static void postInitClient() {
REGISTRY.getAll().forEach(LeavesProperties::processColor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.HashMap;
import java.util.Map;

//@OnlyIn(Dist.CLIENT)
//
public class BlockColorMultipliers {

private static Map<ResourceLocation, BlockColor> colorBase = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.HashMap;
import java.util.Map;

//@OnlyIn(Dist.CLIENT)
//
public class SoundInstanceHandler {

private static final Map<Integer, SoundInstance> instances = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.dtteam.dynamictrees.client;

import com.dtteam.dynamictrees.platform.Services;
import com.dtteam.dynamictrees.platform.ClientServices;
import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;

Expand Down Expand Up @@ -37,7 +37,7 @@ public PixelBuffer(TextureAtlasSprite sprite) {
pixels = new int[w * h];
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
pixels[calcPos(x, y)] = Services.MISC.getPixelRGBA(sprite, x, y);
pixels[calcPos(x, y)] = ClientServices.CLIENT.getPixelRGBA(sprite, x, y);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import net.minecraft.client.resources.metadata.animation.FrameSize;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)

public class ThickBranchRingsSprite extends SpriteContents {
private static final int RESOLUTION = 16;
private static final int LAYERS = 3;
Expand All @@ -18,7 +16,7 @@ public class ThickBranchRingsSprite extends SpriteContents {
};

public ThickBranchRingsSprite(ResourceLocation name, SpriteContents originalSprite){
super(name, getFrameSize(originalSprite), processImage(originalSprite.originalImage), originalSprite.metadata);
super(name, getFrameSize(originalSprite), processImage(originalSprite.originalImage), originalSprite.metadata());
}

private static FrameSize getFrameSize(SpriteContents sprite){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public interface AnimationHandler {

boolean shouldDie(FallingTreeEntity entity);

// @OnlyIn(Dist.CLIENT)
//
void renderTransform(FallingTreeEntity entity, float entityYaw, float partialTick, PoseStack poseStack);

// @OnlyIn(Dist.CLIENT)
//
boolean shouldRender(FallingTreeEntity entity, double x, double y, double z);

}
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public boolean shouldDie(FallingTreeEntity entity) {
}

@Override
// @OnlyIn(Dist.CLIENT)
//
public void renderTransform(FallingTreeEntity entity, float entityYaw, float partialTick, PoseStack poseStack) {

float yaw = Mth.wrapDegrees(MathUtils.angleDegreesInterpolate(entity.yRotO, entity.getYRot(), partialTick));
Expand All @@ -407,7 +407,7 @@ public void renderTransform(FallingTreeEntity entity, float entityYaw, float par
}

@Override
// @OnlyIn(Dist.CLIENT)
//
public boolean shouldRender(FallingTreeEntity entity, double x, double y, double z) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public boolean shouldDie(FallingTreeEntity entity) {
}

@Override
// @OnlyIn(Dist.CLIENT)
//
public void renderTransform(FallingTreeEntity entity, float entityYaw, float partialTick, PoseStack poseStack) {
final float yaw = Mth.wrapDegrees(MathUtils.angleDegreesInterpolate(entity.yRotO, entity.getYRot(), partialTick));
final float pit = Mth.wrapDegrees(MathUtils.angleDegreesInterpolate(entity.xRotO, entity.getXRot(), partialTick));
Expand All @@ -174,7 +174,7 @@ public void renderTransform(FallingTreeEntity entity, float entityYaw, float par
}

@Override
// @OnlyIn(Dist.CLIENT)
//
public boolean shouldRender(FallingTreeEntity entity, double x, double y, double z) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void handleMotion(FallingTreeEntity entity) {}
public void dropPayload(FallingTreeEntity entity) {}

@Override
// @OnlyIn(Dist.CLIENT)
//
public boolean shouldRender(FallingTreeEntity entity, double x, double y, double z) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dtteam.dynamictrees.model;

import com.dtteam.dynamictrees.entity.FallingTreeEntity;
import com.dtteam.dynamictrees.platform.Services;
import com.dtteam.dynamictrees.platform.ClientServices;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

Expand All @@ -17,7 +17,7 @@ public class FallingTreeEntityModelTrackerCache {
@Nullable
public static FallingTreeEntityModel getOrCreateModel(FallingTreeEntity entity) {
if (entity.level().isClientSide())
return models.computeIfAbsent(entity.getId(), i -> Services.MISC.newFallingTreeEntityModel(entity));
return models.computeIfAbsent(entity.getId(), i -> ClientServices.CLIENT.newFallingTreeEntityModel(entity));
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.dtteam.dynamictrees.platform;

import com.dtteam.dynamictrees.DynamicTrees;
import com.dtteam.dynamictrees.platform.services.IClientHelper;

import java.util.ServiceLoader;


public class ClientServices {

public static final IClientHelper CLIENT = load(IClientHelper.class);

public static <T> T load(Class<T> clazz) {
final T loadedService = ServiceLoader.load(clazz)
.findFirst()
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
DynamicTrees.LOG.debug("Loaded {} for service {}", loadedService, clazz);
return loadedService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dtteam.dynamictrees.platform.services;

import com.dtteam.dynamictrees.entity.FallingTreeEntity;
import com.dtteam.dynamictrees.model.FallingTreeEntityModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;


public interface IClientHelper {

int getPixelRGBA(TextureAtlasSprite sprite, int x, int y);


FallingTreeEntityModel newFallingTreeEntityModel(FallingTreeEntity entity);

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package com.dtteam.dynamictrees.platform.services;

import com.dtteam.dynamictrees.entity.FallingTreeEntity;
import com.dtteam.dynamictrees.model.FallingTreeEntityModel;
import com.dtteam.dynamictrees.worldgen.IDTBiomeHolderSet;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.Level;

public interface IMiscHelper {

int getPixelRGBA (TextureAtlasSprite sprite, int x, int y);

FallingTreeEntityModel newFallingTreeEntityModel (FallingTreeEntity entity);

boolean isLevelRestoringBlockSnapshots (Level level);
boolean isLevelRestoringBlockSnapshots(Level level);

MinecraftServer getCurrentServer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ public Species getSpeciesForLocation(LevelAccessor level, BlockPos trunkPos) {

protected float lootVolumeMultiplier = 1.0f;

// @OnlyIn(Dist.CLIENT)
//
public int woodRingColor; // For rooty blocks
// @OnlyIn(Dist.CLIENT)
//
public int woodBarkColor; // For rooty water

/**
Expand Down Expand Up @@ -432,7 +432,7 @@ public void setMaxBranchRadius(int maxBranchRadius) {
this.maxBranchRadius = maxBranchRadius;
}

// @OnlyIn(Dist.CLIENT)
//
public int getRootColor(BlockState state, boolean getBark) {
return getBark ? woodBarkColor : woodRingColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ accessible field net/minecraft/world/level/levelgen/feature/stateproviders/Weigh

accessible field net/minecraft/commands/synchronization/ArgumentTypeInfos BY_CLASS Ljava/util/Map;

accessible class net/minecraft/world/inventory/BrewingStandMenu$PotionSlot
accessible class net/minecraft/world/inventory/BrewingStandMenu$PotionSlot
accessible class net/minecraft/data/tags/IntrinsicHolderTagsProvider$IntrinsicTagAppender
accessible method net/minecraft/client/renderer/texture/SpriteContents metadata ()Lnet/minecraft/server/packs/resources/ResourceMetadata;
accessible field net/minecraft/client/renderer/texture/SpriteContents originalImage Lcom/mojang/blaze3d/platform/NativeImage;
accessible method net/minecraft/client/renderer/texture/atlas/SpriteSources register (Ljava/lang/String;Lcom/mojang/serialization/MapCodec;)Lnet/minecraft/client/renderer/texture/atlas/SpriteSourceType;
42 changes: 41 additions & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import me.modmuss50.mpp.ReleaseType

plugins {
id 'multiloader-loader'
id 'fabric-loom'
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
}

dependencies {
Expand All @@ -11,6 +14,7 @@ dependencies {
}
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"

}

loom {
Expand All @@ -34,6 +38,15 @@ loom {
ideConfigGenerated(true)
runDir('runs/server')
}
datagen {
client()
setConfigName('Fabric Datagen')
ideConfigGenerated(true)
runDir('runs/datagen')
vmArg("-Dfabric-api.datagen")
vmArg("-Dfabric-api.datagen.output-dir=${project(':common').file('src/generated/resources')}")
vmArg("-Dfabric-api.datagen.modid=${mod_id}")
}
}
repositories {
maven {
Expand All @@ -57,4 +70,31 @@ loom {
modImplementation "curse.maven:glitchcore-955399:5660741"
modImplementation "curse.maven:serene-seasons-291874:5753502"
}
}
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

def changelogFile = file("build/changelog.txt")

publishMods {
file = remapJar.archiveFile
displayName = "${mod_name.replace(' ','')}-Fabric-${minecraft_version} ${project.version}"
if (changelogFile.exists()) {
changelog.set(changelogFile.getText())
}
type = ReleaseType.of(versionType.toUpperCase())
modLoaders.add("fabric")
modLoaders.add("quilt")

curseforge {
projectId = "252818"
projectSlug = "dynamictrees"
minecraftVersions.add("1.21.1")
optional("dynamictreesplus")
}
modrinth {
projectId = "vdjF5PL5"
minecraftVersions.add("1.21.1")
optional("qaO9Dqpu")
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
package com.dtteam.dynamictrees;

import com.dtteam.dynamictrees.block.leaves.LeavesProperties;
import com.dtteam.dynamictrees.client.BlockColorMultipliers;
import com.dtteam.dynamictrees.config.DTConfigs;
import com.dtteam.dynamictrees.event.handler.CommonEventHandler;
import com.dtteam.dynamictrees.event.handler.ModEventHandler;
import com.dtteam.dynamictrees.event.handler.VanillaSaplingEventHandler;
import com.dtteam.dynamictrees.platform.FabricMiscHelper;
import com.dtteam.dynamictrees.registry.FabricRegistryHandler;
import com.dtteam.dynamictrees.registry.FabricRegistryLoader;
import com.dtteam.dynamictrees.worldgen.FabricBiomeModifications;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.loader.api.FabricLoader;

public class DynamicTreesFabric implements ModInitializer {

@Override
public void onInitialize() {
DTConfigs.registerConfigs(); //Must be first
DTConfigs.registerConfigs();

FabricRegistryHandler.setup(DynamicTrees.MOD_ID);

CommonEventHandler.RegisterEvents();
ModEventHandler.RegisterEvents();
VanillaSaplingEventHandler.register();

DynamicTrees.init();

FabricRegistryLoader.setup();

DynamicTrees.commonSetup();

FabricBiomeModifications.register();

ServerLifecycleEvents.SERVER_STARTING.register(server -> {
VanillaSaplingEventHandler.updateEnabled();
FabricMiscHelper.debugSpeciesRegistry();
});
Comment on lines +43 to +46
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FabricMiscHelper.debugSpeciesRegistry() logs multiple INFO lines on every server start. This looks like temporary debugging and will add noise for all users/servers. Please remove it or gate it behind a debug config (e.g., IConfigHelper.DEBUG) / log-level check.

Copilot uses AI. Check for mistakes.

ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
FabricMiscHelper.currentServer = null;
});

if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
LeavesProperties.postInitClient();
BlockColorMultipliers.cleanUp();
DynamicTreesFabricClient.registerBlockColors();
DynamicTreesFabricClient.discoverWoodColors();
});
}
}

}
Loading