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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ run/
run
.vscode
>>>>>>> 5ceb4d71bc4382c6d7021bd52f926a62dcac2096




.idea/
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ author = masa
mod_file_name = tweakfork-fabric

# Current mod version
mod_version = 1.2.3
mod_version = 1.2.4

# Required malilib version
malilib_version = 0.12.0
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/config/Callbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public static void init(MinecraftClient mc)
Hotkeys.OPEN_ITEM_LIST.getKeybind().setCallback(callbackGeneric);
Hotkeys.CONTAINER_SCANNER_CLEAR_CACHE.getKeybind().setCallback(callbackGeneric);



Hotkeys.SKIP_ALL_RENDERING.getKeybind().setCallback(callbackMessage);
Hotkeys.SKIP_WORLD_RENDERING.getKeybind().setCallback(callbackMessage);

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/fi/dy/masa/tweakeroo/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public static class Generic
public static final ConfigInteger AFK_TIMEOUT = new ConfigInteger ("afkTimeout", 2400, 200, 200000, "Number of ticks for AFK timeout");
public static final ConfigString AFK_ACTION = new ConfigString ("afkAction", "/disconnect", "The action to perform on AFK timeout. /disconnect is default.");
public static final ConfigBoolean NOTE_EDIT_LETTERS = new ConfigBoolean ("noteEditLetters", false, "When enabled, can use letter keys to set noteblock notes");


public static final ConfigColor CONTAINER_SCAN_ITEM_HIGHLIGHT_COLOR = new ConfigColor ("containerScanHighlightColor", "#AC000000", "Set the color that renders behind selected items from containerScan\n(when the feature is enabled)");

public static final ImmutableList<IConfigBase> OPTIONS = ImmutableList.of(
CARPET_ACCURATE_PLACEMENT_PROTOCOL,
Expand Down Expand Up @@ -221,7 +221,10 @@ public static class Generic
TOOL_SWITCHABLE_SLOTS,
NOTE_EDIT_LETTERS,
TOOL_SWITCH_IGNORED_SLOTS,
ZOOM_FOV
ZOOM_FOV,

//From Jack
CONTAINER_SCAN_ITEM_HIGHLIGHT_COLOR
);
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ public enum FeatureToggle implements IHotkeyTogglable, IConfigNotifiable<IConfig
TWEAK_CONTAINER_SCAN_COUNTS ("tweakContainerScanCounts", false, "", "Enables/disables container scan counts rendering"),
TWEAK_AFK_TIMEOUT ("tweakAfkTimeout", false, "", "When enabled, will perform an action after afking for a while"),
TWEAK_NOTEBLOCK_EDIT ("tweakNoteblockEdit", false, "", "Turns on noteblock editing mode"),
TWEAK_STANDARD_ASPECT_RATIO ("tweakStandardAspectRatio", false, "", "Forces 16:9 aspect ratio for the game.\n#macbook-gang.");

TWEAK_STANDARD_ASPECT_RATIO ("tweakStandardAspectRatio", false, "", "Forces 16:9 aspect ratio for the game.\n#macbook-gang."),

TWEAK_SELECTED_SCAN_ITEM_HIGHLIGHT ("tweakSelectedScanItemHighlight", false, "", "Enables A highlight of selected items from container scan");


public static final ImmutableList<FeatureToggle> VALUES = ImmutableList.copyOf(values());

private final String name;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fi/dy/masa/tweakeroo/config/Hotkeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public class Hotkeys
public static final ConfigHotkey AREA_SELECTION_REMOVE_FROM_LIST = new ConfigHotkey("areaSelectionRemoveFromList", "", KeybindSettings.PRESS_ALLOWEXTRA, "remove selected blocks from list");
public static final ConfigHotkey OPEN_ITEM_LIST = new ConfigHotkey("openItemList", "", "Opens the item list gui");
public static final ConfigHotkey CONTAINER_SCANNER_CLEAR_CACHE = new ConfigHotkey("containerScannerClearCache", "", "Clears the container scanner cache");





