Skip to content

Use argument object for survival autoplace#13

Merged
Glease merged 15 commits intomasterfrom
feature/survival-autoplace-argument-object
Sep 16, 2022
Merged

Use argument object for survival autoplace#13
Glease merged 15 commits intomasterfrom
feature/survival-autoplace-argument-object

Conversation

@Glease
Copy link
Copy Markdown
Contributor

@Glease Glease commented Sep 12, 2022

New Feature

  • Method to start Survival Autoplace now wraps some of its arguments in ISurvivalBuildEnvironment, allowing the API to evolve without requiring client code migrations
  • IStructureElement#survivalPlaceBlock now wraps some of its arguments in AutoPlaceEnvironment, allowing the API to evolve without requiring client code migrations.
  • IStructureElement#survivalPlaceBlock can now inspect its surrounding structure in a limited way via AutoPlaceEnvironment#isContainedInPiece. This allow the structure element to determine if any coordinate is contained within structure. Currently, this means if given coordinate is not literal ' ' in addShape()
  • Added a utility method to get world direction from relative direction.

Impact

  • Necessary to solve GT hatch autoplace orientation issue
  • Necessary for NEI addon to render structure on client side.

Migrations required for client code

IStructrueElement

Reusable IStructrueElement subclass should override the default shim code for survivalPlaceBlock's new overload while keeping the old overload functional.

Single purpose IStructrueElement subclass should override the default shim code for survivalPlaceBlock's new overload. The old overload can be removed or made to throw an AssertionError or UnsupportedOperationException.

Decorating IStructrueElement (e.g. ofChain) should override both survivalPlaceBlock, and call the backing IStructureElement's survivalPlaceBlock whichever overload it was called from.

IStructureDefinition

IStructureDefinition users are encouraged, but not required, to use the new survivalBuild api. The new overload allows passing in EntityPlayer instead of EntityPlayerMP to allow NEI

ISurvivalConstructable

ISurvivalConstructable Implementor should implement the new survivalConstruct to allow third party tools (e.g. NEI addon) to use this API on client side, without the presence of a server.

Mentions

@Quarri6343 This includes the necessary API change for accepting EntityPlayer to survivalPlaceBlock. I did some hack here to ensure the existing multis can use EntityPlayer without any code changes. Please check if this satisfy your needs in the NEI handler you are developing.

Reviews

I'm not asking for a review here, but I will happily accept it if you want to do so.

@github-actions
Copy link
Copy Markdown
Contributor

Warning: 2 uncommitted changes
#14

github-actions Bot and others added 2 commits September 12, 2022 19:03
…for #13 (#14)

Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
@Quarri6343
Copy link
Copy Markdown
Member

It still does not allow client EntityPlayer to SurvivalPlaceBlock

default PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
EntityPlayer actor = env.getActor();
if (actor instanceof EntityPlayerMP)
return survivalPlaceBlock(
t, world, x, y, z, trigger, env.getSource(), (EntityPlayerMP) actor, env.getChatter());
if (PANIC_MODE) throw new RuntimeException("Panic Tripwire hit");
if (StructureLibAPI.isDebugEnabled())
LOGGER.info(
"Fallback shim code of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}",
getClass().getName());
return PlaceResult.SKIP;

キャプチャ1644

@Dream-Master Dream-Master requested review from a team September 13, 2022 16:40
@github-actions
Copy link
Copy Markdown
Contributor

Warning: 2 uncommitted changes
#15

@github-actions
Copy link
Copy Markdown
Contributor

Warning: 2 uncommitted changes
#16

@Glease
Copy link
Copy Markdown
Contributor Author

Glease commented Sep 16, 2022

Seems good now.

@Glease Glease merged commit 978938d into master Sep 16, 2022
@Glease Glease deleted the feature/survival-autoplace-argument-object branch September 16, 2022 10:57
Glease added a commit that referenced this pull request Sep 16, 2022
…for #13 (#14)

Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants