[ref:seggan/feature/elektrikity] ELEKTRIKITY#971
Conversation
# Conflicts: # src/main/java/io/github/pylonmc/pylon/PylonBlocks.java # src/main/resources/lang/en.yml
# Conflicts: # src/main/java/io/github/pylonmc/pylon/PylonBlocks.java # src/main/java/io/github/pylonmc/pylon/PylonFluids.java # src/main/java/io/github/pylonmc/pylon/PylonItems.java # src/main/java/io/github/pylonmc/pylon/PylonKeys.java # src/main/java/io/github/pylonmc/pylon/content/components/FluidHatch.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/SmelteryBurner.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/SmelteryController.java # src/main/resources/lang/en.yml # src/main/resources/recipes/minecraft/crafting_shaped.yml # src/main/resources/researches.yml
# Conflicts: # src/main/java/io/github/pylonmc/pylon/PylonItems.java # src/main/java/io/github/pylonmc/pylon/PylonRecipes.java # src/main/java/io/github/pylonmc/pylon/content/components/FluidHatch.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselBreaker.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselBrickMolder.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselFurnace.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselGrindstone.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselPipeBender.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselPress.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselQuarry.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselTableSaw.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/PalladiumCondenser.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/production/Biorefinery.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/production/Fermenter.java # src/main/java/io/github/pylonmc/pylon/content/machines/experience/FluidExperienceBottler.java # src/main/java/io/github/pylonmc/pylon/content/machines/fluid/FluidLimiter.java # src/main/java/io/github/pylonmc/pylon/content/machines/hydraulics/Quarry.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/Bloomery.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/SmelteryBurner.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/SmelteryController.java # src/main/resources/lang/en.yml
| @lombok.Builder.Default | ||
| private final Consumer<Player> reopenWindow = _unused -> {}; |
There was a problem hiding this comment.
this is unused completely? also no idea why you would need to re-open the window, also is there a reason this is in pylon and not rebar?
There was a problem hiding this comment.
It was used to reopen the window once the player had inputted a specific value in the chat, now that that's been removed this currently sits unused while we switch it over to dialogs
There was a problem hiding this comment.
+1 to moving this to Rebar
| .material(material) | ||
| .itemStack( | ||
| ItemStackBuilder.of(material) | ||
| .addCustomModelDataString("pylon:display_projectile/" + key) |
There was a problem hiding this comment.
| .addCustomModelDataString("pylon:display_projectile/" + key) | |
| .addCustomModelDataString("pylon:display_projectile:" + key) |
|
|
||
| private static final ItemStackBuilder NOT_BURNING = ItemStackBuilder.of(Material.CHARCOAL) | ||
| .name(Component.translatable("pylon.gui.burning.not_burning")) | ||
| .addCustomModelDataString("pylon:burner_progress/not_burning"); |
There was a problem hiding this comment.
| .addCustomModelDataString("pylon:burner_progress/not_burning"); | |
| .addCustomModelDataString("pylon:burner_progress:not_burning"); |
| .addCustomModelDataString("pylon:burner_progress/not_burning"); | ||
| private static final ItemStackBuilder BURNING = ItemStackBuilder.of(Material.BLAZE_POWDER) | ||
| .name(Component.translatable("pylon.gui.burning.burning")) | ||
| .addCustomModelDataString("pylon:burner_progress/burning"); |
There was a problem hiding this comment.
| .addCustomModelDataString("pylon:burner_progress/burning"); | |
| .addCustomModelDataString("pylon:burner_progress:burning"); |
| Furnace furnace = (Furnace) getBlock().getBlockData(); | ||
| furnace.setLit(false); | ||
| getBlock().setBlockData(furnace); | ||
| refreshBlockTextureItem(); |
There was a problem hiding this comment.
| refreshBlockTextureItem(); |
There was a problem hiding this comment.
the block texture entities now automatically update when block data changes so you don't need to manually refresh it
There was a problem hiding this comment.
Should probably be documented somewhere
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| protected abstract @NotNull List<ItemStack> getResults(@NotNull T recipe); | ||
|
|
||
| protected boolean tryStartRecipe(T recipe, ItemStack stack) { | ||
| RecipeInput.Item input = (RecipeInput.Item) recipe.getInputs().getFirst(); | ||
| if (!input.matches(stack)) { | ||
| return false; | ||
| } | ||
|
|
||
| List<ItemStack> results = getResults(recipe); | ||
| if (results.size() > 3) { | ||
| throw new IllegalStateException("Recipe has more than 3 results, which is not supported by GenericMachine"); | ||
| } | ||
|
|
||
| if (!outputInventory.canHold(results)) { | ||
| return true; | ||
| } | ||
|
|
||
| this.results = results; | ||
| startRecipe(recipe, getRecipeTicks(recipe)); | ||
| getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore()); | ||
| inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(input.getAmount())); | ||
| return true; | ||
| } |
There was a problem hiding this comment.
I would update getResults & how you use it so that you clone the return value of getResults instead of all the implementations supplying clones
- reduce the tons of .clone() in implementing classes
- you can clone only when you are sure those are going to be the results which can save memory & tick time
| if (max != null) { | ||
| lore.add(Component.translatable("pylon.gui.number-button.max", RebarArgument.of("max", valueFormatter.apply(max)))); | ||
| } | ||
| return ItemStackBuilder.gui(material, pylonKey("number_input_button")) |
There was a problem hiding this comment.
I would say we'd want custom model data specific to each usage of this not a singular "number_input_button"
| Location playerLocation = event.getPlayer().getLocation(); | ||
| ElectricityPylon pylon = BlockStorage.getByType(ElectricityPylon.class).stream() | ||
| .min(Comparator.comparing(p -> p.getBlock().getLocation().toCenterLocation().distanceSquared(playerLocation))) | ||
| .filter(p -> p.getBlock().getLocation().toCenterLocation().distanceSquared(playerLocation) < 64 * 64) | ||
| .orElse(null); | ||
| if (pylon == null) return; | ||
| throw new UnsupportedOperationException("Multimeter interaction not implemented yet"); |
There was a problem hiding this comment.
regardless of how this is changed I just don't think we should every be using getByType like this, instead maybe getting by chunk in a chunk radius loop if you don't change this to just be direct block interaction (which is what I think this should be)
even if you do keep using getByType like this, this will throw an exception for any blocks not in the same dimension as the player, but again I would not do this.
There was a problem hiding this comment.
Oh oops forgot to remove debug code lol
LordIdra
left a comment
There was a problem hiding this comment.
Stuff I have found from in-game testing so far (have not looked at code much yet):
Almost everything is missing recipes
Almost everything is missing researches
Basically all electric machines are missing WAILAs. (Might be worth rebasing off my PR for this since you'll have to change the WAILAs anyway? I am happy to rebase it and deal with conflicts if you want)
Quarries appear to now be trying to mine air? Not 100% sure if that was introduced by this PR
A lot of the electric machines are iron blocks. I would use some more variety here as it makes them very hard to distinguish, as we do for diesel and hydraulic machines. You could do this in conjunction with some very simple item displays potentially, if you want to keep the base as an iron blocks.
It is also a bit strange that some electric machines have extra item displays (like the press) and some don't
Would be worth adding electric experience bottler (I know this requires a rework of the experience bottler... this is why we should not abstract stuff like we did with the bottler...)
I am not able to test several items in this PR because they immediately cause errors...
| public static final SimpleStaticGuidePage CARGO = new SimpleStaticGuidePage(pylonKey("machines_cargo")); | ||
| public static final SimpleStaticGuidePage DIESEL_MACHINES = new SimpleStaticGuidePage(pylonKey("machines_diesel_machines")); | ||
| public static final SimpleStaticGuidePage DIESEL_PRODUCTION = new SimpleStaticGuidePage(pylonKey("machines_diesel_production")); | ||
| public static final SimpleStaticGuidePage ELECTRICITY = new SimpleStaticGuidePage(pylonKey("machines_electricity")); |
There was a problem hiding this comment.
Maybe split this into Electricity Production, Electric Machines, and Electric Utilities?
| @Override | ||
| public void tick() { | ||
| ElectricNetwork network = getElectricNodes().getFirst().getNetwork(); | ||
| for (ElectricNode node : network.getNodes()) { | ||
| Particle.DUST.builder() | ||
| .color(Color.fromARGB(network.hashCode())) | ||
| .location(node.getBlock().toLocation().toCenterLocation().add(0, 0.6, 0)) | ||
| .receivers(32, true) | ||
| .spawn(); | ||
| } | ||
| } |
There was a problem hiding this comment.
This being a sea lantern feels a bit weird, and the name is also a bit weird considering it's much more a node than a pylon from a player perspective. Maybe worth changing this to use a small cube item display and changing it to 'Electric connector' or similar?
| public static final ItemStack WIRE_1_GAUGE = ItemStackBuilder.rebar(Material.STRING, PylonKeys.WIRE_1_GAUGE) | ||
| .build(); | ||
|
|
||
| static { | ||
| RebarItem.register(PylonWire.class, WIRE_1_GAUGE, PylonKeys.WIRE_1_GAUGE); | ||
| PylonPages.TOOLS.addItem(WIRE_1_GAUGE); | ||
| } |
There was a problem hiding this comment.
This being in tools doesn't make much sense from a gameplay perspective - I'd suggest moving it to electric machines or components
There was a problem hiding this comment.
Would it be possible to use six item displays which each span the length of the block, rather than twelve? I know this is quite annoying, but given how many of these are likely to be placed I'm very worried about performance
| heat_exchanger: | ||
| name: "Heat Exchanger" | ||
| lore: |- | ||
| <arrow> Exchanges heat between two fluids |
There was a problem hiding this comment.
Clueless on what this does from the description
There was a problem hiding this comment.
The WAILA just constantly errors when not completed
There was a problem hiding this comment.
The turbine errors and turns into a phantom block on completion???
| wire_1_gauge: | ||
| name: "1-Gauge Wire" | ||
| lore: |- | ||
| <arrow> Transmits electricity | ||
| <arrow> <attr>Max power:</attr> %max-power% |
There was a problem hiding this comment.
Might be worth having the power connection on the top or back here
|
I mentioned in Discord that I'm splitting the electric content PR into 2: these are just the base, and recipes/researches/more items will come in my next PR |
There was a problem hiding this comment.
Why aren't we using FluidTankWithDisplayEntity here?
There was a problem hiding this comment.
Cause the original code didn't
There was a problem hiding this comment.
The original code worked differently so it didn't need to. The way it works now I think you can take advantage of FluidTankWithDisplayEntity to remove a lot of code
| name: "Gas Turbine" | ||
| lore: |- | ||
| <arrow> Uses hot gases to produce power | ||
| <arrow> The more hot gases piped into it, the more power it produces |
There was a problem hiding this comment.
Ah ok. SO presumably it'll be fine once the display recipes are viewable. Might still be worth adding something to hint towards that like 'different gases produce different amounts of power' but idk
# Conflicts: # src/main/java/io/github/pylonmc/pylon/PylonRecipes.java # src/main/java/io/github/pylonmc/pylon/content/components/FluidHatch.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselBrickMolder.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselFurnace.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselGrindstone.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselPipeBender.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselPress.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/DieselTableSaw.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/machines/PalladiumCondenser.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/production/Biorefinery.java # src/main/java/io/github/pylonmc/pylon/content/machines/diesel/production/Fermenter.java # src/main/java/io/github/pylonmc/pylon/content/machines/hydraulics/BurnerHydraulicPurifier.java # src/main/java/io/github/pylonmc/pylon/content/machines/hydraulics/Quarry.java # src/main/java/io/github/pylonmc/pylon/content/machines/smelting/SmelteryBurner.java # src/main/java/io/github/pylonmc/pylon/guide/HydraulicRefuelableItemsPage.java # src/main/resources/lang/en.yml
See #987 section "Foundational Pylon PR"