This commit is contained in:
lordIcocain committed 2025-05-20 06:03:59 +03:00
1 parent eece3f73cb
commit e4d1157d3c
12 files changed
+114 -139

No files matched your search

@@ -1,4 +1,5 @@
package com.glodblock.github.client.gui.widget;
package com.glodblock.github.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -8,9 +9,9 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
// copy from WirelessCraftingTerminal WCTGuiButton
public class FCGuiBaseButton extends GuiButton {
// copy from wct button
protected static final ResourceLocation buttonTextures = new ResourceLocation(
"minecraft",
"textures/gui/widgets.png");
@@ -71,10 +71,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(30, "MAGNET_CARD", "ME", "magnet_card.me");
this.registerApp(30, "MAGNET_CARD", "FILTER", "magnet_card.filter");
this.registerApp(31, "MAGNET_CARD", "OFF", "magnet_card.off");
this.registerApp(32, "DATA_SYNC", "ENABLE", "data_sync.enable");
this.registerApp(33, "ENABLE_12x", "ENABLE", "enable");
this.registerApp(34, "DISABLE_12x", "DISABLE", "disable");
this.registerApp(35, "DATA_SYNC", "DISABLE", "data_sync.disable");
this.registerApp(36, "RESTOCK", "ENABLE", "restock.on");
this.registerApp(37, "RESTOCK", "DISABLE", "restock.off");
}
@@ -1,4 +1,3 @@
/* Author: asdflj */
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
@@ -9,7 +8,6 @@ import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
import com.glodblock.github.client.gui.widget.FCGuiBaseButton;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.item.WirelessMagnet;
@@ -1,4 +1,3 @@
/* Author: asdflj */
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.EntityPlayer;
@@ -38,7 +38,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
public static String infinityBoosterCard = "infinityBoosterCard";
public static String infinityEnergyCard = "InfinityEnergyCard";
public static String restockItems = "restock";
private static boolean effect = false;
public ItemBaseWirelessTerminal(GuiType t) {
super();
@@ -51,7 +50,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
// terminal
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
setEffect(false);
return item;
}
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
@@ -135,22 +133,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
return this.type;
}
public static void setEffect(boolean e) {
effect = e;
}
public static boolean getEffect() {
return effect;
}
@Override
public boolean hasEffect(ItemStack par1ItemStack, int pass) {
if (Platform.isClient()) {
return getEffect();
}
return super.hasEffect(par1ItemStack, pass);
}
public static void toggleRestockItemsMode(ItemStack is, boolean state) {
NBTTagCompound data = Platform.openNbtData(is);
data.setBoolean(restockItems, state);
@@ -1,5 +1,6 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.common.Config.reStockTime;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.ArrayList;
@@ -7,8 +8,11 @@ import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
@@ -25,6 +29,7 @@ import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
@@ -36,11 +41,14 @@ import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.IGridNode;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import baubles.api.IBauble;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -231,7 +239,21 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
if (Platform.isServer() && entityLivingBase instanceof EntityPlayer player) {
IInventory handler = BaublesApi.getBaubles(player);
if (handler != null) {
for (int i = 0; i < handler.getSizeInventory(); ++i) {
if (handler.getStackInSlot(i) == itemStack) {
onUpdate(
itemStack,
null,
player,
Util.GuiHelper.encodeType(i, Util.GuiHelper.InvType.PLAYER_BAUBLES),
false);
}
}
}
}
}
@Override
@@ -253,4 +275,49 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
private static final Minecraft mc = Minecraft.getMinecraft();
private static long refreshTick = System.currentTimeMillis();
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean p_77663_5_) {
if (Platform.isServer() && entityIn instanceof EntityPlayer player) {
if (WirelessMagnet.getMode(stack) != WirelessMagnet.Mode.Off) {
WirelessMagnet.doMagnet(stack, player.worldObj, player);
}
if (refreshTick + reStockTime < System.currentTimeMillis()) {
// try to stock items
if (mc.currentScreen == null && Util.isRestock(stack)) {
IGridNode gridNode = Util.getWirelessGrid(stack);
if (gridNode != null && Util.isRestock(stack) && Util.rangeCheck(stack, player, gridNode)) {
restockItems(stack, gridNode, slot, player);
}
}
refreshTick = System.currentTimeMillis();
}
}
}
private void restockItems(ItemStack terminal, IGridNode gridNode, int slot, EntityPlayer player) {
WirelessCraftingTerminalInventory inv = new WirelessCraftingTerminalInventory(terminal, slot, gridNode, player);
for (int i = 0; i < 9; i++) {
ItemStack is = player.inventory.mainInventory[i];
if (is != null) {
int maxSize = is.getMaxStackSize();
if (is.stackSize < maxSize) {
int fillSize = maxSize - is.stackSize;
IAEItemStack ias = AEApi.instance().storage().createItemStack(is);
ias.setStackSize(fillSize);
IAEItemStack extractedItem = (IAEItemStack) inv
.extractItems(ias, Actionable.MODULATE, inv.getActionSource());
if (extractedItem != null) {
player.inventory.addItemStackToInventory(extractedItem.getItemStack());
}
}
}
}
}
}
@@ -1,4 +1,3 @@
/* Author: asdflj */
package com.glodblock.github.inventory.item;
import static com.glodblock.github.common.Config.magnetRange;
@@ -56,7 +55,6 @@ public class WirelessMagnet {
public static void doMagnet(ItemStack wirelessTerm, World world, EntityPlayer player) {
if (Platform.isClient() || wirelessTerm == null
|| getMode(wirelessTerm) == Mode.Off
|| player == null
|| player.isSneaking()
|| !isConfigured(wirelessTerm))
@@ -69,28 +67,32 @@ public class WirelessMagnet {
(int) player.posY,
(int) player.posZ,
magnetRange).iterator();
while (iterator.hasNext()) {
EntityItem itemToGet = (EntityItem) iterator.next();
if (itemToGet.func_145800_j() != null && itemToGet.func_145800_j()
.equals(player.getCommandSenderName())) { /* don`t pick up items dropped by yourself */
continue;
}
EntityPlayer closestPlayer = world.getClosestPlayerToEntity(itemToGet, magnetRange);
if (closestPlayer != null && closestPlayer != player) {
continue;
}
if (closestPlayer != null && closestPlayer == player) {
NBTTagCompound itemNBT = new NBTTagCompound();
itemToGet.writeEntityToNBT(itemNBT);
if (itemToGet.delayBeforeCanPickup > 0) {
itemToGet.delayBeforeCanPickup = 0;
}
itemToGet.motionX = itemToGet.motionY = itemToGet.motionZ = 0;
itemToGet.setPosition(
player.posX - 0.2 + (world.rand.nextDouble() * 0.4),
player.posY - 0.6,
player.posZ - 0.2 + (world.rand.nextDouble() * 0.4));
if (itemToGet.func_145800_j() == null
|| !itemToGet.func_145800_j().equals(player.getCommandSenderName()))
itemToGet.delayBeforeCanPickup = 0;
if (itemToGet.delayBeforeCanPickup <= 0) {
itemNBT.setBoolean("attractable", true);
itemToGet.readEntityFromNBT(itemNBT);
}
if (itemNBT.getBoolean("attractable")) {
itemToGet.motionX = itemToGet.motionY = itemToGet.motionZ = 0;
itemToGet.setPosition(
player.posX - 0.2 + (world.rand.nextDouble() * 0.4),
player.posY - 0.6,
player.posZ - 0.2 + (world.rand.nextDouble() * 0.4));
}
}
}
// xp
@@ -103,20 +105,21 @@ public class WirelessMagnet {
magnetRange).iterator();
while (iterator.hasNext()) {
EntityXPOrb xpToGet = (EntityXPOrb) iterator.next();
if (xpToGet.isDead || xpToGet.isInvisible()) {
continue;
EntityPlayer closestPlayer = world.getClosestPlayerToEntity(xpToGet, magnetRange);
if (!xpToGet.isDead && !xpToGet.isInvisible() && closestPlayer != null && closestPlayer == player) {
int xpAmount = xpToGet.xpValue;
xpToGet.xpValue = 0;
player.xpCooldown = 0;
player.addExperience(xpAmount);
xpToGet.setDead();
xpToGet.setInvisible(true);
world.playSoundAtEntity(
player,
"random.orb",
0.08F,
0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F));
}
int xpAmount = xpToGet.xpValue;
xpToGet.xpValue = 0;
player.xpCooldown = 0;
player.addExperience(xpAmount);
xpToGet.setDead();
xpToGet.setInvisible(true);
world.playSoundAtEntity(
player,
"random.orb",
0.08F,
0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F));
}
}
@@ -1,4 +1,3 @@
/* Author: asdflj */
package com.glodblock.github.inventory.item;
import static com.glodblock.github.inventory.item.WirelessMagnet.filterConfigKey;
@@ -48,7 +47,14 @@ public class WirelessMagnetCardFilterInventory extends BaseWirelessInventory imp
@SuppressWarnings("unchecked")
public WirelessMagnetCardFilterInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
super(is, slot, gridNode, player, StorageChannel.ITEMS, true);
filterInventory = new ItemBiggerAppEngInventory(is, filterKey, 27);
filterInventory = new ItemBiggerAppEngInventory(is, filterKey, 27) {
@Override
public void setInventorySlotContents(int slot, ItemStack newItemStack) {
if (newItemStack != null) newItemStack.stackSize = 1;
super.setInventorySlotContents(slot, newItemStack);
}
};
settingCache = getSettingTag(is);
filterCache = getFilterTag(is);
readFromNBT();
@@ -11,14 +11,9 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.IGridNode;
import appeng.api.storage.data.IAEItemStack;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -70,44 +65,11 @@ public class CPacketValueConfig implements IMessage {
!Util.isRestock(wirelessTerm)
? NameConst.TT_ULTRA_TERMINAL_RESTOCK_ON
: NameConst.TT_ULTRA_TERMINAL_RESTOCK_OFF)));
} else {
IGridNode gridNode = Util.getWirelessGrid(wirelessTerm);
if (gridNode != null && Util.isRestock(wirelessTerm)
&& Util.rangeCheck(wirelessTerm, player, gridNode)) {
restockItems(wirelessTerm, gridNode, result.getLeft(), player);
}
}
}
}
}
return null;
}
@SuppressWarnings("unchecked")
private void restockItems(ItemStack terminal, IGridNode gridNode, int slot, EntityPlayer player) {
WirelessCraftingTerminalInventory inv = new WirelessCraftingTerminalInventory(
terminal,
slot,
gridNode,
player);
for (int i = 0; i < 9; i++) {
ItemStack is = player.inventory.mainInventory[i];
if (is != null) {
int maxSize = is.getMaxStackSize();
if (is.stackSize < maxSize) {
int fillSize = maxSize - is.stackSize;
IAEItemStack ias = AEApi.instance().storage().createItemStack(is);
ias.setStackSize(fillSize);
IAEItemStack extractedItem = (IAEItemStack) inv
.extractItems(ias, Actionable.MODULATE, inv.getActionSource());
if (extractedItem != null) {
player.inventory.addItemStackToInventory(extractedItem.getItemStack());
}
}
}
}
}
}
}
@@ -1,33 +1,18 @@
package com.glodblock.github.proxy;
import static com.glodblock.github.common.Config.reStockTime;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.ImmutablePair;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.KeybindLoader;
import com.glodblock.github.loader.ListenerLoader;
import com.glodblock.github.loader.RenderLoader;
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
import com.glodblock.github.network.CPacketValueConfig;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
public class ClientProxy extends CommonProxy {
private static final Minecraft mc = Minecraft.getMinecraft();
private static long refreshTick = System.currentTimeMillis();
@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
@@ -53,17 +38,4 @@ public class ClientProxy extends CommonProxy {
new DefaultExtractorLoader().run();
}
}
@SubscribeEvent
public void tickEvent(TickEvent.PlayerTickEvent e) {
super.tickEvent(e);
if (refreshTick + reStockTime < System.currentTimeMillis()) {
// try to stock items
ImmutablePair<Integer, ItemStack> result = Util.getUltraWirelessTerm(mc.thePlayer);
if (result != null && mc.currentScreen == null && Util.isRestock(result.getRight())) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(1, 0));
}
refreshTick = System.currentTimeMillis();
}
}
}
@@ -39,7 +39,6 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
public class CommonProxy {
@@ -88,18 +87,6 @@ public class CommonProxy {
}
}
@SubscribeEvent
public void tickEvent(TickEvent.PlayerTickEvent e) {
EntityPlayer player = e.player;
ImmutablePair<Integer, ItemStack> result = Util.getUltraWirelessTerm(player);
if (result != null) {
final ItemStack wirelessTerm = result.getRight();
if (WirelessMagnet.getMode(wirelessTerm) != WirelessMagnet.Mode.Off) {
WirelessMagnet.doMagnet(wirelessTerm, e.player.worldObj, e.player);
}
}
}
public void preInit(FMLPreInitializationEvent event) {
ModAndClassUtil.init();
ItemAndBlockHolder.init();