mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-12 16:27:36 +00:00
437 lines
20 KiB
HTML
437 lines
20 KiB
HTML
<!DOCTYPE HTML>
|
|
<!-- NewPage -->
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Generated by javadoc -->
|
|
<title>Overview (StructureLib 1.2.9-feature-doc.4+6626ed89ae API)</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
|
<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.min.css" title="Style">
|
|
<link rel="stylesheet" type="text/css" href="jquery-ui.overrides.css" title="Style">
|
|
<script type="text/javascript" src="script.js"></script>
|
|
<script type="text/javascript" src="jquery/jszip/dist/jszip.min.js"></script>
|
|
<script type="text/javascript" src="jquery/jszip-utils/dist/jszip-utils.min.js"></script>
|
|
<!--[if IE]>
|
|
<script type="text/javascript" src="jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
|
|
<![endif]-->
|
|
<script type="text/javascript" src="jquery/jquery-3.6.1.min.js"></script>
|
|
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
try {
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="Overview (StructureLib 1.2.9-feature-doc.4+6626ed89ae API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
var pathtoroot = "./";
|
|
var useModuleDirectories = true;
|
|
loadScripts(document, 'script');</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<header role="banner">
|
|
<nav role="navigation">
|
|
<div class="fixedNav">
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a id="navbar.top">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a id="navbar.top.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li class="navBarCell1Rev">Overview</li>
|
|
<li>Package</li>
|
|
<li>Class</li>
|
|
<li><a href="overview-tree.html">Tree</a></li>
|
|
<li><a href="deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="index-all.html">Index</a></li>
|
|
<li><a href="help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="index.html?overview-summary.html" target="_top">Frames</a></li>
|
|
<li><a href="overview-summary.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<ul class="navListSearch">
|
|
<li><label for="search">SEARCH:</label>
|
|
<input type="text" id="search" value="search" disabled="disabled">
|
|
<input type="reset" id="reset" value="reset" disabled="disabled">
|
|
</li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
</div>
|
|
<a id="skip.navbar.top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
</div>
|
|
<div class="navPadding"> </div>
|
|
<script type="text/javascript"><!--
|
|
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
|
|
//-->
|
|
</script>
|
|
</nav>
|
|
</header>
|
|
<main role="main">
|
|
<div class="header">
|
|
<h1 class="title">StructureLib 1.2.9-feature-doc.4+6626ed89ae API</h1>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<div class="block">StructureLib API documentation.
|
|
|
|
<h1>Key API class outline</h1>
|
|
<p>
|
|
Here we outline a few key API classes/interfaces.
|
|
</p>
|
|
|
|
<h2> <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureDefinition</code></a></h2>
|
|
<p>
|
|
This is the structure definition of your multi.
|
|
You will have one `IStructureDefinition` for each multi.
|
|
</p>
|
|
|
|
<h2> <a href="com/gtnewhorizon/structurelib/structure/IStructureElement.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureElement</code></a></h2>
|
|
<p>
|
|
These are how you define which block will be accepted.
|
|
</p>
|
|
|
|
<h2> <a href="com/gtnewhorizon/structurelib/structure/StructureUtility.html" title="class in com.gtnewhorizon.structurelib.structure"><code>StructureUtility</code></a></h2>
|
|
<p>
|
|
This is the standard library of <a href="com/gtnewhorizon/structurelib/structure/IStructureElement.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureElement</code></a>s.
|
|
The Standard Library contains structure elements that handle basic block element and elements that allow composing
|
|
these basic elements.
|
|
</p>
|
|
|
|
<h2> <a href="com/gtnewhorizon/structurelib/alignment/constructable/IConstructable.html" title="interface in com.gtnewhorizon.structurelib.alignment.constructable"><code>IConstructable</code></a></h2>
|
|
<p>
|
|
This interface should be implemented by tile entities that support creative autoplacing and hint particle emitting.
|
|
You will usually want to have a backing <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureDefinition</code></a>
|
|
and call its <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html#build(T,net.minecraft.item.ItemStack,java.lang.String,net.minecraft.world.World,com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing,int,int,int,int,int,int)"><code>build()</code></a>
|
|
or <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html#hints(T,net.minecraft.item.ItemStack,java.lang.String,net.minecraft.world.World,com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing,int,int,int,int,int,int)"><code>hints()</code></a> method here.
|
|
</p>
|
|
|
|
<h2> <a href="com/gtnewhorizon/structurelib/alignment/constructable/ISurvivalConstructable.html" title="interface in com.gtnewhorizon.structurelib.alignment.constructable"><code>ISurvivalConstructable</code></a></h2>
|
|
<p>
|
|
This interface is an enhancement over <a href="com/gtnewhorizon/structurelib/alignment/constructable/IConstructable.html" title="interface in com.gtnewhorizon.structurelib.alignment.constructable"><code>IConstructable</code></a>.
|
|
If your tile entities also support survival autoplacing then you should implement this.
|
|
You will usually want to have a backing <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureDefinition</code></a>
|
|
and call its <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html#survivalBuild(T,net.minecraft.item.ItemStack,java.lang.String,net.minecraft.world.World,com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing,int,int,int,int,int,int,int,com.gtnewhorizon.structurelib.structure.IItemSource,net.minecraft.entity.player.EntityPlayerMP,boolean)"><code>survivalBuild()</code></a>.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/alignment/constructable/IConstructableProvider.html" title="interface in com.gtnewhorizon.structurelib.alignment.constructable"><code>IConstructableProvider</code></a></h2>
|
|
<p>
|
|
This interface should be implemented on tile entities that will delegate all constructable or survival construable
|
|
functionality to some other class.
|
|
This is mostly only to support gregtech meta tile entity system.
|
|
</p>
|
|
<p>
|
|
Return null if the delegate does not exist.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/util/InventoryUtility.html" title="class in com.gtnewhorizon.structurelib.util"><code>InventoryUtility</code></a></h2>
|
|
<p>
|
|
This class backs the standard implementations of <a href="com/gtnewhorizon/structurelib/structure/IItemSource.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IItemSource</code></a>.
|
|
You might want to register new inventory provider or inventory extractor there to facilitate survival auto place.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/alignment/IAlignmentProvider.html" title="interface in com.gtnewhorizon.structurelib.alignment"><code>IAlignmentProvider</code></a>, <a href="com/gtnewhorizon/structurelib/alignment/IAlignment.html" title="interface in com.gtnewhorizon.structurelib.alignment"><code>IAlignment</code></a> and <a href="com/gtnewhorizon/structurelib/alignment/IAlignmentLimits.html" title="interface in com.gtnewhorizon.structurelib.alignment"><code>IAlignmentLimits</code></a></h2>
|
|
<p>
|
|
These interfaces will be used to implement rotation.
|
|
Provide a framework to rotate the block.
|
|
You can skip this if you store ExtendedFacing and do rotation in other means.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/alignment/constructable/ChannelDataAccessor.html" title="class in com.gtnewhorizon.structurelib.alignment.constructable"><code>ChannelDataAccessor</code></a></h2>
|
|
<p>
|
|
This class contains the accessors for channel data held on a trigger item. See <a href="#channels">below</a> for more
|
|
information.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/StructureLibAPI.html" title="class in com.gtnewhorizon.structurelib"><code>StructureLibAPI</code></a></h2>
|
|
<p>
|
|
This class contains the low level utility used for implementing new <a href="com/gtnewhorizon/structurelib/structure/IStructureElement.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureElement</code></a>.
|
|
You will also need methods in this class to while implementing rotation.
|
|
</p>
|
|
<p>
|
|
<b>IF THERE IS A SAME NAMED METHOD IN OTHER CLASS, ONLY USE METHODS FOUND IN THIS CLASS, NOT OTHER CLASS.</b>
|
|
This abstraction is necessary so we can change how underlying code work (e.g. how hint particles are rendered)
|
|
without
|
|
breaking client code.
|
|
</p>
|
|
|
|
<h2><a href="com/gtnewhorizon/structurelib/StructureEvent.html" title="class in com.gtnewhorizon.structurelib"><code>StructureEvent</code></a></h2>
|
|
<p>
|
|
This class is the base class of all events that will be posted while a IStructureDefinition are visited.
|
|
These events are disabled by default, and can be enabled by calling <a href="com/gtnewhorizon/structurelib/StructureLibAPI.html#enableInstrument(java.lang.Object)"><code>StructureLibAPI.enableInstrument(Object)</code></a>.
|
|
To receive these events, register an event handler to <code>MinecraftForge.EVENT_BUS</code>.
|
|
Handlers should filter the events received by <a href="com/gtnewhorizon/structurelib/StructureEvent.html#getInstrumentIdentifier()"><code>StructureEvent.getInstrumentIdentifier()</code></a>.
|
|
</p>
|
|
<p>
|
|
<b>These events are intended for third party tools to inspect structure details.</b> Normal users should not use
|
|
these at all.
|
|
</p>
|
|
|
|
<h1>Important Concepts</h1>
|
|
<h2>Context Object</h2>
|
|
<p>
|
|
Context Object are what you pass to <a href="com/gtnewhorizon/structurelib/structure/IStructureDefinition.html#check(T,java.lang.String,net.minecraft.world.World,com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing,int,int,int,int,int,int,boolean)"><code>IStructureDefinition.check(Object, String, World, ExtendedFacing, int, int,
|
|
int, int, int, int, boolean)</code></a> and alike as first parameter. It will hold the necessary states for <a href="com/gtnewhorizon/structurelib/structure/IStructureElement.html" title="interface in com.gtnewhorizon.structurelib.structure"><code>IStructureElement</code></a>. It's usually, but not necessarily, the multiblock controller.
|
|
</p>
|
|
<p>
|
|
Standard structure element library offers method to switch context objects if needed.
|
|
</p>
|
|
|
|
<h2>Trigger Item</h2>
|
|
<p>
|
|
Trigger Item is the item used to trigger hint spawn, creative build and survival auto place.
|
|
The trigger item will be passed to relevant classes as an indicator of structure tier.
|
|
The item type and stack tag compound of this item stack are opaque objects that should not be parsed.
|
|
</p>
|
|
<p>
|
|
StructureLib comes with a trigger item implementation.
|
|
It does register it to the game registries, but does not come with a recipe.
|
|
Usually there is no reason to reimplement this on your own.
|
|
</p>
|
|
|
|
<h2><a href="#channels" id="channels">Channels</a></h2>
|
|
|
|
<p>
|
|
Trigger item carries the player's choice of structure tier by its stack size.
|
|
When one multi have multiple tiered component that can have interleaving tier, this becomes an obnoxious
|
|
restriction, as one ItemStack cannot have two stack sizes at the same time.
|
|
Here we use the <i>channels</i> to bypass this restriction.
|
|
</p>
|
|
|
|
<p>
|
|
Basically, channels are information stored on the trigger item's NBT tags.
|
|
One trigger item can carry multiple channels.
|
|
Each channel can be identified with <b>lower case</b> strings and has the value being one positive Java int.
|
|
There will be one and only one master channel and 0 or more sub channel.
|
|
When a non-existent sub channel is queried, master channel will be used instead to fill its place.
|
|
</p>
|
|
|
|
<p>
|
|
Structure Definition Author and/or Structure Element Author can choose whether they use a channel and which channel
|
|
to use.
|
|
</p>
|
|
|
|
<p>
|
|
Structure Element Author will usually not need to consider channels, i.e. proceed as if this concept does not exist,
|
|
unless it must take input from multiple channels.
|
|
</p>
|
|
|
|
<p>
|
|
Structure Definition Author will consider how to map each channel to each tiered component.
|
|
He will be using `com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel` to direct structure element
|
|
on which channel to use.
|
|
Conceptually, it will return an ItemStack with the master channel being the value of selected channel.
|
|
In implementation, withChannel will return a new ItemStack with same item, nbt but different stack size.
|
|
</p>
|
|
|
|
<p>
|
|
It's worth mentioning that the returned new ItemStack will still have all the channel data on it, so a multi-channel
|
|
structure element can still query the channel it wants just fine. It is however impossible to recover the original
|
|
master channel.
|
|
</p>
|
|
|
|
<h3>why is this called channel?</h3>
|
|
|
|
Just give me a better name and I'd do the renaming.
|
|
|
|
<h3>Examples</h3>
|
|
|
|
<h4>For Structure Definition Author</h4>
|
|
|
|
<p>GT++ Chemical Plant is a multi with 4 distinctly tiered component.</p>
|
|
|
|
<p>It will use
|
|
<ul>
|
|
<li>master channel for its outer shell</li>
|
|
<li>channel `"casing"` for machine casings</li>
|
|
<li>channel `"pipe"` for pipe casings</li>
|
|
<li>channel `"coil"` for heating coils</li>
|
|
</ul>
|
|
Its structure code will then look like
|
|
<pre>
|
|
.addElement('a', shellStructureElement())
|
|
.addElement('b', withChannel("casing", machineCasingStructureElement()))
|
|
.addElement('c', withChannel("pipe", pipeCasingStructureElement()))
|
|
.addElement('d', withChannel("coil", coilStructureElement()))
|
|
</pre>
|
|
whereas all these structure elements are designed without considering channels whatsoever
|
|
|
|
<h4> Multi channel input Structure Element</h4>
|
|
|
|
<p>
|
|
Suppose your hatch element has a required facing and can accept arbitrary meta tile entity, so it will need both
|
|
meta id
|
|
and facing input.
|
|
</p>
|
|
|
|
<p>
|
|
It will use
|
|
<ul>
|
|
<li>master channel for its facing</li>
|
|
<li>channel `"id"` for meta tile entity id</li>
|
|
</ul>
|
|
<p>
|
|
Its code will then look like
|
|
<pre>
|
|
import com.gtnewhorizon.structurelib.structure.IStructureElement;
|
|
|
|
public class MyHatchElement<T> implements IStructureElement<T> {
|
|
//...
|
|
@Override
|
|
public PlaceResult survivalPlaceBlock(
|
|
Object o,
|
|
World world,
|
|
int x,
|
|
int y,
|
|
int z,
|
|
ItemStack trigger,
|
|
IItemSource s,
|
|
EntityPlayerMP actor,
|
|
Consumer chatter) {
|
|
if (shouldSkip(o, world, x, y, z)) return PlaceResult.SKIP;
|
|
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
|
|
ItemStack taken = s.takeOne(filterByID(ChannelDataAccessor.getChannelData(trigger, "id")).andThen(filterByFacing(trigger.stackSize)));
|
|
if (taken == null) return PlaceResult.REJECT;
|
|
return StructureUtility.survivalPlaceBlock(taken, ItemStackPredicate.NBTMode.IGNORE, null, true, world, x, y, z, s, actor);
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
The code for placeBlock() and spawnHint() will be left as an exercise for the reader.
|
|
|
|
<h2>Instrumenting StructureLib</h2>
|
|
<p>
|
|
StructureLib support third party tools to poke into structure's internals via events. This is done by listening to <a href="com/gtnewhorizon/structurelib/StructureEvent.html" title="class in com.gtnewhorizon.structurelib"><code>StructureEvent</code></a>
|
|
and its subclasses on the <code>forge main event bus</code>.
|
|
</p>
|
|
<p>
|
|
Please refer to <a href="com/gtnewhorizon/structurelib/StructureEvent.html" title="class in com.gtnewhorizon.structurelib"><code>StructureEvent</code></a> to see what events are available.
|
|
</p></div>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<table class="overviewSummary">
|
|
<caption><span>Packages</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Package</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tbody>
|
|
<tr class="altColor" id="i0">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/package-summary.html">com.gtnewhorizon.structurelib</a></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr class="rowColor" id="i1">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/alignment/package-summary.html">com.gtnewhorizon.structurelib.alignment</a></th>
|
|
<td class="colLast">
|
|
<div class="block">This package provide a framework for rotating a given block, or a multiblock structure.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor" id="i2">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/alignment/constructable/package-summary.html">com.gtnewhorizon.structurelib.alignment.constructable</a></th>
|
|
<td class="colLast">
|
|
<div class="block">This package contains interfaces and utility methods for autobuilding a structure.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor" id="i3">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/alignment/enumerable/package-summary.html">com.gtnewhorizon.structurelib.alignment.enumerable</a></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
<tr class="altColor" id="i4">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/structure/package-summary.html">com.gtnewhorizon.structurelib.structure</a></th>
|
|
<td class="colLast">
|
|
<div class="block">This package provide support for multiblock structure checking.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor" id="i5">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/structure/adders/package-summary.html">com.gtnewhorizon.structurelib.structure.adders</a></th>
|
|
<td class="colLast">
|
|
<div class="block">Adder interfaces used in various standard structure elements.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor" id="i6">
|
|
<th class="colFirst" scope="row"><a href="com/gtnewhorizon/structurelib/util/package-summary.html">com.gtnewhorizon.structurelib.util</a></th>
|
|
<td class="colLast"> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</main>
|
|
<footer role="contentinfo">
|
|
<nav role="navigation">
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a id="navbar.bottom">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a id="navbar.bottom.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li class="navBarCell1Rev">Overview</li>
|
|
<li>Package</li>
|
|
<li>Class</li>
|
|
<li><a href="overview-tree.html">Tree</a></li>
|
|
<li><a href="deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="index-all.html">Index</a></li>
|
|
<li><a href="help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="index.html?overview-summary.html" target="_top">Frames</a></li>
|
|
<li><a href="overview-summary.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
</div>
|
|
<a id="skip.navbar.bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
</nav>
|
|
</footer>
|
|
</body>
|
|
</html>
|