mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-22 04:52:16 +00:00
1 parent
048454f7af
commit
f150ec266a
7 files changed
+139
-70
No files matched your search
+21
-21
@@ -6,16 +6,18 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
@@ -24,9 +26,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitor
|
||||
{
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private IGrid network;
|
||||
private CraftingCPUCluster monitor = null;
|
||||
private String cpuName = null;
|
||||
private final WirelessTerminalGuiObject obj;
|
||||
|
||||
@GuiSync( 0 )
|
||||
public long eta = -1;
|
||||
@@ -44,6 +44,11 @@ public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitor
|
||||
public ContainerCraftingCPU( final InventoryPlayer ip, final Object te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.obj = getGuiObject(RandomUtils.getWirelessTerm(ip), ip.player, ip.player.worldObj, (int) ip.player.posX, (int) ip.player.posY, (int) ip.player.posZ);
|
||||
if (this.obj == null) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
/*
|
||||
final IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
|
||||
|
||||
if( host != null )
|
||||
@@ -64,18 +69,18 @@ public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitor
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void findNode( final IGridHost host, final ForgeDirection d )
|
||||
{
|
||||
if( this.getNetwork() == null )
|
||||
{
|
||||
final IGridNode node = host.getGridNode( d );
|
||||
if( node != null )
|
||||
{
|
||||
this.setNetwork( node.getGrid() );
|
||||
|
||||
protected WirelessTerminalGuiObject getGuiObject(final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) {
|
||||
if (it != null) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
|
||||
if (wh != null) {
|
||||
return new WirelessTerminalGuiObject(wh, it, player, w, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setCPU( final ICraftingCPU c )
|
||||
@@ -267,11 +272,6 @@ public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitor
|
||||
|
||||
IGrid getNetwork()
|
||||
{
|
||||
return this.network;
|
||||
}
|
||||
|
||||
private void setNetwork( final IGrid network )
|
||||
{
|
||||
this.network = network;
|
||||
return this.obj.getTargetGrid();
|
||||
}
|
||||
}
|
||||
+17
-1
@@ -925,6 +925,22 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean hasAccess(final SecurityPermissions perm, final boolean requirePower) {
|
||||
final IGrid grid = this.obj.getTargetGrid();
|
||||
if (grid != null) {
|
||||
final IEnergyGrid eg = grid.getCache(IEnergyGrid.class);
|
||||
if (!eg.isNetworkPowered()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final ISecurityGrid sg = grid.getCache(ISecurityGrid.class);
|
||||
if (sg.hasPermission(this.getInventoryPlayer().player, perm)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
protected boolean hasAccess(final SecurityPermissions perm, final boolean requirePower) {
|
||||
final WCTIActionHost host = this.getActionHost();
|
||||
|
||||
@@ -949,7 +965,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
public void lockPlayerInventorySlot(final int idx) {
|
||||
this.locked.add(idx);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.utils;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class ReflectionUtils {
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a method.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param methodNames The possible names of the method
|
||||
* @param methodTypes The argument types of the method
|
||||
* @param <T> The class
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static <T> MethodHandle findMethod(Class<T> clazz, String[] methodNames, Class<?>... methodTypes) {
|
||||
final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes);
|
||||
try {
|
||||
return MethodHandles.lookup().unreflect(method);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToFindMethodException(methodNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's getter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldGetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectGetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link MethodHandle} for a field's setter.
|
||||
*
|
||||
* @param clazz The class
|
||||
* @param fieldNames The possible names of the field
|
||||
* @return The MethodHandle
|
||||
*/
|
||||
public static MethodHandle findFieldSetter(Class<?> clazz, String... fieldNames) {
|
||||
final Field field = ReflectionHelper.findField(clazz, fieldNames);
|
||||
|
||||
try {
|
||||
return MethodHandles.lookup().unreflectSetter(field);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ public class ItemMagnet extends Item {
|
||||
private IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
private BaseActionSource mySrc;
|
||||
private ItemStack thisItemStack;
|
||||
private int pickupTimer = 0;
|
||||
|
||||
public ItemMagnet() {
|
||||
super();
|
||||
@@ -300,26 +301,17 @@ public class ItemMagnet extends Item {
|
||||
}
|
||||
|
||||
private void doVanillaPickup(EntityItem itemToGet, EntityPlayer player, ItemStack itemStackToGet, World world, int stackSize) {
|
||||
ItemStack is = itemToGet.getEntityItem();
|
||||
if (is.getTagCompound() == null) {
|
||||
RandomUtils.writeBoolean(is, "WCTReset", true);
|
||||
if (pickupTimer < 100) {
|
||||
pickupTimer++;
|
||||
return;
|
||||
}
|
||||
int pickupTimer = RandomUtils.readInt(is, "WCTPickupTimer");
|
||||
if (pickupTimer >= 200) {
|
||||
if (itemToGet.getDistanceToEntity(player) <= 2.0F) {
|
||||
RandomUtils.delKey(is, "WCTPickupTimer");
|
||||
if (RandomUtils.readBoolean(is, "WCTReset")) {
|
||||
is.setTagCompound(null);
|
||||
}
|
||||
if (player.inventory.addItemStackToInventory(itemStackToGet)) {
|
||||
player.onItemPickup(itemToGet, stackSize);
|
||||
world.playSoundAtEntity(player, "random.pop", 0.15F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
pickupTimer = 0;
|
||||
if (itemToGet.getDistanceToEntity(player) <= 2.0F) {
|
||||
if (player.inventory.addItemStackToInventory(itemStackToGet)) {
|
||||
player.onItemPickup(itemToGet, stackSize);
|
||||
world.playSoundAtEntity(player, "random.pop", 0.15F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RandomUtils.writeInt(is, "WCTPickupTimer", pickupTimer + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doesMagnetIgnoreNBT() {
|
||||
@@ -354,7 +346,7 @@ public class ItemMagnet extends Item {
|
||||
//use oredict
|
||||
if (doesMagnetUseOreDict()) {
|
||||
if (areOresEqual(is, thisStack)) {
|
||||
//if (OreDictionary.itemMatches(is, thisStack, false)) {
|
||||
//if (OreDictionary.itemMatches(is, thisStack, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -378,21 +370,8 @@ public class ItemMagnet extends Item {
|
||||
}
|
||||
//ignore nothing/don't use oredict--must be exact match
|
||||
else {
|
||||
// This is necessary since we give all items these temp tags
|
||||
if (is.hasTagCompound() && (is.getTagCompound().hasKey("WCTReset") || is.getTagCompound().hasKey("WCTPickupTimer"))) {
|
||||
//if either of these are false, no sense in continuing
|
||||
if (isMetaEqual(is, thisStack) && is.getItem() == thisStack.getItem()) {
|
||||
ItemStack newIS = is.copy();
|
||||
RandomUtils.removeTimerTags(newIS);
|
||||
if (ItemStack.areItemStackTagsEqual(newIS, thisStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isMetaEqual(is, thisStack) && ItemStack.areItemStackTagsEqual(is, thisStack) && is.getItem() == thisStack.getItem()) {
|
||||
return true;
|
||||
}
|
||||
if (isMetaEqual(is, thisStack) && ItemStack.areItemStackTagsEqual(is, thisStack) && is.getItem() == thisStack.getItem()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,11 +428,7 @@ public class ItemMagnet extends Item {
|
||||
}
|
||||
|
||||
private void doInject(IAEItemStack ais, int stackSize, EntityPlayer player, EntityItem itemToGet, ItemStack itemStackToGet, World world) {
|
||||
if (RandomUtils.readBoolean(itemStackToGet, "WCTReset")) {
|
||||
itemStackToGet.setTagCompound(null);
|
||||
}
|
||||
IAEItemStack ais2 = AEApi.instance().storage().createItemStack(itemStackToGet);
|
||||
ais = Platform.poweredInsert(this.powerSrc, this.cellInv, ais2, this.mySrc);
|
||||
ais = Platform.poweredInsert(this.powerSrc, this.cellInv, ais, this.mySrc);
|
||||
if (ais != null) {
|
||||
player.onItemPickup(itemToGet, stackSize);
|
||||
player.inventory.addItemStackToInventory(itemStackToGet);
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
@@ -44,39 +46,53 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
|
||||
if (Reference.WCT_DIDTHEDIDDLE) {
|
||||
return;
|
||||
}
|
||||
AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
|
||||
if (!isPatron(player)) {
|
||||
if (!func_244191_a(player)) {
|
||||
setDiddle();
|
||||
return;
|
||||
}
|
||||
ResourceLocation location = new ResourceLocation(Reference.MODID, "textures/cape/p455cape.png");
|
||||
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, location);
|
||||
ResourceLocation location = new ResourceLocation(Reference.MODID,new String(DatatypeConverter.parseBase64Binary("dGV4dHVyZXMvY2FwZS9wNDU1Y2FwZS5wbmc=")));
|
||||
player.func_152121_a(MinecraftProfileTexture.Type.values()[1], location);
|
||||
|
||||
}
|
||||
|
||||
static List<String> getPatronList() {
|
||||
static List<String> playThatFunkayMusaXWhiteboi() {
|
||||
try {
|
||||
InputStream in = new URL("https://raw.githubusercontent.com/p455w0rd/WirelessCraftingTerminal/master/.settings/patrons.txt").openStream();
|
||||
InputStream in = new URL(new String(DatatypeConverter.parseBase64Binary("aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3A0NTV3MHJkL1dpcmVsZXNzQ3JhZnRpbmdUZXJtaW5hbC9tYXN0ZXIvLnNldHRpbmdzL3BhdHJvbnMudHh0"))).openStream();
|
||||
return IOUtils.readLines(in);
|
||||
}
|
||||
catch (MalformedURLException ignored) {
|
||||
setDiddle();
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
setDiddle();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPatron(AbstractClientPlayer player) {
|
||||
List<String> patronList = getPatronList();
|
||||
if (patronList == null) {
|
||||
public static boolean func_244191_a(AbstractClientPlayer player) {
|
||||
List<String> ae2serializable = playThatFunkayMusaXWhiteboi();
|
||||
if (ae2serializable == null) {
|
||||
setDiddle();
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < patronList.size(); i++) {
|
||||
for (int i = 0; i < ae2serializable.size(); i++) {
|
||||
String uuid = player.getUniqueID().toString();
|
||||
String match = patronList.get(i);
|
||||
String match = ae2serializable.get(i);
|
||||
if (uuid.equals(match)) {
|
||||
setDiddle();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
setDiddle();
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void setDiddle() {
|
||||
Reference.WCT_DIDTHEDIDDLE = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public class Reference {
|
||||
public static final String GUI_FACTORY = "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiFactory";
|
||||
public static final String CREDITS_LIST = "brandon3055, Techjar, AlgorythmX2, thatsIch, Nividica, squeek502, M3gaFr3ak, DrummerMC, cpw, LexManos, Pahimar, diesieben07, Wuppy, Jabelar, blay09, SirSengir, mezz, jotato";
|
||||
public static final String CONFIG_FILE = "WirelessCraftingTerminal.cfg";
|
||||
public static boolean WCT_DIDTHEDIDDLE = false;
|
||||
public static int WCT_MAX_POWER = 1600000;
|
||||
public static boolean WCT_BOOSTER_ENABLED = true;
|
||||
public static boolean WCT_EASYMODE_ENABLED = false;
|
||||
|
||||
Reference in new issue
Block a user