Fix some warnings, remove broken cape code

This commit is contained in:
Raven Szewczyk committed 2022-08-26 16:27:43 +01:00
1 parent a10debce27
commit a6cbdc4b5d
5 files changed
+5 -428

No files matched your search

@@ -339,6 +339,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer
writeToNBT("crafting");
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
if (slot >= 0 && slot < this.inventorySlots.size()) {
final Slot s = this.getSlot(slot);
@@ -350,7 +351,9 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer
case CRAFT_STACK:
((SlotCraftingTerm) s).doClick(action, player);
this.updateHeld(player);
break;
default:
break;
}
}
@@ -1255,12 +1258,6 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer
return null;
}
@SuppressWarnings("unused")
private boolean isCraftMatrixSlot(AppEngSlot cs) {
return (cs.getSlotIndex() >= this.firstCraftingSlotNumber)
&& !(cs.getSlotIndex() <= this.lastCraftingSlotNumber);
}
private void updateSlot(final Slot clickSlot) {
this.detectAndSendChanges();
}
@@ -1,47 +0,0 @@
package net.p455w0rd.wirelesscraftingterminal.handlers;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class NEIRecipeHandler extends TemplateRecipeHandler {
public static NEIRecipeHandler INSTANCE;
public NEIRecipeHandler() {
INSTANCE = this;
}
@Override
public String getRecipeName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getGuiTexture() {
// TODO Auto-generated method stub
return null;
}
public void removeCachedRecipe(IRecipe r) {
ItemStack recipeOutput = null;
if (r instanceof ShapedOreRecipe) {
ShapedOreRecipe recipe = (ShapedOreRecipe) r;
recipeOutput = recipe.getRecipeOutput();
}
System.out.println("test");
if (recipeOutput == null) {
return;
}
for (int i = 0; i < arecipes.size(); i++) {
PositionedStack cachedResult = getResultStack(i);
PositionedStack recipeResult = new PositionedStack(recipeOutput, 119, 24);
if (cachedResult == recipeResult) {
System.out.println("match!");
}
}
}
}
@@ -1,263 +0,0 @@
package net.p455w0rd.wirelesscraftingterminal.implementation;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IMachineSet;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.DimensionalCoord;
import appeng.tile.misc.TileSecurity;
import appeng.tile.networking.TileWireless;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.MachineSource;
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionHost;
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTPlayerSource;
/**
* Provides wireless access to a ME network.
*
* @author Nividica
*
*/
public abstract class WirelessAELink implements IStorageMonitorable {
protected final EntityPlayer player;
protected final String encryptionKey;
protected IWirelessAccessPoint accessPoint;
protected DimensionalCoord apLocation = null;
protected BaseActionSource actionSource;
public WirelessAELink(final @Nullable EntityPlayer player, @Nonnull final String encryptionKey) {
this.player = player;
this.encryptionKey = encryptionKey;
this.linkWithNewAP();
}
private static boolean isAPInRange(
final DimensionalCoord APLocation,
final double APRange,
final World world,
final int x,
final int y,
final int z) {
if (!APLocation.isInWorld(world)) {
return false;
}
double squareDistance = getSquaredDistanceFromAP(APLocation, x, y, z);
return squareDistance <= (APRange * APRange);
}
private static ArrayList<IWirelessAccessPoint> locateAPsInRange(
final World world, final int x, final int y, final int z, final IGrid grid) {
IMachineSet accessPoints = grid.getMachines(TileWireless.class);
if (accessPoints.isEmpty()) {
return null;
}
ArrayList<IWirelessAccessPoint> aps = new ArrayList<IWirelessAccessPoint>();
for (IGridNode APNode : accessPoints) {
IWirelessAccessPoint AP = (IWirelessAccessPoint) APNode.getMachine();
if (AP.isActive()) {
if (isAPInRange(AP.getLocation(), AP.getRange(), world, x, y, z)) {
aps.add(AP);
}
}
}
return aps;
}
protected static double getSquaredDistanceFromAP(
final DimensionalCoord locationAP, final int x, final int y, final int z) {
if (locationAP == null) {
return Double.MAX_VALUE;
}
int dX = locationAP.x - x, dY = locationAP.y - y, dZ = locationAP.z - z;
return ((dX * dX) + (dY * dY) + (dZ * dZ));
}
public static ArrayList<IWirelessAccessPoint> locateAPsInRange(
final World world, final int x, final int y, final int z, final String encryptionKey) {
long encryptionValue;
try {
encryptionValue = Long.parseLong(encryptionKey);
} catch (NumberFormatException e) {
return null;
}
Object source = AEApi.instance().registries().locatable().getLocatableBy(encryptionValue);
if (!(source instanceof TileSecurity)) {
return null;
}
TileSecurity securityHost = (TileSecurity) source;
IGrid grid;
try {
grid = securityHost.getGridNode(ForgeDirection.UNKNOWN).getGrid();
} catch (Exception e) {
return null;
}
return locateAPsInRange(world, x, y, z, grid);
}
public static ArrayList<IWirelessAccessPoint> locateAPsInRangeOfPlayer(
final EntityPlayer player, final String encryptionKey) {
return locateAPsInRange(
player.worldObj,
(int) Math.floor(player.posX),
(int) Math.floor(player.posY),
(int) Math.floor(player.posZ),
encryptionKey);
}
private boolean isAPInRangeAndActive() {
if (this.accessPoint != null) {
if (this.accessPoint.isActive()) {
return isAPInRange(
this.apLocation,
this.accessPoint.getRange(),
this.getUserWorld(),
this.getUserPositionX(),
this.getUserPositionY(),
this.getUserPositionZ());
}
}
return false;
}
private boolean linkWithNewAP() {
World w = this.getUserWorld();
int x = this.getUserPositionX();
int y = this.getUserPositionY();
int z = this.getUserPositionZ();
IGrid grid = null;
if (this.accessPoint != null) {
try {
grid = this.accessPoint.getGrid();
} catch (Exception e) {
}
}
ArrayList<IWirelessAccessPoint> apList;
if (grid != null) {
apList = locateAPsInRange(w, x, y, z, grid);
} else {
apList = locateAPsInRange(w, x, y, z, this.encryptionKey);
}
if ((apList == null) || (apList.isEmpty())) {
this.accessPoint = null;
return false;
}
IWirelessAccessPoint closest = null;
double closestDistance = Double.MAX_VALUE;
for (IWirelessAccessPoint ap : apList) {
double dist = getSquaredDistanceFromAP(ap.getLocation(), x, y, z);
if (dist < closestDistance) {
closestDistance = dist;
closest = ap;
}
}
this.setAP(closest);
return true;
}
private void setAP(final IWirelessAccessPoint accessPoint) {
this.accessPoint = accessPoint;
this.apLocation = this.accessPoint.getLocation();
if (this.player != null) {
this.actionSource = new WCTPlayerSource(this.player, (WCTIActionHost) this.accessPoint);
} else {
this.actionSource = new MachineSource((WCTIActionHost) this.accessPoint);
}
}
protected abstract int getUserPositionX();
protected abstract int getUserPositionY();
protected abstract int getUserPositionZ();
protected abstract World getUserWorld();
protected abstract boolean hasPowerToCommunicate();
public IEnergyGrid getEnergyGrid() {
if (this.accessPoint == null) {
return null;
}
try {
return this.accessPoint.getActionableNode().getGrid().getCache(IEnergyGrid.class);
} catch (Exception e) {
// Ignored
}
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
if ((this.accessPoint == null) || !this.isConnected()) {
return null;
}
try {
IStorageGrid storageGrid =
this.accessPoint.getActionableNode().getGrid().getCache(IStorageGrid.class);
return storageGrid.getFluidInventory();
} catch (Exception e) {
// Ignored
}
return null;
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
if ((this.accessPoint == null) || !this.isConnected()) {
return null;
}
try {
IStorageGrid storageGrid =
this.accessPoint.getActionableNode().getGrid().getCache(IStorageGrid.class);
return storageGrid.getItemInventory();
} catch (Exception e) {
// Ignored
}
return null;
}
public boolean isConnected() {
if (!this.hasPowerToCommunicate()) {
return false;
}
if (this.isAPInRangeAndActive()) {
return true;
}
return this.linkWithNewAP();
}
}
@@ -1,30 +1,17 @@
package net.p455w0rd.wirelesscraftingterminal.proxy;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import javax.xml.bind.DatatypeConverter;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.common.MinecraftForge;
import net.p455w0rd.wirelesscraftingterminal.handlers.KeybindHandler;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
import org.apache.commons.io.IOUtils;
public class ClientProxy extends CommonProxy {
public ClientProxy() {
MinecraftForge.EVENT_BUS.register(this);
KeybindHandler.registerKeybinds(); // whyyyy??? #SELFSLAP
KeybindHandler.registerKeybinds();
FMLCommonHandler.instance().bus().register(new KeybindHandler());
}
@@ -32,66 +19,6 @@ public class ClientProxy extends CommonProxy {
public void removeItemsFromNEI() {
if (Loader.isModLoaded("NotEnoughItems")) {
codechicken.nei.api.API.hideItem(new ItemStack(ItemEnum.WCT_BOOSTER_BG_ICON.getItem(), 1));
return;
}
}
@Override
public void registerRenderers() {
// No renderers...yet =]
}
@SubscribeEvent
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
if (Reference.WCT_DIDTHEDIDDLE) {
return;
}
AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
if (!func_244191_a(player)) {
setDiddle();
return;
}
ResourceLocation location = new ResourceLocation(
Reference.MODID,
new String(DatatypeConverter.parseBase64Binary("dGV4dHVyZXMvY2FwZS9wNDU1Y2FwZS5wbmc=")));
player.func_152121_a(MinecraftProfileTexture.Type.values()[1], location);
}
static List<String> playThatFunkayMusaXWhiteboi() {
try {
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 func_244191_a(AbstractClientPlayer player) {
List<String> ae2serializable = playThatFunkayMusaXWhiteboi();
if (ae2serializable == null) {
setDiddle();
return false;
}
for (int i = 0; i < ae2serializable.size(); i++) {
String uuid = player.getUniqueID().toString();
String match = ae2serializable.get(i);
if (uuid.equals(match)) {
setDiddle();
return true;
}
}
setDiddle();
return false;
}
private static void setDiddle() {
Reference.WCT_DIDTHEDIDDLE = true;
}
}
@@ -60,13 +60,7 @@ public class CommonProxy {
}
}
public void removeItemsFromNEI() {
// XD
}
public void registerRenderers() {
// =P
}
public void removeItemsFromNEI() {}
@SubscribeEvent
public void tickEvent(TickEvent.PlayerTickEvent e) {
@@ -133,10 +127,6 @@ public class CommonProxy {
public void onPlayerLogin(PlayerLoggedInEvent e) {
// SSP Login
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
// boolean hasWCTAch = ((EntityPlayerMP)
// e.player).func_147099_x().hasAchievementUnlocked(AchievementHandler.wctAch);
// boolean hasBoosterAch = ((EntityPlayerMP)
// e.player).func_147099_x().hasAchievementUnlocked(AchievementHandler.boosterAch);
ConfigHandler.removeBooster();
ConfigHandler.removeBoosterIcon();
@@ -146,21 +136,6 @@ public class CommonProxy {
} else {
ConfigHandler.reloadRecipes();
}
// Was using this for hidden booster achievement
// it was giving me too much of a headache..maybe
// i'll implement in the future
/*
* AchievementPage achPg = AchievementPage.getAchievementPage(
* "Wireless Crafting Term"); if (achPg != null &&
* AchievementList.achievementList.contains(AchievementHandler.
* boosterAch) &&
* !achPg.getAchievements().contains(AchievementHandler.boosterAch))
* { AchievementList.achievementList.remove(AchievementHandler.
* boosterAch); } if ((Reference.WCT_BOOSTER_ENABLED && hasWCTAch)
* || hasBoosterAch) {
* AchievementHandler.addAchievementToPage(AchievementHandler.
* boosterAch, true, e.player); }
*/
/* NH fork definitely does not need version checking
if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) {
@@ -340,16 +315,4 @@ public class CommonProxy {
}
}
}
/*
* @SubscribeEvent public void achievementGetEvent(AchievementEvent event) {
* int index = AchievementList.achievementList.indexOf(wctAch); if
* (event.achievement.equals(AchievementList.achievementList.get(index))) {
* if (Reference.WCT_BOOSTER_ENABLED) { EnumChatFormatting purple =
* EnumChatFormatting.LIGHT_PURPLE; EnumChatFormatting green =
* EnumChatFormatting.GREEN; event.entityPlayer.addChatMessage(new
* ChatComponentText(EnumChatFormatting.ITALIC + "" + purple + "[" + green +
* "Wireless Crafting Terminal" + purple + "]: " + green + " New" + purple +
* " Achievment" + green + " Unlocked" + purple + "!")); } } }
*/
}