Skip to content

Commit

Permalink
Ported
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Jan 15, 2024
1 parent 2f4cc6c commit 543a749
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.0
# Mod Properties
mod_version=1.4.1
mod_version=1.4.2
maven_group=essential-client
# Dependencies
carpet_version=1.4.128
fabric_version=0.91.1+1.20.4
modmenu_version=9.0.0-pre.1
arucas_version=239610d1ce529ab087125dab4c592f28cc963ca7
arucas_version=127776e596fa79f3133ef677805115fc60c4f672
bytebuddy_version=1.14.11
minecraft_dependency=1.20.x
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package me.senseiwells.essentialclient.clientscript.core;

import me.senseiwells.arucas.api.ArucasFileHandler;
import me.senseiwells.arucas.api.ArucasInput;
import me.senseiwells.arucas.api.ArucasOutput;
import me.senseiwells.arucas.compiler.LocatableTrace;
import me.senseiwells.arucas.interpreter.Interpreter;
import me.senseiwells.essentialclient.utils.EssentialUtils;
import me.senseiwells.essentialclient.utils.render.ChatColour;
import net.minecraft.util.Util;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.concurrent.CompletableFuture;

public enum ClientScriptIO implements ArucasInput, ArucasOutput {
public enum ClientScriptIO implements ArucasInput, ArucasOutput, ArucasFileHandler {
INSTANCE;

private final Logger logger = LogManager.getLogger("ClientScript");
Expand Down Expand Up @@ -90,4 +93,9 @@ public void logError(Object o) {
public String formatStackTrace(@NotNull Interpreter interpreter, String message, @NotNull LocatableTrace trace) {
return ArucasOutput.defaultFormatStackTrace(interpreter, message, trace);
}

@Override
public void open(@NotNull File file) {
Util.getOperatingSystem().open(file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ private static void load() {
.setInput(ClientScriptIO.INSTANCE)
.setOutput(ClientScriptIO.INSTANCE)
.setErrorHandler(ClientScriptErrorHandler.INSTANCE)
.setFileHandler(ClientScriptIO.INSTANCE)
.setInterpreterProperties(() -> {
Properties properties = new Properties();
properties.setErrorMaxLength(40);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ private Object mirrorLeftRight(Arguments arguments) {
)
private Object isFluid(Arguments arguments) {
ScriptBlockState blockState = arguments.nextPrimitive(this);
return blockState.state.contains(FluidBlock.LEVEL);
return !blockState.state.getFluidState().isEmpty();
}

@FunctionDoc(
Expand All @@ -414,11 +414,7 @@ private Object isFluid(Arguments arguments) {
)
private Object isFluidSource(Arguments arguments) {
ScriptBlockState blockState = arguments.nextPrimitive(this);
Block block = blockState.asBlock();
if ((block instanceof FluidBlock && blockState.state.get(FluidBlock.LEVEL) == 0) || block instanceof BubbleColumnBlock) {
return true;
}
return block instanceof Waterloggable && blockState.state.get(Properties.WATERLOGGED);
return blockState.state.getFluidState().isStill();
}

@FunctionDoc(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import me.senseiwells.arucas.utils.misc.Language;
import me.senseiwells.essentialclient.clientscript.core.MinecraftAPI;
import me.senseiwells.essentialclient.utils.EssentialUtils;
import me.senseiwells.essentialclient.utils.clientscript.ClientScriptUtils;
import me.senseiwells.essentialclient.utils.clientscript.impl.ScriptItemStack;
import me.senseiwells.essentialclient.utils.render.FakeInventoryScreen;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -132,7 +133,9 @@ private Void setStackForSlot(Arguments arguments) {
FakeInventoryScreen fakeScreen = arguments.nextPrimitive(FakeScreenDef.class);
int slotNum = arguments.nextPrimitive(NumberDef.class).intValue();
ScriptItemStack itemStack = arguments.nextPrimitive(ItemStackDef.class);
fakeScreen.setStack(slotNum, itemStack.stack);
ClientScriptUtils.ensureMainThread("setStackForSlot", arguments.getInterpreter(), () -> {
fakeScreen.setStack(slotNum, itemStack.stack);
});
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void reload(ResourceManager manager) {
public Sprite[] getFluidSprites(@Nullable BlockRenderView view, @Nullable BlockPos pos, FluidState state) {
if (view != null && pos != null && ClientRules.HIGHLIGHT_WATER_SOURCES.getValue()) {
BlockState blockState = view.getBlockState(pos);
if (blockState.contains(FluidBlock.LEVEL) && blockState.get(FluidBlock.LEVEL) == 0) {
if (blockState.getFluidState().isStill()) {
return new Sprite[]{waterSourceStillSprite, waterSourceFlowSprite};
}
}
Expand All @@ -102,10 +102,10 @@ public Sprite[] getFluidSprites(@Nullable BlockRenderView view, @Nullable BlockP

@Override
public int getFluidColor(@Nullable BlockRenderView view, @Nullable BlockPos pos, FluidState state) {
if (ClientRules.HIGHLIGHT_WATER_SOURCES.getValue() && state.getLevel() == 8) {
// Returns blank colour
return -1;
}
// if (ClientRules.HIGHLIGHT_WATER_SOURCES.getValue() && state.getLevel() == 8) {
// // Returns blank colour
// return -1;
// }
return (view == null || pos == null) ? DEFAULT_WATER_COLOUR : BiomeColors.getWaterColor(view, pos);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package me.senseiwells.essentialclient.mixins.longChatMessages;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.senseiwells.essentialclient.utils.EssentialUtils;
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin({ChatMessageC2SPacket.class, CommandExecutionC2SPacket.class})
public class GenericChatMessageC2SPacketMixin {
@ModifyConstant(method = "write", constant = @Constant(intValue = 256))
@ModifyExpressionValue(method = "write", at = @At(value = "CONSTANT", args = "intValue=256"))
private static int getMaxLength(int constant) {
return EssentialUtils.getMaxChatLength(constant);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 3
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"animation": {
"frametime": 2,
"frames": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
18,
17,
16,
15,
14,
13,
12,
11,
10,
9,
8,
7,
6,
5,
4,
3,
2,
1
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"animation": {}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

0 comments on commit 543a749

Please sign in to comment.