mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-18 11:19:33 +00:00
1 parent
c91163d3fa
commit
a9bcdf0643
18 files changed
+253
-111
No files matched your search
@@ -58,7 +58,7 @@ public class WirelessCraftingTerminal {
|
||||
long stopwatch = WCTLog.beginSection("Init");
|
||||
IntegrationRegistry.INSTANCE.init();
|
||||
WirelessCraftingTerminal.WCTState = LoaderState.INITIALIZATION;
|
||||
RecipeHandler.addRecipes(true);
|
||||
RecipeHandler.loadRecipes(!Reference.WCT_MINETWEAKER_OVERRIDE);
|
||||
AchievementHandler.init();
|
||||
WCTLog.endSection("Init", stopwatch);
|
||||
}
|
||||
|
||||
@@ -312,6 +312,7 @@ public class ContainerMagnet extends Container {
|
||||
stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
ItemStack phantomStack = stackHeld.copy();
|
||||
RandomUtils.removeTimerTags(phantomStack);
|
||||
phantomStack.stackSize = stackSize;
|
||||
|
||||
slot.putStack(phantomStack);
|
||||
|
||||
@@ -122,15 +122,68 @@ public class RandomUtils {
|
||||
}
|
||||
|
||||
public static boolean readBoolean(ItemStack is, String key) {
|
||||
return (is.hasTagCompound() ? is.getTagCompound().getBoolean(key) : false);
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getBoolean(key) : false);
|
||||
}
|
||||
|
||||
public static int readInt(ItemStack is, String key) {
|
||||
return (is.hasTagCompound() ? is.getTagCompound().getInteger(key) : 0);
|
||||
if (is == null) {
|
||||
return 0;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
return (tag.hasKey(key) ? tag.getInteger(key) : -1);
|
||||
}
|
||||
|
||||
public static void writeInt(ItemStack is, String key, int value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setInteger(key, value);
|
||||
}
|
||||
|
||||
public static void writeBoolean(ItemStack is, String key, boolean value) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.setBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void delKey(ItemStack is, String key) {
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = getTag(is);
|
||||
tag.removeTag(key);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getTag(ItemStack is) {
|
||||
if (!is.hasTagCompound()) {
|
||||
is.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
return is.getTagCompound();
|
||||
}
|
||||
|
||||
public static ItemStack readStack(NBTTagCompound nbtTC, String key) {
|
||||
return (nbtTC.hasKey(key) ? ItemStack.loadItemStackFromNBT(nbtTC) : null);
|
||||
}
|
||||
|
||||
public static void removeTimerTags(ItemStack is) {
|
||||
if (is == null || is.getTagCompound() == null) {
|
||||
return;
|
||||
}
|
||||
if (is.getTagCompound().hasKey("WCTReset")) {
|
||||
is.setTagCompound(null);
|
||||
}
|
||||
if (is.getTagCompound() != null) {
|
||||
if (is.getTagCompound().hasKey("WCTPickupTimer")) {
|
||||
is.getTagCompound().removeTag("WCTPickupTimer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+14
-3
@@ -6,26 +6,31 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.ConfigHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.RecipeHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class PacketConfigSync extends WCTPacket {
|
||||
|
||||
int wirelessTermMaxPower, boosterDropChance;
|
||||
boolean easyMode, boosterEnabled;
|
||||
boolean easyMode, boosterEnabled, mineTweakerOverride, oldMT, mtChanged = false;
|
||||
|
||||
public PacketConfigSync(final ByteBuf stream) {
|
||||
this.oldMT = Reference.WCT_MINETWEAKER_OVERRIDE;
|
||||
this.wirelessTermMaxPower = stream.readInt();
|
||||
this.easyMode = stream.readBoolean();
|
||||
this.boosterEnabled = stream.readBoolean();
|
||||
this.boosterDropChance = stream.readInt();
|
||||
this.mineTweakerOverride = stream.readBoolean();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketConfigSync(int power, boolean mode, boolean booster, int dropChance) {
|
||||
public PacketConfigSync(int power, boolean mode, boolean booster, int dropChance, boolean mtOverride) {
|
||||
this.oldMT = Reference.WCT_MINETWEAKER_OVERRIDE;
|
||||
this.wirelessTermMaxPower = power;
|
||||
this.easyMode = mode;
|
||||
this.boosterEnabled = booster;
|
||||
this.boosterDropChance = dropChance;
|
||||
this.mineTweakerOverride = mtOverride;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
data.writeInt(this.getPacketID());
|
||||
@@ -33,6 +38,7 @@ public class PacketConfigSync extends WCTPacket {
|
||||
data.writeBoolean(this.easyMode);
|
||||
data.writeBoolean(this.boosterEnabled);
|
||||
data.writeInt(this.boosterDropChance);
|
||||
data.writeBoolean(this.mineTweakerOverride);
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@@ -43,13 +49,18 @@ public class PacketConfigSync extends WCTPacket {
|
||||
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
if (oldMT != this.mineTweakerOverride) {
|
||||
mtChanged = true;
|
||||
}
|
||||
Reference.WCT_MAX_POWER = this.wirelessTermMaxPower;
|
||||
Reference.WCT_EASYMODE_ENABLED = this.easyMode;
|
||||
Reference.WCT_BOOSTER_ENABLED = this.boosterEnabled;
|
||||
Reference.WCT_BOOSTER_DROPCHANCE = this.boosterDropChance;
|
||||
Reference.WCT_MINETWEAKER_OVERRIDE = this.mineTweakerOverride;
|
||||
ConfigHandler.removeBooster();
|
||||
ConfigHandler.removeBoosterIcon();
|
||||
ConfigHandler.reloadRecipes();
|
||||
RecipeHandler.loadRecipes(mtChanged);
|
||||
mtChanged = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.handlers;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
@@ -43,19 +40,10 @@ public class AchievementHandler {
|
||||
}
|
||||
|
||||
public static void addAchievementToPage(Achievement a, boolean hidden, EntityPlayer player) {
|
||||
if (hidden) {
|
||||
if (player != null && FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||
if (!isAchievementUnlocked(player, wctAch) || achPage.getAchievements().contains(boosterAch)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
achPage.getAchievements().add(a);
|
||||
}
|
||||
|
||||
public static boolean isAchievementUnlocked(EntityPlayer p, Achievement a) {
|
||||
return ((EntityPlayerMP) p).func_147099_x().hasAchievementUnlocked(a);
|
||||
}
|
||||
|
||||
|
||||
public static void triggerAch(Achievement a, EntityPlayer p) {
|
||||
p.addStat(a, 1);
|
||||
|
||||
@@ -8,7 +8,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
@@ -24,9 +23,11 @@ public class ConfigHandler {
|
||||
public static int ae2wctMaxPower = Reference.WCT_MAX_POWER;
|
||||
public static int boosterDropChance = Reference.WCT_BOOSTER_DROPCHANCE;
|
||||
public static boolean boosterDropsEnabled = Reference.WCT_BOOSTERDROP_ENABLED;
|
||||
public static boolean mineTweakerOverride = Reference.WCT_MINETWEAKER_OVERRIDE;
|
||||
private static boolean doSave;
|
||||
public static boolean firstLoad = true;
|
||||
private static int pwrInCfgFile, boosterDropInCfgFile;
|
||||
private static boolean mtChanged = false;
|
||||
|
||||
public static void init(File configFile) {
|
||||
if (config == null) {
|
||||
@@ -49,9 +50,11 @@ public class ConfigHandler {
|
||||
String easyModeDesc = LocaleHandler.EasyModeDesc.getLocal();
|
||||
String boosterDropDesc = LocaleHandler.BoosterDropChance.getLocal();
|
||||
String boosterDropEnabledDesc = LocaleHandler.DisableBoosterDrop.getLocal();
|
||||
String mineTweakerOverrideDesc = LocaleHandler.MineTweakerOverride.getLocal();
|
||||
enableInfinityBooster = config.getBoolean("enableInfinityBooster", Configuration.CATEGORY_GENERAL, true, boosterDesc);
|
||||
enableEasyMode = config.getBoolean("enableEasyMode", Configuration.CATEGORY_GENERAL, false, easyModeDesc);
|
||||
boosterDropsEnabled = config.getBoolean("boosterDropsEnabled", Configuration.CATEGORY_GENERAL, true, boosterDropEnabledDesc);
|
||||
mineTweakerOverride = config.getBoolean("mineTweakerOverride", Configuration.CATEGORY_GENERAL, false, mineTweakerOverrideDesc);
|
||||
/*
|
||||
* I did the max power cfg loading like this because while using
|
||||
* Configuration#getInt did enforce the min/max values in-game, it
|
||||
@@ -92,25 +95,29 @@ public class ConfigHandler {
|
||||
boosterDropKey.comment = boosterDropDesc;
|
||||
doSave = true;
|
||||
}
|
||||
if (Reference.WCT_MINETWEAKER_OVERRIDE != mineTweakerOverride) {
|
||||
mtChanged = true;
|
||||
}
|
||||
|
||||
Reference.WCT_BOOSTER_ENABLED = enableInfinityBooster;
|
||||
Reference.WCT_EASYMODE_ENABLED = enableEasyMode;
|
||||
Reference.WCT_MAX_POWER = ae2wctMaxPower;
|
||||
Reference.WCT_BOOSTER_DROPCHANCE = boosterDropChance;
|
||||
Reference.WCT_BOOSTERDROP_ENABLED = boosterDropsEnabled;
|
||||
Reference.WCT_MINETWEAKER_OVERRIDE = mineTweakerOverride;
|
||||
|
||||
if (config.hasChanged() || doSave) {
|
||||
config.save();
|
||||
reloadRecipes();
|
||||
removeBooster();
|
||||
removeBoosterIcon();
|
||||
doSave = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadRecipes() {
|
||||
WCTLog.info("Reinitializing Recipes");
|
||||
RecipeHandler.removeRecipes();
|
||||
RecipeHandler.addRecipes();
|
||||
RecipeHandler.loadRecipes(mtChanged);
|
||||
mtChanged = false;
|
||||
}
|
||||
|
||||
public static void removeBoosterIcon() {
|
||||
|
||||
@@ -9,7 +9,7 @@ public enum LocaleHandler {
|
||||
MagnetDesc, MagnetDesc2, PressShift, OnlyWorks, LinkStatus, Installed, NotInstalled, Active, Inactive,
|
||||
Status, EmptyTrash, EmptyTrashDesc, MagnetFilterTitle, NoNetworkPower("chatmessages.ae2wct"), InitializeMagnet("chatmessages.ae2wct"), FilterMode,
|
||||
Whitelisting, Blacklisting, MagnetMode1("chatmessages.ae2wct"), MagnetMode2("chatmessages.ae2wct"), MagnetMode3("chatmessages.ae2wct"),
|
||||
MagnetActiveDesc1, MagnetActiveDesc2, BoosterDropChance("config.ae2wct"), DisableBoosterDrop("config.ae2wct");
|
||||
MagnetActiveDesc1, MagnetActiveDesc2, BoosterDropChance("config.ae2wct"), DisableBoosterDrop("config.ae2wct"), MineTweakerOverride("config.ae2wct");
|
||||
|
||||
private final String root;
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class RecipeHandler {
|
||||
|
||||
public static ArrayList<IRecipe> recipeList = new ArrayList<IRecipe>();
|
||||
public static ArrayList<IRecipe> easyRecipeList = new ArrayList<IRecipe>();
|
||||
public static ArrayList<IRecipe> hardRecipeList = new ArrayList<IRecipe>();
|
||||
|
||||
public static void init() {
|
||||
Item multiMaterial = GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial");
|
||||
@@ -25,78 +26,77 @@ public class RecipeHandler {
|
||||
Item blockSpatialIO = GameRegistry.findItem("appliedenergistics2", "tile.BlockSpatialPylon");
|
||||
Item blockCraftingStorage = GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingStorage");
|
||||
|
||||
// Is easy mode enabled?
|
||||
if (Reference.WCT_EASYMODE_ENABLED) {
|
||||
//EASY MODE RECIPES
|
||||
|
||||
// Wireless Crafting Terminal
|
||||
recipeList.add(new ShapedOreRecipe(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getStack(), new Object[] { "a", "b", "c", Character.valueOf('a'), new ItemStack(multiMaterial, 1, 41), Character.valueOf('b'), new ItemStack(multiPart, 1, 360), Character.valueOf('c'), new ItemStack(ae2WirelessTerm, 1, 0) }));
|
||||
// Wireless Crafting Terminal
|
||||
easyRecipeList.add(new ShapedOreRecipe(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getStack(), new Object[] { "a", "b", "c", Character.valueOf('a'), new ItemStack(multiMaterial, 1, 41), Character.valueOf('b'), new ItemStack(multiPart, 1, 360), Character.valueOf('c'), new ItemStack(ae2WirelessTerm, 1, 0) }));
|
||||
|
||||
// Magnet Card
|
||||
recipeList.add(new ShapedOreRecipe(ItemEnum.MAGNET_CARD.getStack(), new Object[] {
|
||||
"a b", "cdc", "ccc",
|
||||
Character.valueOf('a'), "dustRedstone",
|
||||
Character.valueOf('b'), "gemLapis",
|
||||
Character.valueOf('c'), "ingotIron",
|
||||
Character.valueOf('d'), new ItemStack(multiMaterial, 1, 28) }));
|
||||
// Magnet Card
|
||||
easyRecipeList.add(new ShapedOreRecipe(ItemEnum.MAGNET_CARD.getStack(), new Object[] {
|
||||
"a b", "cdc", "ccc",
|
||||
Character.valueOf('a'), "dustRedstone",
|
||||
Character.valueOf('b'), "gemLapis",
|
||||
Character.valueOf('c'), "ingotIron",
|
||||
Character.valueOf('d'), new ItemStack(multiMaterial, 1, 28) }));
|
||||
|
||||
// Is Booster Card Enabled?
|
||||
if (Reference.WCT_BOOSTER_ENABLED) {
|
||||
// Infinity Booster Card
|
||||
recipeList.add(new ShapedOreRecipe(ItemEnum.BOOSTER_CARD.getStack(), new Object[] { "abc", "ded", "cba", Character.valueOf('a'), new ItemStack(blockSpatialIO, 1, 0), Character.valueOf('b'), new ItemStack(multiMaterial, 1, 42), Character.valueOf('c'), new ItemStack(blockCraftingStorage, 1, 3), Character.valueOf('d'), new ItemStack(multiMaterial, 1, 48), Character.valueOf('e'), new ItemStack(itemWAP, 1, 0) }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Wireless Crafting Terminal
|
||||
recipeList.add(new ShapedOreRecipe(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getStack(), new Object[] { "aba", "cdc", "efe", Character.valueOf('a'), new ItemStack(multiMaterial, 1, 9), Character.valueOf('b'), new ItemStack(itemWAP, 1, 0), Character.valueOf('c'), new ItemStack(multiMaterial, 1, 12), Character.valueOf('d'), new ItemStack(multiPart, 1, 360), Character.valueOf('e'), new ItemStack(multiMaterial, 1, 38), Character.valueOf('f'), new ItemStack(multiMaterial, 1, 47) }));
|
||||
|
||||
// Magnet Card
|
||||
recipeList.add(new ShapedOreRecipe(ItemEnum.MAGNET_CARD.getStack(), new Object[] {
|
||||
"abc", "ded", "ddd",
|
||||
Character.valueOf('a'), "blockRedstone",
|
||||
Character.valueOf('b'), new ItemStack(multiPart, 1, 301),
|
||||
Character.valueOf('c'), "blockLapis",
|
||||
Character.valueOf('d'), "blockIron",
|
||||
Character.valueOf('e'), new ItemStack(multiMaterial, 1, 28) }));
|
||||
}
|
||||
// Infinity Booster Card
|
||||
easyRecipeList.add(new ShapedOreRecipe(ItemEnum.BOOSTER_CARD.getStack(), new Object[] { "abc", "ded", "cba", Character.valueOf('a'), new ItemStack(blockSpatialIO, 1, 0), Character.valueOf('b'), new ItemStack(multiMaterial, 1, 42), Character.valueOf('c'), new ItemStack(blockCraftingStorage, 1, 3), Character.valueOf('d'), new ItemStack(multiMaterial, 1, 48), Character.valueOf('e'), new ItemStack(itemWAP, 1, 0) }));
|
||||
|
||||
}
|
||||
//==================
|
||||
// HARD MODE RECIPES
|
||||
|
||||
// Wireless Crafting Terminal
|
||||
hardRecipeList.add(new ShapedOreRecipe(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getStack(), new Object[] { "aba", "cdc", "efe", Character.valueOf('a'), new ItemStack(multiMaterial, 1, 9), Character.valueOf('b'), new ItemStack(itemWAP, 1, 0), Character.valueOf('c'), new ItemStack(multiMaterial, 1, 12), Character.valueOf('d'), new ItemStack(multiPart, 1, 360), Character.valueOf('e'), new ItemStack(multiMaterial, 1, 38), Character.valueOf('f'), new ItemStack(multiMaterial, 1, 47) }));
|
||||
|
||||
public static void addRecipes() {
|
||||
addRecipes(false);
|
||||
}
|
||||
// Magnet Card
|
||||
hardRecipeList.add(new ShapedOreRecipe(ItemEnum.MAGNET_CARD.getStack(), new Object[] {
|
||||
"abc", "ded", "ddd",
|
||||
Character.valueOf('a'), "blockRedstone",
|
||||
Character.valueOf('b'), new ItemStack(multiPart, 1, 300),
|
||||
Character.valueOf('c'), "blockLapis",
|
||||
Character.valueOf('d'), "blockIron",
|
||||
Character.valueOf('e'), new ItemStack(multiMaterial, 1, 28) }));
|
||||
|
||||
public static void addRecipes(boolean init) {
|
||||
if (init) {
|
||||
init();
|
||||
}
|
||||
if (recipeList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (IRecipe recipe : recipeList) {
|
||||
GameRegistry.addRecipe(recipe);
|
||||
WCTLog.info("Added Recipe for " + recipe.getRecipeOutput().getDisplayName());
|
||||
}
|
||||
recipeList.clear();
|
||||
init();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void removeRecipes() {
|
||||
if (recipeList.size() == 0) {
|
||||
public static void loadRecipes(boolean mtChanged) {
|
||||
if (Reference.WCT_MINETWEAKER_OVERRIDE && !mtChanged) {
|
||||
return;
|
||||
}
|
||||
ArrayList<IRecipe> recipeList = (Reference.WCT_EASYMODE_ENABLED ? easyRecipeList : hardRecipeList);
|
||||
ArrayList<IRecipe> recipeList2 = (!Reference.WCT_EASYMODE_ENABLED ? easyRecipeList : hardRecipeList);
|
||||
|
||||
WCTLog.info("Reinitializing Recipes");
|
||||
if (recipeList.size() <= 0 || recipeList2.size() <= 0) {
|
||||
init();
|
||||
}
|
||||
|
||||
// remove old recipes
|
||||
Iterator<IRecipe> iterator = CraftingManager.getInstance().getRecipeList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack r = iterator.next().getRecipeOutput();
|
||||
for (IRecipe recipe : recipeList) {
|
||||
for (IRecipe recipe : recipeList2) {
|
||||
ItemStack recipeOutput = recipe.getRecipeOutput();
|
||||
if (r != null && r.getItem() == recipeOutput.getItem()) {
|
||||
if (r == null) {
|
||||
continue;
|
||||
}
|
||||
if (r.getItem() == recipeOutput.getItem()) {
|
||||
iterator.remove();
|
||||
WCTLog.info("Removed Recipe for " + r.getDisplayName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
recipeList.clear();
|
||||
init();
|
||||
|
||||
// add new recipes
|
||||
for (IRecipe recipe : recipeList) {
|
||||
if (Reference.WCT_MINETWEAKER_OVERRIDE) {
|
||||
return;
|
||||
}
|
||||
GameRegistry.addRecipe(recipe);
|
||||
WCTLog.info("Added Recipe for " + recipe.getRecipeOutput().getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,18 +197,24 @@ public class ItemMagnet extends Item {
|
||||
return;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
|
||||
List<ItemStack> filteredList = getFilteredItems(this.getItemStack());
|
||||
// items
|
||||
Iterator iterator = getEntitiesInRange(EntityItem.class, world, (int) player.posX, (int) player.posY, (int) player.posZ, this.distanceFromPlayer).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
EntityItem itemToGet = (EntityItem) iterator.next();
|
||||
itemToGet.delayBeforeCanPickup = 50;
|
||||
if (itemToGet == null) {
|
||||
return;
|
||||
}
|
||||
itemToGet.delayBeforeCanPickup = 75;
|
||||
|
||||
EntityItemPickupEvent pickupEvent = new EntityItemPickupEvent(player, itemToGet);
|
||||
ItemPickupEvent itemPickupEvent = new ItemPickupEvent(player, itemToGet);
|
||||
ItemStack itemStackToGet = itemToGet.getEntityItem();
|
||||
if (itemStackToGet == null) {
|
||||
return;
|
||||
}
|
||||
int stackSize = itemStackToGet.stackSize;
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(pickupEvent);
|
||||
@@ -292,14 +298,28 @@ public class ItemMagnet extends Item {
|
||||
world.playSoundAtEntity(player, "random.orb", 0.08F, 0.5F * ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.8F));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void doVanillaPickup(EntityItem itemToGet, EntityPlayer player, ItemStack itemStackToGet, World world, int stackSize) {
|
||||
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);
|
||||
ItemStack is = itemToGet.getEntityItem();
|
||||
if (is.getTagCompound() == null) {
|
||||
RandomUtils.writeBoolean(is, "WCTReset", true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
RandomUtils.writeInt(is, "WCTPickupTimer", pickupTimer + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doesMagnetIgnoreNBT() {
|
||||
@@ -331,30 +351,48 @@ public class ItemMagnet extends Item {
|
||||
if (is != null && itemList != null) {
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
ItemStack thisStack = (ItemStack) itemList.get(i);
|
||||
//use oredict
|
||||
if (doesMagnetUseOreDict()) {
|
||||
if (areOresEqual(is, thisStack)) {
|
||||
//if (OreDictionary.itemMatches(is, thisStack, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//ignore meta & nbt
|
||||
if (doesMagnetIgnoreMeta() && doesMagnetIgnoreNBT()) {
|
||||
if (is.getItem().equals(thisStack.getItem()) && (is.getItem() == thisStack.getItem())) {
|
||||
if (is.getItem().equals(thisStack.getItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//ignore meta only
|
||||
else if (doesMagnetIgnoreMeta() && !doesMagnetIgnoreNBT()) {
|
||||
if (ItemStack.areItemStackTagsEqual(is, thisStack) && (is.getItem() == thisStack.getItem())) {
|
||||
if (ItemStack.areItemStackTagsEqual(is, thisStack) && is.getItem() == thisStack.getItem()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (!doesMagnetIgnoreMeta() && doesMagnetIgnoreNBT()) {
|
||||
if (isMetaEqual(is, thisStack) && (is.getItem() == thisStack.getItem())) {
|
||||
//ignore nbt only
|
||||
else if (!doesMagnetIgnoreMeta() && doesMagnetIgnoreNBT() && is.getItem() == thisStack.getItem()) {
|
||||
if (isMetaEqual(is, thisStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//ignore nothing/don't use oredict--must be exact match
|
||||
else {
|
||||
if (isMetaEqual(is, thisStack) && ItemStack.areItemStackTagsEqual(is, thisStack) && (is.getItem() == thisStack.getItem())) {
|
||||
return true;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,7 +449,11 @@ public class ItemMagnet extends Item {
|
||||
}
|
||||
|
||||
private void doInject(IAEItemStack ais, int stackSize, EntityPlayer player, EntityItem itemToGet, ItemStack itemStackToGet, World world) {
|
||||
ais = Platform.poweredInsert(this.powerSrc, this.cellInv, ais, this.mySrc);
|
||||
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);
|
||||
if (ais != null) {
|
||||
player.onItemPickup(itemToGet, stackSize);
|
||||
player.inventory.addItemStackToInventory(itemStackToGet);
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.proxy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
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 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;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@@ -26,5 +41,42 @@ public class ClientProxy extends CommonProxy {
|
||||
public void registerRenderers() {
|
||||
// No renderers...yet =]
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
|
||||
AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer;
|
||||
if (!isPatron(player)) {
|
||||
return;
|
||||
}
|
||||
ResourceLocation location = new ResourceLocation(Reference.MODID, "textures/cape/p455cape.png");
|
||||
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, location);
|
||||
}
|
||||
|
||||
static List<String> getPatronList() {
|
||||
try {
|
||||
InputStream in = new URL("https://raw.githubusercontent.com/p455w0rd/WirelessCraftingTerminal/master/.settings/patrons.txt").openStream();
|
||||
return IOUtils.readLines(in);
|
||||
}
|
||||
catch (MalformedURLException ignored) {
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isPatron(AbstractClientPlayer player) {
|
||||
List<String> patronList = getPatronList();
|
||||
if (patronList == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < patronList.size(); i++) {
|
||||
String uuid = player.getUniqueID().toString();
|
||||
String match = patronList.get(i);
|
||||
if (uuid.equals(match)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -138,7 +137,7 @@ public class CommonProxy {
|
||||
*/
|
||||
}
|
||||
else {
|
||||
final PacketConfigSync p = new PacketConfigSync(Reference.WCT_MAX_POWER, Reference.WCT_EASYMODE_ENABLED, Reference.WCT_BOOSTER_ENABLED, Reference.WCT_BOOSTER_DROPCHANCE);
|
||||
final PacketConfigSync p = new PacketConfigSync(Reference.WCT_MAX_POWER, Reference.WCT_EASYMODE_ENABLED, Reference.WCT_BOOSTER_ENABLED, Reference.WCT_BOOSTER_DROPCHANCE, Reference.WCT_MINETWEAKER_OVERRIDE);
|
||||
NetworkHandler.instance.sendTo((WCTPacket) p, (EntityPlayerMP) e.player);
|
||||
}
|
||||
}
|
||||
@@ -165,9 +164,7 @@ public class CommonProxy {
|
||||
public void pickupEvent(PlayerEvent.ItemPickupEvent e) {
|
||||
if (Reference.WCT_BOOSTER_ENABLED && !Reference.WCT_EASYMODE_ENABLED) {
|
||||
if (e.pickedUp.getEntityItem().getItem() == ItemEnum.BOOSTER_CARD.getItem()) {
|
||||
if (AchievementHandler.isAchievementUnlocked(e.player, wctAch)) {
|
||||
AchievementHandler.triggerAch(boosterAch, e.player);
|
||||
}
|
||||
AchievementHandler.triggerAch(boosterAch, e.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,21 +179,6 @@ public class CommonProxy {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
boolean hasWCTAch = false;
|
||||
if (!event.player.worldObj.isRemote) {
|
||||
hasWCTAch = ((EntityPlayerMP) event.player).func_147099_x().hasAchievementUnlocked(AchievementHandler.wctAch);
|
||||
}
|
||||
else {
|
||||
hasWCTAch = ((EntityClientPlayerMP) event.player).getStatFileWriter().hasAchievementUnlocked(AchievementHandler.wctAch);
|
||||
}
|
||||
if (event.crafting.getItem() == ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem()) {
|
||||
AchievementHandler.triggerAch(wctAch, event.player);
|
||||
}
|
||||
if (event.crafting.getItem() == ItemEnum.MAGNET_CARD.getItem() && hasWCTAch) {
|
||||
AchievementHandler.triggerAch(magnetAch, event.player);
|
||||
}
|
||||
*/
|
||||
if (event.crafting.getItem() == ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem()) {
|
||||
AchievementHandler.triggerAch(wctAch, event.player);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Reference {
|
||||
public static int WCT_CRAFTMATRIX_Y_OFFSET = 100;
|
||||
public static int WCT_BOOSTER_DROPCHANCE = 50;
|
||||
public static boolean WCT_BOOSTERDROP_ENABLED = true;
|
||||
public static boolean WCT_MINETWEAKER_OVERRIDE = false;
|
||||
|
||||
// Gui IDs
|
||||
private static int ae2wctGuiIndex = 0;
|
||||
|
||||
Reference in new issue
Block a user