Skip to content

Commit

Permalink
Merge branch '1.20.6' into 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Oct 13, 2024
2 parents f5f4193 + 42a87c2 commit 14a2a2e
Show file tree
Hide file tree
Showing 50 changed files with 1,062 additions and 99 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Make sure to clear this after each release
Put changelog here:

-----------------
- Added JavaDocs to classes that may be used frequently for ease of use outside FrozenBlock.
- Added a `disable` method to the `FrozenBiome` that prevents it from automatically being injected into worldgen.
- The `windoverride` command has been revamped and renamed to `wind.`
- Added the `EntityLootHelper` class, currently containing the `shouldSmeltLoot` method.
Expand All @@ -19,3 +20,13 @@ Put changelog here:
- Currently, these capes can only be accessed through FrozenLib's config.
- An optional list of allowed UUIDs can be defined for capes.
- Fixed the `ColumnWithDiskFeature` not generating as intended.
- Added an API to send and receive files between the client and server.
- This is useful in cases where, for example, you want to send a screenshot from Minecraft to the server to be used as a texture.
- This can be disabled both client-side and server-side separately in FrozenLib's config.
- Significantly optimized DataFixing.
- In cases where something like a structure with a pre-defined set of DataVersions is loaded and a separate mod with a DataFixer is loaded, the new DataFixer would run for every structure piece.
- This would cause tremendous amounts of lag while not fixing any data, as no fixable data was present to begin with.
- Due to this optimization, we recommend that any mods using FrozenLib implement a DataFixer, even an empty one, so it will have a 100% success rate of DataFixing.
- Added `IS_DATAGEN` to the `FrozenBools` class.
- This is useful in cases you want to remove a BlockState Property during datagen so it doesn't create unnecessary data.
- `PlayerDamageSourceSounds` has been renamed to `PlayerDamageTypeSounds,` and now takes DamageType as a parameter instead of DamageSource.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
}

