Compare commits

...

236 Commits

Author SHA1 Message Date
Sebastian Hartte 31544a8086 Reconfigure Spotless to leave comments alone, and removed some dead code. 2020-10-11 13:33:35 +02:00
Sebastian Hartte e76ca86602 Added a mechanism to add mods downloaded from curseforge to a dev-environment by simply dropping them into an extra-mods-<mc-version> folder. 2020-10-09 22:47:21 +02:00
Sebastian Hartte b8f48407cd Fix tooltip rendering. 2020-09-20 01:06:53 +02:00
Sebastian Hartte 489b0f635e Merge remote-tracking branch 'origin/8.0.x-1.16.1' 2020-09-20 00:42:52 +02:00
shartte e6fb553a53 Fixes #4741: Rework Crafting CPU cycling and extract commonalities into a separate class. (#4742)
Also Fixes:
- Enter key confirms the "Confirm Crafting" dialog again
- Right Mouse Button correctly cycles backwards through CPUs, while left mouse button forward
- Fixes an internal problem with syncing CPU names
- Naming of unnamed CPUs begins at #1 now
2020-09-20 00:26:34 +02:00
Sebastian Hartte cacd824db3 Remove unused field indicating availability of client classes. 2020-09-19 18:20:11 +02:00
yueh 876bb52087 Update forge mappings to 20200916-1.16.2 (#4749) 2020-09-19 17:32:23 +02:00
shartte 971a9d22e8 Improvements to the usability of the number entry widgets (Priority, Level Emitter, Craft Amount): (#4737)
- Fixed tab order
- Introduced focus state for corner buttons
- Allowed the player to enter any text, but add validation that only persist it if it is a valid number
- Enter will now confirm these dialogs and return to the previous dialog
- The text field is automatically focused and its contents are selected
2020-09-19 16:27:29 +02:00
Sebastian Hartte 76efe6026d Add an indicator that shows the number of active crafting jobs. 2020-09-18 21:34:42 +02:00
yueh 4e03cbd356 Simply build all branches 2020-09-18 10:32:06 +02:00
yueh 9005db6f1c Fix yaml syntax 2020-09-17 21:42:20 +02:00
yueh 58afe755b8 Build PRs for all release branches (#4746) 2020-09-17 21:37:53 +02:00
Sebastian Hartte f368f9dac2 Fixes #4697: Show number of required items in condenser tooltips. 2020-09-17 14:33:43 +02:00
Sebastian Hartte e5b45d51cc Minor style fixes. 2020-09-17 11:43:29 +02:00
shartte 5a1d5356d1 Fixes #4733: Fix a crash bug when an external machine tries draining fluids from a fluid interface without a filter. (#4738) 2020-09-16 23:13:18 +02:00
Sebastian Hartte 1759f92164 Prevent FG from force-exiting the daemon if runData is used. 2020-09-16 19:51:22 +02:00
Sebastian Hartte e50c13e570 Rolled back the memory change since it'll cause a daemon to launch even during a CI build. 2020-09-16 19:29:47 +02:00
Sebastian Hartte 749dd35f88 Updated forge and increased memory for IDE-sync daemon. 2020-09-16 18:18:22 +02:00
Sebastian Hartte ca79a377bd Merge remote-tracking branch 'origin/8.0.x-1.16.1'
# Conflicts:
#	gradle/scripts/dependencies.gradle
2020-09-16 17:49:59 +02:00
Sebastian Hartte 475c8ff5a1 Adapt the same sorting logic used for items stored in the network for items obtained from patterns, which fixes items from patterns not being able to be shift-clicked into new patterns. 2020-09-16 17:44:49 +02:00
yueh 5b3ccf26d0 Merge all gradle files (#4732)
* Merge all gradle files

The specific build files are now much smaller, so a single one is mostly acceptable now.
Also updates Gradle to 5.6.3

* Disable the Mixin annotation processor when importing this project into IntelliJ since it should only be needed to generate refmaps on an actual build.

* Removed Sonarqube and JaCoCo plugins.

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
2020-09-14 14:14:00 +02:00
Sebastian Hartte e73dbe4891 Updated Forge / MC to 1.16.3
Keep Mappings
Allow higher range for MC + Forge versions
2020-09-14 02:02:59 +02:00
Sebastian Hartte 38244000c9 Fixes #4731: Take the position where the user clicked the handle into account when calculating the new scrollbar position.
Also fixes: The scrollbar did not subtract the handle height when determining the available space for moving the handle, thus introducing drift the further down a user scrolled.
Also fixes: The scrollbar did not resize it's trackbar when the ME inventory screens were resized and the number of rows changed, same for craft confirm.
2020-09-13 23:12:59 +02:00
Sebastian Hartte d87ff9d1e7 Formatting fixes. 2020-09-13 22:18:38 +02:00
Sebastian Hartte 4ba97ec899 Remove unnecessary debug prints, and rename methods. 2020-09-13 22:11:40 +02:00
Sebastian Hartte 0147e1ddfb Fixes #4730 and also introduces repeat-pageup/pagedown when holding the mouse on the area above or below the scrollbar handle. 2020-09-13 22:09:47 +02:00
yueh 621d2ee715 Fixes #4728: Mark all offloading threads as daemons (#4729) 2020-09-13 11:55:18 +02:00
shartte d07937fa93 Render Performance Improvements (#4721)
* Return a fixed bounding box for frustrum culling of AE tile entity renderers to prevent Forge from re-retrieving the TE from the world and calculating the collision box (very costly for cables).

* Changed dynamic cable bus lighting to be based on block states to improved rendering speed and fix optifine issues. (Potential fix for #4716).
2020-09-10 22:56:50 +02:00
shartte 65f58913a4 Make players assume ownership of networks when they place security stations onto unsecured ones (#4714)
* Fixes #4712: When a security station is placed onto an unsecured network, the placer assumes ownership of the entire network. Otherwise the contiguous network would not necessarily reconnect in the same way when the chunk is reloaded due to differing player-ids throughout the network.
In addition, changes to the node's owner were not being persisted due to the host never being marked as dirty.

* Fix formatting
2020-09-10 22:34:16 +02:00
yueh b8e53adf40 Fixes #4719: Take the entity size into account when spawning item entities (#4720) 2020-09-10 17:54:02 +02:00
yueh 44544c598f Fixes #4253: Just transfer the recipe id instead of every ingredient. (#4689)
* Fixes #4253: Just transfer the recipe id instead of every ingredient.
* If possible handle any IRecipe for processing mode
* Improvements and support for AE2 facades.
* Switched to using JEI's displayed stacks (which means we can remove the shapeless variant).

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
2020-09-09 14:08:24 +02:00
Sebastian Hartte bcee2ec427 Slightly increased the height of the item hitbox for crystals to make their pickup by annihilation planes less "clippy". 2020-09-09 02:23:58 +02:00
Sebastian Hartte 9e41d543f5 Merge remote-tracking branch 'origin/8.0.x-1.16.1' 2020-09-09 00:59:58 +02:00
Sebastian Hartte 81cc0b804d Fixes #4699: AE's glass should only hide it's sides adjacent to other AE glass.
Also disables spawn on AE's glass same as Vanilla glass.
2020-09-09 00:58:14 +02:00
Sebastian Hartte e1fc9908b3 Fixes #4693: Fix color applicator not working on cable-buses. 2020-09-09 00:51:45 +02:00
shartte 9ed1535477 Fixes #4661: Do not update a tile entity when it's in an unloaded chunk (i.e. during chunk unloading) (#4708) 2020-09-08 22:28:30 +02:00
Sebastian Hartte 1ef345d4a4 Formatting fixes. 2020-09-08 22:24:27 +02:00
Sebastian Hartte ff7d1b9719 Fixes #4704: QNB is not finding a registered QNB because it believes the chunk to be unloaded.
Also adds debug logging to the locatable registry to better debug this issues in the future.
2020-09-08 22:20:33 +02:00
shartte 88c9370e4f Crystal Growth Refactor (#4702)
* Refactored crystal in-world purification:
- Removed iterative formula
- Set the default growth factor to 1 rather than 0.5 to simplify settings
- Made the growth-tick-progress-per-tick a configuration setting for 0-6 accelerators
- Unfinished seeds now slowly sink when ejected by an annihilation plane or other system (emulates a player throwing it in)
- Instead of checking for "isLiquid", we now check for a new tag (appliedenergistics2:crystal_purification_medium) to check if the crystal is submerged in an allowed fluid for growth, defaults to #minecraft:water.

* Removed configuration options for changing how accelerators work,
replaced with improved fluid tag option with a clamped multiplier [1,10].
2020-09-08 18:10:45 +02:00
Sebastian Hartte f2aae3ef0f Added a global Voxelshape cache for cable bus voxel shapes, since combining voxel shapes turns out to be an extremely expensive process (i.e. 1.7s for 10000x5 shapes). 2020-09-08 17:56:02 +02:00
Sebastian Hartte 12739f1e66 Remove unneeded cable-bus inventory-model, which caused the part models to be loaded twice leading to unnecessary memory-usage. 2020-09-08 17:53:14 +02:00
shartte 81d2170ada Implemented a cache with maximum quad-count it will cache for the cable bus, (#4670)
which also fixes concurrent access to the hashmap.

(cherry picked from commit b756d68be1)
2020-09-08 14:28:08 +02:00
Sebastian Hartte 0f469e9df6 Bumped Forge version. 2020-09-07 23:34:56 +02:00
Sebastian Hartte 0f34f09b32 Remove object-scanning subscriptions and remove unused test-file. 2020-09-06 20:59:37 +02:00
Sebastian Hartte 8e54a8fed9 Fixes a problem where tile entities would become unremovable (well, one more of these at least),
because they would reset their block state upon removal and loss of power.
2020-09-06 20:59:19 +02:00
Sebastian Hartte d9bb81a00f Fixes #4680: Facade advancement is showing an untextured facade. 2020-09-03 17:36:20 +02:00
yueh 39e038d916 Fixes #4683: Hopefully LazyOptional works as advertised (#4684) 2020-09-02 21:36:40 +02:00
Sebastian Hartte 12ca8d109a Merge remote-tracking branch 'origin/8.0.x-1.16.1' 2020-09-02 02:55:12 +02:00
yueh f0d0595c8f Fixes #4669: Take NBT into account for comparing. (#4675)
This only covers combining different items together.
Fuzzy filtering is still a bit too fuzzy for corner cases.
2020-09-01 21:59:08 +02:00
shartte b756d68be1 Implemented a cache with maximum quad-count it will cache for the cable bus, (#4670)
which also fixes concurrent access to the hashmap.
2020-09-01 18:20:51 +02:00
Sebastian Hartte 60b07e5ca5 Merge branch '8.0.x-1.16.1' 2020-09-01 01:07:47 +02:00
shartte 7c99fca789 Fixes removal of facades not invalidating the cached server-side collision boxes. (#4663)
(cherry picked from commit 957bc4c5cc)
2020-09-01 01:07:30 +02:00
yueh ab393b0ed1 Serialize the complete NBT data to avoid mismatches (#4665)
This might increase the network traffic a bit, but the amount of mods actually using the share tag seems to be very limited.
For now it is worth the risk as it solves the problem. In case we run into actual issues, there might still be other solutions, which will be way more complex and can potentially introduce additional problems.

(cherry picked from commit e90dd2f9c6)
2020-09-01 01:07:28 +02:00
shartte 957bc4c5cc Fixes removal of facades not invalidating the cached server-side collision boxes. (#4663) 2020-08-31 23:10:25 +02:00
yueh 133ed1f09d Remove GZipStreams from packets. (#4664)
This should now be handled by the normal network manager (hopefully).
Also renamed the `CompressedNBTPacket` to `MEInterfaceUpdatePacket` as that is the only use case.
2020-08-31 23:09:28 +02:00
yueh e90dd2f9c6 Serialize the complete NBT data to avoid mismatches (#4665)
This might increase the network traffic a bit, but the amount of mods actually using the share tag seems to be very limited.
For now it is worth the risk as it solves the problem. In case we run into actual issues, there might still be other solutions, which will be way more complex and can potentially introduce additional problems.
2020-08-31 23:09:14 +02:00
Sebastian Hartte 9719c7ffc3 Bump to Forge 33.0.22 2020-08-29 23:13:29 +02:00
Sebastian Hartte 319d92a371 Merge branch '8.0.x-1.16.1' 2020-08-29 22:18:12 +02:00
shartte db9ec2b070 Remove the use of SlotItemHandler since we are only faking an inventory-backed slot, (#4654)
we might as well use what we had used pre-2017, which is simply extending a normal Slot.
This should also fix #4652.
2020-08-29 22:03:35 +02:00
Masakitenchi 3a0552c56e Update zh_cn.json (#4653) 2020-08-28 10:49:11 +02:00
Sebastian Hartte 8a0dd192e5 Added Modmaven repository to README.md 2020-08-26 23:19:42 +02:00
Sebastian Hartte a97b35f3d0 Merge branch '8.0.x-1.16.1' 2020-08-26 11:39:20 +02:00
Sebastian Hartte 00d4c20d9f Strip pom.xml dependencies. 2020-08-26 11:39:03 +02:00
Sebastian Hartte 1394ab0863 Merge branch '8.0.x-1.16.1' 2020-08-24 23:54:57 +02:00
Sebastian Hartte 5efc085693 Fix tiles that have a "powered" block state from not being able to be broken when
they are connected to a powered grid.
2020-08-24 23:54:37 +02:00
Sebastian Hartte 159f4c7f14 Merge branch '8.0.x-1.16.1' 2020-08-24 22:33:38 +02:00
Sebastian Hartte aff94cec8c Fix search box interactions in the interface terminal. 2020-08-24 22:33:04 +02:00
Sebastian Hartte ee7fe9f40d Merge branch '8.0.x-1.16.1' 2020-08-24 01:06:50 +02:00
Sebastian Hartte 2184d03d0b Actually save the rotation when a tile is rotated. 2020-08-24 01:06:26 +02:00
Sebastian Hartte 9c9a49f9e7 Merge branch '8.0.x-1.16.1' 2020-08-23 20:48:19 +02:00
Sebastian Hartte 44c0931c02 Fixes #4635: Actually remove requesters when removing requesters. 2020-08-23 20:47:05 +02:00
Sebastian Hartte b7949e4134 Re-Enabled JEI and TOP in dev. 2020-08-22 19:56:37 +02:00
Sebastian Hartte ea95913ec8 Merge branch '8.0.x-1.16.1' 2020-08-22 19:38:36 +02:00
yueh 423ab81813 Added step to publish to modmaven (#4607)
(cherry picked from commit 7e1bfdb5ac)
2020-08-21 20:40:03 +02:00
shartte 33d7f02323 Fixes #4590: Crystal seeds (other than certus) don't display their growth stages. (#4619) 2020-08-19 16:43:47 +02:00
shartte 4e42b17e81 Fixes #4590: Crystal seeds (other than certus) don't display their growth stages. (#4618) 2020-08-19 16:43:45 +02:00
shartte b8d4f0cffa Fixes #4611: Use of client-side only method for Tiny TNT explosion. (#4612) 2020-08-18 01:35:31 +02:00
shartte fc0f8eab56 Fixes #4611: Use of client-side only method for Tiny TNT explosion. (#4612) 2020-08-18 01:33:47 +02:00
yueh 7e1bfdb5ac Added step to publish to modmaven (#4607) 2020-08-17 22:28:01 +02:00
shartte 41b7900706 Fixes #4598: Incorrectly rotated face for determining block lightlevel in ME Chest renderer. (#4599) (#4609)
(cherry picked from commit 954ce1442e)
2020-08-17 21:58:51 +02:00
shartte 1f9707e256 Fixes #4602: Prevent encoding invalid patterns and handle corrupted patterns a little more gracefully. (#4608) 2020-08-17 21:50:28 +02:00
shartte 7656157b0d Fixes #4602: Prevent encoding invalid patterns and handle corrupted patterns a little more gracefully. (#4608) 2020-08-17 21:49:37 +02:00
shartte 954ce1442e Fixes #4598: Incorrectly rotated face for determining block lightlevel in ME Chest renderer. (#4599) 2020-08-17 21:43:16 +02:00
Sebastian Hartte ee67c5ea50 Use different naming for fullbright, and always reset it back after setting it. 2020-08-16 14:05:10 +02:00
Sebastian Hartte 73735c5cd5 Remove use of func_244388_a, which is client-only. 2020-08-15 17:29:36 +02:00
Sebastian Hartte c1713f1682 Bump to Forge 33.0.5 2020-08-15 14:32:53 +02:00
Sebastian Hartte f455fd1994 Initial port to 1.16.2 2020-08-13 23:29:55 +02:00
Sebastian Hartte 1657c88681 Initial port to 1.16.2 2020-08-13 23:15:09 +02:00
Sebastian Hartte fd67e0e5c6 Initial port to 1.16.2 2020-08-13 23:14:49 +02:00
Sebastian Hartte 87c2c94bd4 Use minus sign for minus buttons in number widget. 2020-08-11 16:31:20 +02:00
yueh d591a1492c Fixes #4583: Confine fluix crafting into the same block (#4586)
Fluix crystals will now spawn within an area around the center of the block as well as some tuned down motion while still maintaining some randomness.
2020-08-10 11:30:04 +02:00
shartte d1ba26311b One Spatial Dimension (#4570)
* Ported the "one spatial dimension" concept from pre-1.15

* Apply lighting updates after moving chunks.
Mark world data as dirty when changing it.

* Consolidated naming of spatial storage world/dimension.
Use server light manager to update lighting info in chunk.

* Save last transition information,
and add ae2 spatial command to interact with spatial storage.

* Formatting fixes.

* Improved docs for the origin generation.

Inverted condition on when the x/z axis are flipped.
Also added a helper to map a plot to a region file

* Remove TransitionResult since it's only used in lieu of a boolean.
Rework transition to make the checks BEFORE allocating a new cell.

* Removed unused imports.

Co-authored-by: yueh <yueh@users.noreply.github.com>
2020-08-10 11:29:07 +02:00
shartte 8733c2c11f Fix Special Model Registration (#4577)
* Fixes #4575 by updating Forge (ModelRegistryEvent is a modbus event but was misflagged as not being one). And update Forge because their breaking change breaks our mod.

* Update gradle.properties

Co-authored-by: yueh <yueh@users.noreply.github.com>

* Update src/main/resources/META-INF/mods.toml

Co-authored-by: yueh <yueh@users.noreply.github.com>

Co-authored-by: yueh <yueh@users.noreply.github.com>
2020-08-10 11:25:26 +02:00
yueh 4230fc7325 Fixes #4576: Append the amount to each button (#4580) 2020-08-09 13:23:24 +02:00
shartte 484af8baf3 Fixes #4574 by referencing only non-pure fluix crystals in the fluix dust grinder recipe. (#4578) 2020-08-09 12:24:42 +02:00
shartte 9456f639d4 Simplify "unlit" quad loading and move to Mixins (#4569)
* Simplified the UV loader concept: We only need it to make quads "unlit" which means that the lighting system is not applied to them. They always render at their full brightness.

* More documentation and slight cleanups.
2020-08-09 01:27:19 +02:00
shartte fe753c540b Fixes #4571: When not used for displaying localized text, specify Locale.ROOT for toLowerCase/toUpperCase to avoid issues with locale-specific non-ASCII lowercase conversions for ASCII uppercase characters (i.e. turkish lowercase i for uppercase I). (#4573) 2020-08-08 14:56:51 +02:00
Sebastian Hartte 2fabab3a6a Fix AO lighting for faces not fully snapped to block edges. 2020-08-08 02:20:40 +02:00
shartte 6f39bd8fe8 Move the nether quartz dust tag to the forge namespace and use it instead of AE's internal one. (#4568) 2020-08-07 23:13:02 +02:00
yueh c7d3877129 Use the declared power drain for p2p tunnels (#4567) 2020-08-06 20:07:40 +02:00
Sebastian Hartte 822249dda8 Added missing @Override annotations. 2020-08-05 22:11:00 +02:00
yueh 1404806d3d Fixes #4559: Use visual bounding box for overlay (#4561) 2020-08-05 21:52:34 +02:00
yueh 12e3fa9127 Makes formation planes a bit more consistent and less violent. (#4553)
* Makes formation planes a bit more consistent and less violent.

Items will now have a slower speed when spawning as well as a narrower area to avoid having them glitch into a wall and be teleported around

* Removed debug output, added clarifying parenthesis and extracted method.

* Fixes various other issues with the formation plane

Also removed now useless code

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
2020-08-05 17:56:42 +02:00
shartte 8617dc8340 Plane Connection Refactor (#4556)
* Refactors all plane parts to use a common helper for
calculating connections to adjacent planes.
Also fixes problems with updating these connections on neighbor updates.

* Fix conflicting GuiSync ID.

* Slightly refactor PlaneConnectionHelper, and fix an issue where the bounding box was calculated incorrectly by using the wrong up-direction.
2020-08-05 17:45:33 +02:00
shartte 9bc844738c Fixes #4547: Name clash between ITooltip#getWidth, ITooltip#getHeight and Vanilla Widget methods leads to missing methods at runtime, since the implementing methods will be remapped to SRG names, while referees of the interface will try to call the renamed methods by their name in the interface, leading to an AbstractMethodError. (#4557) 2020-08-05 16:33:44 +02:00
Sebastian Hartte eab6483bd7 Fixes #4551: Bounding box of annihilation planes is too small. 2020-08-05 00:54:26 +02:00
yueh 7ca9405c8b Apply the FE tunnel behaviour to the fluid tunnel (#4550) 2020-08-04 17:57:59 +02:00
yueh 39959145a3 Revert "Apply the FE tunnel behaviour to the fluid tunnel (#4545)" (#4549)
This reverts commit 22f552217f.
2020-08-04 08:45:10 +02:00
yueh 22f552217f Apply the FE tunnel behaviour to the fluid tunnel (#4545)
* Apply the FE tunnel behaviour to the fluid tunnel

* Make a second pass to try and get all the requested fill amount sent out to outputs.

Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
2020-08-03 21:39:34 +02:00
yueh 8f0e408772 Fixes NPE on empty tooltips (#4546) 2020-08-03 20:57:10 +02:00
Sebastian Hartte 62bbc32763 Minor cleanup. 2020-08-03 20:31:30 +02:00
shartte 872d8d33cb Clean up global state for cable render mode (#4539)
* Clean up the global state used to hack part interaction into respecting
the player's facade render mode. Make the name more indicative of
what is actually happening.

* Fun.
2020-08-03 14:46:39 +02:00
shartte 1801302d8f Fix SkyStone chest model issues that I had introduced back in 1.8. (#4542)
This makes the chest 1 pixel higher to restore the look it had in 1.7.
Since the skystone chest's texture is a grungy mess, only the most
obvious texture problems were fixed, while for the skystone block chest,
the look should be close to what it was now.
Also introduces caching for the skystone chest's block shape.
2020-08-03 14:46:23 +02:00
Sebastian Hartte a85ffec9f9 Unified Parameter-Names for Slots 2020-08-02 22:12:08 +02:00
Sebastian Hartte 5fca946ef3 The lambda has to be replaced with an explicit method to annotate it with @OnlyIn. 2020-08-02 15:45:15 +02:00
Sebastian Hartte f8446209ce Move CraftingMonitor rendering customization out to its own class to circumvent issues with a client-side only lambda method being generated in a common-side class. 2020-08-02 15:40:50 +02:00
Sebastian Hartte 088627aedf Remove client-only methods from ChargerBlock which could potentially create synthetic lambda methods that reference client-only classes (and are not stripped). 2020-08-02 15:13:20 +02:00
shartte c8d08f9726 Fixes sidedness issues that cropped up with 1.16 (#4533) 2020-08-01 22:16:57 +02:00
yueh 259d932946 Fixes 4529: Updated IPart to match new ICapabilityProvider (#4534) 2020-08-01 21:01:19 +02:00
shartte d66986df85 Fix cell models not being loaded. (#4528) 2020-08-01 12:59:05 +02:00
shartte 4fa78a2add Fix #4521: Register RecipeTypes. (#4523) 2020-07-31 17:22:44 +02:00
Sebastian Hartte 98e9faa262 Ported model dependency changes from Fabric 1.16.
Made IChestLid sided.
2020-07-30 22:08:19 +02:00
Sebastian Hartte a628a469ce Fix refmap reference for non-dev deployment. 2020-07-28 21:02:51 +02:00
Sebastian Hartte 2fca330ff1 Use BlockPos.toMutable 2020-07-28 20:25:18 +02:00
Sebastian Hartte 3802eace7a Use StringTextComponent.EMPTY 2020-07-28 20:24:07 +02:00
Sebastian Hartte 2b9c997191 Fix formatting. 2020-07-28 20:19:11 +02:00
Sebastian Hartte 1cb32517ae Added missing chunk generator registration. 2020-07-28 20:11:18 +02:00
yueh b3b7547325 Updated mappings to 20200723-1.16.1 (#4514)
* Limit to 1 gradle worker
2020-07-28 18:33:28 +02:00
yueh 307a6817d4 Remove xvfb steps as runData should now run headless (#4513)
Also run `prepareRunData` in a separate step to avoid a race condition with ForgeGradle writing the generated dependency after it has already written it for `runData`
2020-07-28 14:49:33 +02:00
yueh 0beab559a6 Fix formatting 2020-07-28 11:44:57 +02:00
yueh a65be62cd1 Organize and clean imports 2020-07-28 10:29:57 +02:00
Sebastian Hartte e640918ca0 Compiles, can get ingame, uses Mixins to work around missing Fork Hooks for structures and custom dimensions. 2020-07-28 02:05:24 +02:00
Sebastian Hartte 84e6aaa122 Compiles again. 2020-07-27 23:50:28 +02:00
yueh 56ecda5173 1.16 port 2020-07-27 11:21:50 +02:00
yueh 662dbca3e1 Fixes #4508: Correctly construct the sparse lists. (#4511)
* Fixes #4508: Correctly construct the sparse lists.

Also renamed all uncondensed getters to sparse and all condensed to the simple ones.

* Apply suggestions from code review

Co-authored-by: shartte <shartte@users.noreply.github.com>

* Streamlined collapsing the sparse lists

* Extracted helper to condense stacks

* Sort lists desc by stack size

Co-authored-by: shartte <shartte@users.noreply.github.com>
2020-07-27 11:21:06 +02:00
Sebastian Hartte 6cb6c21495 Mention spotlessApply. 2020-07-26 23:29:34 +02:00
Sebastian Hartte 79e9a3913a Update README.md to reflect that the data generation needs to be run. 2020-07-26 23:29:01 +02:00
shartte 7e89317dd5 Fix substitutions not being correctly recognized. (#4507) 2020-07-26 22:25:18 +02:00
shartte 59e40ccbd9 Fixes mouse handling for right-clicks to clear the search box and middle-click for crafting. (#4505) 2020-07-26 16:30:53 +02:00
yueh 774f88ee90 Clear searchfield on rightclick (#4503) 2020-07-26 15:28:52 +02:00
yueh 0528879833 Moved datagens to appeng.datagen (#4502) 2020-07-26 15:28:18 +02:00
yueh b6110e4f4a Remove all maven repos except modmaven (#4501)
Also upgrades gradle to 4.10.3
2020-07-26 15:27:32 +02:00
yueh 5b82e59264 Removed superfluous crash enhancement (#4498) 2020-07-26 12:42:48 +02:00
yueh 3a4b171443 Fixes #4468: Default to ae serverside (#4496) 2020-07-25 16:05:58 +02:00
yueh 2ac27fd9ce Fixes patterns always returning a recipe. (#4495) 2020-07-24 22:39:38 +02:00
shartte d01aa28cdc Use standard mechanics for damaging the quartz knife. (#4494) 2020-07-24 16:39:32 +02:00
shartte 21aa5ce33b Don't use PacketBuffer#readString since it's client-only. (#4489)
Fixes #4488
2020-07-22 10:22:28 +02:00
shartte f7ef6eb772 Same method name as in superclass leads to ForgeGradle reobf problems. (#4491)
Fixes #4490
2020-07-22 10:22:00 +02:00
shartte 10037a9ac5 Correct link to CurseForge page 2020-07-21 18:39:48 +02:00
yueh 888de430ba Also test for generated asset cache 2020-07-20 22:27:01 +02:00
A. Regnander 83d661ab2a Create sv_se.json (#4485) 2020-07-20 21:33:44 +02:00
shartte a537bcf0ee Merge pull request #4486 from AppliedEnergistics/number-entry-dialogs
Number Entry Dialogs
2020-07-20 20:13:04 +02:00
Sebastian Hartte 590e435ad6 Formatting fixes 2020-07-19 23:51:57 +02:00
Sebastian Hartte 8d92a51e4f Formatting fixes 2020-07-19 23:50:47 +02:00
Sebastian Hartte 4322910614 Added labels that specify the unit of power (AE) and the unit of fluid (mB) for the level emitters. 2020-07-19 23:50:18 +02:00
Sebastian Hartte ebe589a714 Ported the other number entry dialogs over to the shared widget. 2020-07-19 23:25:11 +02:00
Sebastian Hartte 6187e6a7bb Started refactoring number entry dialogs to use shared code. 2020-07-19 20:04:08 +02:00
shartte d5f113eb35 Merge pull request #4484 from AppliedEnergistics/energy-grid-failfast
Guard Against Concurrent EnergyGrid Modifications
2020-07-19 17:56:22 +02:00
shartte 9ad5bb21c0 Merge pull request #4480 from AppliedEnergistics/mb-fixes
Fix more MultiBlock issues
2020-07-19 17:31:06 +02:00
Sebastian Hartte 1c88ea7b78 Fail faster when something modifies the list of energy providers/requesters while an extract/inject operation is ongoing, since this would lead to ConcurrentModificationExceptions later, without a way of tracking down what caused the modification in the first place. 2020-07-19 16:39:37 +02:00
shartte 5a976ebfae Merge pull request #4483 from AppliedEnergistics/texture-cleanup
Texture Cleanup
2020-07-19 16:20:32 +02:00
Sebastian Hartte b45669bb82 Removed several unchecked casts. 2020-07-19 16:01:19 +02:00
Sebastian Hartte e52cc40dbf JSON Formatting Fix 2020-07-19 16:00:01 +02:00
Sebastian Hartte 8a20d3c1d7 Consolidated fluid models to reuse the item counterparts with different textures. 2020-07-19 15:00:46 +02:00
Sebastian Hartte 749ebeb91d Moved part textures from parts to part to be consistent with singular naming used in Minecraft (and for the model directory). 2020-07-19 14:14:18 +02:00
Sebastian Hartte 82586732e3 Removed unused crafting and fluid terminal models and associated textures.
Unified naming for textures used by the fluid terminal.
2020-07-19 14:09:57 +02:00
Sebastian Hartte e023d83e62 Deleted unused matrix frame related documentation images. 2020-07-19 13:40:42 +02:00
Sebastian Hartte de7cbc4949 Moved part-related textures from textures/item/part to textures/parts/ and adapted the level emitter item models to use the normal part texture. 2020-07-19 13:37:23 +02:00
Sebastian Hartte 71a91e51fb Naming improvements 2020-07-19 13:16:50 +02:00
yueh 223163aa0a Fixes #4330: Avoid mutating the input stack (#4481) 2020-07-19 13:13:20 +02:00
Sebastian Hartte bdd22093c3 Account for empty messages when drawing tooltips. 2020-07-19 12:05:26 +02:00
Sebastian Hartte 0367b35ce0 Never return null from Widget#getMessage since the
narrator will always dereference it, leading to a crash.
2020-07-19 12:04:15 +02:00
yueh 755ac12b8a Fix SortedSet using compare for equals (#4479)
Fix SortedSet using compare for equals
2020-07-19 11:43:20 +02:00
Sebastian Hartte e1f9e01404 Force cluster-rebuilds on the first detected change, if their bounds do not match.
Also use a client-side method to update connected textures
for crafting cubes if two previously distinct clusters are connected.
Refactored MBCalculator to use generics for type checks and remove more casts.
2020-07-19 00:16:33 +02:00
Sebastian Hartte 7121426fc9 Disable AO for the Spatial Pylon due to artifacts. 2020-07-19 00:12:35 +02:00
yueh a94e8504f8 Correctly convert milliseconds to microseconds (#4478) 2020-07-18 20:51:30 +02:00
yueh 9275bfe001 Split TickHandler#onTick into more specific event handlers (#4477) 2020-07-18 19:35:33 +02:00
shartte 5b3c4aef79 When blocks adjacent to multiblock-capable blocks are updated, (#4474)
do not always recalculate existing multiblocks. Only do so,
if the adjacent block is either part of the multiblock's bounding
box, or if the adjacent block would be a valid part of the multiblock.
2020-07-18 18:18:24 +02:00
yueh 4a289470e2 Added a priority to IAEPowerStorage (#4473)
Added a priority to IAEPowerStorage
2020-07-18 18:06:05 +02:00
shartte d79c0f642c Do not allow recursive creation of multiblocks. (#4472) 2020-07-18 18:00:40 +02:00
aoisensi 9ecad8749f Added new japanese translate (#4475)
* Added new japanese translate
2020-07-18 12:38:23 +02:00
shartte e8b57c6dc5 Multiblocks sometimes can't be broken because during removal, (#4469)
they update their own block-state to display the disconnected
state, effectively reversing their own removal. This occurs
because the cached block state in the tile entity base class is
outdated and doesn't reflect the removal.
2020-07-17 22:35:49 +02:00
shartte 8142eb90a6 Added new Cell Rendering to ME Chest (#4464)
Moved cell models to origin 0,0,0.
Implemented a TER to render cell models/LED in the ME chest as they are rendered in the drive.
2020-07-17 20:37:07 +02:00
Sebastian Hartte 08abd4a770 Fixed formatting. 2020-07-17 20:26:17 +02:00
Sebastian Hartte b8722dbbc0 Do not rely on exceptions for control flow, when the
cell has no fuzzy mode.
2020-07-17 19:51:59 +02:00
Sebastian Hartte 1ac6d5d967 Fixes creation of entangled singularities. 2020-07-17 15:27:03 +02:00
Sebastian Hartte 5c290789e0 Fixes #4467: Private methods also need to be annotated with @OnlyIn(Dist.CLIENT)
if they use client-side classes.
2020-07-17 12:45:17 +02:00
yueh 38f6bf16f2 Updated dependencies (#4466)
Changed forge to 31.2.31 and also marked it as required version.
Changed JEI to 6.0.2.12 for dev usage.
2020-07-15 23:25:35 +02:00
Sebastian Hartte 4953509255 P2P Fluid Tunnel Fix 2020-07-13 17:45:40 +02:00
Sebastian Hartte 188f105730 Fix the alive check for the matter cannon. 2020-07-12 17:20:42 +02:00
yueh 9bb23bcac8 Refactored crafting patterns (#4458)
* Deduplicate crafting patterns internals

This should save a bit memory for duplicate patterns as well as speed up
loading new patterns on reloading chunks.

* Encode recipe id in pattern
* Use the recipe id directly for looking it up
* Slightly refactored how patterns encode whether they are crafting patterns or not.
* Renamed PatternHelper.
* Added APIs to encode patterns. (#4463)
* Removed ICraftingPatternItem.
* Renamed isCrafting to isCraftable

Co-authored-by: shartte <shartte@users.noreply.github.com>
2020-07-12 16:21:30 +02:00
yueh 06735f5c39 Rewrite drive model to support custom cell models (#4459)
* Rewrite driver model to support custom cell models

Each cell can now register a mapping Item -> ResourceLocation for a
custom cell model. Fallback will always be a 1k item cell.
2020-07-11 23:07:20 +02:00
shartte e8143d3618 Merge pull request #4462 from AppliedEnergistics/aeplugin-loader
Restored the old PluginLoader as AddonLoader
2020-07-11 21:00:58 +02:00
yueh 0d43ca15be Removed AEApi
Moved all internal access to the internal `Api` class using a new static
getter.
2020-07-11 19:40:34 +02:00
yueh d18eabe1fc Restored the old PluginLoader as AddonLoader
Introduce a new `IAEAddon` interface, which has to be implemented and
annotated wit `@AEAddon` to obtain access to our public API.
2020-07-11 18:40:51 +02:00
yueh d9d491d51c Removed deprecated API parts (#4457) 2020-07-10 19:35:29 +02:00
yueh 9a5bd114a4 Updated IStorageCell docs to mention int limitations. 2020-07-10 16:04:30 +02:00
Sebastian Hartte 30cc8c8abc Changed Javadoc for Upgrade tooltip group 2020-07-07 20:43:56 +02:00
shartte 815094e5bf Merge pull request #4454 from AppliedEnergistics/fix-4453
Fixes #4453: Avoid using clientside methods serverside.
2020-07-07 20:23:54 +02:00
yueh 1eaddef694 Fixes #4453: Avoid using clientside methods serverside. 2020-07-07 18:13:32 +02:00
yueh 450299cb67 Updated README.md
Removed crafttweaker info. Will be moved to a wiki page when necessary
again.
Updated API part with the info about github packages and also moved it
higher.
2020-07-07 12:39:37 +02:00
yueh 235fc2e81f Removed superfluous IAEStack methods 2020-07-07 12:12:48 +02:00
yueh 92fb39d53a Added curseforge task 2020-07-07 10:21:58 +02:00
Sebastian Hartte eb0e4289b3 Unify the client/server-side shared itemstack registry to avoid over-dependence on the current thread
when this class is used. Otherwise if a thread is not correctly detected to be part of the server or client
thread groups, a shared item stack from the wrong domain is returned.
2020-07-05 12:23:16 +02:00
Sebastian Hartte ebbb5b1059 Removed unused storage dimension cap. 2020-07-05 12:22:06 +02:00
yueh d4a1590b51 Added a blocktag for movable tile entities with spatial IO. (#4448)
`#spatial/whitelist` needs to be explicitly enabled through a config
value.
`#spatial/blacklist` will always be consider on top of the normal
blacklist.
2020-07-03 20:34:53 +02:00
yueh bd1d9701a9 Try to fail with missing assets (#4449) 2020-07-03 20:31:41 +02:00
yueh 4b3a232add Fix formatting 2020-07-03 20:07:51 +02:00
Sebastian Hartte b8aa810a5f Add equals(ItemStack) to IAEItemStack contract. 2020-07-03 14:32:48 +02:00
yueh 22facb9748 Don't tick debug energy tileentity clientside 2020-07-03 13:56:22 +02:00
yueh ef3cc8a0a0 Enables replicator card to place multiple instances at once. (#4447) 2020-07-03 13:04:12 +02:00
Sebastian Hartte 55b3dc0823 Removed unused class. 2020-07-02 23:22:40 +02:00
shartte 9445fad5a6 Merge pull request #4446 from AppliedEnergistics/removed-part-type
Part type's gone!
2020-07-02 13:49:46 +02:00
shartte 1a7bac1fcc Merge pull request #4438 from AppliedEnergistics/drive-state-sync
Refactored drive state sync
2020-07-02 12:18:40 +02:00
shartte 19dee8d339 Merge pull request #4443 from AppliedEnergistics/cable-bus-redstone-connections
Refactored CableBus to pass the direction directly.
2020-07-02 12:17:54 +02:00
shartte a4f66c5923 Merge pull request #4444 from AppliedEnergistics/update-mappings
Update MCP mappings
2020-07-02 12:17:21 +02:00
Sebastian Hartte fe439bfb23 Part type's gone! 2020-07-02 12:05:34 +02:00
yueh 25da0b7357 Removed unused code from DriveLedTER 2020-07-02 11:37:59 +02:00
shartte a2344f52e1 Merge pull request #4445 from AppliedEnergistics/materials-rework
Changed AEGlassMaterial to Materials
2020-07-02 10:55:32 +02:00
yueh bafc65d3a8 Changed AEGlassMaterial to Materials
Preparation in case we need more to support custom non solid, non
opaque, or similar blocks.
Removed custom fullSize/opaque blocks in favour of Material
2020-07-02 09:57:47 +02:00
shartte 4e8296d3e7 Merge pull request #4442 from AppliedEnergistics/cleanups
Reduce Importance of PartType and Fix Upgrade Card Tooltip Grouping
2020-07-02 09:41:00 +02:00
Sebastian Hartte 26eeeb4c75 Fix player id logging. 2020-07-02 09:25:38 +02:00
Sebastian Hartte f573b52b1b Be more lenient with the return value of BlockItem.tryPlace (it might be CONSUME in future versions). 2020-07-02 01:12:53 +02:00
Sebastian Hartte a1042384e3 Minor simplification of PartPlacement. 2020-07-02 01:09:17 +02:00
yueh 1ce82cc3b9 Update MCP mappings 2020-07-01 20:23:27 +02:00
yueh 7dffbf78ce Refactored CableBus to pass the direction directly. 2020-07-01 19:56:39 +02:00
yueh 0f11c1e0a4 Hide debug tools from JEI when disabled via config (#4439) 2020-07-01 14:29:43 +02:00
yueh 77b544ce4f Refactored drive state sync
Removed blinking state for now
2020-07-01 14:22:07 +02:00
Sebastian Hartte c67dba2f13 Removed reliance on PartType from code outside of Bootstrapping,
and restored ability to group different supported items on
Upgrade Card tooltips.
2020-07-01 00:56:17 +02:00
Sebastian Hartte 400fcdb633 Formatting fix 2020-07-01 00:50:37 +02:00
Sebastian Hartte fba157a707 Removed unused ItemPredicate 2020-07-01 00:44:48 +02:00
Sebastian Hartte 538965e74a Crash when someone tries to overwrite existing grid cache implementations. 2020-07-01 00:44:48 +02:00
shartte 0a56c724ed Merge pull request #4441 from AppliedEnergistics/cleanups
Minor Cleanups / Refactoring
2020-07-01 00:30:25 +02:00
Sebastian Hartte 8d8d3dd2d7 Minor refactoring.
Replaced use of reflection with use of functional factory interface (API change).
2020-06-30 18:58:30 +02:00
Sebastian Hartte d17f8cec92 Removed unused fields. 2020-06-30 18:39:34 +02:00
Sebastian Hartte d0acc9ccf1 Removed reliance of TickTracker on implementation detail to generate additional crash information. 2020-06-30 18:34:36 +02:00
1180 changed files with 13651 additions and 13328 deletions
+8 -5
View File
@@ -21,10 +21,13 @@ jobs:
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Clean gradle
run: ./gradlew clean --no-daemon --max-workers 1
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
run: ./gradlew runData --no-daemon --max-workers 1
- name: Validate assets
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
- name: Build with Gradle
run: ./gradlew build --no-daemon
run: ./gradlew build --no-daemon --max-workers 1
+8 -4
View File
@@ -21,9 +21,13 @@ jobs:
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Clean gradle
run: ./gradlew clean --no-daemon --max-workers 1
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
run: ./gradlew runData --no-daemon --max-workers 1
- name: Validate assets
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
- name: Build with Gradle
run: ./gradlew build --no-daemon
run: ./gradlew build --no-daemon --max-workers 1
+10 -5
View File
@@ -2,7 +2,8 @@ name: 'Build PRs'
on:
pull_request:
branches: [ master ]
branches:
- '*'
jobs:
build:
@@ -21,14 +22,18 @@ jobs:
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Clean gradle
run: ./gradlew clean --no-daemon --max-workers 1
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
run: ./gradlew runData --no-daemon --max-workers 1
- name: Validate assets
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
- name: Build with Gradle
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: ./gradlew build --no-daemon
run: ./gradlew build --no-daemon --max-workers 1
- uses: actions/upload-artifact@v2
with:
name: dist
+31 -6
View File
@@ -2,7 +2,7 @@ name: 'Release'
on:
release:
types: [created]
types: [published]
jobs:
build:
@@ -28,17 +28,42 @@ jobs:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
- name: Build, sign, and publish with Gradle
run: ./gradlew runData --no-daemon --max-workers 1
- name: Validate assets
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
- name: Build with Gradle
env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build publish --no-daemon
run: ./gradlew build --no-daemon --max-workers 1
- name: Upload to curseforge
env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
CHANGELOG: ${{ github.event.release.body }}
CURSEFORGE: ${{ secrets.CURSEFORGE }}
run: ./gradlew curseforge --no-daemon --max-workers 1
- name: Publish to github packages
env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1
- name: Publish to modmaven
env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }}
MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }}
run: ./gradlew publishMavenPublicationToModmavenRepository --no-daemon --max-workers 1
- name: Prepare artifact metadata
id: prepare_artifact_metadata
run: |
+50 -70
View File
@@ -12,10 +12,9 @@
* [Downloads](#downloads)
* [Installation](#installation)
* [Issues](#issues)
* [API](#applied-energistics-2-api)
* [Building](#building)
* [Contribution](#contribution)
* [API](#applied-energistics-2-api)
* [CraftTweaker](#applied-energistics-2-crafttweaker)
* [Localization](#applied-energistics-2-localization)
* [Credits](#credits)
@@ -46,7 +45,7 @@ A Mod about Matter, Energy and using them to conquer the world..
## Downloads
Downloads can be found on [CurseForge](http://www.curse.com/mc-mods/minecraft/223794-applied-energistics-2) or on the [official website](http://ae-mod.info/Downloads/).
Downloads can be found on [CurseForge](https://www.curseforge.com/minecraft/mc-mods/applied-energistics-2) or on the [official website](http://ae-mod.info/Downloads/).
## Installation
@@ -67,12 +66,52 @@ Providing as many details as possible does help us to find and resolve the issue
Please note that we might close any issue not matching these requirements.
## Applied Energistics 2 API
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
### Maven
Our authoritative Maven repository is Github Packages, which you can also use in your builds. Use of Github Packages
[requires special setup](https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages)
to authenticate with your personal access token.
AE2 is also available without authentication from Modmaven. You can use the following snippet as example on how to add a repository to your gradle build file.
repositories {
maven {
name "Modmaven"
url "https://modmaven.k-4u.nl/"
// For Gradle 5.1 and above, limit it to just AE2
content {
includeGroup 'appeng'
}
}
}
When compiling against the AE2 API you can use gradle dependencies, just add
dependencies {
compileOnly "appeng:appliedenergistics2:VERSION:api"
}
or add the `compileOnly` line to your existing dependencies task to your build.gradle.
Replace `VERSION` with the desired one. With 1.15+ we switched to using [semver](https://semver.org/).
It is highly recommended following its specification and further considering an upper bound for the dependency version.
A change of the `MAJOR` version will be an API break and can lead to various crashes. Better to inform a player about the addon not supporting the new version until it could be tested or updated.
An example string would be `appeng:appliedenergistics2:7.0.0-alpha.6:api` for the API only or `appeng:appliedenergistics2:7.0.0-alpha.6` for the whole mod.
Builds obtained [here](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) or via [maven](https://github.com/AppliedEnergistics/Applied-Energistics-2/packages) should work in a development environment.
However the dependency might need to be wrapped in `fg.deobf()` like `runtimeOnly fg.deobf("appeng:appliedenergistics2:VERSION:api")`
## Building
1. Clone this repository via
- SSH `git clone git@github.com:AppliedEnergistics/Applied-Energistics-2.git` or
- HTTPS `git clone https://github.com/AppliedEnergistics/Applied-Energistics-2.git`
2. Build using the gradle `build` task. Jar will be in `build/libs`
2. Build using the `gradlew runData build` command. Jar will be in `build/libs`
3. For core developer: Setup IDE
- IntelliJ: Import as gradle project
- Eclipse: Import as gradle project or execute gradle task `eclipse` and potentially `genEclipseRuns`
@@ -101,75 +140,16 @@ Here are a few things to keep in mind that will help get your PR approved.
* SSH `git clone git@github.com:<your username>/Applied-Energistics-2.git` or
* HTTPS `git clone https://github.com/<your username>/Applied-Energistics-2.git`
3. Change code base
4. Add changes to git `git add -A`
5. Commit changes to your clone `git commit -m "<summary of made changes>"`
6. Push to your fork `git push`
7. Create a Pull-Request on GitHub
8. Wait for review
9. Squash commits for cleaner history
4. Run `gradlew spotlessApply` to apply automatic code formatting
5. Add changes to git `git add -A`
6. Commit changes to your clone `git commit -m "<summary of made changes>"`
7. Push to your fork `git push`
8. Create a Pull-Request on GitHub
9. Wait for review
10. Squash commits for cleaner history
If you are only doing single file pull requests, GitHub supports using a quick way without the need of cloning your fork. Also read up about [synching](https://help.github.com/articles/syncing-a-fork) if you plan to contribute on regular basis.
## Applied Energistics 2 API
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
Universal builds obtained [Here](http://ae2.ae-mod.info/Downloads/) should work in a development environment.
### Maven
When compiling against the AE2 API you can use gradle dependencies, just add
dependencies {
compile "appeng:appliedenergistics2:rv_-_____-__:api"
}
or add the compile line to your existing dependencies task to your build.gradle
Where the __ are filled in with the correct version criteria; AE2 is available from the default forge maven so no additional repositories are necessary.
An example string would be `appeng:appliedenergistics2:rv5-stable-1:api` for the API only or `appeng:appliedenergistics2:rv5-stable-1` for the whole mod.
## Applied Energistics 2 CraftTweaker
### Inscriber
The inscriber uses the vanilla recipe system with a custom `type` of `appliedenergistics2:inscriber`.
See the [inscriber recipe folder](src/main/resources/data/appliedenergistics2/recipes/inscriber) for some examples.
### Grindstone
The grindstone uses the vanilla recipe system with a custom `type` of `appliedenergistics2:grinder`.
See the [grinder recipe folder](src/main/resources/data/appliedenergistics2/recipes/grinder) for some examples.
### Spatial
Whitelist a TileEntity class for Spatial IO.
mods.appliedenergistics2.Spatial.whitelistEntity( String fullEntityClassName );
### Attunement
Attune a ItemStack or ModID to a specific P2P-Tunnel type. ModID's are used as fallback when no ItemStack was found.
mods.appliedenergistics2.Attunement.attuneME( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneME( String modID );
mods.appliedenergistics2.Attunement.attuneItem( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneItem( String modID );
mods.appliedenergistics2.Attunement.attuneFluid( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneFluid( String modID );
mods.appliedenergistics2.Attunement.attuneRedstone( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneRedstone( String modID );
mods.appliedenergistics2.Attunement.attuneRF( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneRF( String modID );
mods.appliedenergistics2.Attunement.attuneIC2( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneIC2( String modID );
mods.appliedenergistics2.Attunement.attuneLight( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneLight( String modID );
### Cannon
Add ammo types for the matter cannon.
mods.appliedenergistics2.Cannon.registerAmmo( ItemStack itemStack, double weight );
## Applied Energistics 2 Localization
### English Text
+199 -15
View File
@@ -19,30 +19,72 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven { url = 'https://repo.spongepowered.org/maven' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
plugins {
id "maven-publish"
id "com.diffplug.gradle.spotless" version "4.3.0"
id "org.sonarqube" version "2.8"
id "jacoco"
id "maven-publish"
id "com.diffplug.gradle.spotless" version "4.3.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "idea"
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: "eclipse"
// All jar files from this folder will be added automatically as runtime mod dependencies
def extraModsDir = "extra-mods-${minecraft_version}"
repositories {
flatDir {
name "extra-mods"
dir file(extraModsDir)
}
mavenLocal()
jcenter()
mavenCentral()
maven { // modmaven, maven proxy
name 'modmaven'
url "https://modmaven.k-4u.nl/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// compile against provided APIs
compileOnly "mezz.jei:jei-${jei_minecraft_version}:${jei_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api"
// Runtime, Mods
runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}:${jei_version}")
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
// Locally sourced extra mods for runtime (i.e. testing)
for (extraModJar in fileTree(dir: extraModsDir, include: '*.jar')) {
def basename = extraModJar.name.substring(0, extraModJar.name.length() - ".jar".length())
def versionSep = basename.lastIndexOf('-')
assert versionSep != -1
def artifactId = basename.substring(0, versionSep)
def version = basename.substring(versionSep + 1)
runtimeOnly fg.deobf("extra-mods:$artifactId:$version")
}
// unit test dependencies
testCompile "junit:junit:4.13"
// Annotation Processors
annotationProcessor 'org.spongepowered:mixin:0.8:processor'
}
group = artifact_group
archivesBaseName = artifact_basename
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
@@ -54,7 +96,8 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Create version number
///////////////////
// Version Number
version = version_major + "." + version_minor + "." + version_patch
ext.pr = System.getenv('PR_NUMBER') ?: ""
@@ -72,10 +115,8 @@ if (ext.release) {
version = ext.release
}
// Maven group and artifact name
group = artifact_group
archivesBaseName = artifact_basename
ext.isAlpha = project.version.contains("alpha")
ext.isBeta = project.version.contains("beta")
sourceSets {
api
@@ -99,9 +140,8 @@ configurations {
apiCompile.extendsFrom(compile)
}
apply from: 'gradle/scripts/dependencies.gradle'
apply from: 'gradle/scripts/spotless.gradle'
////////////////////
// Forge/Minecraft
minecraft {
mappings channel: "snapshot", version: project.mcp_mappings
@@ -111,6 +151,7 @@ minecraft {
client {
property 'forge.logging.console.level', 'debug'
workingDirectory project.file('run')
property "mixin.debug.export", "true"
mods {
appliedenergistics2 {
source sourceSets.main
@@ -131,6 +172,9 @@ minecraft {
data {
property 'forge.logging.console.level', 'debug'
workingDirectory project.file('run')
// ForgeGradle will just force-exit the Gradle Daemon which fails our builds in case
// a daemon is used for any reason.
forceExit false
args '--mod', 'appliedenergistics2', '--all', '--output', file('src/generated/resources/')
mods {
appliedenergistics2 {
@@ -142,6 +186,14 @@ minecraft {
}
}
///////////
// Mixins
mixin {
add sourceSets.main, "appliedenergistics2.mixins.refmap.json"
}
////////////////
// Jar Signing
def signProps = [:]
if (System.getenv("KEY_STORE_FILE")) {
signProps['keyStore'] = System.getenv("KEY_STORE_FILE")
@@ -164,14 +216,88 @@ task signJar(type: net.minecraftforge.gradle.common.task.SignJar, dependsOn: 're
}
}
apply from: 'gradle/scripts/artifacts.gradle'
//////////////
// Aritfacts
processResources {
exclude '.cache'
}
jar {
finalizedBy 'reobfJar'
finalizedBy 'signJar'
from sourceSets.main.output.classesDirs
from sourceSets.api.output.classesDirs
from sourceSets.main.output.resourcesDir
from sourceSets.api.output.resourcesDir
manifest {
attributes([
"Specification-Title": "Applied Energistics 2",
"Specification-Vendor": "TeamAppliedEnergistics",
"Specification-Version": "${project.version}",
"Implementation-Title": "${project.name}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor" :"TeamAppliedEnergistics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "appliedenergistics2.mixins.json"
])
}
}
task javadocs(type: Javadoc) {
classpath = sourceSets.main.compileClasspath
source = sourceSets.api.java
include "appeng/api/**"
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
task javadocJar(type: Jar, dependsOn: javadocs) {
classifier = "javadoc"
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allJava
from sourceSets.api.allJava
}
task apiJar(type: Jar) {
classifier = "api"
from sourceSets.api.output
include "appeng/api/**"
// TODO: when FG bug is fixed, remove allJava from the api jar.
// https://github.com/MinecraftForge/ForgeGradle/issues/369
// Gradle should be able to pull them from the -sources jar.
from sourceSets.api.allJava
}
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
//////////////////
// Maven publish
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = project.archivesBaseName
version = project.version
// ForgeGradle will generate wild dependency definitions, see https://github.com/MinecraftForge/ForgeGradle/issues/584
// Since we don't actually depend on anything, just remove the entire node.
pom.withXml {
asNode().remove(asNode().dependencies)
}
from components.java
artifact sourcesJar
artifact javadocJar
@@ -187,5 +313,63 @@ publishing {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
}
maven {
credentials {
username System.getenv("MODMAVEN_USER")
password System.getenv("MODMAVEN_PASSWORD")
}
name = "modmaven"
url = "https://modmaven.k-4u.nl/artifactory/local-releases/"
}
}
}
/////////////
// Spotless
spotless {
java {
target 'src/*/java/appeng/**/*.java'
indentWithSpaces()
eclipse().configFile 'codeformat/codeformat.xml'
importOrderFile 'codeformat/ae2.importorder'
}
format 'json', {
target 'src/*/resources/**/*.json'
targetExclude 'src/generated/resources/**'
prettier().config(['parser': 'json'])
}
}
////////////////
// Curse Forge
if (System.getenv("CURSEFORGE")) {
def cfReleaseType = "release"
if (ext.isAlpha) {
cfReleaseType = "alpha"
} else if (ext.isBeta) {
cfReleaseType = "beta"
}
curseforge {
apiKey = System.getenv("CURSEFORGE")
project {
id = project.curseforge_project
changelogType = "markdown"
changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) for a changelog"
releaseType = cfReleaseType
}
}
}
////////////////
// IntelliJ Project Import
// The Mixin annotation process does not have an obfuscation source when running through the IntelliJ compiler,
// thus we have to prevent it from being activated as part of importing this Gradle project into IntelliJ.
if (System.getProperty("idea.sync.active") == "true") {
afterEvaluate {
tasks.withType(JavaCompile).all {
it.options.annotationProcessorPath = files()
}
}
}
+3 -3
View File
@@ -157,7 +157,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
@@ -192,7 +192,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
@@ -285,7 +285,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
+10 -8
View File
@@ -8,24 +8,26 @@ artifact_basename=appliedenergistics2
#########################################################
# Minecraft Versions #
#########################################################
minecraft_release=1.15
minecraft_version=1.15.2
mcp_mappings=20200613-1.15.1
forge_version=31.2.20
minecraft_release=1.16
minecraft_version=1.16.3
mcp_mappings=20200916-1.16.2
forge_version=34.1.15
#########################################################
# Provided APIs #
#########################################################
jei_version=6.0.0.4
top_version=2.0.4-5
jei_minecraft_version=1.16.2
jei_version=7.3.2.25
top_version=3.0.3-beta-6
hwyla_version=1.10.8-B72_1.15.2
ctm_version=MC1.15.2-1.1.0.9
#########################################################
# Deployment #
#########################################################
website_version=1.15.2
curse_versions=1.15.2
website_version=1.16.2
curse_versions=1.16.2
curseforge_project=223794
#########################################################
# Gradle #
-81
View File
@@ -1,81 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
processResources {
exclude '.cache'
}
jar {
finalizedBy 'reobfJar'
finalizedBy 'signJar'
from sourceSets.main.output.classesDirs
from sourceSets.api.output.classesDirs
from sourceSets.main.output.resourcesDir
from sourceSets.api.output.resourcesDir
manifest {
attributes([
"Specification-Title": "Applied Energistics 2",
"Specification-Vendor": "TeamAppliedEnergistics",
"Specification-Version": "${project.version}",
"Implementation-Title": "${project.name}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor" :"TeamAppliedEnergistics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
}
task javadocs(type: Javadoc) {
classpath = sourceSets.main.compileClasspath
source = sourceSets.api.java
include "appeng/api/**"
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
task javadocJar(type: Jar, dependsOn: javadocs) {
classifier = "javadoc"
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allJava
from sourceSets.api.allJava
}
task apiJar(type: Jar) {
classifier = "api"
from sourceSets.api.output
include "appeng/api/**"
// TODO: when FG bug is fixed, remove allJava from the api jar.
// https://github.com/MinecraftForge/ForgeGradle/issues/369
// Gradle should be able to pull them from the -sources jar.
from sourceSets.api.allJava
}
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
-87
View File
@@ -1,87 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
repositories {
mavenLocal()
maven { // modmaven, maven proxy
name 'modmaven'
url "https://modmaven.k-4u.nl/"
}
maven {
name "Mobius"
url "http://mobiusstrip.eu/maven"
}
maven {
name = "JEI repo"
url "http://dvs1.progwml6.com/files/maven"
}
maven {
name = "Tesla repo"
url "http://maven.mcmoddev.com"
}
maven {
name = "IC2 repo"
url = "http://maven.ic2.player.to"
}
maven {
name = "CoFH Maven"
url = "http://maven.covers1624.net"
}
maven { // TheOneProbe
name 'tterrag maven'
url "http://maven.tterrag.com/"
}
maven {
name 'mcjty'
url "http://maven.k-4u.nl/"
}
maven { // CraftTweaker
name 'jared maven'
url "http://maven.blamejared.com/"
}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// compile against provided APIs
compileOnly "mezz.jei:jei-${minecraft_version}:${jei_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}:api"
// Runtime, Mods
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}")
runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}")
// unit test dependencies
testCompile "junit:junit:4.13"
}
-32
View File
@@ -1,32 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*g GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
spotless {
java {
target 'src/*/java/appeng/**/*.java'
indentWithSpaces()
eclipse().configFile 'codeformat/codeformat.xml'
importOrderFile 'codeformat/ae2.importorder'
}
format 'json', {
target 'src/*/resources/**/*.json'
targetExclude 'src/generated/resources/**'
prettier().config(['parser': 'json'])
}
}
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
@@ -26,12 +26,16 @@ import java.lang.annotation.Target;
/**
* Use this annotation on a class in your Mod to have it instantiated during the
* initialization phase of Applied Energistics. AE expects your class to have a
* single constructor and can supply certain arguments to your constructor using
* dependency injection.
* initialization phase of Applied Energistics.
*
* The class also needs to implement {@link IAEAddon}.
*
* AE expects your class to have a single constructor without any parameters.
*
* This is the only way to get access to the public {@link IAppEngApi} instance.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Retention(RetentionPolicy.CLASS)
@Documented
public @interface AEPlugin {
public @interface AEAddon {
}
-67
View File
@@ -1,67 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api;
import java.lang.reflect.Field;
import appeng.api.exceptions.CoreInaccessibleException;
/**
* Entry point for api.
*/
public enum AEApi {
;
private static final String CORE_API_FQN = "appeng.core.Api";
private static final String CORE_API_FIELD = "INSTANCE";
private static final IAppEngApi HELD_API;
static {
try {
final Class<?> apiClass = Class.forName(CORE_API_FQN);
final Field apiField = apiClass.getField(CORE_API_FIELD);
HELD_API = (IAppEngApi) apiField.get(apiClass);
} catch (final ClassNotFoundException e) {
throw new CoreInaccessibleException(
"AE2 API tried to access the " + CORE_API_FQN + " class, without it being declared.");
} catch (final NoSuchFieldException e) {
throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in "
+ CORE_API_FQN + " without it being declared.");
} catch (final IllegalAccessException e) {
throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in "
+ CORE_API_FQN + " without enough access permissions.");
}
}
/**
* API Entry Point.
*
* @return the {@link IAppEngApi}
*/
public static IAppEngApi instance() {
return HELD_API;
}
}
-33
View File
@@ -1,33 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks interfaces that can be used as injectable constructor arguments for an
* {@link AEPlugin}.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface AEInjectable {
}
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -21,23 +21,30 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations.items;
package appeng.api;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
/**
* Lets you specify the name of the group of items this falls under.
* Every AE2 addon requiring access to {@link IAppEngApi}, needs to provide at
* least one class implementing this interface.
*
* Further it requires the class to be annotated with {@link AEAddon}.
*
*/
public interface IItemGroup {
public interface IAEAddon {
/**
* returning null, is the same as not implementing the interface at all.
*
* @param is item
*
* @return an unlocalized string to use for the items group name.
* This gets called once the API is successfully constructed and ready to be
* used.
*
* For now this happens during {@link FMLCommonSetupEvent}.
*
* Each addon is responsible to maintain a reference to {@link IAppEngApi} for
* future use. Otherwise there is no alternative to access it later.
*
* @param api The API instance when ready.
*/
String getUnlocalizedGroupName(Set<ItemStack> otherItems, ItemStack is);
void onAPIAvailable(IAppEngApi api);
}
+13 -7
View File
@@ -23,16 +23,22 @@
package appeng.api;
import appeng.api.client.IClientHelper;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartHelper;
import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
@AEInjectable
public interface IAppEngApi {
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/**
* @return Registry Container for the numerous registries in AE2.
*/
@@ -43,6 +49,11 @@ public interface IAppEngApi {
*/
IStorageHelper storage();
/**
* @return A helper for working with crafting related tasks.
*/
ICraftingHelper crafting();
/**
* @return A helper to create {@link IGridNode} and other grid related objects.
*/
@@ -53,11 +64,6 @@ public interface IAppEngApi {
*/
IPartHelper partHelper();
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/**
* @return Utility methods primarily useful for client side stuff
*/
@@ -0,0 +1,88 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.client;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
/**
* A registry for 3D models used to render storage cells in the world, when they
* are inserted into a drive or similar machines.
*/
public interface ICellModelRegistry {
/**
* Register a new model for a storage cell item.
*
* <p>
* You are responsible for ensuring that the given model is actually loaded by
* the game. See
* {@see net.minecraftforge.client.model.ModelLoader#addSpecialModel}.
*
* This method only maps an {@link Item} to a {@link ResourceLocation} which can
* be looked up from the {@link ModelBakery}. No validation about missing models
* will be done.
*
* Will throw an exception in case a model is already registered for an item.
*
* For examples look at our cell part models within the drive model directory.
*
* @param item The cell item
* @param model The {@link ResourceLocation} representing the model.
* @return
*/
void registerModel(@Nonnull Item item, @Nonnull ResourceLocation model);
/**
* The {@link ResourceLocation} of the model used to render the given storage
* cell {@link Item} when inserted into a drive or similar.
*
* @param item
* @return null, if no model is registered.
*/
@Nullable
ResourceLocation model(@Nonnull Item item);
/**
* An unmodifiable map of all registered mappings.
*
* @return
*/
@Nonnull
Map<Item, ResourceLocation> models();
/**
* Returns the default model, which can be used when no explicit model is
* registered.
*/
@Nonnull
ResourceLocation getDefaultModel();
}
@@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.util;
package appeng.api.client;
import java.util.List;
@@ -39,4 +39,11 @@ public interface IClientHelper {
*/
<T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<ITextComponent> lines);
/**
* A helper to work with clientside related tasks for cells.
*
* @return
*/
ICellModelRegistry cells();
}
@@ -23,6 +23,8 @@
package appeng.api.config;
import java.util.Locale;
/**
* Represent the security systems basic permissions, these are not for
* anti-griefing, they are part of the mod as a gameplay feature.
@@ -58,7 +60,7 @@ public enum SecurityPermissions {
*/
SECURITY;
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase();
private final String translationKey = "gui.appliedenergistics2.security." + this.name().toLowerCase(Locale.ROOT);
public String getTranslatedName() {
return this.translationKey + ".name";
+107 -18
View File
@@ -23,12 +23,22 @@
package appeng.api.config;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
import appeng.api.definitions.IItemDefinition;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
public enum Upgrades {
/**
@@ -42,7 +52,8 @@ public enum Upgrades {
FUZZY(1), SPEED(1), INVERTER(1);
private final int tier;
private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
private final List<Supported> supported = new ArrayList<>();
private List<ITextComponent> supportedTooltipLines;
Upgrades(final int tier) {
this.tier = tier;
@@ -52,8 +63,12 @@ public enum Upgrades {
* @return list of Items/Blocks that support this upgrade, and how many it
* supports.
*/
public Map<ItemStack, Integer> getSupported() {
return this.supportedMax;
public List<Supported> getSupported() {
return this.supported;
}
public void registerItem(final IItemProvider item, final int maxSupported) {
this.registerItem(item, maxSupported, null);
}
/**
@@ -61,24 +76,98 @@ public enum Upgrades {
*
* @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
* @param tooltipGroup If more than one item of the same group are supported,
* the tooltip will show this translation key instead. If
* the items have different maxSupported values, the highest
* will be shown.
*/
public void registerItem(final IItemDefinition item, final int maxSupported) {
item.maybeStack(1).ifPresent(is -> this.registerItem(is, maxSupported));
public void registerItem(final IItemProvider item, final int maxSupported, @Nullable String tooltipGroup) {
Preconditions.checkNotNull(item);
this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup));
supportedTooltipLines = null; // Reset tooltip
}
/**
* Registers a specific amount of this upgrade into a specific machine
*
* @param stack machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
*/
public void registerItem(final ItemStack stack, final int maxSupported) {
if (stack != null) {
this.supportedMax.put(stack, maxSupported);
public List<ITextComponent> getTooltipLines() {
if (supportedTooltipLines == null) {
supported.sort(Comparator.comparingInt(o -> o.maxCount));
supportedTooltipLines = new ArrayList<>(supported.size());
// Use a separate set because the final text will include numbers
Set<ITextComponent> namesAdded = new HashSet<>();
for (int i = 0; i < supported.size(); i++) {
Supported supported = this.supported.get(i);
ITextComponent name = supported.item.getName();
// If the group was already added by a previous item, skip this
if (supported.getTooltipGroup() != null && namesAdded.contains(supported.getTooltipGroup())) {
continue;
}
// If any of the following items would be of the same group, use the group name
// instead
if (supported.getTooltipGroup() != null) {
for (int j = i + 1; j < this.supported.size(); j++) {
ITextComponent otherGroup = this.supported.get(j).getTooltipGroup();
if (supported.getTooltipGroup().equals(otherGroup)) {
name = supported.getTooltipGroup();
break;
}
}
}
if (namesAdded.add(name)) {
// append the supported count only if its > 1
if (supported.maxCount > 1) {
name = name.deepCopy().appendString(" (" + supported.maxCount + ")");
}
supportedTooltipLines.add(name);
}
}
}
return supportedTooltipLines;
}
public int getTier() {
return this.tier;
}
public static class Supported {
private final Item item;
private final Block block;
private final int maxCount;
// Translation key of the tooltip group
@Nullable
private final String tooltipGroup;
public Supported(Item item, int maxCount, @Nullable String tooltipGroup) {
this.item = item;
if (item.getItem() instanceof BlockItem) {
this.block = ((BlockItem) item.getItem()).getBlock();
} else {
this.block = null;
}
this.maxCount = maxCount;
this.tooltipGroup = tooltipGroup;
}
public int getMaxCount() {
return maxCount;
}
public boolean isSupported(Block block) {
return block != null && this.block == block;
}
public boolean isSupported(Item item) {
return item != null && this.item == item;
}
public ITextComponent getTooltipGroup() {
return this.tooltipGroup != null ? new TranslationTextComponent(this.tooltipGroup) : null;
}
}
}
@@ -0,0 +1,112 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.crafting;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
public interface ICraftingHelper {
/**
* Checks that the given item stack is an encoded pattern.
*/
boolean isEncodedPattern(@Nullable IAEItemStack item);
/**
* Checks that the given item stack is an encoded pattern.
*/
boolean isEncodedPattern(ItemStack item);
/**
* Encodes a processing pattern which represents the ability to convert the
* given inputs into the given outputs using some process external to the ME
* system.
*
* @param stack If null, a new item will be created to hold the encoded pattern.
* Otherwise the given item must already contains an encoded
* pattern that will be overwritten.
* @throws IllegalArgumentException If either in or out contain only empty
* ItemStacks.
* @return A new encoded pattern, or the given stack with the pattern encoded in
* it.
*/
ItemStack encodeProcessingPattern(@Nullable ItemStack stack, ItemStack[] in, ItemStack[] out);
/**
* Encodes a crafting pattern which represents a Vanilla crafting recipe.
*
* @param stack If null, a new item will be created to hold the
* encoded pattern. Otherwise the given item must
* already contains an encoded pattern that will be
* overwritten.
* @param recipe The Vanilla crafting recipe to be encoded.
* @param in The items in the crafting grid, which are used to
* determine what items are supplied from the ME system
* to craft using this pattern.
* @param out What is to be expected as the result of this crafting
* operation by the ME system.
* @param allowSubstitutes Controls whether the ME system will allow the use of
* equivalent items to craft this recipe.
* @throws IllegalArgumentException If either in or out contain only empty
* ItemStacks.
*/
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
boolean allowSubstitutes);
/**
* Same as {@link #decodePattern(ItemStack, World, boolean)} with no auto
* recovery of changed recipe ids.
*/
@Nullable
default ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world) {
return decodePattern(itemStack, world, false);
}
/**
* Decodes an encoded crafting pattern and returns the pattern details.
* <p>
* The item backing the {@link ItemStack} needs to be an item returned by the
* encode methods of this class.
*
* @param itemStack pattern
* @param world world used to access the
* {@link net.minecraft.item.crafting.RecipeManager}.
* @param autoRecovery If true, the method will try to recover from changed
* recipe ids by searching the entire recipe manager for a
* recipe matching the inputs. If this is successful, the
* given item stack will be changed to reflect the new
* recipe id.
* @return The pattern details if the pattern could be decoded. Otherwise null.
*/
@Nullable
ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world, boolean autoRecovery);
}
@@ -30,10 +30,11 @@ import javax.annotation.Nonnull;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IItemProvider;
import appeng.api.features.AEFeature;
public interface IItemDefinition extends IComparableDefinition {
public interface IItemDefinition extends IComparableDefinition, IItemProvider {
/**
* @return the unique name of the definition which will be used to register the
* underlying structure. Will never be null
@@ -63,4 +64,10 @@ public interface IItemDefinition extends IComparableDefinition {
* @return an immutable set of the features of this item
*/
Set<AEFeature> features();
@Override
default Item asItem() {
return item();
}
}
@@ -23,7 +23,6 @@
package appeng.api.features;
import appeng.api.AEInjectable;
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
@@ -36,7 +35,6 @@ import appeng.api.storage.ICellRegistry;
* @version 7
* @since rv0
*/
@AEInjectable
public interface IRegistryContainer {
/**
@@ -24,18 +24,15 @@
package appeng.api.features;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IWorld;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.server.ServerWorld;
public interface IWorldGen {
void disableWorldGenForProviderID(WorldGenType type, Class<? extends Dimension> provider);
void enableWorldGenForDimension(WorldGenType type, ResourceLocation dimID);
void disableWorldGenForDimension(WorldGenType type, ResourceLocation dimID);
boolean isWorldGenEnabled(WorldGenType type, IWorld w);
boolean isWorldGenEnabled(WorldGenType type, ServerWorld w);
enum WorldGenType {
CERTUS_QUARTZ, CHARGED_CERTUS_QUARTZ, METEORITES
@@ -1,46 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;
/**
* Implemented on {@link Item}
*/
public interface ICraftingPatternItem {
/**
* Access Details about a pattern
*
* @param is pattern
* @param w crafting world
*
* @return details of pattern
*/
ICraftingPatternDetails getPatternForItem(ItemStack is, World w);
}
@@ -1,38 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations;
/**
* Defines the result of performing a transition from the world into a storage
* cell, if its possible, and what the energy usage is.
*/
public class TransitionResult {
public final boolean success;
public final double energyUsage;
public TransitionResult(final boolean success, final double power) {
this.success = success;
this.energyUsage = power;
}
}
@@ -23,13 +23,23 @@
package appeng.api.implementations.items;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IGrowableCrystal {
ItemStack triggerGrowth(ItemStack is);
float getMultiplier(Block blk, Material mat);
/**
* Gets the crystal growth multiplier based on the material it is submerged in.
*
* @param state The blockstate of the block the crystal is currently in.
* @return The multiplier for the growth tick progress. Zero if the crystal
* cannot grow in the current material.
*/
float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos);
}
@@ -25,10 +25,8 @@ package appeng.api.implementations.items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import appeng.api.implementations.TransitionResult;
import appeng.api.util.WorldCoord;
/**
@@ -51,13 +49,13 @@ public interface ISpatialStorageCell {
int getMaxStoredDim(ItemStack is);
/**
* get the currently stored Dimension id.
* get the currently stored spatial storage plot id.
*
* @param is spatial storage cell
*
* @return dimension id or -1
* @return plot id or -1
*/
DimensionType getStoredDimension(ItemStack is);
int getAllocatedPlotId(ItemStack is);
/**
* Perform a spatial swap with the contents of the cell, and the world.
@@ -68,7 +66,7 @@ public interface ISpatialStorageCell {
* @param max max coord
* @param playerId owner of current grid or -1
*
* @return result of transition
* @return success of transition
*/
TransitionResult doSpatialTransition(ItemStack is, World w, WorldCoord min, WorldCoord max, int playerId);
boolean doSpatialTransition(ItemStack is, ServerWorld w, WorldCoord min, WorldCoord max, int playerId);
}
@@ -28,18 +28,25 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.api.storage.data.IAEStack;
/**
* Any item which implements this can be treated as an IMEInventory via
* Util.getCell / Util.isCell It automatically handles the internals and NBT
* data, which is both nice, and bad for you!
* {@link ICellHandler#getCellInventory(ItemStack, appeng.api.storage.cells.ISaveProvider, IStorageChannel)}
* or {@link ICellHandler#isCell(ItemStack)}. It automatically handles the
* internals and NBT data, which is both nice, and bad for you!
*
* Good cause it means you don't have to do anything, bad because you have
* little to no control over it.
*
* The standard AE implementation only provides 1-63 Types
*
* Limited to {@link Integer} internally for most calculations. E.g. if the used
* or remaining bytes would overflow {@link Integer#MAX_VALUE} the behaviour is
* no longer specified. Even if {@link ICellInventory} is using {@link Long}.
*
* The standard AE implementation also only provides 1-63 Types.
*/
public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem {
@@ -28,4 +28,9 @@ public enum GridNotification {
* the visible connections for this node have changed, useful for cable.
*/
CONNECTIONS_CHANGED,
/**
* the owner of the grid node has changed, and the node needs to be re-saved
*/
OWNER_CHANGED
}
@@ -87,20 +87,11 @@ public interface IGridBlock {
AEColor getGridColor();
/**
* Notifies your IGridBlock that changes were made to your connections
* Called by the {@link IGridNode} to notify its {@link IGridBlock} about
* events.
*/
void onGridNotification(@Nonnull GridNotification notification);
/**
* Update Blocks network/connection/booting status. grid,
*
* @param grid grid
* @param channelsInUse used channels
* @deprecated to be removed in rv7
*/
@Deprecated
void setNetworkStatus(IGrid grid, int channelsInUse);
/**
* Determine which sides of the block can be connected too, only used when
* isWorldAccessible returns true, not used for {@link IPart} implementations.
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 - 2015 AlgorithmX2
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -21,20 +21,23 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import java.io.BufferedReader;
package appeng.api.networking;
import javax.annotation.Nonnull;
@Deprecated
public interface IRecipeLoader {
/**
* A factory for grid cache implementations.
*/
@FunctionalInterface
public interface IGridCacheFactory<T extends IGridCache> {
/**
* @param filePath the path to the to be loaded file
* Creates a grid cache for the given grid.
*
* @return reader handler of the file
*
* @throws Exception if reading goes wrong
* @param grid The grid for which the cache should be created.
* @return A new grid cache instance.
*/
BufferedReader getFile(@Nonnull String filePath) throws Exception;
@Nonnull
T createCache(IGrid grid);
}
@@ -36,10 +36,10 @@ public interface IGridCacheRegistry {
* Register a new grid cache for use during operation, must be called during the
* loading phase.
*
* @param iface grid cache class
* @param iface grid cache class
* @param factory Factory for creating a new instance for each constructed grid
*/
void registerGridCache(@Nonnull Class<? extends IGridCache> iface,
@Nonnull Class<? extends IGridCache> implementation);
<T extends IGridCache> void registerGridCache(@Nonnull Class<T> iface, @Nonnull IGridCacheFactory<T> factory);
/**
* requests a new INSTANCE of a grid cache for use, used internally
@@ -23,22 +23,25 @@
package appeng.api.networking.crafting;
import java.util.List;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.storage.data.IAEItemStack;
/**
* do not implement provided by {@link ICraftingPatternItem}
*
* caching this INSTANCE will increase performance of validation and checks.
* Describes a crafting or processing pattern decoded by
* {@link appeng.api.crafting.ICraftingHelper}.
* <p>
* Do not cache instances of this class unless you handle recipe reloads on the
* server and client correctly.
*/
public interface ICraftingPatternDetails {
/**
* @return source item.
* @return encodes this crafting pattern into a new item stack.
*/
ItemStack getPattern();
@@ -52,29 +55,72 @@ public interface ICraftingPatternDetails {
boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world);
/**
* @return if this pattern is a crafting pattern ( work bench )
* @return if this pattern is for a Vanilla
* {@link net.minecraft.item.crafting.IRecipeType#CRAFTING crafting
* recipe}.
*/
boolean isCraftable();
/**
* Equal itemstacks will be aggregated into one, respectively 3*64 will be
* returned as one stack of 192, up to 576 of a single type.
* <p>
* This should be the preferred way to deal with the list of inputs.
* <p>
* The list will be sorted in descending order by stack size. However there is
* no guarantee about maintaining the placement order of the inputs in case of
* equal values.
*
* @return an immutable list of inputs without nulls
*/
List<IAEItemStack> getInputs();
/**
* Equal itemstacks will be aggregated into one, respectively 2*32 will be
* returned as one stack of 64, up to 192 of a single type.
* <p>
* This should be the preferred way to deal with the list of outputs.
* <p>
*
* The list will be sorted in descending order by stack size. However there is
* no guarantee about maintaining the placement order of the outputs in case of
* equal values.
*
* @return an immutable list of outputs without nulls
*/
List<IAEItemStack> getOutputs();
/**
* A sparse list representing the placement order of a crafting grid, left to
* right, then top to bottom.
* <p>
* Only use when absolutely necessary, always prefer
* {@link ICraftingPatternDetails#getInputs()}
* <p>
* This will contain exactly 9 entries.
* <p>
* This can return a copy from the internal structure, so there are no
* guarantees about modifications.
*
* @return a list of the inputs, will include nulls.
*/
IAEItemStack[] getInputs();
/**
* @return a list of the inputs, will be clean
*/
IAEItemStack[] getCondensedInputs();
/**
* @return a list of the outputs, will be clean
*/
IAEItemStack[] getCondensedOutputs();
IAEItemStack[] getSparseInputs();
/**
* A sparse list representing the placement order of the respective output
* slots.
* <p>
* Only use when absolutely necessary, always prefer
* {@link ICraftingPatternDetails#getOutputs()}
* <p>
* This will either contain 1 entry for crafting patterns or 3 for processing.
* <p>
* This can return a copy from the internal structure, so there are no
* guarantees about modifications.
*
* @return a list of the outputs, will include nulls.
*/
IAEItemStack[] getOutputs();
IAEItemStack[] getSparseOutputs();
/**
* @return if this pattern is enabled to support substitutions.
@@ -23,6 +23,7 @@
package appeng.api.networking.crafting;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.storage.data.IAEItemStack;
/**
@@ -33,6 +34,9 @@ public interface ICraftingProviderHelper {
/**
* Add new Pattern to AE's crafting cache.
*
* This will only accept instances created by
* {@link ICraftingHelper#decodePattern(net.minecraft.item.ItemStack, net.minecraft.world.World)}
*/
void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api);
@@ -27,6 +27,7 @@ import javax.annotation.Nonnull;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.IGrid;
/**
* Used to access information about AE's various power accepting blocks for
@@ -71,4 +72,22 @@ public interface IAEPowerStorage extends IEnergySource {
*/
@Nonnull
AccessRestriction getPowerFlow();
}
/**
* The priority to use this energy storage.
*
* A higher value means it is more likely to be extracted from first, and less
* likely to be inserted into first.
*
* The value needs to be constant once added to a {@link IGrid}. Should it ever
* need to be changed, it has to be removed from the grid, then update the
* value, and finally added back to the grid.
*
* This should never use {@link Integer#MIN_VALUE} or {@link Integer#MAX_VALUE}.
*
* @return the priority for this storage
*/
default int getPriority() {
return 0;
}
}
@@ -23,7 +23,6 @@
package appeng.api.networking.security;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.networking.IGridNode;
@@ -31,6 +31,6 @@ public interface ICustomCableConnection {
* @return This controls the cable connection to the node. -1 to render
* connection yourself.
*/
public float getCableConnectionLength(AECableType cable);
float getCableConnectionLength(AECableType cable);
}
@@ -24,7 +24,6 @@
package appeng.api.parts;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+22 -8
View File
@@ -32,6 +32,7 @@ import javax.annotation.Nonnull;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -41,7 +42,7 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -49,6 +50,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import appeng.api.networking.IGridNode;
@@ -220,7 +222,7 @@ public interface IPart extends ICustomCableConnection {
*
* @return if your activate method performed something.
*/
boolean onActivate(PlayerEntity player, Hand hand, Vec3d pos);
boolean onActivate(PlayerEntity player, Hand hand, Vector3d pos);
/**
* Called when you right click the part, very similar to Block.onActivateBlock
@@ -232,7 +234,7 @@ public interface IPart extends ICustomCableConnection {
* @return if your activate method performed something, you should use false
* unless you really need it.
*/
boolean onShiftActivate(PlayerEntity player, Hand hand, Vec3d pos);
boolean onShiftActivate(PlayerEntity player, Hand hand, Vector3d pos);
/**
* Called when you left click the part, very similar to Block.onBlockClicked
@@ -244,7 +246,7 @@ public interface IPart extends ICustomCableConnection {
* @return if your activate method performed something, you should use false
* unless you really need it.
*/
default boolean onClicked(PlayerEntity player, Hand hand, Vec3d pos) {
default boolean onClicked(PlayerEntity player, Hand hand, Vector3d pos) {
return false;
}
@@ -259,7 +261,7 @@ public interface IPart extends ICustomCableConnection {
* @return if your activate method performed something, you should use false
* unless you really need it.
*/
default boolean onShiftClicked(PlayerEntity player, Hand hand, Vec3d pos) {
default boolean onShiftClicked(PlayerEntity player, Hand hand, Vector3d pos) {
return false;
}
@@ -278,7 +280,7 @@ public interface IPart extends ICustomCableConnection {
* the node. -1 to render connection yourself.
*/
@Override
public float getCableConnectionLength(AECableType cable);
float getCableConnectionLength(AECableType cable);
/**
* same as Block.animateTick, for but parts.
@@ -345,10 +347,12 @@ public interface IPart extends ICustomCableConnection {
* capabilities on the cable bus will be forwarded to parts on the appropriate
* side.
*
* @see TileEntity#getCapability(Capability, net.minecraft.util.Direction)
* @see CapabilityProvider#getCapability(Capability,
* net.minecraft.util.Direction)
*
* @return The capability or null.
* @return The capability
*/
@Nonnull
default <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
return LazyOptional.empty();
}
@@ -371,4 +375,14 @@ public interface IPart extends ICustomCableConnection {
*/
void getBoxes(final IPartCollisionHelper bch);
/**
* This will be used by the core to add information about this part to a crash
* report if it is attached to a host that caused a crash during tick
* processing.
*
* @param section The crash report section the information will be added to.
*/
default void addEntityCrashInfo(final CrashReportCategory section) {
}
}
+2 -2
View File
@@ -30,7 +30,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
@@ -146,7 +146,7 @@ public interface IPartHost extends ICustomCableConnection {
*
* @return a new SelectedPart, this is never null.
*/
SelectedPart selectPart(Vec3d pos);
SelectedPart selectPart(Vector3d pos);
/**
* can be used by parts to trigger the tile or part to save.
@@ -23,13 +23,10 @@ import java.util.Collection;
import net.minecraft.util.ResourceLocation;
import appeng.api.AEInjectable;
/**
* Allows registration of part models that can then be used in
* {@link IPart#getStaticModels()}.
*/
@AEInjectable
public interface IPartModels {
/**
@@ -1,54 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import java.util.List;
import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RecipeException;
import appeng.api.exceptions.RegistrationException;
@Deprecated
public interface ICraftHandler {
/**
* Called when your recipe handler receives a newly parsed list of
* inputs/outputs.
*
* @param input parsed inputs
* @param output parsed outputs
*
* @throws RecipeException
*/
void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeException;
/**
* called when all recipes are parsed, and your required to register your
* recipe.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
void register() throws RegistrationException, MissingIngredientException;
}
@@ -1,92 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RegistrationException;
@Deprecated
public interface IIngredient {
/**
* Acquire a single input stack for the current recipe, if more then one
* ItemStack is possible a RegistrationError exception will be thrown, ignore
* these and let the system handle the error.
*
* @return a single ItemStack for the recipe handler.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
ItemStack getItemStack() throws RegistrationException, MissingIngredientException;
/**
* Acquire a list of all the input stacks for the current recipe, this is for
* handlers that support multiple inputs per slot.
*
* @return an array of ItemStacks for the recipe handler.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException;
/**
* If you wish to support air, you must test before getting the ItemStack, or
* ItemStackSet
*
* @return true if this slot contains no ItemStack, this is passed as "_"
*/
boolean isAir();
/**
* @return The Name Space of the item. Prefer getItemStack or getItemStackSet
*/
String getNameSpace();
/**
* @return The Name of the item. Prefer getItemStack or getItemStackSet
*/
String getItemName();
/**
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
*/
int getDamageValue();
/**
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
*/
int getQty();
/**
* Bakes the lists in for faster runtime look-ups.
*
* @throws MissingIngredientException
* @throws RegistrationException
*/
void bake() throws RegistrationException, MissingIngredientException;
}
@@ -1,44 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
/**
* Represents the AE2 Recipe Loading/Reading Class
*/
@Deprecated
public interface IRecipeHandler {
/**
* Call when you want to read recipes in from a file based on a loader
*
* @param loader recipe loader
* @param path path of file
*/
void parseRecipes(IRecipeLoader loader, String path);
/**
* this loads the read recipes into minecraft, should be called in Init.
*/
void injectRecipes();
}
@@ -1,45 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import net.minecraft.nbt.CompoundNBT;
public class ResolverResult {
public final String itemName;
public final int damageValue;
public final CompoundNBT compound;
public ResolverResult(final String name, final int damage) {
this.itemName = name;
this.damageValue = damage;
this.compound = null;
}
public ResolverResult(final String name, final int damage, final CompoundNBT data) {
this.itemName = name;
this.damageValue = damage;
this.compound = data;
}
}
@@ -1,40 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
public class ResolverResultSet {
public final String name;
public final List<ItemStack> results;
public ResolverResultSet(final String myName, final ItemStack... set) {
this.results = Arrays.asList(set);
this.name = myName;
}
}
@@ -1,50 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.api.storage;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
public interface ISpatialDimension {
ServerWorld getWorld(DimensionType cellDim);
@Nullable
DimensionType createNewCellDimension(BlockPos capacity);
void deleteCellDimension(DimensionType cellDim);
boolean isCellDimension(DimensionType cellDim);
BlockPos getCellDimensionOrigin(DimensionType cellDim);
BlockPos getCellDimensionSize(DimensionType cellDim);
/**
* Adds a user-facing tooltip that describes this dimension so that a player can
* keep storage cells apart.
*/
void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> lines);
}
@@ -50,5 +50,5 @@ public enum CellState {
/**
* Full cell, technically could have free types
*/
FULL,
FULL;
}
@@ -106,4 +106,13 @@ public interface IAEItemStack extends IAEStack<IAEItemStack> {
* @return definition stack
*/
ItemStack getDefinition();
/**
* Compare this AE item stack to another item stack, but ignores the amount. It
* checks the item type, NBT and damage values.
*
* @param is An item stack
*/
boolean equals(ItemStack is);
}
@@ -179,17 +179,7 @@ public interface IAEStack<T extends IAEStack<T>> {
T empty();
/**
* @return true if the stack is a {@link IAEItemStack}
*/
boolean isItem();
/**
* @return true if the stack is a {@link IAEFluidStack}
*/
boolean isFluid();
/**
* @return ITEM or FLUID
* @return The {@link IStorageChannel} backing this stack.
*/
IStorageChannel<T> getChannel();
@@ -25,16 +25,17 @@ package appeng.api.util;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DimensionType;
import net.minecraft.world.IWorld;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.World;
/**
* Represents a location in the Minecraft Universe
*/
public class DimensionalCoord extends WorldCoord {
private final IWorld world;
private final Dimension dimension;
private final World world;
private final DimensionType dimension;
public DimensionalCoord(final DimensionalCoord coordinate) {
super(coordinate.x, coordinate.y, coordinate.z);
@@ -45,19 +46,19 @@ public class DimensionalCoord extends WorldCoord {
public DimensionalCoord(final TileEntity tileEntity) {
super(tileEntity);
this.world = tileEntity.getWorld();
this.dimension = this.world.getDimension();
this.dimension = this.world.getDimensionType();
}
public DimensionalCoord(final IWorld world, final int x, final int y, final int z) {
public DimensionalCoord(final World world, final int x, final int y, final int z) {
super(x, y, z);
this.world = world;
this.dimension = world.getDimension();
this.dimension = world.getDimensionType();
}
public DimensionalCoord(final IWorld world, final BlockPos pos) {
public DimensionalCoord(final World world, final BlockPos pos) {
super(pos);
this.world = world;
this.dimension = world.getDimension();
this.dimension = world.getDimensionType();
}
@Override
@@ -84,7 +85,7 @@ public class DimensionalCoord extends WorldCoord {
return this.world == world;
}
public IWorld getWorld() {
public World getWorld() {
return this.world;
}
+2 -35
View File
@@ -18,22 +18,14 @@
package appeng.block;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
@@ -41,13 +33,11 @@ import net.minecraftforge.common.ToolType;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.util.Platform;
public abstract class AEBaseBlock extends Block {
private boolean isOpaque = true;
private boolean isFullSize = true;
private boolean isInventory = false;
protected AEBaseBlock(final Block.Properties props) {
@@ -74,7 +64,7 @@ public abstract class AEBaseBlock extends Block {
}
private static SoundType getDefaultSoundByMaterial(Material mat) {
if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) {
if (mat == AEMaterials.GLASS || mat == Material.GLASS) {
return SoundType.GLASS;
} else if (mat == Material.ROCK) {
return SoundType.STONE;
@@ -85,11 +75,6 @@ public abstract class AEBaseBlock extends Block {
}
}
@Override
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
return this.isFullSize() && this.isOpaque();
}
@Override
public boolean hasComparatorInputOverride(BlockState state) {
return this.isInventory();
@@ -214,24 +199,6 @@ public abstract class AEBaseBlock extends Block {
return true;
}
protected boolean isOpaque() {
return this.isOpaque;
}
protected boolean setOpaque(final boolean isOpaque) {
this.isOpaque = isOpaque;
return isOpaque;
}
protected boolean isFullSize() {
return this.isFullSize;
}
protected boolean setFullSize(final boolean isFullSize) {
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean isInventory() {
return this.isInventory;
}
@@ -129,7 +129,7 @@ public class AEBaseBlockItem extends BlockItem {
}
ActionResultType result = super.tryPlace(context);
if (result != ActionResultType.SUCCESS) {
if (!result.isSuccessOrConsume()) {
return result;
}
@@ -139,7 +139,7 @@ public class AEBaseBlockItem extends BlockItem {
ori = tile;
if (tile == null) {
return ActionResultType.SUCCESS;
return result;
}
if (ori.canBeRotated() && !this.blockType.hasCustomRotation()) {
@@ -155,7 +155,7 @@ public class AEBaseBlockItem extends BlockItem {
ori.setOrientation(forward, up);
}
return ActionResultType.SUCCESS;
return result;
}
}
@@ -25,32 +25,24 @@ import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.Api;
import appeng.core.localization.GuiText;
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage {
public AEBaseBlockItemChargeable(Block id, Properties props) {
super(id, props);
addPropertyOverride(new ResourceLocation("appliedenergistics2:fill_level"), (is, world, entity) -> {
double curPower = getAECurrentPower(is);
double maxPower = getAEMaxPower(is);
return (int) Math.round(100 * curPower / maxPower);
});
}
@Override
@@ -68,10 +60,10 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
final double percent = internalCurrentPower / internalMaxPower;
lines.add(GuiText.StoredEnergy.textComponent()
.appendText(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
.appendSibling(new TranslationTextComponent(PowerUnits.AE.unlocalizedName))
.appendText(" - " + MessageFormat.format("{0,number,#.##%}", percent)));
lines.add(GuiText.StoredEnergy.text().deepCopy()
.appendString(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower))
.append(new TranslationTextComponent(PowerUnits.AE.unlocalizedName))
.appendString(" - " + MessageFormat.format("{0,number,#.##%}", percent)));
}
}
@@ -123,7 +115,7 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
private double getMaxEnergyCapacity() {
final Block blockID = Block.getBlockFromItem(this);
final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell();
final IBlockDefinition energyCell = Api.instance().definitions().blocks().energyCell();
return energyCell.maybeBlock().map(block -> {
if (blockID == block) {
@@ -31,26 +31,21 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.util.AEColor;
import appeng.api.util.IOrientable;
import appeng.block.networking.CableBusBlock;
import appeng.tile.AEBaseInvTileEntity;
@@ -116,11 +111,6 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
return this.tileEntityFactory.get();
}
@Override
public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount) {
super.dropXpOnBlockBreak(worldIn, pos, amount);
}
@Override
public void onReplaced(BlockState state, World w, BlockPos pos, BlockState newState, boolean isMoving) {
if (newState.getBlock() == state.getBlock()) {
@@ -144,26 +134,6 @@ public abstract class AEBaseTileBlock<T extends AEBaseTileEntity> extends AEBase
super.onReplaced(state, w, pos, newState, isMoving);
}
@Override
public boolean recolorBlock(BlockState state, final IWorld world, final BlockPos pos, final Direction side,
final DyeColor color) {
final TileEntity te = this.getTileEntity(world, pos);
if (te instanceof IColorableTile) {
final IColorableTile ct = (IColorableTile) te;
final AEColor c = ct.getColor();
final AEColor newColor = AEColor.values()[color.ordinal()];
if (c != newColor) {
ct.recolourBlock(side, newColor, null);
return true;
}
return false;
}
return super.recolorBlock(state, world, pos, side, color);
}
@Override
public int getComparatorInputOverride(BlockState state, final World w, final BlockPos pos) {
final TileEntity te = this.getTileEntity(w, pos);
@@ -23,10 +23,13 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
@@ -54,12 +57,22 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
builder.add(FORMED);
}
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn,
BlockPos currentPos, BlockPos facingPos) {
TileEntity te = worldIn.getTileEntity(currentPos);
if (te != null) {
te.requestModelDataUpdate();
}
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
}
@Override
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
final BlockPos fromPos, boolean isMoving) {
final CraftingTileEntity cp = this.getTileEntity(worldIn, pos);
if (cp != null) {
cp.updateMultiBlock();
cp.updateMultiBlock(fromPos);
}
}
@@ -0,0 +1,33 @@
package appeng.block.crafting;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.client.render.crafting.MonitorBakedModel;
import appeng.client.render.model.AutoRotatingBakedModel;
public class CraftingMonitorBlockRendering extends BlockRenderingCustomizer {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
rendering.renderType(RenderType.getCutout());
rendering.modelCustomizer(CraftingMonitorBlockRendering::customizeModel);
}
@OnlyIn(Dist.CLIENT)
private static IBakedModel customizeModel(ResourceLocation path, IBakedModel model) {
// The formed model handles rotations itself, the unformed one does not
if (model instanceof MonitorBakedModel) {
return model;
}
return new AutoRotatingBakedModel(model);
}
}
@@ -21,10 +21,10 @@ package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlockItem;
import appeng.core.AEConfig;
import appeng.core.Api;
public class CraftingStorageItem extends AEBaseBlockItem {
@@ -34,7 +34,7 @@ public class CraftingStorageItem extends AEBaseBlockItem {
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
return Api.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
}
@Override
@@ -19,20 +19,12 @@
package appeng.block.misc;
import java.util.Random;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.TransformationMatrix;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
@@ -49,13 +41,11 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ParticleTypes;
import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.tile.misc.ChargerTileEntity;
import appeng.util.Platform;
@@ -64,8 +54,6 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
public ChargerBlock() {
super(defaultProps(Material.IRON).notSolid());
this.setFullSize(this.setOpaque(false));
}
@Override
@@ -103,7 +91,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
final ChargerTileEntity tile = this.getTileEntity(w, pos);
if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
if (Api.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) {
final double xOff = 0.0;
final double yOff = 0.0;
@@ -177,15 +165,4 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
return VoxelShapes.create(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
}
@OnlyIn(Dist.CLIENT)
public static Function<TileEntityRendererDispatcher, TileEntityRenderer<ChargerTileEntity>> createTesr() {
return dispatcher -> new ModularTESR<>(dispatcher, new ItemRenderable<>(ChargerBlock::getRenderedItem));
}
@OnlyIn(Dist.CLIENT)
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(ChargerTileEntity tile) {
TransformationMatrix transform = new TransformationMatrix(new Vector3f(0.5f, 0.375f, 0.5f), null, null, null);
return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
}
}
@@ -80,8 +80,8 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
public static final BooleanProperty ODD = BooleanProperty.create("odd");
public QuartzFixtureBlock() {
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14)
.sound(SoundType.GLASS));
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0)
.setLightLevel((b) -> 14).sound(SoundType.GLASS).notSolid());
this.setDefaultState(getDefaultState().with(FACING, Direction.UP).with(ODD, false));
}
@@ -199,9 +199,4 @@ public class QuartzFixtureBlock extends AEBaseBlock implements IOrientableBlock
return new MetaRotation(w, pos, FACING);
}
@Override
public boolean isOpaque() {
return false;
}
}
@@ -18,10 +18,9 @@
package appeng.block.misc;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -52,8 +51,7 @@ public class TinyTNTBlock extends AEBaseBlock {
.create(new AxisAlignedBB(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f));
public TinyTNTBlock(Block.Properties props) {
super(props);
setFullSize(setOpaque(false));
super(defaultProps(Material.TNT).notSolid());
}
@Override
@@ -120,12 +118,10 @@ public class TinyTNTBlock extends AEBaseBlock {
LivingEntity igniter = null;
// Check if the shooter still exists
if (w instanceof ServerWorld) {
ServerWorld serverWorld = (ServerWorld) w;
Entity shooter = serverWorld.getEntityByUuid(entityarrow.shootingEntity);
Entity shooter = entityarrow.func_234616_v_();
if (shooter instanceof LivingEntity) {
igniter = (LivingEntity) shooter;
}
}
this.startFuse(w, pos, igniter);
w.removeBlock(pos, false);
@@ -18,7 +18,6 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
@@ -31,26 +30,31 @@ import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -68,7 +72,7 @@ import appeng.client.render.cablebus.CableBusBreakingParticle;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ClickPacket;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
@@ -80,8 +84,12 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
private static final IntegerProperty LIGHT_LEVEL = IntegerProperty.create("light_level", 0, 15);
public CableBusBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid().noDrops().variableOpacity());
super(defaultProps(AEMaterials.GLASS).notSolid().noDrops().variableOpacity()
.setLightLevel(state -> state.get(LIGHT_LEVEL)));
setDefaultState(getDefaultState().with(LIGHT_LEVEL, 0));
}
@Override
@@ -124,11 +132,9 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
@Override
public int getLightValue(final BlockState state, final IBlockReader world, final BlockPos pos) {
if (state.getBlock() != this) {
return state.getBlock().getLightValue(state, world, pos);
}
return this.cb(world, pos).getLightValue();
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(LIGHT_LEVEL);
}
@Override
@@ -144,7 +150,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player,
boolean willHarvest, IFluidState fluid) {
boolean willHarvest, FluidState fluid) {
if (player.abilities.isCreativeMode) {
final AEBaseTileEntity tile = this.getTileEntity(world, pos);
if (tile != null) {
@@ -158,17 +164,18 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
@Override
public boolean canConnectRedstone(final BlockState state, final IBlockReader w, final BlockPos pos,
Direction side) {
// TODO: Verify this.
if (side == null) {
side = Direction.UP;
return false;
}
return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
return this.cb(w, pos).canConnectRedstone(side.getOpposite());
}
@Override
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos,
PlayerEntity player) {
final Vec3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
final Vector3d v3 = target.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ());
final SelectedPart sp = this.cb(world, pos).selectPart(v3);
if (sp.part != null) {
@@ -219,8 +226,8 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
double z = target.getHitVec().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the
// ability to supply particle textures???
effectRenderer
.addEffect(new CableBusBreakingParticle(world, x, y, z, texture).multiplyParticleScaleBy(0.8F));
effectRenderer.addEffect(
new CableBusBreakingParticle((ClientWorld) world, x, y, z, texture).multiplyParticleScaleBy(0.8F));
}
return true;
@@ -261,8 +268,8 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
// FIXME: Check how this looks, probably like shit, maybe provide parts the
// ability to supply particle textures???
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
Particle effect = new CableBusBreakingParticle((ClientWorld) world, x, y, z,
x - pos.getX() - 0.5D, y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
effectRenderer.addEffect(effect);
}
}
@@ -310,7 +317,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
if (rtr instanceof BlockRayTraceResult) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
final Vector3d hitVec = rtr.getHitVec().subtract(new Vector3d(pos.getX(), pos.getY(), pos.getZ()));
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance().sendToServer(new ClickPacket(pos, brtr.getFace(), (float) hitVec.x,
@@ -321,7 +328,7 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
}
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vec3d hitVec) {
public void onBlockClickPacket(World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, Vector3d hitVec) {
this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
}
@@ -329,16 +336,11 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
// Transform from world into block space
Vec3d hitVec = hit.getHitVec();
Vec3d hitInBlock = new Vec3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
Vector3d hitVec = hit.getHitVec();
Vector3d hitInBlock = new Vector3d(hitVec.x - pos.getX(), hitVec.y - pos.getY(), hitVec.z - pos.getZ());
return this.cb(w, pos).activate(player, hand, hitInBlock) ? ActionResultType.SUCCESS : ActionResultType.PASS;
}
@Override
public boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction side, DyeColor color) {
return recolorBlock(world, pos, side, color, null);
}
public boolean recolorBlock(final IBlockReader world, final BlockPos pos, final Direction side,
final DyeColor color, final PlayerEntity who) {
try {
@@ -388,4 +390,13 @@ public class CableBusBlock extends AEBaseTileBlock<CableBusTileEntity> implement
}
}
@Override
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, CableBusTileEntity te) {
if (currentState.getBlock() != this) {
return currentState;
}
int lightLevel = te.getCableBus().getLightValue();
return super.updateBlockStateFromTileEntity(currentState, te).with(LIGHT_LEVEL, lightLevel);
}
}
@@ -24,7 +24,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader;
import net.minecraft.world.IBlockDisplayReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -40,7 +40,7 @@ import appeng.tile.networking.CableBusTileEntity;
public class CableBusColor implements IBlockColor {
@Override
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
public int getColor(BlockState state, @Nullable IBlockDisplayReader worldIn, @Nullable BlockPos pos, int color) {
AEColor busColor = AEColor.TRANSPARENT;
@@ -38,7 +38,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
offline, online, conflicted;
@Override
public String getName() {
public String getString() {
return this.name();
}
@@ -54,7 +54,7 @@ public class ControllerBlock extends AEBaseTileBlock<ControllerTileEntity> {
block, column_x, column_y, column_z, inside_a, inside_b;
@Override
public String getName() {
public String getString() {
return this.name();
}
@@ -19,12 +19,12 @@
package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.tile.networking.CreativeEnergyCellTileEntity;
public class CreativeEnergyCellBlock extends AEBaseTileBlock<CreativeEnergyCellTileEntity> {
public CreativeEnergyCellBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
super(defaultProps(AEMaterials.GLASS));
}
}
@@ -30,7 +30,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.tile.networking.EnergyCellTileEntity;
public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellTileEntity> {
@@ -38,7 +38,7 @@ public class EnergyCellBlock extends AEBaseTileBlock<EnergyCellTileEntity> {
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create("fullness", 0, 7);
public EnergyCellBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
super(defaultProps(AEMaterials.GLASS));
}
@Override
@@ -18,6 +18,8 @@
package appeng.block.networking;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
@@ -40,7 +42,7 @@ import appeng.block.AEBaseTileBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.WirelessContainer;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.tile.networking.WirelessTileEntity;
import appeng.util.Platform;
@@ -50,17 +52,15 @@ public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
OFF, ON, HAS_CHANNEL;
@Override
public String getName() {
return this.name().toLowerCase();
public String getString() {
return this.name().toLowerCase(Locale.ROOT);
}
}
public static final EnumProperty<State> STATE = EnumProperty.create("state", State.class);
public WirelessBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid());
this.setFullSize(false);
this.setOpaque(false);
super(defaultProps(AEMaterials.GLASS).notSolid());
this.setDefaultState(this.getDefaultState().with(STATE, State.OFF));
}
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.RenderMaterial;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
@@ -35,16 +35,16 @@ import appeng.tile.misc.PaintSplotchesTileEntity;
*/
class PaintSplotchesBakedModel implements IDynamicBakedModel {
private static final Material TEXTURE_PAINT1 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_PAINT1 = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint1"));
private static final Material TEXTURE_PAINT2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_PAINT2 = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint2"));
private static final Material TEXTURE_PAINT3 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_PAINT3 = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/paint3"));
private final TextureAtlasSprite[] textures;
PaintSplotchesBakedModel(Function<Material, TextureAtlasSprite> bakedTextureGetter) {
PaintSplotchesBakedModel(Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter) {
this.textures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
bakedTextureGetter.apply(TEXTURE_PAINT2), bakedTextureGetter.apply(TEXTURE_PAINT3) };
}
@@ -79,10 +79,10 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
if (s.isLumen()) {
builder.setColorRGB(s.getColor().whiteVariant);
builder.setRenderFullBright(true);
builder.setEmissiveMaterial(true);
} else {
builder.setColorRGB(s.getColor().mediumVariant);
builder.setRenderFullBright(false);
builder.setEmissiveMaterial(false);
}
float offset = offsetConstant;
@@ -167,11 +167,11 @@ class PaintSplotchesBakedModel implements IDynamicBakedModel {
}
@Override
public boolean func_230044_c_() {
public boolean isSideLit() {
return false;
}
static List<Material> getRequiredTextures() {
static List<RenderMaterial> getRequiredTextures() {
return ImmutableList.of(TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
}
}
@@ -42,9 +42,7 @@ import appeng.util.Platform;
public class PaintSplotchesBlock extends AEBaseTileBlock<PaintSplotchesTileEntity> {
public PaintSplotchesBlock() {
super(defaultProps(Material.WATER, MaterialColor.AIR));
this.setFullSize(false);
this.setOpaque(false);
super(defaultProps(Material.WATER, MaterialColor.AIR).notSolid());
}
@Override
@@ -11,8 +11,8 @@ import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.RenderMaterial;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
@@ -22,13 +22,13 @@ public class PaintSplotchesModel implements IModelGeometry<PaintSplotchesModel>
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, ResourceLocation modelLocation) {
return new PaintSplotchesBakedModel(spriteGetter);
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
public Collection<RenderMaterial> getTextures(IModelConfiguration owner,
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return PaintSplotchesBakedModel.getRequiredTextures();
}
@@ -17,7 +17,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.RenderMaterial;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
@@ -25,25 +25,26 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import appeng.api.AEApi;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.tile.qnb.QuantumBridgeTileEntity;
class QnbFormedBakedModel implements IDynamicBakedModel {
private static final Material TEXTURE_LINK = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_LINK = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/quantum_link"));
private static final Material TEXTURE_RING = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_RING = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring"));
private static final Material TEXTURE_RING_LIGHT = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_RING_LIGHT = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light"));
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
private static final RenderMaterial TEXTURE_RING_LIGHT_CORNER = new RenderMaterial(
AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light_corner"));
private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "parts/cable/glass/transparent"));
private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "parts/cable/covered/transparent"));
private static final RenderMaterial TEXTURE_CABLE_GLASS = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "part/cable/glass/transparent"));
private static final RenderMaterial TEXTURE_COVERED_CABLE = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "part/cable/covered/transparent"));
private static final float DEFAULT_RENDER_MIN = 2.0f;
private static final float DEFAULT_RENDER_MAX = 14.0f;
@@ -65,7 +66,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
private final TextureAtlasSprite lightTexture;
private final TextureAtlasSprite lightCornerTexture;
public QnbFormedBakedModel(IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter) {
public QnbFormedBakedModel(IBakedModel baseModel, Function<RenderMaterial, TextureAtlasSprite> bakedTextureGetter) {
this.baseModel = baseModel;
this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
@@ -73,7 +74,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
this.coveredCableTexture = bakedTextureGetter.apply(TEXTURE_COVERED_CABLE);
this.lightTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT);
this.lightCornerTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT_CORNER);
this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
this.linkBlock = Api.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
}
@Override
@@ -116,7 +117,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
if (formedState.isPowered()) {
builder.setTexture(this.lightCornerTexture);
builder.setRenderFullBright(true);
builder.setEmissiveMaterial(true);
for (Direction facing : Direction.values()) {
// Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture
@@ -130,6 +131,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MAX + xOffset,
DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset);
}
builder.setEmissiveMaterial(false);
}
} else {
builder.setTexture(this.ringTexture);
@@ -142,7 +144,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
if (formedState.isPowered()) {
builder.setTexture(this.lightTexture);
builder.setRenderFullBright(true);
builder.setEmissiveMaterial(true);
for (Direction facing : Direction.values()) {
// Offset the face by a slight amount so that it is drawn over the already drawn
// ring texture
@@ -201,7 +203,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
}
@Override
public boolean func_230044_c_() {
public boolean isSideLit() {
return false;
}
@@ -220,7 +222,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
return this.baseModel.getOverrides();
}
public static List<Material> getRequiredTextures() {
public static List<RenderMaterial> getRequiredTextures() {
return ImmutableList.of(TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE,
TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER);
}
@@ -1,41 +1,43 @@
package appeng.block.qnb;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Stream;
import com.mojang.datafixers.util.Pair;
import com.google.common.collect.ImmutableSet;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.RenderMaterial;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import appeng.client.render.BasicUnbakedModel;
import appeng.core.AppEng;
public class QnbFormedModel implements IModelGeometry<QnbFormedModel> {
public class QnbFormedModel implements BasicUnbakedModel<QnbFormedModel> {
private static final ResourceLocation MODEL_RING = new ResourceLocation(AppEng.MOD_ID, "block/qnb/ring");
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, ResourceLocation modelLocation) {
IBakedModel ringModel = bakery.getBakedModel(MODEL_RING, modelTransform, spriteGetter);
return new QnbFormedBakedModel(ringModel, spriteGetter);
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return QnbFormedBakedModel.getRequiredTextures();
public Collection<ResourceLocation> getModelDependencies() {
return ImmutableSet.of(MODEL_RING);
}
@Override
public Stream<RenderMaterial> getAdditionalTextures() {
return QnbFormedBakedModel.getRequiredTextures().stream();
}
}
@@ -46,7 +46,6 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
public QuantumBaseBlock(Block.Properties props) {
super(props);
this.setFullSize(this.setOpaque(false));
this.setDefaultState(this.getDefaultState().with(FORMED, false));
}
@@ -71,7 +70,7 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
boolean isMoving) {
final QuantumBridgeTileEntity bridge = this.getTileEntity(world, pos);
if (bridge != null) {
bridge.neighborUpdate();
bridge.neighborUpdate(fromPos);
}
}
@@ -41,7 +41,7 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.QNBContainer;
import appeng.core.AppEng;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.util.Platform;
@@ -56,7 +56,7 @@ public class QuantumLinkChamberBlock extends QuantumBaseBlock {
}
public QuantumLinkChamberBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
super(defaultProps(AEMaterials.GLASS));
}
@Override
@@ -47,7 +47,7 @@ import appeng.block.AEBaseBlock;
public class MatrixFrameBlock extends AEBaseBlock {
private static final Material MATERIAL = new Material(MaterialColor.AIR, false, true, true, false, false, false,
false, PushReaction.PUSH_ONLY);
PushReaction.PUSH_ONLY);
public MatrixFrameBlock() {
super(Properties.create(MATERIAL).hardnessAndResistance(-1.0F, 6000000.0F).notSolid().noDrops());
@@ -25,13 +25,13 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.AEMaterials;
import appeng.tile.spatial.SpatialPylonTileEntity;
public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
public SpatialPylonBlock() {
super(defaultProps(AEGlassMaterial.INSTANCE));
super(defaultProps(AEMaterials.GLASS));
}
@Override
@@ -39,7 +39,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
boolean isMoving) {
final SpatialPylonTileEntity tsp = this.getTileEntity(world, pos);
if (tsp != null) {
tsp.neighborChanged();
tsp.neighborChanged(fromPos);
}
}
@@ -25,10 +25,11 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
@@ -42,18 +43,17 @@ import appeng.tile.storage.ChestTileEntity;
public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
DriveSlotState.class);
private final static BooleanProperty LIGHTS_ON = BooleanProperty.create("lights_on");
public ChestBlock() {
super(defaultProps(Material.IRON));
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY));
this.setDefaultState(this.getDefaultState().with(LIGHTS_ON, false));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(SLOT_STATE);
builder.add(LIGHTS_ON);
}
@Override
@@ -68,7 +68,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
slotState = DriveSlotState.OFFLINE;
}
return currentState.with(SLOT_STATE, slotState);
return currentState.with(LIGHTS_ON, slotState != DriveSlotState.EMPTY && slotState != DriveSlotState.OFFLINE);
}
@Override
@@ -82,7 +82,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
if (hit.getFace() == tg.getUp()) {
if (!tg.openGui(p)) {
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get(), Util.DUMMY_UUID);
}
} else {
ContainerOpener.openContainer(ChestContainer.TYPE, p,
@@ -1,45 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block.storage;
import net.minecraft.util.IStringSerializable;
/**
* Describes the type of cell present in a slot.
*/
public enum DriveSlotCellType implements IStringSerializable {
EMPTY("empty"),
ITEM("item"),
FLUID("fluid");
private final String name;
DriveSlotCellType(String name) {
this.name = name;
}
@Override
public String getName() {
return this.name;
}
}
@@ -37,6 +37,9 @@ public enum DriveSlotState implements IStringSerializable {
// Online and free space
ONLINE("online"),
// Online and not space
NOT_EMPTY("not_empty"),
// Types full, space left
TYPES_FULL("types_full"),
@@ -50,7 +53,7 @@ public enum DriveSlotState implements IStringSerializable {
}
@Override
public String getName() {
public String getString() {
return this.name;
}
@@ -60,8 +63,9 @@ public enum DriveSlotState implements IStringSerializable {
case ABSENT:
return DriveSlotState.EMPTY;
case EMPTY:
case NOT_EMPTY:
return DriveSlotState.ONLINE;
case NOT_EMPTY:
return DriveSlotState.NOT_EMPTY;
case TYPES_FULL:
return DriveSlotState.TYPES_FULL;
case FULL:
@@ -18,6 +18,9 @@
package appeng.block.storage;
import java.util.EnumMap;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.block.BlockRenderType;
@@ -47,7 +50,18 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
private static final double AABB_OFFSET_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0.06;
private static final double AABB_OFFSET_TOP = 0.125;
private static final double AABB_OFFSET_TOP = 0.0625;
// Precomputed bounding boxes of the chest, sorted into the map by the UP
// direction
private static final Map<Direction, VoxelShape> SHAPES = new EnumMap<>(Direction.class);
static {
for (Direction up : Direction.values()) {
AxisAlignedBB aabb = computeAABB(up);
SHAPES.put(up, VoxelShapes.create(aabb));
}
}
public enum SkyChestType {
STONE, BLOCK
@@ -87,37 +101,30 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
// TODO Cache this! It can't be that hard!
AxisAlignedBB aabb = computeAABB(worldIn, pos);
return VoxelShapes.create(aabb);
final SkyChestTileEntity sk = this.getTileEntity(worldIn, pos);
Direction up = sk != null ? sk.getUp() : Direction.UP;
return SHAPES.get(up);
}
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) {
final SkyChestTileEntity sk = this.getTileEntity(w, pos);
Direction o = Direction.UP;
if (sk != null) {
o = sk.getUp();
}
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
private static AxisAlignedBB computeAABB(Direction up) {
final double offsetX = up.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = up.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = up.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
// for x/z top and bottom is swapped
final double minX = Math.max(0.0,
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP)));
offsetX + (up.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getXOffset() * AABB_OFFSET_TOP)));
final double minY = Math.max(0.0,
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM)));
offsetY + (up.getYOffset() < 0 ? AABB_OFFSET_TOP : (up.getYOffset() * AABB_OFFSET_BOTTOM)));
final double minZ = Math.max(0.0,
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP)));
offsetZ + (up.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getZOffset() * AABB_OFFSET_TOP)));
final double maxX = Math.min(1.0,
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM)));
1.0 - offsetX - (up.getXOffset() < 0 ? AABB_OFFSET_TOP : (up.getXOffset() * AABB_OFFSET_BOTTOM)));
final double maxY = Math.min(1.0,
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP)));
1.0 - offsetY - (up.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getYOffset() * AABB_OFFSET_TOP)));
final double maxZ = Math.min(1.0,
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM)));
1.0 - offsetZ - (up.getZOffset() < 0 ? AABB_OFFSET_TOP : (up.getZOffset() * AABB_OFFSET_BOTTOM)));
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
}
@@ -31,6 +31,8 @@ import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemModelsProperties;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -38,8 +40,10 @@ import appeng.api.definitions.IBlockDefinition;
import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseBlockItem;
import appeng.block.AEBaseBlockItemChargeable;
import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IClientSetupComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEItemGroup;
@@ -149,6 +153,24 @@ class BlockDefinitionBuilder implements IBlockBuilder {
item.setRegistryName(AppEng.MOD_ID, this.registryName);
}
// Register the client-only item model property for chargeable items
if (item instanceof AEBaseBlockItemChargeable) {
AEBaseBlockItemChargeable chargeable = (AEBaseBlockItemChargeable) item;
this.factory.addBootstrapComponent(new IClientSetupComponent() {
@Override
@OnlyIn(Dist.CLIENT)
public void setup() {
ItemModelsProperties.registerProperty(item, new ResourceLocation("appliedenergistics2:fill_level"),
(is, world, entity) -> {
double curPower = chargeable.getAECurrentPower(is);
double maxPower = chargeable.getAEMaxPower(is);
return (int) Math.round(100 * curPower / maxPower);
});
}
});
}
// Register the item and block with the game
this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
if (item != null) {
@@ -25,7 +25,6 @@ import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.storage.ISpatialDimension;
import appeng.api.storage.IStorageMonitorableAccessor;
/**
@@ -38,8 +37,6 @@ public final class Capabilities {
public static Capability<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR;
public static Capability<ISpatialDimension> SPATIAL_DIMENSION;
public static Capability<IEnergyStorage> FORGE_ENERGY;
/**
@@ -48,7 +45,6 @@ public final class Capabilities {
public static void register() {
CapabilityManager.INSTANCE.register(IStorageMonitorableAccessor.class, createNullStorage(),
NullMENetworkAccessor::new);
CapabilityManager.INSTANCE.register(ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new);
}
@CapabilityInject(IStorageMonitorableAccessor.class)
@@ -56,11 +52,6 @@ public final class Capabilities {
STORAGE_MONITORABLE_ACCESSOR = cap;
}
@CapabilityInject(ISpatialDimension.class)
private static void capISpatialDimensionRegistered(Capability<ISpatialDimension> cap) {
SPATIAL_DIMENSION = cap;
}
@CapabilityInject(IEnergyStorage.class)
private static void capIEnergyStorageRegistered(Capability<IEnergyStorage> cap) {
FORGE_ENERGY = cap;
@@ -1,63 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.capabilities;
import java.util.List;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import appeng.api.storage.ISpatialDimension;
class NullSpatialDimension implements ISpatialDimension {
@Override
public DimensionType createNewCellDimension(BlockPos size) {
return null;
}
@Override
public void deleteCellDimension(DimensionType cellStorageId) {
}
@Override
public BlockPos getCellDimensionOrigin(DimensionType cellStorageId) {
return null;
}
@Override
public BlockPos getCellDimensionSize(DimensionType cellDim) {
return BlockPos.ZERO;
}
@Override
public void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> tooltip) {
}
@Override
public ServerWorld getWorld(DimensionType cellStorageId) {
return null;
}
@Override
public boolean isCellDimension(DimensionType cellDimID) {
return false;
}
}
+3 -1
View File
@@ -1,6 +1,8 @@
package appeng.client;
import java.util.Locale;
import org.lwjgl.glfw.GLFW;
public enum ActionKey {
@@ -13,7 +15,7 @@ public enum ActionKey {
}
public String getTranslationKey() {
return "key." + this.name().toLowerCase() + ".desc";
return "key." + this.name().toLowerCase(Locale.ROOT) + ".desc";
}
public int getDefaultKey() {
+23 -19
View File
@@ -26,11 +26,12 @@ import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
@@ -39,7 +40,10 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
import appeng.api.parts.CableRenderMode;
import appeng.block.AEBaseBlock;
import appeng.client.render.effects.*;
import appeng.client.render.effects.EnergyParticleData;
import appeng.client.render.effects.LightningArcFX;
import appeng.client.render.effects.LightningFX;
import appeng.client.render.effects.ParticleTypes;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
@@ -104,7 +108,7 @@ public class ClientHelper extends ServerHelper {
this.spawnLightning(world, posX, posY, posZ);
return;
case LightningArc:
this.spawnLightningArc(world, posX, posY, posZ, (Vec3d) o);
this.spawnLightningArc(world, posX, posY, posZ, (Vector3d) o);
return;
default:
}
@@ -134,15 +138,15 @@ public class ClientHelper extends ServerHelper {
}
@Override
public CableRenderMode getRenderMode() {
public CableRenderMode getCableRenderMode() {
if (Platform.isServer()) {
return super.getRenderMode();
return super.getCableRenderMode();
}
final Minecraft mc = Minecraft.getInstance();
final PlayerEntity player = mc.player;
return this.renderModeForPlayer(player);
return this.getCableRenderModeForPlayer(player);
}
@Override
@@ -165,16 +169,16 @@ public class ClientHelper extends ServerHelper {
}
private void postPlayerRender(final RenderLivingEvent.Pre p) {
// FIXME final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() );
// FIXME if( player != null )
// FIXME {
// FIXME final AEColor col = player.myColor;
// FIXME final float r = 0xff & ( col.mediumVariant >> 16 );
// FIXME final float g = 0xff & ( col.mediumVariant >> 8 );
// FIXME final float b = 0xff & ( col.mediumVariant );
// FIXME // FIXME: This is most certainly not going to work!
// FIXME GlStateManager.color4f( r / 255.0f, g / 255.0f, b / 255.0f, 1.0f );
// FIXME }
// FIXME final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get( p.getEntity().getEntityId() );
// FIXME if( player != null )
// FIXME {
// FIXME final AEColor col = player.myColor;
// FIXME final float r = 0xff & ( col.mediumVariant >> 16 );
// FIXME final float g = 0xff & ( col.mediumVariant >> 8 );
// FIXME final float b = 0xff & ( col.mediumVariant );
// FIXME // FIXME: This is most certainly not going to work!
// FIXME GlStateManager.color4f( r / 255.0f, g / 255.0f, b / 255.0f, 1.0f );
// FIXME }
}
private void spawnVibrant(final World w, final double x, final double y, final double z) {
@@ -203,9 +207,9 @@ public class ClientHelper extends ServerHelper {
}
private void spawnLightningArc(final World world, final double posX, final double posY, final double posZ,
final Vec3d second) {
final LightningFX fx = new LightningArcFX(world, posX, posY, posZ, second.x, second.y, second.z, 0.0f, 0.0f,
0.0f);
final Vector3d second) {
final LightningFX fx = new LightningArcFX((ClientWorld) world, posX, posY, posZ, second.x, second.y, second.z,
0.0f, 0.0f, 0.0f);
Minecraft.getInstance().particles.addEffect(fx);
}
@@ -22,6 +22,9 @@ import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
@@ -41,14 +44,14 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
}
@Override
protected void renderTooltip(final ItemStack stack, final int x, final int y) {
protected void renderTooltip(MatrixStack matrixStack, final ItemStack stack, final int x, final int y) {
final Slot s = this.getSlot(x, y);
if (s instanceof SlotME && !stack.isEmpty()) {
final int bigNumber = AEConfig.instance().isUseLargeFonts() ? 999 : 9999;
IAEItemStack myStack = null;
final List<String> currentToolTip = this.getTooltipFromItem(stack);
final List<ITextComponent> currentToolTip = this.getTooltipFromItem(stack);
try {
final SlotME theSlotField = (SlotME) s;
@@ -58,38 +61,33 @@ public abstract class AEBaseMEScreen<T extends AEBaseContainer> extends AEBaseSc
if (myStack != null) {
if (myStack.getStackSize() > bigNumber || (myStack.getStackSize() > 1 && stack.isDamaged())) {
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
.format(myStack.getStackSize());
final String format = String.format(local, formattedAmount);
currentToolTip.add(TextFormatting.GRAY + format);
currentToolTip
.add(ButtonToolTips.ItemsStored.text(formattedAmount).mergeStyle(TextFormatting.GRAY));
}
if (myStack.getCountRequestable() > 0) {
final String local = ButtonToolTips.ItemsRequestable.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
.format(myStack.getCountRequestable());
final String format = String.format(local, formattedAmount);
currentToolTip.add(format);
currentToolTip.add(ButtonToolTips.ItemsRequestable.text(formattedAmount));
}
this.renderTooltip(currentToolTip, x, y, this.font);
this.renderToolTip(matrixStack, Lists.transform(currentToolTip, ITextComponent::func_241878_f), x, y,
this.font);
return;
} else if (stack.getCount() > bigNumber) {
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
final String format = String.format(local, formattedAmount);
currentToolTip.add(ButtonToolTips.ItemsStored.text(formattedAmount).mergeStyle(TextFormatting.GRAY));
currentToolTip.add(TextFormatting.GRAY + format);
this.renderTooltip(currentToolTip, x, y, this.font);
this.renderToolTip(matrixStack, Lists.transform(currentToolTip, ITextComponent::func_241878_f), x, y,
this.font);
return;
}
}
super.renderTooltip(stack, x, y);
super.renderTooltip(matrixStack, stack, x, y);
}
}
+128 -80
View File
@@ -24,10 +24,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.glfw.GLFW;
@@ -35,6 +36,7 @@ import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.IGuiEventListener;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.renderer.BufferBuilder;
@@ -53,6 +55,8 @@ import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -60,6 +64,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.CustomSlotWidget;
import appeng.client.gui.widgets.ITickingWidget;
import appeng.client.gui.widgets.ITooltip;
import appeng.client.gui.widgets.Scrollbar;
import appeng.client.me.InternalSlotME;
@@ -88,6 +93,9 @@ import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction;
public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerScreen<T> {
public static final int COLOR_DARK_GRAY = 4210752;
private final List<InternalSlotME> meSlots = new ArrayList<>();
// drag y
private final Set<Slot> drag_click = new HashSet<>();
@@ -98,6 +106,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
private ItemStack dbl_whichItem = ItemStack.EMPTY;
private Slot bl_clicked;
private boolean handlingRightClick;
protected final List<CustomSlotWidget> guiSlots = new ArrayList<>();
public AEBaseScreen(T container, PlayerInventory playerInventory, ITextComponent title) {
@@ -121,114 +130,121 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
@Override
public void render(final int mouseX, final int mouseY, final float partialTicks) {
super.renderBackground();
super.render(mouseX, mouseY, partialTicks);
public void render(MatrixStack matrixStack, final int mouseX, final int mouseY, final float partialTicks) {
super.renderBackground(matrixStack);
super.render(matrixStack, mouseX, mouseY, partialTicks);
RenderSystem.pushMatrix();
RenderSystem.translatef(this.guiLeft, this.guiTop, 0.0F);
RenderSystem.enableDepthTest();
for (final CustomSlotWidget c : this.guiSlots) {
this.drawGuiSlot(c, mouseX, mouseY, partialTicks);
this.drawGuiSlot(matrixStack, c, mouseX, mouseY, partialTicks);
}
RenderSystem.disableDepthTest();
for (final CustomSlotWidget c : this.guiSlots) {
this.drawTooltip(c, mouseX - this.guiLeft, mouseY - this.guiTop);
this.drawTooltip(matrixStack, c, mouseX - this.guiLeft, mouseY - this.guiTop);
}
RenderSystem.popMatrix();
RenderSystem.enableDepthTest();
this.renderHoveredToolTip(mouseX, mouseY);
this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
for (final Object c : this.buttons) {
if (c instanceof ITooltip) {
this.drawTooltip((ITooltip) c, mouseX, mouseY);
this.drawTooltip(matrixStack, (ITooltip) c, mouseX, mouseY);
}
}
}
protected void drawGuiSlot(CustomSlotWidget slot, int mouseX, int mouseY, float partialTicks) {
protected void drawGuiSlot(MatrixStack matrixStack, CustomSlotWidget slot, int mouseX, int mouseY,
float partialTicks) {
if (slot.isSlotEnabled()) {
final int left = slot.xPos();
final int top = slot.yPos();
final int right = left + slot.getWidth();
final int bottom = top + slot.getHeight();
final int left = slot.getTooltipAreaX();
final int top = slot.getTooltipAreaY();
final int right = left + slot.getTooltipAreaWidth();
final int bottom = top + slot.getTooltipAreaHeight();
slot.drawContent(getMinecraft(), mouseX, mouseY, partialTicks);
slot.drawContent(matrixStack, getMinecraft(), mouseX, mouseY, partialTicks);
if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
if (this.isPointInRegion(left, top, slot.getTooltipAreaWidth(), slot.getTooltipAreaHeight(), mouseX, mouseY)
&& slot.canClick(getPlayer())) {
RenderSystem.colorMask(true, true, true, false);
this.fillGradient(left, top, right, bottom, -2130706433, -2130706433);
this.fillGradient(matrixStack, left, top, right, bottom, -2130706433, -2130706433);
RenderSystem.colorMask(true, true, true, true);
}
}
}
private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
private void drawTooltip(MatrixStack matrixStack, ITooltip tooltip, int mouseX, int mouseY) {
final int x = tooltip.getTooltipAreaX();
int y = tooltip.getTooltipAreaY();
if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) {
if (y < mouseY && y + tooltip.getHeight() > mouseY) {
if (x < mouseX && x + tooltip.getTooltipAreaWidth() > mouseX && tooltip.isTooltipAreaVisible()) {
if (y < mouseY && y + tooltip.getTooltipAreaHeight() > mouseY) {
if (y < 15) {
y = 15;
}
final String msg = tooltip.getMessage();
if (msg != null) {
this.drawTooltip(x + 11, y + 4, msg);
}
final ITextComponent msg = tooltip.getTooltipMessage();
this.drawTooltip(matrixStack, x + 11, y + 4, msg);
}
}
}
protected void drawTooltip(int x, int y, String message) {
String[] lines = message.split("\n");
this.drawTooltip(x, y, Arrays.asList(lines));
protected void drawTooltip(MatrixStack matrices, int x, int y, ITextComponent message) {
String tooltipText = message.getString();
if (!tooltipText.isEmpty()) {
String[] lines = tooltipText.split("\n"); // FIXME FABRIC
List<ITextComponent> textLines = Arrays.stream(lines).map(StringTextComponent::new)
.collect(Collectors.toList());
this.drawTooltip(matrices, x, y, textLines);
}
}
protected void drawTooltip(int x, int y, List<String> lines) {
// FIXME FABRIC: move out to json (?)
private static final Style TOOLTIP_HEADER = Style.EMPTY.applyFormatting(TextFormatting.WHITE);
private static final Style TOOLTIP_BODY = Style.EMPTY.applyFormatting(TextFormatting.GRAY);
protected void drawTooltip(MatrixStack matrices, int x, int y, List<ITextComponent> lines) {
if (lines.isEmpty()) {
return;
}
// For an explanation of the formatting codes, see
// http://minecraft.gamepedia.com/Formatting_codes
lines = Lists.newArrayList(lines); // Make a copy
// Make the first line white
lines.set(0, TextFormatting.WHITE + lines.get(0));
// All lines after the first are colored gray
for (int i = 1; i < lines.size(); i++) {
lines.set(i, TextFormatting.GRAY + lines.get(i));
List<ITextComponent> styledLines = new ArrayList<>(lines.size());
for (int i = 0; i < lines.size(); i++) {
Style style = (i == 0) ? TOOLTIP_HEADER : TOOLTIP_BODY;
styledLines.add(lines.get(i).deepCopy().modifyStyle(s -> style));
}
this.renderTooltip(lines, x, y, this.font);
this.func_243308_b(matrices, styledLines, x, y);
}
@Override
protected final void drawGuiContainerForegroundLayer(final int x, final int y) {
protected final void drawGuiContainerForegroundLayer(MatrixStack matrixStack, final int x, final int y) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
if (this.getScrollBar() != null) {
this.getScrollBar().draw(this);
this.getScrollBar().draw(matrixStack, this);
}
this.drawFG(ox, oy, x, y);
this.drawFG(matrixStack, ox, oy, x, y);
}
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
public abstract void drawFG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY);
@Override
protected final void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
protected final void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, final float f, final int x,
final int y) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawBG(ox, oy, x, y, f);
this.drawBG(matrixStack, ox, oy, x, y, f);
final List<Slot> slots = this.getInventorySlots();
for (final Slot slot : slots) {
@@ -260,38 +276,58 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
this.drag_click.clear();
// Forward right-clicks as-if they were left-clicks
if (btn == 1) {
for (final Object o : this.buttons) {
final Widget widget = (Widget) o;
if (widget.isMouseOver(xCoord, yCoord)) {
return super.mouseClicked(xCoord, yCoord, 0);
handlingRightClick = true;
try {
for (final Object o : this.buttons) {
final Widget widget = (Widget) o;
if (widget.isMouseOver(xCoord, yCoord)) {
return super.mouseClicked(xCoord, yCoord, 0);
}
}
} finally {
handlingRightClick = false;
}
}
for (CustomSlotWidget slot : this.guiSlots) {
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
&& slot.canClick(getPlayer())) {
if (this.isPointInRegion(slot.getTooltipAreaX(), slot.getTooltipAreaY(), slot.getTooltipAreaWidth(),
slot.getTooltipAreaHeight(), xCoord, yCoord) && slot.canClick(getPlayer())) {
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
}
}
if (this.getScrollBar() != null) {
this.getScrollBar().click(xCoord - this.guiLeft, yCoord - this.guiTop);
// Forward left mouse button down events to the scrollbar
if (btn == 0 && this.getScrollBar() != null) {
if (this.getScrollBar().mouseDown(xCoord - this.guiLeft, yCoord - this.guiTop)) {
return true;
}
}
return super.mouseClicked(xCoord, yCoord, btn);
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
public boolean mouseReleased(double mouseX, double mouseY, int button) {
// Forward left mouse button up events to the scrollbar
if (button == 0 && this.getScrollBar() != null) {
if (this.getScrollBar().mouseUp(mouseX - this.guiLeft, mouseY - this.guiTop)) {
return true;
}
}
return super.mouseReleased(mouseX, mouseY, button);
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
final Slot slot = this.getSlot((int) mouseX, (int) mouseY);
final ItemStack itemstack = getPlayer().inventory.getItemStack();
if (this.getScrollBar() != null) {
// FIXME: Coordinate system of mouseX/mouseY is unclear
this.getScrollBar().click((int) mouseX - this.guiLeft, (int) mouseY - this.guiTop);
this.getScrollBar().mouseDragged((int) mouseX - this.guiLeft, (int) mouseY - this.guiTop);
}
if (slot instanceof FakeSlot && !itemstack.isEmpty()) {
@@ -534,11 +570,6 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return false;
}
@Override
public void removed() {
super.removed();
}
protected Slot getSlot(final int mouseX, final int mouseY) {
final List<Slot> slots = this.getInventorySlots();
for (final Slot slot : slots) {
@@ -551,7 +582,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
return null;
}
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks);
public abstract void drawBG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY,
float partialTicks);
@Override
public boolean mouseScrolled(double x, double y, double wheelDelta) {
@@ -570,7 +602,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (slot instanceof SlotME) {
final IAEItemStack item = ((SlotME) slot).getAEStack();
if (item != null) {
((AEBaseContainer) this.container).setTargetStack(item);
this.container.setTargetStack(item);
final InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP;
final int times = (int) Math.abs(wheel);
final int inventorySize = this.getInventorySlots().size();
@@ -602,16 +634,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
this.itemRenderer.zLevel = 0.0F;
}
protected String getGuiDisplayName(final String in) {
return this.hasCustomInventoryName() ? this.getInventoryName() : in;
}
private boolean hasCustomInventoryName() {
return this.container.getCustomName() != null;
}
private String getInventoryName() {
return this.container.getCustomName();
protected ITextComponent getGuiDisplayName(final ITextComponent in) {
return title.getString().isEmpty() ? in : title;
}
/**
@@ -619,16 +643,16 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
* hackery...
*/
@Override
public void drawSlot(Slot s) {
public void moveItems(MatrixStack matrices, Slot s) {
if (s instanceof SlotME) {
try {
if (!this.isPowered()) {
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
fill(matrices, s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
}
// Annoying but easier than trying to splice into render item
super.drawSlot(new Size1Slot((SlotME) s));
super.moveItems(matrices, new Size1Slot((SlotME) s));
this.stackSizeRenderer.renderStackSize(this.font, ((SlotME) s).getAEStack(), s.xPos, s.yPos);
@@ -657,12 +681,13 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
float blue = (fluidAttributes.getColor() & 255) / 255.0F;
RenderSystem.color3f(red, green, blue);
blit(s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16, sprite);
blit(matrices, s.xPos, s.yPos, 0 /* FIXME: Validate this was previous the controls zindex */, 16, 16,
sprite);
RenderSystem.enableBlend();
this.fluidStackSizeRenderer.renderStackSize(this.font, fs, s.xPos, s.yPos);
} else if (!this.isPowered()) {
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
fill(matrices, s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
}
return;
@@ -734,7 +759,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
setBlitOffset(100);
this.itemRenderer.zLevel = 100.0F;
fill(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666);
fill(matrices, s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66ff6666);
setBlitOffset(0);
this.itemRenderer.zLevel = 0.0F;
@@ -743,9 +768,9 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
if (s instanceof AppEngSlot) {
((AppEngSlot) s).setDisplay(true);
super.drawSlot(s);
super.moveItems(matrices, s);
} else {
super.drawSlot(s);
super.moveItems(matrices, s);
}
return;
@@ -754,7 +779,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
}
}
// do the usual for non-ME Slots.
super.drawSlot(s);
super.moveItems(matrices, s);
}
protected boolean isPowered() {
@@ -781,4 +806,27 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
protected List<InternalSlotME> getMeSlots() {
return this.meSlots;
}
public void tick() {
super.tick();
if (this.getScrollBar() != null) {
this.getScrollBar().tick();
}
for (IGuiEventListener child : children) {
if (child instanceof ITickingWidget) {
((ITickingWidget) child).tick();
}
}
}
/**
* Returns true while the current event being handled is a click of the right
* mouse button.
*/
public boolean isHandlingRightClick() {
return handlingRightClick;
}
}
@@ -0,0 +1,16 @@
package appeng.client.gui;
public enum NumberEntryType {
CRAFT_ITEM_COUNT(Long.class), PRIORITY(Long.class), LEVEL_ITEM_COUNT(Long.class), LEVEL_FLUID_VOLUME(Long.class);
private final Class<? extends Number> inputType;
NumberEntryType(Class<? extends Number> inputType) {
this.inputType = inputType;
}
public Class<? extends Number> getInputType() {
return inputType;
}
}
@@ -8,19 +8,18 @@ import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.SlotItemHandler;
/**
* A proxy for a slot that will always return an itemstack with size 1, if there
* is an item in the slot. Used to prevent the default item count from
* rendering.
*/
class Size1Slot extends SlotItemHandler {
class Size1Slot extends Slot {
private final SlotItemHandler delegate;
private final Slot delegate;
public Size1Slot(SlotItemHandler delegate) {
super(delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
public Size1Slot(Slot delegate) {
super(delegate.inventory, delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
this.delegate = delegate;
}
@@ -7,8 +7,8 @@ import javax.annotation.Nullable;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.client.gui.AEBaseScreen;
@@ -18,6 +18,7 @@ import appeng.container.implementations.CraftingTermContainer;
import appeng.container.implementations.MEMonitorableContainer;
import appeng.container.implementations.PatternTermContainer;
import appeng.container.implementations.WirelessTermContainer;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.IPriorityHost;
@@ -44,7 +45,7 @@ final class AESubScreen {
public AESubScreen(AEBaseScreen<?> gui, Object containerTarget) {
this.gui = gui;
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.instance().definitions();
final IParts parts = definitions.parts();
if (containerTarget instanceof ChestTileEntity) {
@@ -54,35 +55,23 @@ final class AESubScreen {
IPriorityHost priorityHost = (IPriorityHost) containerTarget;
this.previousContainerIcon = priorityHost.getItemStackRepresentation();
this.previousContainerType = ChestContainer.TYPE;
}
else if (containerTarget instanceof IPriorityHost) {
} else if (containerTarget instanceof IPriorityHost) {
IPriorityHost priorityHost = (IPriorityHost) containerTarget;
this.previousContainerIcon = priorityHost.getItemStackRepresentation();
this.previousContainerType = priorityHost.getContainerType();
}
else if (containerTarget instanceof WirelessTerminalGuiObject) {
} else if (containerTarget instanceof WirelessTerminalGuiObject) {
this.previousContainerIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.previousContainerType = WirelessTermContainer.TYPE;
}
else if (containerTarget instanceof TerminalPart) {
} else if (containerTarget instanceof TerminalPart) {
this.previousContainerIcon = parts.terminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.previousContainerType = MEMonitorableContainer.TYPE;
}
else if (containerTarget instanceof CraftingTerminalPart) {
} else if (containerTarget instanceof CraftingTerminalPart) {
this.previousContainerIcon = parts.craftingTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.previousContainerType = CraftingTermContainer.TYPE;
}
else if (containerTarget instanceof PatternTerminalPart) {
} else if (containerTarget instanceof PatternTerminalPart) {
this.previousContainerIcon = parts.patternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.previousContainerType = PatternTermContainer.TYPE;
}
else {
} else {
this.previousContainerIcon = null;
this.previousContainerType = null;
}
@@ -92,10 +81,11 @@ final class AESubScreen {
return addBackButton(buttonAdder, x, y, null);
}
public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y, @Nullable String label) {
public final TabButton addBackButton(Consumer<TabButton> buttonAdder, int x, int y,
@Nullable ITextComponent label) {
if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) {
if (label == null) {
label = previousContainerIcon.getDisplayName().getString();
label = previousContainerIcon.getDisplayName();
}
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
TabButton button = new TabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label,
@@ -18,6 +18,8 @@
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
@@ -60,7 +62,8 @@ public class CellWorkbenchScreen extends UpgradeableScreen<CellWorkbenchContaine
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.handleButtonVisibility();
this.bindTexture(this.getBackground());
@@ -18,6 +18,8 @@
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -41,7 +43,7 @@ public class ChestScreen extends AEBaseScreen<ChestContainer> {
public void init() {
super.init();
this.addButton(new TabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
this.addButton(new TabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.text(),
this.itemRenderer, btn -> openPriority()));
}
@@ -50,13 +52,15 @@ public class ChestScreen extends AEBaseScreen<ChestContainer> {
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
this.font.drawString(matrixStack, this.getGuiDisplayName(GuiText.Chest.text()).getString(), 8, 6, 4210752);
this.font.drawString(matrixStack, GuiText.inventory.text().getString(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.bindTexture("guis/chest.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
}
@@ -18,6 +18,8 @@
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -49,21 +51,23 @@ public class CondenserScreen extends AEBaseScreen<CondenserContainer> {
this.container.getOutput());
this.addButton(new ProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178,
25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.getLocal()));
25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.text()));
this.addButton(this.mode);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(this.getGuiDisplayName(GuiText.Condenser.getLocal()), 8, 6, 4210752);
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
this.font.drawString(matrixStack, this.getGuiDisplayName(GuiText.Condenser.text()).getString(), 8, 6, 4210752);
this.font.drawString(matrixStack, GuiText.inventory.text().getString(), 8, this.ySize - 96 + 3, 4210752);
this.mode.set(this.container.getOutput());
this.mode.setFillVar(String.valueOf(this.container.getOutput().requiredPower));
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.bindTexture("guis/condenser.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
@@ -18,16 +18,16 @@
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.NumberBox;
import appeng.client.gui.NumberEntryType;
import appeng.container.implementations.CraftAmountContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.CraftRequestPacket;
@@ -35,7 +35,7 @@ import appeng.core.sync.packets.CraftRequestPacket;
public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
private final AESubScreen subGui;
private NumberBox amountToCraft;
private NumberEntryWidget amountToCraft;
private Button next;
@@ -48,146 +48,47 @@ public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
public void init() {
super.init();
final int a = AEConfig.instance().craftItemsByStackAmounts(0);
final int b = AEConfig.instance().craftItemsByStackAmounts(1);
final int c = AEConfig.instance().craftItemsByStackAmounts(2);
final int d = AEConfig.instance().craftItemsByStackAmounts(3);
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a)));
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b)));
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c)));
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d)));
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a)));
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b)));
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c)));
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d)));
this.amountToCraft = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.CRAFT_ITEM_COUNT);
this.amountToCraft.setValue(1);
this.amountToCraft.setTextFieldBounds(62, 57, 50);
this.amountToCraft.setMinValue(1);
this.amountToCraft.setHideValidationIcon(true);
this.amountToCraft.addButtons(children::add, this::addButton);
this.next = this.addButton(
new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm));
new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.text(), this::confirm));
this.amountToCraft.setOnConfirm(() -> this.confirm(this.next));
subGui.addBackButton(this::addButton, 154, 0);
this.amountToCraft = new NumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT,
Integer.class);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible(true);
this.amountToCraft.setFocused2(true);
this.amountToCraft.setText("1");
changeFocus(true);
}
private void confirm(Button button) {
NetworkHandler.instance()
.sendToServer(new CraftRequestPacket(Integer.parseInt(this.amountToCraft.getText()), hasShiftDown()));
int amount = this.amountToCraft.getIntValue().orElse(0);
if (amount <= 0) {
return;
}
NetworkHandler.instance().sendToServer(new CraftRequestPacket(amount, hasShiftDown()));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.font.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
this.font.drawString(matrixStack, GuiText.SelectAmount.text().getString(), 8, 6, 4210752);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal());
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.next.setMessage(hasShiftDown() ? GuiText.Start.text() : GuiText.Next.text());
this.bindTexture("guis/craft_amt.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
try {
Long.parseLong(this.amountToCraft.getText());
this.next.active = !this.amountToCraft.getText().isEmpty();
} catch (final NumberFormatException e) {
this.next.active = false;
}
this.next.active = this.amountToCraft.getIntValue().orElse(0) > 0;
this.amountToCraft.render(offsetX, offsetY, partialTicks);
this.amountToCraft.render(matrixStack, offsetX, offsetY, partialTicks);
}
@Override
public boolean charTyped(char ch, int p_charTyped_2_) {
// Forward entered text to the craft amount text-field
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
if (keyCode == 28) {
this.next.onPress();
}
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
&& this.amountToCraft.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.amountToCraft.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
final long result = Long.parseLong(out);
if (result < 0) {
this.amountToCraft.setText("1");
}
} catch (final NumberFormatException e) {
// :P
}
return true;
}
}
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
}
private void addQty(final int i) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.amountToCraft.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
long result = Integer.parseInt(out);
if (result == 1 && i > 1) {
result = 0;
}
result += i;
if (result < 1) {
result = 1;
}
out = Long.toString(result);
Integer.parseInt(out);
this.amountToCraft.setText(out);
} catch (final NumberFormatException e) {
// :P
}
}
protected String getBackground() {
return "guis/craftAmt.png";
}
}
@@ -24,22 +24,26 @@ import java.util.Iterator;
import java.util.List;
import com.google.common.base.Joiner;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftConfirmContainer;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
@@ -51,11 +55,11 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
private final int rows = 5;
private final IItemList<IAEItemStack> storage = AEApi.instance().storage()
private final IItemList<IAEItemStack> storage = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> pending = AEApi.instance().storage()
private final IItemList<IAEItemStack> pending = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
private final IItemList<IAEItemStack> missing = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final List<IAEItemStack> visual = new ArrayList<>();
@@ -74,30 +78,28 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
this.setScrollBar(scrollbar);
}
boolean isAutoStart() {
return this.container.isAutoStart();
}
@Override
public void init() {
super.init();
this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(),
this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.text(),
btn -> start());
this.start.active = false;
this.addButton(this.start);
this.selectCPU = new Button(this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20,
GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu());
getNextCpuButtonLabel(), btn -> selectNextCpu());
this.selectCPU.active = false;
this.addButton(this.selectCPU);
addButton(new Button(this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal(),
addButton(new Button(this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.text(),
btn -> subGui.goBack()));
this.setScrollBar();
}
@Override
public void render(final int mouseX, final int mouseY, final float btn) {
public void render(MatrixStack matrixStack, final int mouseX, final int mouseY, final float btn) {
this.updateCPUButtonText();
this.start.active = !(this.container.hasNoCPU() || this.isSimulation());
@@ -130,26 +132,26 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
}
}
super.render(mouseX, mouseY, btn);
super.render(matrixStack, mouseX, mouseY, btn);
}
private void updateCPUButtonText() {
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if (this.container.getSelectedCpu() >= 0)// && status.selectedCpu < status.cpus.size() )
{
if (this.container.getName() != null) {
final String name = this.container.getName().getStringTruncated(20);
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
} else {
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.container.getSelectedCpu();
}
}
this.selectCPU.setMessage(getNextCpuButtonLabel());
}
private ITextComponent getNextCpuButtonLabel() {
if (this.container.hasNoCPU()) {
btnTextText = GuiText.NoCraftingCPUs.getLocal();
return GuiText.NoCraftingCPUs.text();
}
this.selectCPU.setMessage(btnTextText);
ITextComponent cpuName;
if (this.container.cpuName == null) {
cpuName = GuiText.Automatic.text();
} else {
cpuName = this.container.cpuName;
}
return GuiText.CraftingCPU.withSuffix(": ").append(cpuName);
}
private boolean isSimulation() {
@@ -157,12 +159,13 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
final long BytesUsed = this.container.getUsedBytes();
final String byteUsed = NumberFormat.getInstance().format(BytesUsed);
final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal())
: GuiText.CalculatingWait.getLocal();
this.font.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);
this.font.drawString(matrixStack, GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);
String dsp = null;
@@ -176,7 +179,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
}
final int offset = (219 - this.font.getStringWidth(dsp)) / 2;
this.font.drawString(dsp, offset, 165, 4210752);
this.font.drawString(matrixStack, dsp, offset, 165, 4210752);
final int sectionLength = 67;
@@ -230,7 +233,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
@@ -251,9 +254,9 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
}
str = GuiText.Missing.getLocal() + ": " + str;
str = GuiText.Missing.text().getString() + ": " + str;
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
@@ -276,7 +279,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
@@ -292,7 +295,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
final ItemStack is = refStack.asItemStackRepresentation();
if (this.tooltip == z - viewStart) {
dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText();
dspToolTip = Platform.getItemDisplayName(refStack).getString();
if (lineList.size() > 0) {
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
@@ -307,7 +310,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
if (red) {
final int startX = x * (1 + sectionLength) + xo;
final int startY = posY - 4;
fill(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
fill(matrixStack, startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
}
x++;
@@ -320,12 +323,13 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
}
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip);
this.drawTooltip(matrixStack, toolPosX, toolPosY + 10, new StringTextComponent(dspToolTip));
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.setScrollBar();
this.bindTexture("guis/craftingreport.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
@@ -440,7 +444,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
@Override
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
if (keyCode == 28) {
if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
this.start();
return true;
}
@@ -449,7 +453,7 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
}
private void selectNextCpu() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
final boolean backwards = isHandlingRightClick();
NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next"));
}
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Joiner;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import org.apache.commons.lang3.time.DurationFormatUtils;
@@ -32,9 +33,9 @@ import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.AEApi;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
@@ -47,6 +48,7 @@ import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftingCPUContainer;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
@@ -79,11 +81,11 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
private static final int ITEMSTACK_LEFT_OFFSET = 9;
private static final int ITEMSTACK_TOP_OFFSET = 22;
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private List<IAEItemStack> visual = new ArrayList<>();
@@ -100,9 +102,9 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
}
public void clearItems() {
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.visual = new ArrayList<>();
}
@@ -115,7 +117,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
super.init();
this.setScrollBar();
this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET,
CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal(), btn -> cancel());
CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.text(), btn -> cancel());
this.addButton(this.cancel);
}
@@ -127,7 +129,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
}
@Override
public void render(final int mouseX, final int mouseY, final float btn) {
public void render(MatrixStack matrixStack, final int mouseX, final int mouseY, final float btn) {
this.cancel.active = !this.visual.isEmpty();
final int gx = (this.width - this.xSize) / 2;
@@ -157,12 +159,13 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
}
}
super.render(mouseX, mouseY, btn);
super.render(matrixStack, mouseX, mouseY, btn);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal());
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
String title = this.getGuiDisplayName(GuiText.CraftingStatus.text()).getString();
if (this.container.getEstimatedTime() > 0 && !this.visual.isEmpty()) {
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.container.getEstimatedTime(),
@@ -172,7 +175,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
title += " - " + etaTimeText;
}
this.font.drawString(title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);
this.font.drawString(matrixStack, title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);
int x = 0;
int y = 0;
@@ -218,7 +221,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
| BACKGROUND_ALPHA;
final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2;
final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2;
fill(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor);
fill(matrixStack, startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor);
}
final int negY = ((lines - 1) * 5) / 2;
@@ -228,7 +231,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
final String str = GuiText.Stored.getLocal() + ": "
+ converter.toWideReadableForm(stored.getStackSize());
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
* 2),
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
@@ -245,7 +248,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
+ converter.toWideReadableForm(activeStack.getStackSize());
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
* 2),
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
@@ -262,7 +265,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
+ converter.toWideReadableForm(pendingStack.getStackSize());
final int w = 4 + this.font.getStringWidth(str);
this.font.drawString(str,
this.font.drawString(matrixStack, str,
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
* 2),
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
@@ -279,7 +282,7 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
final ItemStack is = refStack.asItemStackRepresentation();
if (this.tooltip == z - viewStart) {
dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText();
dspToolTip = Platform.getItemDisplayName(refStack).getString();
if (lineList.size() > 0) {
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
@@ -301,12 +304,13 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
}
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip);
this.drawTooltip(matrixStack, toolPosX, toolPosY + 10, new StringTextComponent(dspToolTip));
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
this.bindTexture("guis/craftingcpu.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
}
@@ -16,12 +16,10 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
/**
*
*/
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
@@ -47,50 +45,40 @@ public class CraftingStatusScreen extends CraftingCPUScreen<CraftingStatusContai
public void init() {
super.init();
this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20,
GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu());
this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, getNextCpuButtonLabel(),
btn -> selectNextCpu());
this.addButton(this.selectCPU);
subGui.addBackButton(btn -> {
addButton(btn);
btn.setHideEdge(13);
btn.setHideEdge(true);
}, 213, -4);
}
@Override
public void render(final int mouseX, final int mouseY, final float btn) {
public void render(MatrixStack matrixStack, final int mouseX, final int mouseY, final float btn) {
this.updateCPUButtonText();
super.render(mouseX, mouseY, btn);
super.render(matrixStack, mouseX, mouseY, btn);
}
private void updateCPUButtonText() {
String btnTextText = GuiText.NoCraftingJobs.getLocal();
if (this.container.selectedCpu >= 0)// && status.selectedCpu < status.cpus.size() )
{
if (this.container.myName != null) {
final String name = this.container.myName.getStringTruncated(20);
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
} else {
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu;
}
}
this.selectCPU.setMessage(getNextCpuButtonLabel());
}
private ITextComponent getNextCpuButtonLabel() {
if (this.container.noCPU) {
btnTextText = GuiText.NoCraftingJobs.getLocal();
return GuiText.NoCraftingJobs.text();
}
this.selectCPU.setMessage(btnTextText);
return GuiText.CraftingCPU.withSuffix(": ").append(container.cpuName);
}
@Override
protected String getGuiDisplayName(final String in) {
protected ITextComponent getGuiDisplayName(final ITextComponent in) {
return in; // the cup name is on the button
}
// FIXME: Extract to separate class? Shared with GuiCraftConfirm
private void selectNextCpu() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
final boolean backwards = isHandlingRightClick();
NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next"));
}

Some files were not shown because too many files have changed in this diff Show More