Skip to content
Merged
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
9 changes: 4 additions & 5 deletions config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ style:
maxLineLength: 120
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
excludeCommentStatements: true

ReturnCount:
active: true
max: 1
max: 3
excludedFunctions:
- equals

Expand All @@ -44,7 +44,6 @@ style:
ForbiddenComment:
active: true
comments:
- "TODO:"
- "FIXME:"
- "STOPSHIP:"

Expand All @@ -58,11 +57,11 @@ complexity:

CyclomaticComplexMethod:
active: true
allowedComplexity: 5
allowedComplexity: 6

NestedBlockDepth:
active: true
allowedDepth: 2
allowedDepth: 3

LongParameterList:
active: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
@Mixin(AbstractClientPlayer.class)
public interface AbstractClientPlayerAccessor {

/**
* Returns the client-side player info.
*
* @return the {@link net.minecraft.client.multiplayer.PlayerInfo} associated with this player
*/
@Accessor("playerInfo")
PlayerInfo getClientPlayerInfo();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cobalt/mixin/client/MinecraftMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void registerSkia(GameConfig gameConfig, CallbackInfo ci) {
int finalWidth = Math.max(width[0], 1);
int finalHeight = Math.max(height[0], 1);

SkiaContext.INSTANCE.initSkia(finalWidth, finalHeight);
SkiaContext.INSTANCE.initSkia$cobalt(finalWidth, finalHeight);
}

@Inject(
Expand All @@ -57,7 +57,7 @@ private void registerSkia(GameConfig gameConfig, CallbackInfo ci) {
require = 1
)
private void onBeforeFlipFrame(boolean advanceGameTime, CallbackInfo ci) {
SkiaContext.INSTANCE.draw();
SkiaContext.INSTANCE.draw$cobalt();
}

@Inject(method = "tick", at = @At("HEAD"))
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/org/cobalt/mixin/gui/ChatScreenMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.client.multiplayer.ClientPacketListener;
import org.cobalt.command.CommandManager;
import org.cobalt.event.EventBus;
import org.cobalt.event.impl.ChatSendEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -12,8 +14,10 @@ public class ClientPacketListenerMixin {

@Inject(method = "sendChat", at = @At("HEAD"), cancellable = true)
public void sendChatMessage(String content, CallbackInfo ci) {
if (content.startsWith(String.valueOf(CommandManager.getPrefix()))) {
CommandManager.handleCommandExecution(content);
ChatSendEvent event = new ChatSendEvent(content);
EventBus.post(event);

if (event.isCancelled()) {
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public void refresh(CallbackInfo ci, @Local(name = "reader") StringReader reader
return;
}

if (!reader.canRead() || reader.peek() != CommandManager.getPrefix()) {
if (!reader.canRead() || reader.peek() != CommandManager.PREFIX) {
reader.setCursor(0);
return;
}

reader.skip();

int cursor = this.input.getCursorPosition();
CommandDispatcher<ClientSuggestionProvider> dispatcher = CommandManager.getDispatcher();
CommandDispatcher<ClientSuggestionProvider> dispatcher = CommandManager.getDispatcher$cobalt();

if (this.currentParse == null) {
ClientSuggestionProvider suggestionProvider = this.minecraft.player.connection.getSuggestionsProvider();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cobalt/mixin/platform/WindowMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void onFramebufferResize(long handle, int newWidth, int newHeight, Callb
int finalWidth = Math.max(newWidth, 1);
int finalHeight = Math.max(newHeight, 1);

SkiaContext.INSTANCE.initSkia(finalWidth, finalHeight);
SkiaContext.INSTANCE.initSkia$cobalt(finalWidth, finalHeight);
}

}
13 changes: 13 additions & 0 deletions src/main/java/org/cobalt/mixin/render/FrustumInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
@Mixin(Frustum.class)
public interface FrustumInvoker {

/**
* Tests whether an axis-aligned bounding box is inside, intersecting, or outside the view frustum.
*
* @param minX the x-coordinate of the minimum corner
* @param minY the y-coordinate of the minimum corner
* @param minZ the z-coordinate of the minimum corner
* @param maxX the x-coordinate of the maximum corner
* @param maxY the y-coordinate of the maximum corner
* @param maxZ the z-coordinate of the maximum corner
* @return {@link org.joml.FrustumIntersection#INSIDE},
* {@link org.joml.FrustumIntersection#INTERSECT},
* or a plane index if outside the frustum
*/
@Invoker
int invokeCubeInFrustum(double minX, double minY, double minZ, double maxX, double maxY, double maxZ);

Expand Down
18 changes: 15 additions & 3 deletions src/main/kotlin/org/cobalt/Cobalt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@ import net.fabricmc.fabric.api.client.rendering.v1.level.LevelRenderEvents
import net.fabricmc.loader.api.FabricLoader
import net.fabricmc.loader.api.ModContainer
import net.minecraft.client.Minecraft
import org.cobalt.Cobalt.MOD_CONTAINER
import org.cobalt.Cobalt.MOD_NAME
import org.cobalt.Cobalt.MOD_VERSION
import org.cobalt.Cobalt.minecraft
import org.cobalt.command.CommandManager
import org.cobalt.command.impl.MainCommand
import org.cobalt.event.EventBus
import org.cobalt.event.impl.WorldRenderEvent
import org.cobalt.module.ModuleManager

/**
* Main mod entrypoint and contains shared constants for Cobalt.
*
* @property minecraft global Minecraft client instance
* @property MOD_CONTAINER Fabric mod container for this mod
* @property MOD_NAME display name of the mod from metadata
* @property MOD_VERSION version string from mod metadata
*/
object Cobalt : ClientModInitializer {

@JvmField
val minecraft: Minecraft = Minecraft.getInstance()
@JvmStatic
val minecraft: Minecraft
get() = Minecraft.getInstance()

@JvmField
val MOD_CONTAINER: ModContainer = FabricLoader.getInstance().getModContainer("cobalt").orElseThrow()
Expand All @@ -29,7 +42,6 @@ object Cobalt : ClientModInitializer {
ModuleManager.registerModules()
CommandManager.register(MainCommand)

// Dispatch Events
LevelRenderEvents.END_MAIN.register { context ->
EventBus.post(WorldRenderEvent(context))
}
Expand Down
Loading
Loading