plugins {
id("fabric-loom") version("+")
id("fabric-loom") version("1.7.+")
id("org.ajoberstar.grgit") version("+")
id("org.quiltmc.gradle.licenser") version("+")
id("com.modrinth.minotaur") version("+")
Expand All @@ -30,7 +30,7 @@ plugins {
idea
`java-library`
java
kotlin("jvm") version("2.0.10")
kotlin("jvm") version("2.0.20")
}

val minecraft_version: String by project
Expand Down Expand Up @@ -268,10 +268,10 @@ dependencies {

// ExJson
//relocModApi("org.exjson:xjs-data:$xjs_data_version")
relocModApi(files("libs/xjs-data-0.5.jar"))
relocModApi("com.github.Treetrain1:xjs-data:infinity-compat-SNAPSHOT")
relocModApi("org.exjson:xjs-compat:$xjs_compat_version")
relocModApi("com.personthecat:fresult:$fresult_version")
compileOnly("org.projectlombok:lombok:1.18.30")?.let { annotationProcessor(it) }
compileOnly("org.projectlombok:lombok:1.18.34")?.let { annotationProcessor(it) }

"testmodImplementation"(sourceSets.main.get().output)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Binary file removed libs/xjs-data-0.5.jar
Binary file not shown.
13 changes: 13 additions & 0 deletions src/main/java/net/frozenblock/lib/FrozenBools.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.Bootstrap;
import java.util.Arrays;

public class FrozenBools {

Expand All @@ -29,6 +30,18 @@ public class FrozenBools {

public static boolean useNewDripstoneLiquid = false;

// DATAGEN
/**
* Whether the current instance is running in datagen mode.
*/
public static final boolean IS_DATAGEN = isDatagen();

private static boolean isDatagen() {
return Arrays.stream(
FabricLoader.getInstance().getLaunchArguments(true)
).toList().stream().anyMatch(string -> string.contains("datagen"));
}

// MOD LOADERS
public static final boolean IS_FABRIC = hasMod("fabricloader") && !hasMod("quilt_loader") && !hasMod("connector");
public static final boolean IS_QUILT = hasMod("quilt_loader");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;

/**
* A helper class for adding new {@link MobEffect}s to the Beacon.
*/
public class BeaconEffectRegistry {
/**
* Adds a {@link MobEffect} to the Beacon.
*
* @param effect The {@link MobEffect} to add.
* @param tier The tier to add the {@link MobEffect} to. Tier 4 contains Regeneration and can be used simultaneously with tier 1-3 effects.
*/
public static void register(MobEffect effect, int tier) {
if (tier <= 0 || tier >= 4) {
throw new IllegalArgumentException("Attempted to register Beacon effect " + effect.getDisplayName().getString() + " at tier " + tier + ". Tier must be between 1 and 4.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;
import org.joml.Quaternionf;

/**
* A {@link BlockEntityRenderer} that renders a given texture as a billboard, like a particle.
*/
@Environment(EnvType.CLIENT)
public abstract class BillboardBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T> {
private final ModelPart base;
Expand All @@ -50,17 +54,21 @@ public BillboardBlockEntityRenderer(Context ctx) {
public static LayerDefinition getTexturedModelData() {
MeshDefinition modelData = new MeshDefinition();
PartDefinition modelPartData = modelData.getRoot();
modelPartData.addOrReplaceChild("base", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -16.0F, 0.0F, 16.0F, 16.0F, 0.0F), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, (float) Math.PI, 0.0F, 0.0F));
modelPartData.addOrReplaceChild("base", CubeListBuilder.create()
.texOffs(0, 0)
.addBox(-8F, -16F, 0F, 16F, 16F, 0.0F),
PartPose.offsetAndRotation(0F, 0F, 0F, Mth.PI, 0F, 0F)
);
return LayerDefinition.create(modelData, 16, 16);
}

private final Quaternionf rotation = new Quaternionf(0F, 0F, 0F, 1F);

@Override
public void render(@NotNull T entity, float tickDelta, @NotNull PoseStack poseStack, @NotNull MultiBufferSource vertexConsumers, int light, int overlay) {
this.rotation.set(0.0f, 0.0f, 0.0f, 1.0f);
this.rotation.set(0F, 0F, 0F, 1F);
this.rotation.mul(Axis.YP.rotationDegrees(-Minecraft.getInstance().gameRenderer.getMainCamera().yRot));
poseStack.translate(0.5, 0, 0.5);
poseStack.translate(0.5F, 0F, 0.5F);
poseStack.pushPose();
poseStack.mulPose(this.rotation);
this.base.render(poseStack, vertexConsumers.getBuffer(RenderType.entityCutout(this.getTexture(entity))), light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public Integer version() {
}

/**
* @return The current config instance with modifications if applicable
* @return The current config instance with modifications if applicable.
*/
public T config() {
if (this.supportsModification()) return ConfigModification.modifyConfig(this, this.instance(), false);
return this.instance();
}

/**
* @return The current config instance with config sync modifications
* @return The current config instance with config sync modifications.
* @since 1.5
*/
public T configWithSync() {
Expand All @@ -122,7 +122,7 @@ public boolean supportsSync() {
}

/**
* @return The unmodified current config instance
* @return The unmodified current config instance.
*/
public T instance() {
return this.configInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import org.jetbrains.annotations.NotNull;

/**
* Wrapper class for modifying configs
* @param modification The consumer for applying modifications
* @param <T> The type of the config class
* Wrapper class for modifying configs.
* @param modification The consumer for applying modifications.
* @param <T> The type of the config class.
*/
public record ConfigModification<T>(Consumer<T> modification) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import net.frozenblock.lib.config.api.instance.Config;
import net.frozenblock.lib.config.api.instance.ConfigModification;

/**
* Used to integrate config syncing with Cloth Config.
*/
@Environment(EnvType.CLIENT)
public interface DisableableWidgetInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ public void onSave() throws Exception {
public void onSync(FrozenLibConfig syncInstance) {
var config = this.config();
USE_WIND_ON_NON_FROZEN_SERVERS = config.useWindOnNonFrozenServers;
FILE_TRANSFER_SERVER = config.fileTransferServer;
FILE_TRANSFER_CLIENT = config.fileTransferClient;
IS_DEBUG = config.isDebug && FabricLoader.getInstance().isDevelopmentEnvironment();
}
}
);

public static volatile boolean USE_WIND_ON_NON_FROZEN_SERVERS = true;
public static volatile boolean FILE_TRANSFER_SERVER = true;
public static volatile boolean FILE_TRANSFER_CLIENT = true;
public static volatile boolean IS_DEBUG = false;

@Comment("Mods may override any of these options, but the config file will not change.")
Expand All @@ -77,6 +81,12 @@ public void onSync(FrozenLibConfig syncInstance) {
@EntrySyncData("wardenSpawnTrackerCommand")
public boolean wardenSpawnTrackerCommand = false;

@EntrySyncData("fileTransferServer")
public boolean fileTransferServer = true;

@EntrySyncData(value = "fileTransferClient", behavior = SyncBehavior.UNSYNCABLE)
public boolean fileTransferClient = true;

@EntrySyncData(value = "cape", behavior = SyncBehavior.UNSYNCABLE)
public String cape = FrozenSharedConstants.string("dummy");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ private static void setupEntries(@NotNull ConfigCategory category, @NotNull Conf
)
);

var fileTransferServer = category.addEntry(
FrozenClothConfig.syncedEntry(
entryBuilder.startBooleanToggle(text("file_transfer_server"), modifiedConfig.fileTransferServer)
.setDefaultValue(defaultConfig.fileTransferServer)
.setSaveConsumer(newValue -> config.fileTransferServer = newValue)
.setTooltip(tooltip("file_transfer_server"))
.build(),
config.getClass(),
"fileTransferServer",
configInstance
)
);

var fileTransferClient = category.addEntry(
FrozenClothConfig.syncedEntry(
entryBuilder.startBooleanToggle(text("file_transfer_client"), modifiedConfig.fileTransferClient)
.setDefaultValue(defaultConfig.fileTransferClient)
.setSaveConsumer(newValue -> config.fileTransferClient = newValue)
.setTooltip(tooltip("file_transfer_client"))
.build(),
config.getClass(),
"fileTransferClient",
configInstance
)
);

var disabledDataFixTypes = FrozenClothConfig.syncedEntry(
entryBuilder.startStrList(text("disabled_datafix_types"), modifiedConfig.dataFixer.disabledDataFixTypes)
.setDefaultValue(defaultConfig.dataFixer.disabledDataFixTypes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;

public final class ConfigCommand {
private ConfigCommand() {}

public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
public static void register(@NotNull CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal("frozenlib_config")
.then(Commands.literal("reload")
.then(Commands.argument("modId", StringArgumentType.string())
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/net/frozenblock/lib/core/client/api/FrustumUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
@Environment(EnvType.CLIENT)
public class FrustumUtil {

/**
* Returns if an area is visible in the client's frustum.
*
* @param aabb The area to check.
* @return if an area is visible in the client's frustum.
*/
public static boolean isVisible(AABB aabb) {
Frustum frustum = Minecraft.getInstance().levelRenderer.cullingFrustum;
if (frustum != null) {
Expand All @@ -35,6 +41,13 @@ public static boolean isVisible(AABB aabb) {
return true;
}

/**
* Returns if a position is visible in the client's frustum.
*
* @param pos The position to check.
* @param area The area around the position to check.
* @return if a position is visible in the client's frustum.
*/
public static boolean isVisible(Vec3 pos, double area) {
return isVisible(AABB.ofSize(pos, area, area, area));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.util.Optional;
import net.minecraft.util.datafix.fixes.References;

/**
* A {@link DataFix} specialized for fixing the name of a BlockState Property.
*/
public class BlockStateRenameFix extends DataFix {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.util.datafix.schemas.NamespacedSchema;

/**
* A {@link DataFix} specialized for fixing the name of an entity.
*/
public abstract class FrozenEntityRenameFix extends DataFix {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
@Environment(EnvType.CLIENT)
public class DebugRendererEvents {

/**
* An event that triggers upon Minecraft's debug renderers being created.
*/
public static final Event<DebugRenderersCreated> DEBUG_RENDERERS_CREATED = FrozenEvents.createEnvironmentEvent(
DebugRenderersCreated.class,
callbacks -> (client) -> {
Expand Down
21 changes: 6 additions & 15 deletions src/main/java/net/frozenblock/lib/entity/api/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,14 @@ public static void clearEntitiesPerLevel(ServerLevel level) {
ENTITIES_PER_LEVEL.remove(level);
}

/**
* Returns a {@link List} of entities in the {@link ServerLevel}.
*
* @param level The {@link ServerLevel} to check for entities in.
* @return a {@link List} of entities in the {@link ServerLevel}.
*/
public static List<Entity> getEntitiesPerLevel(ServerLevel level) {
return ENTITIES_PER_LEVEL.computeIfAbsent(level, serverLevel -> new ArrayList<>());
}

public static Optional<Direction> getMovementDirectionHorizontal(@NotNull Entity entity) {
Direction direction = null;
Vec3 deltaMovement = entity.getDeltaMovement();
if (deltaMovement.horizontalDistance() > 0) {
double nonNegX = Math.abs(deltaMovement.x);
double nonNegZ = Math.abs(deltaMovement.z);
if (nonNegX > nonNegZ) {
direction = deltaMovement.x > 0 ? Direction.EAST : Direction.WEST;
} else if (nonNegZ > 0) {
direction = deltaMovement.z > 0 ? Direction.SOUTH : Direction.NORTH;
}
}
return Optional.ofNullable(direction);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.minecraft.world.level.Level;

/**
* This is the same as {@link AbstractFish} but the entity will not flop when on land.
* This is the same as {@link AbstractFish} but the entity will not flop while on land.
*/
public abstract class NoFlopAbstractFish extends AbstractFish {

Expand All @@ -39,6 +39,7 @@ protected SoundEvent getFlopSound() {
/**
* Acts as a form of access widener.
*/
@Override
public boolean canRandomSwim() {
return super.canRandomSwim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.behavior.Behavior;
import net.minecraft.world.entity.ai.goal.MoveToBlockGoal;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

/**
* {@link net.minecraft.world.entity.ai.goal.BreathAirGoal} as a behavior.
*/
public class BreatheAir<E extends PathfinderMob> extends Behavior<E> {
public BreatheAir() {
super(ImmutableMap.of());
Expand Down
Loading

0 comments on commit 14a2a2e

Please sign in to comment.