public void setData(TileEntity te, boolean force, NBTTagCompound NBT) { if (dispatch) { if (DragonOptions.LOGSYNCCME.getState()) { DragonAPICore.log("The sync packet for " + te + " would have just CME'd, as the"); DragonAPICore.log( "Server-Thread data-writing code has overlapped with the Network-Thread byte[] dispatch."); DragonAPICore.log("Seeing this message frequently could indicate a serious issue.\n"); } return; } field_148863_a = te.xCoord; field_148861_b = te.yCoord; field_148862_c = te.zCoord; changes.clear(); Collection c = NBT.func_150296_c(); Iterator<String> it = c.iterator(); while (it.hasNext()) { String name = it.next(); if (name == null) { DragonAPICore.logError( "An NBT tag with a null key is being sent to the sync packet from " + te); } else { NBTBase tag = NBT.getTag(name); this.addData(name, tag, force); } } }
public void onInteract(World world, int x, int y, int z, EntityPlayer ep) { LaserEffectTile te = (LaserEffectTile) world.getTileEntity(x, y, z); if (DragonAPICore.isReikasComputer() && ReikaObfuscationHelper.isDeObfEnvironment()) { ItemStack is = ep.getCurrentEquippedItem(); if (ChromaItems.SHARD.matchWith(is)) { int dmg = is.getItemDamage() % 16; if (dmg == CrystalElement.RED.ordinal()) { te.color.red = !te.color.red; } else if (dmg == CrystalElement.GREEN.ordinal()) { te.color.green = !te.color.green; } else if (dmg == CrystalElement.BLUE.ordinal()) { te.color.blue = !te.color.blue; } world.markBlockForUpdate(x, y, z); return; } else if (!this.isOmniDirectional() && is != null && is.getItem() == Items.diamond) { te.rotateable = !te.rotateable; world.markBlockForUpdate(x, y, z); return; } else if (te instanceof TargetTile && is != null && is.getItem() == Items.glowstone_dust) { ((TargetTile) te).trigger(!((TargetTile) te).isTriggered(), true, false); return; } else if (te instanceof PrismTile && is != null && is.getItem() == Items.emerald) { ((PrismTile) te).timer++; return; } if (this == EMITTER && !ep.isSneaking()) { te.fire(); return; } } if (!this.isOmniDirectional() && !world.isRemote) te.rotate(); }
@Override public void readPacketData(PacketBuffer in) throws IOException { receive = true; try { field_148863_a = in.readInt(); field_148861_b = in.readShort(); field_148862_c = in.readInt(); NBTTagCompound received = in.readNBTTagCompoundFromBuffer(); if (!received.getBoolean(ERROR_TAG)) { // try { this.populateFromStream(received); // } // catch (Exception e) { // e.printStackTrace(); // data.clear(); //discard packet // } } } catch (Exception e) { DragonAPICore.logError("Error reading Sync Tag!"); e.printStackTrace(); data.clear(); } receive = false; }
@SideOnly(Side.CLIENT) public void readForSync(TileEntity te, NBTTagCompound NBT) { if (dispatch) { if (DragonOptions.LOGSYNCCME.getState()) { DragonAPICore.log("The sync packet for " + te + " would have just CME'd, as the"); DragonAPICore.log( "Client-Thread data-reading code has overlapped with the Network-Thread byte[] reading."); DragonAPICore.log("Seeing this message frequently could indicate a serious issue.\n"); } return; } for (String key : data.keySet()) { NBT.setTag(key, data.get(key)); } }
/** * Triggers one of TC's native FX. It is your responsibility to ensure the correct parameters are * chosen for the relevant Effect Type. */ @SideOnly(Side.CLIENT) public static void triggerEffect(EffectType type, Object... data) { try { type.call.invoke(proxy, data); } catch (Exception e) { DragonAPICore.logError("Error Triggering ThaumCraft Effect: " + e.getMessage()); e.printStackTrace(); } }
/** Contains a helper function to avoid overwriting existing aspects. */ public static void addAspects(ItemStack is, Object... aspects) { if (aspects.length % 2 != 0) { DragonAPICore.logError( "Could not add aspects to " + is + ": You must specify a level for every aspect!"); ReikaJavaLibrary.dumpStack(); return; } AspectList has = ThaumcraftApi.objectTags.get(Arrays.asList(is.getItem(), is.getItemDamage())); AspectList ot = getAspectList(aspects); if (has != null) { for (Aspect as : has.aspects.keySet()) { ot.merge(as, has.getAmount(as)); } } clearNullAspects(ot); ThaumcraftApi.registerObjectTag(is, ot); DragonAPICore.log("Registering " + is + " aspects " + aspectsToString(ot)); }
public boolean playerCanSee(EntityPlayer ep) { if (this.isDummiedOut()) return DragonAPICore.isReikasComputer(); if (progress != null) { for (int i = 0; i < progress.length; i++) { ProgressStage p = progress[i]; if (!p.isPlayerAtStage(ep)) return false; } } return ChromaResearchManager.instance.playerHasFragment(ep, this); }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block b) { if (DragonAPICore.isReikasComputer() && ReikaObfuscationHelper.isDeObfEnvironment()) { if (world.isBlockIndirectlyGettingPowered(x, y, z)) { if (world.getBlockMetadata(x, y, z) == LaserEffectType.EMITTER.ordinal()) { LaserEffectTile te = (LaserEffectTile) world.getTileEntity(x, y, z); te.fire(); return; } } } }
public static void addAspects(ItemStack is, AspectList aspects) { AspectList has = ThaumcraftApi.objectTags.get(Arrays.asList(is.getItem(), is.getItemDamage())); if (has != null) { for (Aspect as : has.aspects.keySet()) { aspects.merge(as, has.getAmount(as)); } } clearNullAspects(aspects); ThaumcraftApi.registerObjectTag(is, new int[] {is.getItemDamage()}, aspects); DragonAPICore.log("Registering " + is + " aspects " + aspectsToString(aspects)); }
public GuiHandbook(EntityPlayer p5ep, World world, int s, int p) { // super(); player = p5ep; worldObj = world; staticwidth = xSize; staticheight = ySize; screen = s; page = p; if (ConfigRegistry.DYNAMICHANDBOOK.getState() || (DragonAPICore.isReikasComputer() && ReikaObfuscationHelper.isDeObfEnvironment())) this.reloadXMLData(); }
private static AspectList getAspectList(Object... aspects) { AspectList ot = new AspectList(); try { for (int i = 0; i < aspects.length; i += 2) { ot.add((Aspect) aspects[i], (Integer) aspects[i + 1]); } } catch (ClassCastException e) { DragonAPICore.logError( "Invalid parameters! Could not generate aspect list from " + Arrays.toString(aspects) + "!"); e.printStackTrace(); } return ot; }
public boolean isDummiedOut() { if (machine != null) return machine.isDummiedOut(); if (item != null) return item.isDummiedOut(); if (ability != null) return ability.isDummiedOut(); if (this == APIRECIPES && RecipesCastingTable.instance.getAllAPIRecipes().isEmpty() && DragonAPICore.hasGameLoaded()) // only hide display return true; if (this == PACKCHANGES && !PackModificationTracker.instance.modificationsExist(ChromatiCraft.instance)) return true; if (this == BEES) return !ModList.FORESTRY.isLoaded(); if (this == RFDISTRIB) return !PowerTypes.RF.exists(); if (this == BALLLIGHTNING) return !ChromaOptions.BALLLIGHTNING.getState(); if (this == NODENET) return !ModList.THAUMCRAFT.isLoaded(); return false; }
@Override public void writePacketData(PacketBuffer out) throws IOException { dispatch = true; out.writeInt(field_148863_a); out.writeShort(field_148861_b); out.writeInt(field_148862_c); NBTTagCompound toSend = new NBTTagCompound(); try { this.saveChanges(toSend); } catch (Exception e) { toSend.setBoolean(ERROR_TAG, true); e.printStackTrace(); // out.clear(); } try { out.writeNBTTagCompoundToBuffer(toSend); } catch (Exception e) { DragonAPICore.logError("Error writing Sync Tag!"); out.clear(); e.printStackTrace(); } dispatch = false; }
static { if (ModList.THAUMCRAFT.isLoaded()) { nativeCategories.add("BASICS"); nativeCategories.add("THAUMATURGY"); nativeCategories.add("ALCHEMY"); nativeCategories.add("ARTIFICE"); nativeCategories.add("GOLEMANCY"); nativeCategories.add("ELDRITCH"); try { Class c = Class.forName("thaumcraft.common.Thaumcraft"); Field f = c.getField("proxy"); proxy = f.get(null); Class cp = Class.forName("thaumcraft.common.CommonProxy"); Field kn = cp.getField("playerKnowledge"); Object knowledge = kn.get(proxy); Class ck = Class.forName("thaumcraft.common.lib.research.PlayerKnowledge"); Field res = ck.getField("researchCompleted"); Field objs = ck.getField("objectsScanned"); Field ents = ck.getField("entitiesScanned"); Field phen = ck.getField("phenomenaScanned"); Field asp = ck.getField("aspectsDiscovered"); Field warp = ck.getField("warp"); Field warpsticky = ck.getField("warpSticky"); Field warptemp = ck.getField("warpTemp"); aspects = (Map) asp.get(knowledge); research = (Map) res.get(knowledge); scannedObjects = (Map) objs.get(knowledge); scannedEntities = (Map) ents.get(knowledge); scannedPhenomena = (Map) phen.get(knowledge); playerWarp = (Map) warp.get(knowledge); playerStickyWarp = (Map) warpsticky.get(knowledge); playerTempWarp = (Map) warptemp.get(knowledge); } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft PlayerKnowledge Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } try { Class wand = Class.forName("thaumcraft.common.items.wands.ItemWandCasting"); addWandVis = wand.getMethod("addVis", ItemStack.class, Aspect.class, int.class, boolean.class); getWandVis = wand.getMethod("getAllVis", ItemStack.class); maxWandVis = wand.getMethod("getMaxVis", ItemStack.class); setWandInUse = wand.getMethod("setObjectInUse", ItemStack.class, int.class, int.class, int.class); clearWandInUse = wand.getMethod("clearObjectInUse", ItemStack.class); } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft Wand Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } try { Class mgr = Class.forName("thaumcraft.common.lib.research.ResearchManager"); researchComplete = mgr.getMethod("isResearchComplete", String.class, String.class); } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft Research Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } try { Class wisp = Class.forName("thaumcraft.common.entities.monster.EntityWisp"); wispTarget = wisp.getDeclaredField("targetedEntity"); wispTarget.setAccessible(true); } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft Mob Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } try { Field[] fds = Aspect.class.getDeclaredFields(); for (int i = 0; i < fds.length; i++) { Field fd = fds[i]; if (fd.getType() == Aspect.class) { Aspect a = (Aspect) fd.get(null); if (a != null) { allAspects.add(a); } } } } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft Aspect Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { try { Class clip = Class.forName("thaumcraft.client.ClientProxy"); for (int i = 0; i < EffectType.list.length; i++) { EffectType type = EffectType.list[i]; type.call = clip.getMethod(type.name, type.arguments); } } catch (Exception e) { DragonAPICore.logError("Could not load ThaumCraft Effect Handler!"); e.printStackTrace(); ReflectiveFailureTracker.instance.logModReflectiveFailure(ModList.THAUMCRAFT, e); } } } }