Skip to content

Commit

Permalink
Item display changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sddsd2332 committed Jan 18, 2025
1 parent 35db7e2 commit 8ed4c1d
Show file tree
Hide file tree
Showing 58 changed files with 918 additions and 593 deletions.
12 changes: 7 additions & 5 deletions gradle/scripts/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies {
compileOnly "org.jetbrains:annotations:17.0.0"

implementation 'curse.maven:mcmultipart-239431:2615930'
implementation 'curse.maven:had-enough-items-557549:4543375'
implementation rfg.deobf('curse.maven:had-enough-items-557549:4543375')
implementation 'curse.maven:tesla-244651:2487959'
implementation 'curse.maven:inventory-tweaks-API-223094:2923461'
implementation 'curse.maven:opencomputers-223008:4526246'
Expand Down Expand Up @@ -94,19 +94,21 @@ dependencies {
runtimeOnly 'curse.maven:MmmMmmMmmMmm-225738:2503041'
implementation rfg.deobf('curse.maven:ae2-fluid-crafting-rework-623955:5405482')
implementation rfg.deobf('curse.maven:mekanism-energistics-1027681:5402405')
implementation rfg.deobf("kasuminova:lumenized:1.0.3:dev")
implementation rfg.deobf(files('libs/lumenized-1.0.3-dev.jar'))
// implementation rfg.deobf("kasuminova:lumenized:1.0.3:dev")
implementation rfg.deobf("curse.maven:CodeChickenLib-242818:2779848")
implementation rfg.deobf("curse.maven:cofh-core-69162:2920433")
implementation rfg.deobf("curse.maven:thermal-foundation-222880:2926428")
implementation rfg.deobf("curse.maven:thermal-expansion-69163:2926431")
implementation rfg.deobf("curse.maven:cofh-world-271384:2920434")
// implementation rfg.deobf("curse.maven:nuclearcraft-overhauled-336895:5446445")
// implementation rfg.deobf("curse.maven:nuclearcraft-overhauled-336895:5446445")
implementation rfg.deobf("curse.maven:baubles-227083:2518667")
// implementation rfg.deobf("curse.maven:bubbles-a-baubles-fork-995393:5844968")
implementation rfg.deobf("curse.maven:botania-225643:3330934")
implementation rfg.deobf("curse.maven:extrabotany-299086:3112313")
implementation rfg.deobf("curse.maven:brandons-core-231382:3408276")
implementation 'curse.maven:draconic-evolution-223565:3431261'
implementation 'curse.maven:draconic-additions-314515:3514704'
implementation rfg.deobf("curse.maven:draconic-evolution-223565:3431261")
implementation rfg.deobf("curse.maven:draconic-additions-314515:3514704")

runtimeOnly 'curse.maven:packagedauto-308380:5598426'
runtimeOnly 'curse.maven:packageddraconic-833931:5598456'
Expand Down
110 changes: 25 additions & 85 deletions src/main/java/mekanism/client/MekanismKeyHandler.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
package mekanism.client;

import baubles.api.BaublesApi;
import mekanism.api.gas.IGasItem;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.MekanismSounds;
import mekanism.common.block.states.BlockStateMachine.MachineType;
import mekanism.common.config.MekanismConfig;
import mekanism.common.integration.MekanismHooks;
import mekanism.common.item.*;
import mekanism.common.item.armor.ItemMekAsuitFeetArmour;
import mekanism.common.item.interfaces.IJetpackItem;
import mekanism.common.item.interfaces.IJetpackItem.JetpackMode;
import mekanism.common.item.interfaces.IModeItem;
import mekanism.common.moduleUpgrade;
import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage;
import mekanism.common.network.PacketFreeRunnerData;
import mekanism.common.network.PacketFreeRunnerData.FreeRunnerDataMessage;
import mekanism.common.network.PacketItemStack.ItemStackMessage;
import mekanism.common.network.PacketJetpackData.JetpackDataMessage;
import mekanism.common.network.PacketBaublesModeChange.BaublesModeChangMessage;
import mekanism.common.network.PacketJumpBoostData;
import mekanism.common.network.PacketJumpBoostData.JumpBoostDataMessage;
import mekanism.common.network.PacketModeChange.ModeChangMessage;
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
import mekanism.common.network.PacketStepAssistData;
import mekanism.common.network.PacketStepAssistData.StepAssistDataMessage;
import mekanism.common.util.LangUtils;
import mekanism.common.util.TextComponentGroup;
import mekanism.common.util.UpgradeHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
Expand All @@ -46,8 +33,6 @@
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.input.Keyboard;

import java.util.Collections;

@SideOnly(Side.CLIENT)
public class MekanismKeyHandler extends MekKeyHandler {

Expand Down Expand Up @@ -93,75 +78,17 @@ public void onTick(InputEvent event) {
public void keyDown(KeyBinding kb, boolean isRepeat) {
EntityPlayer player = FMLClientHandler.instance().getClient().player;
if (kb == modeSwitchKey) {
ItemStack toolStack = player.inventory.getCurrentItem();
Item item = toolStack.getItem();

if (IModeItem.isModeItem(player, EntityEquipmentSlot.MAINHAND, false)) {
Mekanism.packetHandler.sendToServer(new ModeChangMessage(EntityEquipmentSlot.MAINHAND, player.isSneaking()));
} else if (!IModeItem.isModeItem(player, EntityEquipmentSlot.MAINHAND) && IModeItem.isModeItem(player, EntityEquipmentSlot.OFFHAND)) {
Mekanism.packetHandler.sendToServer(new ModeChangMessage(EntityEquipmentSlot.OFFHAND, player.isSneaking()));
}

if (player.isSneaking()) {
/*
if (item instanceof ItemConfigurator configurator) {
ConfiguratorMode mode = configurator.getMode(toolStack);
ConfiguratorMode newMode = mode.adjust(player.isSneaking() ? -1 : 1);
configurator.setMode(toolStack, newMode);
Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(newMode)));
player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ").translation("mekanism.tooltip.configureState", LangUtils.withColor(newMode.getShortText(), newMode.getColor().textFormatting)));
}*/
if (item instanceof ItemBlockMachine machine) {
if (MachineType.get(toolStack) == MachineType.FLUID_TANK) {
boolean newBucketMode = !machine.getBucketMode(toolStack);
machine.setBucketMode(toolStack, newBucketMode);
Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(machine.getBucketMode(toolStack))));
player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ").translation("mekanism.tooltip.portableTank.bucketMode", LangUtils.onOffColoured(newBucketMode)));
}
} else if (item instanceof ItemWalkieTalkie wt) {
if (wt.getOn(toolStack)) {
int newChan = wt.getChannel(toolStack) + 1;
if (newChan == 9) {
newChan = 1;
}
wt.setChannel(toolStack, newChan);
Mekanism.packetHandler.sendToServer(new ItemStackMessage(EnumHand.MAIN_HAND, Collections.singletonList(newChan)));
}
} else if (item instanceof ItemFlamethrower flamethrower) {
flamethrower.incrementMode(toolStack);
Mekanism.packetHandler.sendToServer(FlamethrowerDataMessage.MODE_CHANGE(EnumHand.MAIN_HAND));
player.sendMessage(new TextComponentGroup(TextFormatting.GRAY).string(Mekanism.LOG_TAG, TextFormatting.DARK_BLUE).string(" ").translation("mekanism.tooltip.flamethrower.modeBump", flamethrower.getMode(toolStack).getTextComponent()));

}
}
} else if (kb == armorModeSwitchKey) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
Item chestItem = chestStack.getItem();
if (chestItem instanceof IJetpackItem jetpack) {
JetpackMode mode = jetpack.getJetpackMode(chestStack);
JetpackMode newMode = mode.adjust(player.isSneaking() ? -1 : 1);
jetpack.setMode(chestStack, newMode);
Mekanism.packetHandler.sendToServer(JetpackDataMessage.MODE_CHANGE(player.isSneaking()));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
} else if (Mekanism.hooks.Baubles) {
setBaublesJetpackMode(player);
} else if (chestItem instanceof ItemScubaTank scubaTank) {
scubaTank.toggleFlowing(chestStack);
Mekanism.packetHandler.sendToServer(ScubaTankDataMessage.MODE_CHANGE(false));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
}
handlePotentialModeItem(EntityEquipmentSlot.CHEST);
} else if (kb == freeRunnerModeSwitchKey) {
handlePotentialModeItem(EntityEquipmentSlot.FEET);
ItemStack feetStack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if (feetStack.getItem() instanceof ItemFreeRunners freeRunners) {
if (player.isSneaking()) {
freeRunners.setMode(feetStack, ItemFreeRunners.FreeRunnerMode.DISABLED);
} else {
freeRunners.incrementMode(feetStack);
}
Mekanism.packetHandler.sendToServer(new FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.MODE, null, player.isSneaking()));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
} else if (feetStack.getItem() instanceof ItemMekAsuitFeetArmour freeArmour && UpgradeHelper.isUpgradeInstalled(feetStack, moduleUpgrade.HYDRAULIC_PROPULSION_UNIT) && !Mekanism.hooks.DraconicEvolution) {
if (feetStack.getItem() instanceof ItemMekAsuitFeetArmour freeArmour && UpgradeHelper.isUpgradeInstalled(feetStack, moduleUpgrade.HYDRAULIC_PROPULSION_UNIT) && !Mekanism.hooks.DraconicEvolution) {
if (player.isSneaking()) {
freeArmour.setJumpBoostMode(feetStack, ItemMekAsuitFeetArmour.JumpBoost.OFF);
} else {
Expand All @@ -186,23 +113,36 @@ public void keyDown(KeyBinding kb, boolean isRepeat) {
}
}

private static void handlePotentialModeItem(EntityEquipmentSlot slot) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (player != null) {
if (IModeItem.isModeItem(player, slot)) {
Mekanism.packetHandler.sendToServer(new ModeChangMessage(slot, player.isSneaking()));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
} else if (Mekanism.hooks.Baubles) {
setBaublesMode(player, slot);
}
}
}


@Optional.Method(modid = MekanismHooks.Baubles_MOD_ID)
public void setBaublesJetpackMode(EntityPlayer player) {
public static void setBaublesMode(EntityPlayer player, EntityEquipmentSlot slot) {
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++) {
ItemStack stack = baubles.getStackInSlot(i);
if (stack.getItem() instanceof IJetpackItem jetpack) {
JetpackMode mode = jetpack.getJetpackMode(stack);
JetpackMode newMode = mode.adjust(player.isSneaking() ? -1 : 1);
jetpack.setMode(stack, newMode);
Mekanism.packetHandler.sendToServer(JetpackDataMessage.MODE_CHANGE(player.isSneaking()));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
if (stack.getItem().isValidArmor(stack, slot, player) && IModeItem.isModeItem(stack, slot)) {
if (!(stack.getItem() instanceof IGasItem item) || item.getGas(stack) != null) {
Mekanism.packetHandler.sendToServer(new BaublesModeChangMessage(i, player.isSneaking()));
SoundHandler.playSound(MekanismSounds.HYDRAULIC);
}
}
}
}


@Override
public void keyUp(KeyBinding kb) {

}
}
45 changes: 45 additions & 0 deletions src/main/java/mekanism/client/SpecialColors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package mekanism.client;

import mekanism.client.render.lib.ColorAtlas;
import mekanism.client.render.lib.ColorAtlas.ColorRegistryObject;

public class SpecialColors {

private SpecialColors() {
}

public static final ColorAtlas GUI_OBJECTS = new ColorAtlas("gui_objects");
public static final ColorAtlas GUI_TEXT = new ColorAtlas("gui_text");

public static final ColorRegistryObject TAB_ENERGY_CONFIG = GUI_OBJECTS.register(0xFF59C15F);
public static final ColorRegistryObject TAB_FLUID_CONFIG = GUI_OBJECTS.register(0xFF366BD0);
public static final ColorRegistryObject TAB_GAS_CONFIG = GUI_OBJECTS.register(0xFFFFDD4F);
public static final ColorRegistryObject TAB_INFUSION_CONFIG = GUI_OBJECTS.register(0xFFC9071F);
public static final ColorRegistryObject TAB_PIGMENT_CONFIG = GUI_OBJECTS.register(0xFFFFBCC4);
public static final ColorRegistryObject TAB_SLURRY_CONFIG = GUI_OBJECTS.register(0xFFA17649);
public static final ColorRegistryObject TAB_ITEM_CONFIG = GUI_OBJECTS.register(0xFFCFCFCF);
public static final ColorRegistryObject TAB_HEAT_CONFIG = GUI_OBJECTS.register(0xFFFFA160);

public static final ColorRegistryObject TAB_REDSTONE_CONTROL = GUI_OBJECTS.register(0xFFC9071F);
public static final ColorRegistryObject TAB_SECURITY = GUI_OBJECTS.register(0xFFFFA160);
public static final ColorRegistryObject TAB_CONTAINER_EDIT_MODE = GUI_OBJECTS.register(0xFF366BD0);
public static final ColorRegistryObject TAB_UPGRADE = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_CONFIGURATION = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_TRANSPORTER = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_DIGITAL_MINER_VISUAL = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_ROBIT_MENU = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_FACTORY_SORT = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_QIO_FREQUENCY = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_RESIZE_CONTROLS = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_LASER_AMPLIFIER = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_CHEMICAL_WASHER = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_MULTIBLOCK_MAIN = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_MULTIBLOCK_STATS = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_CRAFTING_WINDOW = GUI_OBJECTS.register();
public static final ColorRegistryObject TAB_ARMOR_SLOTS = GUI_OBJECTS.register();

public static final ColorRegistryObject TEXT_TITLE = GUI_TEXT.register(0xFF404040);
public static final ColorRegistryObject TEXT_HEADING = GUI_TEXT.register(0xFF202020);
public static final ColorRegistryObject TEXT_SUBHEADING = GUI_TEXT.register(0xFF787878);
public static final ColorRegistryObject TEXT_SCREEN = GUI_TEXT.register(0xFF3CFE9A);
}
39 changes: 39 additions & 0 deletions src/main/java/mekanism/client/gui/IGuiWrapper.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package mekanism.client.gui;

import mekanism.common.Mekanism;
import mekanism.common.inventory.warning.WarningTracker;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.BooleanSupplier;

@SideOnly(Side.CLIENT)
public interface IGuiWrapper {
Expand All @@ -21,4 +26,38 @@ public interface IGuiWrapper {

@Nullable
FontRenderer getFont();

default int getLeft() {
if (this instanceof GuiContainer) {
return ((GuiContainer) this).getGuiLeft();
}
return 0;
}

default int getTop() {
if (this instanceof GuiContainer) {
return ((GuiContainer) this).getGuiTop();
}
return 0;
}

default int getWidth() {
if (this instanceof GuiContainer) {
return ((GuiContainer) this).getXSize();
}
return 0;
}

default int getHeight() {
if (this instanceof GuiContainer) {
return ((GuiContainer) this).getYSize();
}
return 0;
}

@Nonnull
default BooleanSupplier trackWarning(@Nonnull WarningTracker.WarningType type, @Nonnull BooleanSupplier warningSupplier) {
Mekanism.logger.error("Tried to call 'trackWarning' but unsupported in {}", getClass().getName());
return warningSupplier;
}
}
Loading

0 comments on commit 8ed4c1d

Please sign in to comment.