public static final List<ConfigHotkey> HOTKEY_LIST = ImmutableList.of(
ACCURATE_BLOCK_PLACEMENT_IN,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/items/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public void clearSelected() {
public boolean isEntrySelected(ItemListEntry entry) {
return this.selectedItems.contains(entry.getItem());
}
public boolean isItemSelected(Item item) {
return this.selectedItems.contains(item);
}
public Collection<ItemListEntry> getItemsAll()
{
return this.itemListAll.values();
Expand Down
83 changes: 83 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/mixin/MixinHandledScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package fi.dy.masa.tweakeroo.mixin;


import com.mojang.blaze3d.systems.RenderSystem;
import fi.dy.masa.malilib.MaLiLib;
import fi.dy.masa.tweakeroo.config.Configs;
import fi.dy.masa.tweakeroo.config.FeatureToggle;
import fi.dy.masa.tweakeroo.items.ItemList;
import fi.dy.masa.tweakeroo.renderer.RenderUtils;
import net.minecraft.block.Block;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Iterator;

import static net.minecraft.client.gui.screen.ingame.HandledScreen.drawSlotHighlight;

@Mixin(HandledScreen.class)
public abstract class MixinHandledScreen extends DrawableHelper {



@Inject(method = "drawSlot",at=@At("HEAD"))
public void injectItemHighlight(MatrixStack matrices, Slot slot, CallbackInfo ci) {


if (!FeatureToggle.TWEAK_SELECTED_SCAN_ITEM_HIGHLIGHT.getBooleanValue()) return;

if (ItemList.INSTANCE.isItemSelected(slot.getStack().getItem()) || isShulkerAndMatches(slot.getStack())) {

fi.dy.masa.malilib.render.RenderUtils.drawRect(slot.x , slot.y, 16, 16, Configs.Generic.CONTAINER_SCAN_ITEM_HIGHLIGHT_COLOR.getColor().intValue,32);
// Not drawing a border. Maybe one should be drawn?
//fi.dy.masa.malilib.render.RenderUtils.drawOutline(slot.x, slot.y, 16, 16, 1, 0xFF800080,32);
}

}


public boolean isShulkerAndMatches(ItemStack stack) {

if (!(Block.getBlockFromItem(stack.getItem()) instanceof ShulkerBoxBlock)) return false;

NbtCompound nbtCompound = BlockItem.getBlockEntityNbt(stack);
if (nbtCompound != null) {

if (nbtCompound.contains("Items", 9)) {
DefaultedList<ItemStack> defaultedList = DefaultedList.ofSize(27, ItemStack.EMPTY);
Inventories.readNbt(nbtCompound, defaultedList);

for (ItemStack itemStack : defaultedList) {
Item item = itemStack.getItem();
if (ItemList.INSTANCE.isItemSelected(item)) {
return true;
}
}

}
}
return false;

}

}
27 changes: 18 additions & 9 deletions src/main/java/fi/dy/masa/tweakeroo/renderer/RenderUtils.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fi.dy.masa.tweakeroo.renderer;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;

import fi.dy.masa.malilib.MaLiLib;
import fi.dy.masa.malilib.util.Color4f;
import fi.dy.masa.malilib.util.EntityUtils;
import fi.dy.masa.malilib.util.GuiUtils;
Expand All @@ -14,15 +16,13 @@
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.*;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
Expand All @@ -33,6 +33,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
Expand All @@ -44,6 +46,8 @@
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World;

import static fi.dy.masa.malilib.render.RenderUtils.setupBlend;

public class RenderUtils
{
private static long lastRotationChangeTime;
Expand Down Expand Up @@ -922,6 +926,11 @@ public static void renderAreaOutlineNoCorners(BlockPos pos1, BlockPos pos2,
}











}
Loading