Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Dec 18, 2024
1 parent f94246a commit 029409c
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 9 deletions.
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.06:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.06:dev'){ transitive = false }

api("com.github.GTNewHorizons:StructureLib:1.4.0:dev")
api("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
Expand All @@ -54,8 +54,9 @@ dependencies {
compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.4.7-GTNH:dev")
compileOnlyApi("com.github.GTNewHorizons:Navigator:1.0.15:dev")
api('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive=false}
//api('com.github.GTNewHorizons:Baubles-Expanded:2.0.3:dev') {transitive=false}
// Required to prevent an older bauble api from Extra Utilities from loading first in the javac classpath
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive=false}
// compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive=false}

devOnlyNonPublishable("com.github.GTNewHorizons:Infernal-Mobs:1.10.0-GTNH:dev")

Expand Down
56 changes: 52 additions & 4 deletions src/main/java/reobf/proghatches/item/ItemProgrammingToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import reobf.proghatches.lang.LangManager;
import reobf.proghatches.main.MyMod;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.library.accessory.IAccessory;

import com.google.common.collect.ImmutableList;
import com.gtnewhorizons.modularui.api.ModularUITextures;
Expand All @@ -32,11 +37,19 @@

import baubles.api.BaubleType;
import baubles.api.IBauble;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
//import baubles.api.expanded.IBaubleExpanded;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.gui.modularui.GTUIInfos;

public class ItemProgrammingToolkit extends Item implements IItemWithModularUI , IBauble {
public class ItemProgrammingToolkit extends Item implements IItemWithModularUI , IBauble
//,IAccessory

//,IBaubleExpanded
{

/*
* @Override public ModularWindow createWindow(UIBuildContext buildContext,
Expand Down Expand Up @@ -70,7 +83,7 @@ public IIcon getIconFromDamage(int p_77617_1_) {

@SideOnly(Side.CLIENT)
public static boolean holding() {
return lastholdingtick == Minecraft.getMinecraft().thePlayer.ticksExisted;
return Math.abs(lastholdingtick - Minecraft.getMinecraft().thePlayer.ticksExisted)<=2;
}

@SideOnly(Side.CLIENT)
Expand Down Expand Up @@ -133,7 +146,7 @@ public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p

}

int maxModes = 3;
public static int maxModes = 3;

@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer player) {
Expand Down Expand Up @@ -318,7 +331,7 @@ protected int getTextColorOrDefault(String textType, int defaultColor) {
@Override
public BaubleType getBaubleType(ItemStack itemstack) {

return BaubleType.AMULET;
return BaubleType.UNIVERSAL;
}


Expand Down Expand Up @@ -352,4 +365,39 @@ public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
((Item)i).onUpdate(itemstack, null, player, 0, false);
}


@SideOnly(Side.CLIENT)
@SubscribeEvent
public void event(LivingUpdateEvent e){
if( e.entityLiving!=Minecraft.getMinecraft().thePlayer){return;}

IInventory inventory = TPlayerStats.get((EntityPlayer) e.entityLiving).armor;

for(int i=0;i<inventory.getSizeInventory();i++){

ItemStack is = inventory.getStackInSlot(i);
if(is!=null&&is.getItem() instanceof ItemProgrammingToolkit){
((Item)is.getItem()).onUpdate(is, null, e.entityLiving, 0, false);
}
}


}

// {MinecraftForge.EVENT_BUS.register(this);}

//@Override
public boolean canEquipAccessory(ItemStack item, int slot) {

return true;
}

/* @Override
public String[] getBaubleTypes(ItemStack itemstack) {
// TODO Auto-generated method stub
return new String[]{
"universal"
};
}*/

}
45 changes: 44 additions & 1 deletion src/main/java/reobf/proghatches/keybinding/KeyBindings.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
package reobf.proghatches.keybinding;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.settings.KeyBinding;
import reobf.proghatches.main.MyMod;
import reobf.proghatches.net.SwitchModeMessage;

public class KeyBindings {
public static KeyBinding key = new KeyBinding("switch", 0, "programmable hatches key");

@SideOnly(Side.CLIENT)
public KeyBinding key;

interface Run {
public default void run() {
}
}

{

((Run) new Run() {
@SideOnly(Side.CLIENT)
@Override
public void run() {
key = new KeyBinding("proghatch.keybinding.kit.switch.desc", 0, "itemGroup.proghatches");
ClientRegistry.registerKeyBinding(key);
FMLCommonHandler.instance().bus().register(KeyBindings.this);
}
}).run();

}

@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.HIGH, receiveCanceled = false)
public void tick(final TickEvent.ClientTickEvent event) {
if (key.isPressed()) {

MyMod.net.sendToServer(new SwitchModeMessage());

}
;
}

}
12 changes: 10 additions & 2 deletions src/main/java/reobf/proghatches/main/MyMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
import reobf.proghatches.gt.metatileentity.multi.LargeProgrammingCircuitProvider;
import reobf.proghatches.item.ItemBookTutorial;
import reobf.proghatches.item.ItemProgrammingCircuit;
import reobf.proghatches.keybinding.KeyBindings;
import reobf.proghatches.lang.LangManager;
import reobf.proghatches.main.mixin.mixins.MixinFixPipeCoverBug;
import reobf.proghatches.main.registration.Registration;
Expand All @@ -175,6 +176,7 @@
import reobf.proghatches.net.OpenPartGuiMessage;
import reobf.proghatches.net.PriorityMessage;
import reobf.proghatches.net.RenameMessage;
import reobf.proghatches.net.SwitchModeMessage;
import reobf.proghatches.net.UpgradesMessage;
import reobf.proghatches.net.VoidFXMessage;
import reobf.proghatches.net.WayPointMessage;
Expand Down Expand Up @@ -294,7 +296,7 @@ public void preInit(FMLPreInitializationEvent event) {
net.registerMessage(new VoidFXMessage.Handler(), VoidFXMessage.class, 6, Side.CLIENT);
net.registerMessage(new ConnectionModeMessage.Handler(), ConnectionModeMessage.class, 7, Side.SERVER);
net.registerMessage(new MAFXMessage.Handler(), MAFXMessage.class, 8, Side.CLIENT);

net.registerMessage(new SwitchModeMessage.Handler(), SwitchModeMessage.class, 9, Side.SERVER);
proxy.preInit(event);
}

Expand All @@ -308,7 +310,7 @@ public void preInit(FMLPreInitializationEvent event) {
public void init(FMLInitializationEvent event) {
proxy.init(event);


new KeyBindings();

AEApi.instance().partHelper().registerNewLayer("reobf.proghatches.fmp.LazerLayer",
"reobf.proghatches.eucrafting.ILazer");
Expand Down Expand Up @@ -407,8 +409,14 @@ public void join(PlayerLoggedInEvent e) {

public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
//KeyBindings






//MinecraftForge.EVENT_BUS.register(this);
// Api.INSTANCE.registries().p2pTunnel().addNewAttunement(null, null);
// ShutDownReasonRegistry.register(ACCESS_LOOP);
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/reobf/proghatches/net/SwitchModeMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package reobf.proghatches.net;

import baubles.api.BaublesApi;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import reobf.proghatches.item.ItemProgrammingToolkit;
import tconstruct.armor.player.TPlayerStats;

public class SwitchModeMessage implements IMessage {


public SwitchModeMessage(){}
public static class Handler implements IMessageHandler<SwitchModeMessage, SwitchModeMessage> {

@Override
public SwitchModeMessage onMessage(SwitchModeMessage message, MessageContext ctx) {

IInventory[] invs =
{TPlayerStats.get(((NetHandlerPlayServer)ctx.netHandler).playerEntity).armor,
BaublesApi.getBaubles(((NetHandlerPlayServer)ctx.netHandler).playerEntity)
};

for(IInventory inv:invs)
for(int i=0;i<inv.getSizeInventory();i++){
ItemStack is = inv.getStackInSlot(i);
if(is!=null&&is.getItem() instanceof ItemProgrammingToolkit){
is.setItemDamage((is.getItemDamage() + 1) % ItemProgrammingToolkit.maxModes);
((NetHandlerPlayServer)ctx.netHandler).playerEntity.addChatMessage(new

ChatComponentTranslation("proghatch.keybinding.kit.switch.mode."+(is.getItemDamage()))
);
break;
//((ItemProgrammingToolkit)is.getItem()).onItemRightClick(is, null, null);
}

}
return null;

}
}

@Override
public void fromBytes(ByteBuf buf) {


}

@Override
public void toBytes(ByteBuf buf) {


}



}
4 changes: 4 additions & 0 deletions src/main/resources/assets/proghatches/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,7 @@ item.proghatch.upgrades.tooltips.3.1=Unlock Infinity Buffer Mode, for non-ME hat
item.proghatch.upgrades.tooltips.3.2=Harvest the Hatch to retrieve installed Upgrades.
item.proghatch.upgrades.3=Infinity Buffer Upgrade
proghatch.gui.button.power_switch.ex=§cShift-Click to open experimental option panel.
proghatch.keybinding.kit.switch.mode.0=Mode 1: Disabled
proghatch.keybinding.kit.switch.mode.1=Mode 2: Normal
proghatch.keybinding.kit.switch.mode.2=Mode 3: Normal + Reset Circuit
proghatch.keybinding.kit.switch.desc=Switch Toolkit Mode (equipped in Baubles slot)
4 changes: 4 additions & 0 deletions src/main/resources/assets/proghatches/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,7 @@ item.proghatch.upgrades.tooltips.3.1=为非ME仓解锁无尽缓冲模式
item.proghatch.upgrades.tooltips.3.2=拆卸输入仓回收已安装的升级
item.proghatch.upgrades.3=无尽缓冲升级
proghatch.gui.button.power_switch.ex=§cShift点击打开实验性功能选项窗口
proghatch.keybinding.kit.switch.mode.0=模式 1: 禁用
proghatch.keybinding.kit.switch.mode.1=模式 2: 常规
proghatch.keybinding.kit.switch.mode.2=模式 3: 常规+重置电路
proghatch.keybinding.kit.switch.desc=切换编程工具箱模式(装备在Baubles饰品栏)

0 comments on commit 029409c

Please sign in to comment.