mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-21 20:42:09 +00:00
Compare commits
19
Commits
1.1.10
...
1.2.0-beta.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
978938d450 | ||
|
|
7a2328c294 | ||
|
|
d2cd45e07b | ||
|
|
8a24900623 | ||
|
|
15a0034e03 | ||
|
|
7aae6dc31c | ||
|
|
875bc1990e | ||
|
|
74aefd22be | ||
|
|
72ff51d093 | ||
|
|
7d74a65ec0 | ||
|
|
0ac8908b37 | ||
|
|
2dd4349e54 | ||
|
|
f813104ec4 | ||
|
|
4fe9eb6ea5 | ||
|
|
c0814274ec | ||
|
|
23605fc22d | ||
|
|
8ee90a7338 | ||
|
|
9bd19b9254 | ||
|
|
df4c54ea8d |
No files matched your search
@@ -6,6 +6,7 @@ javadoc {
|
|||||||
include "com/gtnewhorizon/structurelib/structure/**"
|
include "com/gtnewhorizon/structurelib/structure/**"
|
||||||
include "com/gtnewhorizon/structurelib/util/**"
|
include "com/gtnewhorizon/structurelib/util/**"
|
||||||
include "com/gtnewhorizon/structurelib/StructureLibAPI.java"
|
include "com/gtnewhorizon/structurelib/StructureLibAPI.java"
|
||||||
|
include "com/gtnewhorizon/structurelib/StructureEvent.java"
|
||||||
|
|
||||||
options {
|
options {
|
||||||
overview "src/main/javadoc/overview.html"
|
overview "src/main/javadoc/overview.html"
|
||||||
@@ -22,3 +23,10 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
|
|||||||
artifacts {
|
artifacts {
|
||||||
archives javadocJar
|
archives javadocJar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events "passed", "skipped", "failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,4 +3,7 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile("com.github.GTNewHorizons:GTNHLib:0.0.1:dev")
|
compile("com.github.GTNewHorizons:GTNHLib:0.0.1:dev")
|
||||||
runtime("com.github.GTNewHorizons:NotEnoughItems:2.2.20-GTNH:dev")
|
runtime("com.github.GTNewHorizons:NotEnoughItems:2.2.20-GTNH:dev")
|
||||||
|
|
||||||
|
testImplementation(platform('org.junit:junit-bom:5.8.2'))
|
||||||
|
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,11 @@ public class ClientProxy extends CommonProxy {
|
|||||||
|
|
||||||
private static class HintParticleInfo {
|
private static class HintParticleInfo {
|
||||||
private final World w;
|
private final World w;
|
||||||
|
// these are the block coordinate for e.g. w.getBlock()
|
||||||
private final int x, y, z;
|
private final int x, y, z;
|
||||||
|
// these are the lower bounds for rendering. the upper bound would be X + size
|
||||||
|
// currently size is fixed to be 0.5
|
||||||
|
// it is not made into a constants because this will allow for easy changing during debug
|
||||||
private final double X, Y, Z;
|
private final double X, Y, Z;
|
||||||
private final IIcon[] icons;
|
private final IIcon[] icons;
|
||||||
private short[] tint;
|
private short[] tint;
|
||||||
@@ -319,10 +323,10 @@ public class ClientProxy extends CommonProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInFrustrum(Frustrum frustrum) {
|
public boolean isInFrustrum(Frustrum frustrum) {
|
||||||
return frustrum.isBoxInFrustum(x, y, z, X, Y, Z);
|
return frustrum.isBoxInFrustum(X, Y, Z, X + 0.5, Y + 0.5, Z + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Tessellator tes) {
|
public void draw(Tessellator tes, double eyeX, double eyeY, double eyeZ) {
|
||||||
double size = 0.5;
|
double size = 0.5;
|
||||||
|
|
||||||
int brightness = w.blockExists(x, 0, z) ? w.getLightBrightnessForSkyBlocks(x, y, z, 0) : 0;
|
int brightness = w.blockExists(x, 0, z) ? w.getLightBrightnessForSkyBlocks(x, y, z, 0) : 0;
|
||||||
@@ -343,43 +347,63 @@ public class ClientProxy extends CommonProxy {
|
|||||||
double U = icons[i].getMaxU();
|
double U = icons[i].getMaxU();
|
||||||
double v = icons[i].getMinV();
|
double v = icons[i].getMinV();
|
||||||
double V = icons[i].getMaxV();
|
double V = icons[i].getMaxV();
|
||||||
switch (i) { // {DOWN, UP, NORTH, SOUTH, WEST, EAST}
|
|
||||||
case 0:
|
// cube is a very special model. its facings can be rendered correctly by viewer distance without using
|
||||||
tes.addVertexWithUV(X, Y, Z + size, u, V);
|
// surface normals and view vector
|
||||||
tes.addVertexWithUV(X, Y, Z, u, v);
|
// here we do a 2 pass render.
|
||||||
tes.addVertexWithUV(X + size, Y, Z, U, v);
|
// first pass we draw obstructed faces (i.e. faces that are further away from player)
|
||||||
tes.addVertexWithUV(X + size, Y, Z + size, U, V);
|
// second pass we draw unobstructed faces
|
||||||
break;
|
for (int j = 0; j < 2; j++) {
|
||||||
case 1:
|
switch (i) { // {DOWN, UP, NORTH, SOUTH, WEST, EAST}
|
||||||
tes.addVertexWithUV(X, Y + size, Z, u, v);
|
case 0:
|
||||||
tes.addVertexWithUV(X, Y + size, Z + size, u, V);
|
if ((Y >= eyeY) != (j == 1)) continue;
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z + size, U, V);
|
tes.setNormal(0, -1, 0);
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z, U, v);
|
tes.addVertexWithUV(X, Y, Z + size, u, V);
|
||||||
break;
|
tes.addVertexWithUV(X, Y, Z, u, v);
|
||||||
case 2:
|
tes.addVertexWithUV(X + size, Y, Z, U, v);
|
||||||
tes.addVertexWithUV(X, Y, Z, U, V);
|
tes.addVertexWithUV(X + size, Y, Z + size, U, V);
|
||||||
tes.addVertexWithUV(X, Y + size, Z, U, v);
|
break;
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z, u, v);
|
case 1:
|
||||||
tes.addVertexWithUV(X + size, Y, Z, u, V);
|
if ((Y + size <= eyeY) != (j == 1)) continue;
|
||||||
break;
|
tes.setNormal(0, 1, 0);
|
||||||
case 3:
|
tes.addVertexWithUV(X, Y + size, Z, u, v);
|
||||||
tes.addVertexWithUV(X + size, Y, Z + size, U, V);
|
tes.addVertexWithUV(X, Y + size, Z + size, u, V);
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z + size, U, v);
|
tes.addVertexWithUV(X + size, Y + size, Z + size, U, V);
|
||||||
tes.addVertexWithUV(X, Y + size, Z + size, u, v);
|
tes.addVertexWithUV(X + size, Y + size, Z, U, v);
|
||||||
tes.addVertexWithUV(X, Y, Z + size, u, V);
|
break;
|
||||||
break;
|
case 2:
|
||||||
case 4:
|
if ((Z >= eyeZ) != (j == 1)) continue;
|
||||||
tes.addVertexWithUV(X, Y, Z + size, U, V);
|
tes.setNormal(0, 0, -1);
|
||||||
tes.addVertexWithUV(X, Y + size, Z + size, U, v);
|
tes.addVertexWithUV(X, Y, Z, U, V);
|
||||||
tes.addVertexWithUV(X, Y + size, Z, u, v);
|
tes.addVertexWithUV(X, Y + size, Z, U, v);
|
||||||
tes.addVertexWithUV(X, Y, Z, u, V);
|
tes.addVertexWithUV(X + size, Y + size, Z, u, v);
|
||||||
break;
|
tes.addVertexWithUV(X + size, Y, Z, u, V);
|
||||||
case 5:
|
break;
|
||||||
tes.addVertexWithUV(X + size, Y, Z, U, V);
|
case 3:
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z, U, v);
|
if ((Z <= eyeZ) != (j == 1)) continue;
|
||||||
tes.addVertexWithUV(X + size, Y + size, Z + size, u, v);
|
tes.setNormal(0, 0, 1);
|
||||||
tes.addVertexWithUV(X + size, Y, Z + size, u, V);
|
tes.addVertexWithUV(X + size, Y, Z + size, U, V);
|
||||||
break;
|
tes.addVertexWithUV(X + size, Y + size, Z + size, U, v);
|
||||||
|
tes.addVertexWithUV(X, Y + size, Z + size, u, v);
|
||||||
|
tes.addVertexWithUV(X, Y, Z + size, u, V);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if ((X >= eyeX) != (j == 1)) continue;
|
||||||
|
tes.setNormal(-1, 0, 0);
|
||||||
|
tes.addVertexWithUV(X, Y, Z + size, U, V);
|
||||||
|
tes.addVertexWithUV(X, Y + size, Z + size, U, v);
|
||||||
|
tes.addVertexWithUV(X, Y + size, Z, u, v);
|
||||||
|
tes.addVertexWithUV(X, Y, Z, u, V);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if ((X + size <= eyeX) != (j == 1)) continue;
|
||||||
|
tes.setNormal(1, 0, 0);
|
||||||
|
tes.addVertexWithUV(X + size, Y, Z, U, V);
|
||||||
|
tes.addVertexWithUV(X + size, Y + size, Z, U, v);
|
||||||
|
tes.addVertexWithUV(X + size, Y + size, Z + size, u, v);
|
||||||
|
tes.addVertexWithUV(X + size, Y, Z + size, u, V);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,12 +454,11 @@ public class ClientProxy extends CommonProxy {
|
|||||||
for (HintGroup c : allGroups) allHintsForRender.addAll(c.getHints());
|
for (HintGroup c : allGroups) allHintsForRender.addAll(c.getHints());
|
||||||
sortRequired = true;
|
sortRequired = true;
|
||||||
}
|
}
|
||||||
if (renderThrough > 0 && (sortRequired || playerPos.squareDistanceTo(lastPlayerPos) > 1e-2)) {
|
if (sortRequired || playerPos.squareDistanceTo(lastPlayerPos) > 1e-2) {
|
||||||
// only sort if there is anything that need depth test disabled
|
|
||||||
// only redo sort if player moved some distance
|
// only redo sort if player moved some distance
|
||||||
// default is 0.1 block
|
// default is 0.1 block
|
||||||
// if there was a full rebuild, go sort it as well
|
// if there was a full rebuild, go sort it as well
|
||||||
allHintsForRender.sort(Comparator.comparingDouble(info -> info.getSquareDistanceTo(playerPos)));
|
allHintsForRender.sort(Comparator.comparingDouble(info -> -info.getSquareDistanceTo(playerPos)));
|
||||||
resetPlayerLocation();
|
resetPlayerLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -481,6 +504,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT); // TODO figure out original states
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT); // TODO figure out original states
|
||||||
// we need the back facing rendered because the thing is transparent
|
// we need the back facing rendered because the thing is transparent
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
GL11.glEnable(GL11.GL_BLEND); // enable blend so it is transparent
|
GL11.glEnable(GL11.GL_BLEND); // enable blend so it is transparent
|
||||||
GL11.glBlendFunc(GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_SRC_ALPHA);
|
||||||
// depth test begin as enabled
|
// depth test begin as enabled
|
||||||
@@ -503,7 +527,8 @@ public class ClientProxy extends CommonProxy {
|
|||||||
else GL11.glEnable(GL11.GL_DEPTH_TEST);
|
else GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
renderThrough = hint.renderThrough;
|
renderThrough = hint.renderThrough;
|
||||||
}
|
}
|
||||||
hint.draw(tes);
|
// TODO verify if we need to add eyeHeight
|
||||||
|
hint.draw(tes, d0, d1, d2);
|
||||||
}
|
}
|
||||||
p.endStartSection("Draw");
|
p.endStartSection("Draw");
|
||||||
tes.draw();
|
tes.draw();
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public enum ConfigurationHandler {
|
|||||||
300,
|
300,
|
||||||
0,
|
0,
|
||||||
20000,
|
20000,
|
||||||
"Unit: milisecond. Minimal interval between two auto place round.\n"
|
"Unit: millisecond. Minimal interval between two auto place round.\n"
|
||||||
+ "As expected, server side settings will overrides client settings.\n"
|
+ "As expected, server side settings will overrides client settings.\n"
|
||||||
+ "Note this relates to the wall clock, not in game ticks.\n"
|
+ "Note this relates to the wall clock, not in game ticks.\n"
|
||||||
+ "Value smaller than default is likely to be perceived as no minimal interval whatsoever.");
|
+ "Value smaller than default is likely to be perceived as no minimal interval whatsoever.");
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
package com.gtnewhorizon.structurelib;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import org.lwjgl.opengl.ARBVertexBufferObject;
|
|
||||||
import org.lwjgl.opengl.ContextCapabilities;
|
|
||||||
import org.lwjgl.opengl.GL15;
|
|
||||||
import org.lwjgl.opengl.GLContext;
|
|
||||||
|
|
||||||
class GLHelper {
|
|
||||||
public static final boolean vboSupported;
|
|
||||||
private static final boolean arbVbo;
|
|
||||||
|
|
||||||
static {
|
|
||||||
ContextCapabilities contextcapabilities = GLContext.getCapabilities();
|
|
||||||
|
|
||||||
arbVbo = !contextcapabilities.OpenGL15 && contextcapabilities.GL_ARB_vertex_buffer_object;
|
|
||||||
vboSupported = contextcapabilities.OpenGL15 || arbVbo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int glGenBuffers() {
|
|
||||||
return arbVbo ? ARBVertexBufferObject.glGenBuffersARB() : GL15.glGenBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void glBindBuffer(int target, int buffer) {
|
|
||||||
if (arbVbo) {
|
|
||||||
ARBVertexBufferObject.glBindBufferARB(target, buffer);
|
|
||||||
} else {
|
|
||||||
GL15.glBindBuffer(target, buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void glBufferData(int target, ByteBuffer data, int usage) {
|
|
||||||
if (arbVbo) {
|
|
||||||
ARBVertexBufferObject.glBufferDataARB(target, data, usage);
|
|
||||||
} else {
|
|
||||||
GL15.glBufferData(target, data, usage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void glDeleteBuffers(int buffer) {
|
|
||||||
if (arbVbo) {
|
|
||||||
ARBVertexBufferObject.glDeleteBuffersARB(buffer);
|
|
||||||
} else {
|
|
||||||
GL15.glDeleteBuffers(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean useVbo() {
|
|
||||||
return vboSupported;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package com.gtnewhorizon.structurelib;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.structure.IStructureElement;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribers are <b>required</b> to not keep reference to these events, nor to depend on values of these events after
|
||||||
|
* the method call returns.
|
||||||
|
* <p>
|
||||||
|
* All of these events will be fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}, if they are
|
||||||
|
* enabled by {@link StructureLibAPI#enableInstrument(Object)}.
|
||||||
|
* <p>
|
||||||
|
* All public stuff in this class and its enclosed classes are considered part of the public API.
|
||||||
|
* Backwards compatibility is maintained to the maximum extend possible.
|
||||||
|
*/
|
||||||
|
public abstract class StructureEvent extends Event {
|
||||||
|
/*
|
||||||
|
* In case the event is passed to another thread for processing.
|
||||||
|
*/
|
||||||
|
private final Object identifier = StructureLibAPI.instrument.get();
|
||||||
|
|
||||||
|
StructureEvent() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The instrument identifier. Subscribers should filter by these identifiers to prevent listening to a structure
|
||||||
|
* event for other people.
|
||||||
|
*/
|
||||||
|
public Object getInstrumentIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired <b>just before</b> any structure element is visited.
|
||||||
|
*/
|
||||||
|
public static final class StructureElementVisitedEvent extends StructureEvent {
|
||||||
|
private final World world;
|
||||||
|
private final int x, y, z;
|
||||||
|
private final int a, b, c;
|
||||||
|
private final IStructureElement<?> element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire this event on {@link MinecraftForge#EVENT_BUS} by populating it with given arguments.
|
||||||
|
* Do nothing if instrumenting isn't enabled for current thread.
|
||||||
|
* <p>
|
||||||
|
* Any {@link Exception} thrown by event listeners will be logged and ignored. {@link Error} will be propagated
|
||||||
|
* as is.
|
||||||
|
*/
|
||||||
|
public static void fireEvent(
|
||||||
|
World world, int x, int y, int z, int a, int b, int c, IStructureElement<?> element) {
|
||||||
|
if (StructureLibAPI.isInstrumentEnabled()) {
|
||||||
|
try {
|
||||||
|
MinecraftForge.EVENT_BUS.post(new StructureElementVisitedEvent(world, x, y, z, a, b, c, element));
|
||||||
|
} catch (Exception e) {
|
||||||
|
// logging is done by event bus, we just ignore the consequence here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StructureElementVisitedEvent(
|
||||||
|
World world, int x, int y, int z, int a, int b, int c, IStructureElement<?> element) {
|
||||||
|
this.world = world;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.c = c;
|
||||||
|
this.element = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A position in ABC coordinate, relative to (0,0,0) in the piece, i.e. without baseOffset
|
||||||
|
* <p>
|
||||||
|
* Submit a feature request if you need the baseOffset.
|
||||||
|
*/
|
||||||
|
public int getA() {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* B position in ABC coordinate, relative to (0,0,0) in the piece, i.e. without baseOffset
|
||||||
|
* <p>
|
||||||
|
* Submit a feature request if you need the baseOffset.
|
||||||
|
*/
|
||||||
|
public int getB() {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C position in ABC coordinate, relative to (0,0,0) in the piece, i.e. without baseOffset
|
||||||
|
* <p>
|
||||||
|
* Submit a feature request if you need the baseOffset.
|
||||||
|
*/
|
||||||
|
public int getC() {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element being visited.
|
||||||
|
*/
|
||||||
|
public IStructureElement<?> getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StructureElementVisitedEvent{" + "a="
|
||||||
|
+ a + ", b="
|
||||||
|
+ b + ", c="
|
||||||
|
+ c + ", element="
|
||||||
|
+ element + ", world="
|
||||||
|
+ getWorld() + ", x="
|
||||||
|
+ getX() + ", y="
|
||||||
|
+ getY() + ", z="
|
||||||
|
+ getZ() + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of this event.
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of this event. Absolute world coordinate.
|
||||||
|
*/
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of this event. Absolute world coordinate.
|
||||||
|
*/
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of this event. Absolute world coordinate.
|
||||||
|
*/
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,14 +42,14 @@ public class StructureLib {
|
|||||||
private static final String STRUCTURECOMPAT_MODID = "structurecompat";
|
private static final String STRUCTURECOMPAT_MODID = "structurecompat";
|
||||||
public static boolean DEBUG_MODE;
|
public static boolean DEBUG_MODE;
|
||||||
public static boolean PANIC_MODE = Boolean.getBoolean("structurelib.panic");
|
public static boolean PANIC_MODE = Boolean.getBoolean("structurelib.panic");
|
||||||
public static Logger LOGGER = LogManager.getLogger("StructureLib");
|
public static final Logger LOGGER = LogManager.getLogger("StructureLib");
|
||||||
|
|
||||||
@SidedProxy(
|
@SidedProxy(
|
||||||
serverSide = "com.gtnewhorizon.structurelib.CommonProxy",
|
serverSide = "com.gtnewhorizon.structurelib.CommonProxy",
|
||||||
clientSide = "com.gtnewhorizon.structurelib.ClientProxy")
|
clientSide = "com.gtnewhorizon.structurelib.ClientProxy")
|
||||||
static CommonProxy proxy;
|
static CommonProxy proxy;
|
||||||
|
|
||||||
static SimpleNetworkWrapper net = NetworkRegistry.INSTANCE.newSimpleChannel(StructureLibAPI.MOD_ID);
|
static final SimpleNetworkWrapper net = NetworkRegistry.INSTANCE.newSimpleChannel(StructureLibAPI.MOD_ID);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
net.registerMessage(
|
net.registerMessage(
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
|||||||
import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
|
import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
import com.gtnewhorizon.structurelib.net.AlignmentMessage;
|
import com.gtnewhorizon.structurelib.net.AlignmentMessage;
|
||||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -38,6 +39,54 @@ public class StructureLibAPI {
|
|||||||
public static final int HINT_BLOCK_META_AIR = 13;
|
public static final int HINT_BLOCK_META_AIR = 13;
|
||||||
public static final int HINT_BLOCK_META_NOT_AIR = 14;
|
public static final int HINT_BLOCK_META_NOT_AIR = 14;
|
||||||
public static final int HINT_BLOCK_META_ERROR = 15;
|
public static final int HINT_BLOCK_META_ERROR = 15;
|
||||||
|
static final ThreadLocal<Object> instrument = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start instrumenting <b>for the current thread only</b>. When instrumentation is enabled,
|
||||||
|
* {@link IStructureDefinition}'s builtin iteration methods will send {@link StructureEvent} and its subclasses when
|
||||||
|
* appropriate. Otherwise, these events will not be sent at all, regardless of whether a listener for these events
|
||||||
|
* are registered.
|
||||||
|
* <p>
|
||||||
|
* Identifiers are required to be value-comparable, i.e. overrides {@link Object#equals(Object)}.
|
||||||
|
* Suggested identifier includes
|
||||||
|
* <ul>
|
||||||
|
* <li>Mod Instance or {@link cpw.mods.fml.common.ModContainer}</li>
|
||||||
|
* <li>{@link com.gtnewhorizon.structurelib.alignment.constructable.IConstructable} and its friends, if you are triggering structure check via this interface.</li>
|
||||||
|
* <li>{@link net.minecraft.util.ResourceLocation}</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>
|
||||||
|
* It's an API abuse for normal {@link IStructureDefinition} users to depend on this feature. They have full control
|
||||||
|
* and full knowledge of the {@link IStructureDefinition} they are using. Using events to instrument the structure
|
||||||
|
* check/autoplace is completely unnecessary and does nothing but add overhead.
|
||||||
|
* <p>
|
||||||
|
* Instruments are required to call {@link #disableInstrument()} whenever it is done with its business, as there can
|
||||||
|
* be only one instrument for any given thread.
|
||||||
|
*
|
||||||
|
* @param identifier an identifier sent along the actual event.
|
||||||
|
* @throws IllegalStateException if instrument has already been enabled.
|
||||||
|
*/
|
||||||
|
public static void enableInstrument(Object identifier) {
|
||||||
|
if (isInstrumentEnabled()) throw new IllegalStateException();
|
||||||
|
instrument.set(instrument);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop instrumenting.
|
||||||
|
*
|
||||||
|
* @throws IllegalStateException if instrumenting hasn't been enabled.
|
||||||
|
*/
|
||||||
|
public static void disableInstrument() {
|
||||||
|
if (!isInstrumentEnabled()) throw new IllegalStateException();
|
||||||
|
instrument.set(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if instrumenting is enabled.
|
||||||
|
* @return true if enabled, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isInstrumentEnabled() {
|
||||||
|
return instrument.get() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a batch of hinting. All hints particles generated during one batch will be considered to belong to one hologram.
|
* Start a batch of hinting. All hints particles generated during one batch will be considered to belong to one hologram.
|
||||||
@@ -59,12 +108,13 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new hint particle on client side at given location using given textures with a tint.
|
* Generate a new hint particle on client side at given location using given textures with a tint.
|
||||||
* @param w World to spawn. Usually the client world.
|
*
|
||||||
* @param x x coord
|
* @param w World to spawn. Usually the client world.
|
||||||
* @param y y coord
|
* @param x x coord
|
||||||
* @param z z coord
|
* @param y y coord
|
||||||
|
* @param z z coord
|
||||||
* @param icons 6 texture. in forge direction order.
|
* @param icons 6 texture. in forge direction order.
|
||||||
* @param RGBa a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
|
* @param RGBa a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
|
||||||
*/
|
*/
|
||||||
public static void hintParticleTinted(World w, int x, int y, int z, IIcon[] icons, short[] RGBa) {
|
public static void hintParticleTinted(World w, int x, int y, int z, IIcon[] icons, short[] RGBa) {
|
||||||
proxy.hintParticleTinted(w, x, y, z, icons, RGBa);
|
proxy.hintParticleTinted(w, x, y, z, icons, RGBa);
|
||||||
@@ -72,13 +122,14 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new hint particle on client side at given location using textures from given block with a tint.
|
* Generate a new hint particle on client side at given location using textures from given block with a tint.
|
||||||
* @param w World to spawn. Usually the client world.
|
*
|
||||||
* @param x x coord
|
* @param w World to spawn. Usually the client world.
|
||||||
* @param y y coord
|
* @param x x coord
|
||||||
* @param z z coord
|
* @param y y coord
|
||||||
|
* @param z z coord
|
||||||
* @param block block to take texture from
|
* @param block block to take texture from
|
||||||
* @param meta the meta of block to take texture from
|
* @param meta the meta of block to take texture from
|
||||||
* @param RGBa a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
|
* @param RGBa a 4 short array. tint in rgba form. currently alpha channel is ignored, but we might change this later on.
|
||||||
*/
|
*/
|
||||||
public static void hintParticleTinted(World w, int x, int y, int z, Block block, int meta, short[] RGBa) {
|
public static void hintParticleTinted(World w, int x, int y, int z, Block block, int meta, short[] RGBa) {
|
||||||
proxy.hintParticleTinted(w, x, y, z, block, meta, RGBa);
|
proxy.hintParticleTinted(w, x, y, z, block, meta, RGBa);
|
||||||
@@ -86,10 +137,11 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new hint particle on client side at given location using given textures.
|
* Generate a new hint particle on client side at given location using given textures.
|
||||||
* @param w World to spawn. Usually the client world.
|
*
|
||||||
* @param x x coord
|
* @param w World to spawn. Usually the client world.
|
||||||
* @param y y coord
|
* @param x x coord
|
||||||
* @param z z coord
|
* @param y y coord
|
||||||
|
* @param z z coord
|
||||||
* @param icons 6 texture. in forge direction order.
|
* @param icons 6 texture. in forge direction order.
|
||||||
*/
|
*/
|
||||||
public static void hintParticle(World w, int x, int y, int z, IIcon[] icons) {
|
public static void hintParticle(World w, int x, int y, int z, IIcon[] icons) {
|
||||||
@@ -98,12 +150,13 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new hint particle on client side at given location using textures from given block.
|
* Generate a new hint particle on client side at given location using textures from given block.
|
||||||
* @param w World to spawn. Usually the client world.
|
*
|
||||||
* @param x x coord
|
* @param w World to spawn. Usually the client world.
|
||||||
* @param y y coord
|
* @param x x coord
|
||||||
* @param z z coord
|
* @param y y coord
|
||||||
|
* @param z z coord
|
||||||
* @param block block to take texture from
|
* @param block block to take texture from
|
||||||
* @param meta the meta of block to take texture from
|
* @param meta the meta of block to take texture from
|
||||||
*/
|
*/
|
||||||
public static void hintParticle(World w, int x, int y, int z, Block block, int meta) {
|
public static void hintParticle(World w, int x, int y, int z, Block block, int meta) {
|
||||||
proxy.hintParticle(w, x, y, z, block, meta);
|
proxy.hintParticle(w, x, y, z, block, meta);
|
||||||
@@ -111,7 +164,7 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the tint of given hint particle. Do nothing if particle not found.
|
* Update the tint of given hint particle. Do nothing if particle not found.
|
||||||
*
|
* <p>
|
||||||
* Can be called on either client side or server side.
|
* Can be called on either client side or server side.
|
||||||
* Server side will schedule a network message to update it for this player only.
|
* Server side will schedule a network message to update it for this player only.
|
||||||
* Will do nothing if no hint particle is found at given location.
|
* Will do nothing if no hint particle is found at given location.
|
||||||
@@ -219,9 +272,20 @@ public class StructureLibAPI {
|
|||||||
* Determines if given block can be replaced without much effort. The exact predicate clauses is not stable and
|
* Determines if given block can be replaced without much effort. The exact predicate clauses is not stable and
|
||||||
* will be changed, but the general idea will always stay the same.
|
* will be changed, but the general idea will always stay the same.
|
||||||
* <p>
|
* <p>
|
||||||
* Use this in your {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, java.util.function.Consumer)}
|
* Use this in your {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isBlockTriviallyReplaceable(World w, int x, int y, int z, EntityPlayerMP actor) {
|
public static boolean isBlockTriviallyReplaceable(World w, int x, int y, int z, EntityPlayerMP actor) {
|
||||||
|
return isBlockTriviallyReplaceable(w, x, y, z, (EntityPlayer) actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if given block can be replaced without much effort. The exact predicate clauses is not stable and
|
||||||
|
* will be changed, but the general idea will always stay the same.
|
||||||
|
* <p>
|
||||||
|
* Use this in your {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
|
||||||
|
*/
|
||||||
|
public static boolean isBlockTriviallyReplaceable(World w, int x, int y, int z, EntityPlayer actor) {
|
||||||
// TODO extend this function a bit
|
// TODO extend this function a bit
|
||||||
Block block = w.getBlock(x, y, z);
|
Block block = w.getBlock(x, y, z);
|
||||||
return block.isAir(w, x, y, z) || block.isReplaceable(w, x, y, z);
|
return block.isAir(w, x, y, z) || block.isReplaceable(w, x, y, z);
|
||||||
@@ -229,10 +293,11 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send chat to player, but throttled.
|
* Send chat to player, but throttled.
|
||||||
* @param throttleKey throttle key. Must properly implement {@link Object#hashCode()} and {@link Object#equals(Object)}
|
*
|
||||||
* to handle value equality.
|
* @param throttleKey throttle key. Must properly implement {@link Object#hashCode()} and {@link Object#equals(Object)}
|
||||||
* @param player player to send chat to
|
* to handle value equality.
|
||||||
* @param text chat to send
|
* @param player player to send chat to
|
||||||
|
* @param text chat to send
|
||||||
* @param intervalRequired interval required before last recorded time to actually send the message. unit in millisecond.
|
* @param intervalRequired interval required before last recorded time to actually send the message. unit in millisecond.
|
||||||
* we purposefully chose to not use a bigger data type to limit how long this interval can be
|
* we purposefully chose to not use a bigger data type to limit how long this interval can be
|
||||||
*/
|
*/
|
||||||
@@ -243,12 +308,13 @@ public class StructureLibAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send chat to player, but throttled.
|
* Send chat to player, but throttled.
|
||||||
* @param throttleKey throttle key. Must properly implement {@link Object#hashCode()} and {@link Object#equals(Object)}
|
*
|
||||||
* to handle value equality.
|
* @param throttleKey throttle key. Must properly implement {@link Object#hashCode()} and {@link Object#equals(Object)}
|
||||||
* @param player player to send chat to
|
* to handle value equality.
|
||||||
* @param text chat to send
|
* @param player player to send chat to
|
||||||
* @param intervalRequired interval required before last recorded time to actually send the message. unit in millisecond.
|
* @param text chat to send
|
||||||
* we purposefully chose to not use a bigger data type to limit how long this interval can be
|
* @param intervalRequired interval required before last recorded time to actually send the message. unit in millisecond.
|
||||||
|
* we purposefully chose to not use a bigger data type to limit how long this interval can be
|
||||||
* @param forceUpdateLastSend if true, always update the last send time, even if the message isn't actually sent.
|
* @param forceUpdateLastSend if true, always update the last send time, even if the message isn't actually sent.
|
||||||
*/
|
*/
|
||||||
public static void addThrottledChat(
|
public static void addThrottledChat(
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public interface IAlignmentLimits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefers rotation over flip, so both flip will get translated to opposite rotation and no flip
|
* Prefers rotation to flip, so both flip will get translated to opposite rotation and no flip
|
||||||
*
|
*
|
||||||
* @param flip the preferred flip to be used Horizontal or vertical
|
* @param flip the preferred flip to be used Horizontal or vertical
|
||||||
* @return this
|
* @return this
|
||||||
|
|||||||
+2
-2
@@ -6,6 +6,7 @@ import com.gtnewhorizon.structurelib.StructureLibAPI;
|
|||||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
@@ -78,8 +79,7 @@ public class ConstructableUtility {
|
|||||||
.survivalConstruct(
|
.survivalConstruct(
|
||||||
aStack,
|
aStack,
|
||||||
ConfigurationHandler.INSTANCE.getAutoPlaceBudget(),
|
ConfigurationHandler.INSTANCE.getAutoPlaceBudget(),
|
||||||
IItemSource.fromPlayer(playerMP),
|
ISurvivalBuildEnvironment.create(IItemSource.fromPlayer(playerMP), playerMP));
|
||||||
playerMP);
|
|
||||||
if (built > 0) {
|
if (built > 0) {
|
||||||
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.built_stat", built));
|
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.built_stat", built));
|
||||||
} else if (built == -1) {
|
} else if (built == -1) {
|
||||||
|
|||||||
+8
@@ -1,5 +1,6 @@
|
|||||||
package com.gtnewhorizon.structurelib.alignment.constructable;
|
package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -10,6 +11,13 @@ import net.minecraft.item.ItemStack;
|
|||||||
public interface IConstructable {
|
public interface IConstructable {
|
||||||
void construct(ItemStack stackSize, boolean hintsOnly);
|
void construct(ItemStack stackSize, boolean hintsOnly);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the structure definition used for this constructable. Can be null if this constructable is not backed by one.
|
||||||
|
*/
|
||||||
|
default IStructureDefinition<?> getStructureDefinition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
String[] getStructureDescription(ItemStack stackSize);
|
String[] getStructureDescription(ItemStack stackSize);
|
||||||
}
|
}
|
||||||
+64
-3
@@ -1,17 +1,78 @@
|
|||||||
package com.gtnewhorizon.structurelib.alignment.constructable;
|
package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
|
||||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||||
|
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An extension to {@link IConstructable}. Tile Entities (or delegates returned by {@link IConstructableProvider#getConstructable()}
|
||||||
|
* should implement this interface to allow third party tools and StructureLib builtin constructable tools to trigger
|
||||||
|
* autoplace in survival mode.
|
||||||
|
* <p>
|
||||||
|
* While not originally planned, a creative player can also use this interface to trigger autoplace by using an
|
||||||
|
* {@link IItemSource} with every possible items in the game.
|
||||||
|
*/
|
||||||
public interface ISurvivalConstructable extends IConstructable {
|
public interface ISurvivalConstructable extends IConstructable {
|
||||||
|
/**
|
||||||
|
* End player might want to disable this hack if it turns out to be too crashy
|
||||||
|
*/
|
||||||
|
boolean DISABLE_HACKY_MIGRATION_CODE = Boolean.getBoolean("structurelib.disable_isc_migration_hack");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, java.util.function.Consumer)}
|
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, java.util.function.Consumer)}
|
||||||
|
* or {@link com.gtnewhorizon.structurelib.structure.IStructureDefinition#survivalBuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int, int, IItemSource, EntityPlayerMP, boolean)}
|
||||||
*
|
*
|
||||||
* @param elementBudget The server configured element budget. You can tune this up a bit if the structure is too big, but
|
* @param elementBudget The server configured element budget. The implementor can choose to tune this up a bit if
|
||||||
* generally should not be a 4 digits number to not overwhelm the server
|
* the structure is too big, but generally should not be a 4 digits number to not overwhelm the
|
||||||
|
* server
|
||||||
* @return -1 if done, otherwise number of elements placed this round
|
* @return -1 if done, otherwise number of elements placed this round
|
||||||
*/
|
*/
|
||||||
int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor);
|
@Deprecated
|
||||||
|
default int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) {
|
||||||
|
return survivalConstruct(stackSize, elementBudget, ISurvivalBuildEnvironment.create(source, actor));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
|
||||||
|
* or {@link com.gtnewhorizon.structurelib.structure.IStructureDefinition#survivalBuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int, int, ISurvivalBuildEnvironment, boolean)}
|
||||||
|
*
|
||||||
|
* @param elementBudget The server configured element budget. The implementor can choose to tune this up a bit if
|
||||||
|
* the structure is too big, but generally should not be a 4 digits number to not overwhelm the
|
||||||
|
* server
|
||||||
|
* @return -1 if done, -2 if not supported (e.g. due to an incompatible change in the API of env, otherwise number
|
||||||
|
* of elements placed this round
|
||||||
|
*/
|
||||||
|
default int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
|
||||||
|
EntityPlayer actor = env.getActor();
|
||||||
|
if (actor instanceof EntityPlayerMP)
|
||||||
|
return survivalConstruct(stackSize, elementBudget, env.getSource(), (EntityPlayerMP) actor);
|
||||||
|
else if (!DISABLE_HACKY_MIGRATION_CODE && __get_player() == null) {
|
||||||
|
// as far as I know, no implementor would actually do anything to actor beyond passing it down to
|
||||||
|
// IStructureDefinition, so it's probably fine to proceed like this
|
||||||
|
GlobalStates.entityPlayer.set(env.getActor());
|
||||||
|
try {
|
||||||
|
return survivalConstruct(stackSize, elementBudget, env.getSource(), null);
|
||||||
|
} finally {
|
||||||
|
GlobalStates.entityPlayer.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal hack. Do not use.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
static EntityPlayer __get_player() {
|
||||||
|
return GlobalStates.entityPlayer.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GlobalStates {
|
||||||
|
public static final ThreadLocal<EntityPlayer> entityPlayer = new ThreadLocal<>();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.gtnewhorizon.structurelib.alignment.enumerable;
|
package com.gtnewhorizon.structurelib.alignment.enumerable;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
@@ -14,10 +18,12 @@ public enum Direction {
|
|||||||
private final ForgeDirection forgeDirection;
|
private final ForgeDirection forgeDirection;
|
||||||
private final Vec3Impl axisVector;
|
private final Vec3Impl axisVector;
|
||||||
public static final Direction[] VALUES = values();
|
public static final Direction[] VALUES = values();
|
||||||
|
private static final Map<Vec3Impl, Direction> reverseMap =
|
||||||
|
Arrays.stream(VALUES).collect(Collectors.toMap(d -> d.axisVector, Function.identity()));
|
||||||
|
|
||||||
Direction(ForgeDirection forgeDirection) {
|
Direction(ForgeDirection forgeDirection) {
|
||||||
this.forgeDirection = forgeDirection;
|
this.forgeDirection = forgeDirection;
|
||||||
axisVector = new Vec3Impl(forgeDirection.offsetX, forgeDirection.offsetY, forgeDirection.offsetZ);
|
axisVector = Vec3Impl.getFromPool(forgeDirection.offsetX, forgeDirection.offsetY, forgeDirection.offsetZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgeDirection getForgeDirection() {
|
public ForgeDirection getForgeDirection() {
|
||||||
@@ -31,4 +37,8 @@ public enum Direction {
|
|||||||
public static Vec3Impl getAxisVector(ForgeDirection forgeDirection) {
|
public static Vec3Impl getAxisVector(ForgeDirection forgeDirection) {
|
||||||
return VALUES[forgeDirection.ordinal()].axisVector;
|
return VALUES[forgeDirection.ordinal()].axisVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Direction getByAxisVector(Vec3Impl vec3) {
|
||||||
|
return reverseMap.get(vec3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -354,6 +354,28 @@ public enum ExtendedFacing {
|
|||||||
integerAxisSwap.inverseTranslate(point, out);
|
integerAxisSwap.inverseTranslate(point, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* do note the ABC coordinate system is (X, -Y, Z).
|
||||||
|
*/
|
||||||
|
public ForgeDirection getWorldDirection(ForgeDirection abcDirection) {
|
||||||
|
switch (abcDirection) {
|
||||||
|
case NORTH:
|
||||||
|
return getRelativeForwardInWorld();
|
||||||
|
case SOUTH:
|
||||||
|
return getRelativeBackInWorld();
|
||||||
|
case UP:
|
||||||
|
return getRelativeDownInWorld();
|
||||||
|
case DOWN:
|
||||||
|
return getRelativeUpInWorld();
|
||||||
|
case EAST:
|
||||||
|
return getRelativeLeftInWorld();
|
||||||
|
case WEST:
|
||||||
|
return getRelativeRightInWorld();
|
||||||
|
default:
|
||||||
|
return ForgeDirection.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates world offset to relative front facing offset
|
* Translates world offset to relative front facing offset
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -236,7 +236,8 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
// this will be called from setText of key and value. NEVER UPDATE THE VALUE OF THESE HERE OR GET A
|
// this will be called from setText of key and value. NEVER UPDATE THE VALUE OF THESE HERE OR GET A
|
||||||
// STACKOVERFLOW!
|
// STACKOVERFLOW!
|
||||||
boolean existing = ChannelDataAccessor.hasSubChannel(trigger, key.getText());
|
String keyText = key.getText();
|
||||||
|
boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText);
|
||||||
getButtonList().get(0).displayString = existing
|
getButtonList().get(0).displayString = existing
|
||||||
? I18n.format("item.structurelib.constructableTrigger.gui.set")
|
? I18n.format("item.structurelib.constructableTrigger.gui.set")
|
||||||
: I18n.format("item.structurelib.constructableTrigger.gui.add");
|
: I18n.format("item.structurelib.constructableTrigger.gui.add");
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ import org.lwjgl.opengl.GL11;
|
|||||||
public abstract class GuiScrollableList<T> {
|
public abstract class GuiScrollableList<T> {
|
||||||
protected final int slotHeight;
|
protected final int slotHeight;
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
protected int originX;
|
protected final int originX;
|
||||||
protected int originY;
|
protected final int originY;
|
||||||
protected int width;
|
protected final int width;
|
||||||
protected int height;
|
protected final int height;
|
||||||
protected int minY;
|
protected int minY;
|
||||||
protected int maxY;
|
protected int maxY;
|
||||||
protected int minX;
|
protected int minX;
|
||||||
@@ -41,7 +41,7 @@ public abstract class GuiScrollableList<T> {
|
|||||||
protected int mouseY;
|
protected int mouseY;
|
||||||
protected int selectedIndex = -1;
|
protected int selectedIndex = -1;
|
||||||
protected int margin = 4;
|
protected int margin = 4;
|
||||||
protected List<ListSelectionListener<T>> listeners = new CopyOnWriteArrayList<>();
|
protected final List<ListSelectionListener<T>> listeners = new CopyOnWriteArrayList<>();
|
||||||
private int scrollUpButtonID;
|
private int scrollUpButtonID;
|
||||||
private int scrollDownButtonID;
|
private int scrollDownButtonID;
|
||||||
private float initialClickY = -2.0F;
|
private float initialClickY = -2.0F;
|
||||||
@@ -153,11 +153,11 @@ public abstract class GuiScrollableList<T> {
|
|||||||
public void actionPerformed(GuiButton b) {
|
public void actionPerformed(GuiButton b) {
|
||||||
if (b.enabled) {
|
if (b.enabled) {
|
||||||
if (b.id == scrollUpButtonID) {
|
if (b.id == scrollUpButtonID) {
|
||||||
amountScrolled -= slotHeight * 2 / 3;
|
amountScrolled -= slotHeight * 2f / 3;
|
||||||
initialClickY = -2.0F;
|
initialClickY = -2.0F;
|
||||||
clampScrollToBounds();
|
clampScrollToBounds();
|
||||||
} else if (b.id == scrollDownButtonID) {
|
} else if (b.id == scrollDownButtonID) {
|
||||||
amountScrolled += slotHeight * 2 / 3;
|
amountScrolled += slotHeight * 2f / 3;
|
||||||
initialClickY = -2.0F;
|
initialClickY = -2.0F;
|
||||||
clampScrollToBounds();
|
clampScrollToBounds();
|
||||||
}
|
}
|
||||||
@@ -325,9 +325,9 @@ public abstract class GuiScrollableList<T> {
|
|||||||
public void handleDWheel(int mouseWheelDelta) {
|
public void handleDWheel(int mouseWheelDelta) {
|
||||||
if (!Mouse.isButtonDown(0)) {
|
if (!Mouse.isButtonDown(0)) {
|
||||||
if (mouseWheelDelta > 0) {
|
if (mouseWheelDelta > 0) {
|
||||||
amountScrolled -= slotHeight / 2;
|
amountScrolled -= slotHeight / 2f;
|
||||||
} else /* if (mouseWheelDelta < 0) */ {
|
} else /* if (mouseWheelDelta < 0) */ {
|
||||||
amountScrolled += slotHeight / 2;
|
amountScrolled += slotHeight / 2f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,12 @@ public class ItemBlockHint extends ItemBlock {
|
|||||||
"structurelib.blockhint.desc.4")); // Make sure it does not contain Air material.
|
"structurelib.blockhint.desc.4")); // Make sure it does not contain Air material.
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
aList.add(EnumChatFormatting.BLUE.toString()
|
aList.add(EnumChatFormatting.BLUE
|
||||||
+ translateToLocal("structurelib.blockhint.desc.5")); // ERROR, what did u expect?
|
+ translateToLocal("structurelib.blockhint.desc.5")); // ERROR, what did u expect?
|
||||||
break;
|
break;
|
||||||
default: // WTF?
|
default: // WTF?
|
||||||
aList.add("Damn son where did you get that!?");
|
aList.add("Damn son where did you get that!?");
|
||||||
aList.add(EnumChatFormatting.BLUE.toString() + "From outer space... I guess...");
|
aList.add(EnumChatFormatting.BLUE + "From outer space... I guess...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,10 +45,6 @@ public abstract class AlignmentMessage implements IMessage {
|
|||||||
ByteBufUtils.writeTag(pBuffer, tFXTag);
|
ByteBufUtils.writeTag(pBuffer, tFXTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link com.gtnewhorizon.structurelib.structure.IStructureDefinition#check(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)}
|
|
||||||
* @param provider
|
|
||||||
*/
|
|
||||||
private AlignmentMessage(IAlignmentProvider provider) {
|
private AlignmentMessage(IAlignmentProvider provider) {
|
||||||
if (!(provider instanceof TileEntity)) throw new IllegalArgumentException("Provider must be a TileEntity");
|
if (!(provider instanceof TileEntity)) throw new IllegalArgumentException("Provider must be a TileEntity");
|
||||||
IAlignment alignment = provider.getAlignment();
|
IAlignment alignment = provider.getAlignment();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
public class SetChannelDataMessage implements IMessage {
|
public class SetChannelDataMessage implements IMessage {
|
||||||
private List<Map.Entry<String, Integer>> data = new ArrayList<>();
|
private final List<Map.Entry<String, Integer>> data = new ArrayList<>();
|
||||||
|
|
||||||
public SetChannelDataMessage() {}
|
public SetChannelDataMessage() {}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,238 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent the environment in which autoplace of a single element took place.
|
||||||
|
*/
|
||||||
|
public class AutoPlaceEnvironment {
|
||||||
|
private IItemSource source;
|
||||||
|
private final EntityPlayer actor;
|
||||||
|
private final Consumer<IChatComponent> chatter;
|
||||||
|
private final IStructureDefinition<?> definition;
|
||||||
|
private final String piece;
|
||||||
|
private final ExtendedFacing facing;
|
||||||
|
final int[] offsetABC;
|
||||||
|
private final int[] baseOffsetABC;
|
||||||
|
|
||||||
|
public static AutoPlaceEnvironment fromLegacy(
|
||||||
|
IItemSource source, EntityPlayer actor, Consumer<IChatComponent> chatter) {
|
||||||
|
if (source instanceof WrappedIItemSource) {
|
||||||
|
AutoPlaceEnvironment original = ((WrappedIItemSource) source).container;
|
||||||
|
// feels like this is extremely likely to cause issues, but this does allow us to recover lost info.
|
||||||
|
// TODO probably should remove this once all addons migrate over
|
||||||
|
if (actor != original.actor || chatter != original.chatter) {
|
||||||
|
AutoPlaceEnvironment newEnv = original;
|
||||||
|
if (actor != original.actor) newEnv = newEnv.withActor(actor);
|
||||||
|
if (chatter != original.chatter) newEnv = newEnv.withChatter(chatter);
|
||||||
|
return newEnv;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
return new AutoPlaceEnvironment(source, actor, chatter, null, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoPlaceEnvironment(
|
||||||
|
EntityPlayer actor,
|
||||||
|
Consumer<IChatComponent> chatter,
|
||||||
|
IStructureDefinition<?> definition,
|
||||||
|
String piece,
|
||||||
|
ExtendedFacing facing,
|
||||||
|
int[] baseOffsetABC) {
|
||||||
|
this.source = null;
|
||||||
|
this.actor = actor;
|
||||||
|
this.chatter = chatter;
|
||||||
|
this.definition = definition;
|
||||||
|
this.piece = piece;
|
||||||
|
this.facing = facing;
|
||||||
|
this.offsetABC = new int[3];
|
||||||
|
this.baseOffsetABC = baseOffsetABC;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoPlaceEnvironment(
|
||||||
|
IItemSource source,
|
||||||
|
EntityPlayer actor,
|
||||||
|
Consumer<IChatComponent> chatter,
|
||||||
|
IStructureDefinition<?> definition,
|
||||||
|
String piece,
|
||||||
|
ExtendedFacing facing,
|
||||||
|
int[] offsetABC,
|
||||||
|
int[] baseOffsetABC) {
|
||||||
|
this.source = definition != null && !(source instanceof WrappedIItemSource)
|
||||||
|
? new WrappedIItemSource(this, source)
|
||||||
|
: source;
|
||||||
|
this.actor = actor;
|
||||||
|
this.chatter = chatter;
|
||||||
|
this.definition = definition;
|
||||||
|
this.piece = piece;
|
||||||
|
this.facing = facing;
|
||||||
|
this.offsetABC = offsetABC;
|
||||||
|
this.baseOffsetABC = baseOffsetABC;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AutoPlaceEnvironment(AutoPlaceEnvironment parent) {
|
||||||
|
this(
|
||||||
|
parent.getSource(),
|
||||||
|
parent.getActor(),
|
||||||
|
parent.getChatter(),
|
||||||
|
parent.definition,
|
||||||
|
parent.piece,
|
||||||
|
parent.facing,
|
||||||
|
parent.offsetABC,
|
||||||
|
parent.baseOffsetABC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSource(IItemSource source) {
|
||||||
|
this.source = definition != null && !(source instanceof WrappedIItemSource)
|
||||||
|
? new WrappedIItemSource(this, source)
|
||||||
|
: source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APILevel getAPILevel() {
|
||||||
|
return definition == null
|
||||||
|
? actor instanceof EntityPlayerMP ? APILevel.Legacy : APILevel.LegacyRelaxed
|
||||||
|
: APILevel.V2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From where survival autoplace will drain resources.
|
||||||
|
*/
|
||||||
|
public IItemSource getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The initiator of actions. for very critical errors you can also just send the error messages here, bypassing
|
||||||
|
* any filter that {@link #getChatter()} might have. You might want to use
|
||||||
|
* {@link com.gtnewhorizon.structurelib.StructureLibAPI#addThrottledChat(Object, EntityPlayer, IChatComponent, short)}
|
||||||
|
* to help reduce spam.
|
||||||
|
*/
|
||||||
|
public EntityPlayer getActor() {
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* send error messages here. Caller will choose an appropriate way to forward it to player if the other fallbacks
|
||||||
|
* also fails.
|
||||||
|
*/
|
||||||
|
public Consumer<IChatComponent> getChatter() {
|
||||||
|
return chatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if given location is contained within the current piece.
|
||||||
|
*
|
||||||
|
* @param offsetA offset in A direction <b>relative to current element</b>
|
||||||
|
* @param offsetB offset in B direction <b>relative to current element</b>
|
||||||
|
* @param offsetC offset in C direction <b>relative to current element</b>
|
||||||
|
* @return true if contained, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isContainedInPiece(int offsetA, int offsetB, int offsetC) {
|
||||||
|
if (definition == null) return false;
|
||||||
|
return definition.isContainedInStructure(
|
||||||
|
piece,
|
||||||
|
offsetABC[0] + offsetA + baseOffsetABC[0],
|
||||||
|
offsetABC[1] + offsetB + baseOffsetABC[1],
|
||||||
|
offsetABC[2] + offsetC + baseOffsetABC[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedFacing getFacing() {
|
||||||
|
return facing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new instance with source modified to given value.
|
||||||
|
*
|
||||||
|
* @param source new source
|
||||||
|
* @return new instance
|
||||||
|
*/
|
||||||
|
public AutoPlaceEnvironment withSource(IItemSource source) {
|
||||||
|
return new AutoPlaceEnvironment(source, actor, chatter, definition, piece, facing, offsetABC, baseOffsetABC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new instance with actor modified to given value.
|
||||||
|
*
|
||||||
|
* @param actor new actor
|
||||||
|
* @return new instance
|
||||||
|
*/
|
||||||
|
public AutoPlaceEnvironment withActor(EntityPlayer actor) {
|
||||||
|
return new AutoPlaceEnvironment(source, actor, chatter, definition, piece, facing, offsetABC, baseOffsetABC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new instance with chatter modified to given value.
|
||||||
|
*
|
||||||
|
* @param chatter new chatter
|
||||||
|
* @return new instance
|
||||||
|
*/
|
||||||
|
public AutoPlaceEnvironment withChatter(Consumer<IChatComponent> chatter) {
|
||||||
|
return new AutoPlaceEnvironment(source, actor, chatter, definition, piece, facing, offsetABC, baseOffsetABC);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class WrappedIItemSource implements IItemSource {
|
||||||
|
final AutoPlaceEnvironment container;
|
||||||
|
final IItemSource delegate;
|
||||||
|
|
||||||
|
public WrappedIItemSource(AutoPlaceEnvironment container, IItemSource delegate) {
|
||||||
|
this.container = container;
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nonnull
|
||||||
|
public Map<ItemStack, Integer> take(Predicate<ItemStack> predicate, boolean simulate, int count) {
|
||||||
|
return delegate.take(predicate, simulate, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate) {
|
||||||
|
return delegate.takeOne(predicate, simulate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean takeAll(Predicate<ItemStack> predicate, boolean simulate, int count) {
|
||||||
|
return delegate.takeAll(predicate, simulate, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean takeOne(ItemStack stack, boolean simulate) {
|
||||||
|
return delegate.takeOne(stack, simulate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean takeAll(ItemStack stack, boolean simulate) {
|
||||||
|
return delegate.takeAll(stack, simulate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the various API level an {@link AutoPlaceEnvironment} has implemented.
|
||||||
|
* <p>
|
||||||
|
* Enum constants are defined in chronological order.
|
||||||
|
*/
|
||||||
|
public enum APILevel {
|
||||||
|
/**
|
||||||
|
* Implements {@link #getChatter()}, {@link #getActor()} and {@link #getSource()}.
|
||||||
|
* {@link #getActor()} is guaranteed to be an {@link net.minecraft.entity.player.EntityPlayerMP}
|
||||||
|
*/
|
||||||
|
Legacy,
|
||||||
|
/**
|
||||||
|
* Implements {@link #getChatter()}, {@link #getActor()} and {@link #getSource()}.
|
||||||
|
* {@link #getActor()} is <b>NOT</b> guaranteed to be an {@link net.minecraft.entity.player.EntityPlayerMP}
|
||||||
|
*/
|
||||||
|
LegacyRelaxed,
|
||||||
|
/**
|
||||||
|
* Implements everything so far we have defined.
|
||||||
|
*/
|
||||||
|
V2,
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
class DefaultSurvivalBuildEnvironment implements ISurvivalBuildEnvironment {
|
||||||
|
private final IItemSource source;
|
||||||
|
private final EntityPlayer actor;
|
||||||
|
|
||||||
|
public DefaultSurvivalBuildEnvironment(IItemSource source, EntityPlayer actor) {
|
||||||
|
this.source = source;
|
||||||
|
this.actor = actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IItemSource getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityPlayer getActor() {
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,19 +11,47 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent an item source. Take only, cannot be placed back.
|
||||||
|
*/
|
||||||
public interface IItemSource {
|
public interface IItemSource {
|
||||||
/**
|
/**
|
||||||
* We are probably not going to need to get a lot of items from this method
|
* Retrieve some amount of items from this item source matching given filter.
|
||||||
|
* <p>
|
||||||
|
* We probably don't need to get a lot of items from this method,
|
||||||
* so I don't care about the overhead of storing all fetched items even if downstream code doesn't need it
|
* so I don't care about the overhead of storing all fetched items even if downstream code doesn't need it
|
||||||
|
*
|
||||||
|
* @param predicate filtering predicate. should return true for ItemStacks that should be added to result collection
|
||||||
|
* @param simulate whether to actually commit the modification. true for dry run, false otherwise.
|
||||||
|
* @param count how many items to extract.
|
||||||
|
* @return A nonnull map reflecting the result of extraction. Note this map is NBT and metadata aware.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Map<ItemStack, Integer> take(Predicate<ItemStack> predicate, boolean simulate, int count);
|
Map<ItemStack, Integer> take(Predicate<ItemStack> predicate, boolean simulate, int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take exactly one item that matches the predicate.
|
||||||
|
*
|
||||||
|
* @param predicate filtering predicate. should return true for ItemStacks that should be added to result collection
|
||||||
|
* @param simulate whether to actually commit the modification. true for dry run, false otherwise.
|
||||||
|
* @return item stack, or null if none matches
|
||||||
|
* @throws IllegalArgumentException if given predicate is null.
|
||||||
|
*/
|
||||||
default ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate) {
|
default ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate) {
|
||||||
|
if (predicate == null) throw new IllegalArgumentException();
|
||||||
Map<ItemStack, Integer> take = take(predicate, simulate, 1);
|
Map<ItemStack, Integer> take = take(predicate, simulate, 1);
|
||||||
return take.isEmpty() ? null : take.keySet().iterator().next();
|
return take.isEmpty() ? null : take.keySet().iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take exactly count amount of items matching predicate.
|
||||||
|
*
|
||||||
|
* @param predicate filtering predicate. should return true for ItemStacks that should be added to result collection
|
||||||
|
* @param simulate whether to actually commit the modification. true for dry run, false otherwise.
|
||||||
|
* @param count how many items to extract.
|
||||||
|
* @return true if at least count amount of items can be/is taken.
|
||||||
|
* @throws IllegalArgumentException if given predicate is null
|
||||||
|
*/
|
||||||
default boolean takeAll(Predicate<ItemStack> predicate, boolean simulate, int count) {
|
default boolean takeAll(Predicate<ItemStack> predicate, boolean simulate, int count) {
|
||||||
// fast path for 1 item take requests
|
// fast path for 1 item take requests
|
||||||
if (count == 1) return takeOne(predicate, simulate) != null;
|
if (count == 1) return takeOne(predicate, simulate) != null;
|
||||||
@@ -33,22 +61,53 @@ public interface IItemSource {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take exactly one item. ItemStack given must have a stack size of 1.
|
||||||
|
* <p>
|
||||||
|
* This is meant to be an optimized version of {@link #takeOne(Predicate, boolean)}.
|
||||||
|
* Implementations that support item storage indexed by ItemStack can use this to speed up calculation.
|
||||||
|
*
|
||||||
|
* @param stack what item to extract. The NBT tag of this ItemStack is siginifcant and will be
|
||||||
|
* considered during matching. must have a stack size of 1.
|
||||||
|
* @param simulate whether to actually commit the modification. true for dry run, false otherwise.
|
||||||
|
* @return true if found. false otherwise
|
||||||
|
* @throws IllegalArgumentException if given stack is invalid, or has a stack size other than 1.
|
||||||
|
*/
|
||||||
default boolean takeOne(ItemStack stack, boolean simulate) {
|
default boolean takeOne(ItemStack stack, boolean simulate) {
|
||||||
if (stack == null || stack.getItem() == null || stack.stackSize != 1) throw new IllegalArgumentException();
|
if (stack == null || stack.getItem() == null || stack.stackSize != 1) throw new IllegalArgumentException();
|
||||||
ItemStack took = takeOne(ItemStackPredicate.from(stack, NBTMode.EXACT), simulate);
|
ItemStack took = takeOne(ItemStackPredicate.from(stack, NBTMode.EXACT), simulate);
|
||||||
return took == null || took.stackSize <= 0;
|
return took != null && took.stackSize > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take some item. Will not take item if it cannot find enough items to take.
|
||||||
|
* <p>
|
||||||
|
* This is meant to be an optimized version of {@link #takeOne(Predicate, boolean)}.
|
||||||
|
* Implementations that support indexing off ItemStack can use this to speed up calculation.
|
||||||
|
*
|
||||||
|
* @param stack what item and how many to extract. The NBT tag of this ItemStack is siginifcant and will be
|
||||||
|
* considered during matching
|
||||||
|
* @param simulate whether to actually commit the modification. true for dry run, false otherwise.
|
||||||
|
* @return true if enough item can be/has been extracted. false otherwise
|
||||||
|
* @throws IllegalArgumentException if given stack is invalid
|
||||||
|
*/
|
||||||
default boolean takeAll(ItemStack stack, boolean simulate) {
|
default boolean takeAll(ItemStack stack, boolean simulate) {
|
||||||
|
if (stack == null || stack.getItem() == null) throw new IllegalArgumentException();
|
||||||
// fast path for 1 item take requests
|
// fast path for 1 item take requests
|
||||||
if (stack.stackSize == 1) return takeOne(stack, simulate);
|
if (stack.stackSize == 1) return takeOne(stack, simulate);
|
||||||
ItemStackPredicate predicate = ItemStackPredicate.from(stack, NBTMode.EXACT);
|
ItemStackPredicate predicate = ItemStackPredicate.from(stack, NBTMode.EXACT);
|
||||||
Map<ItemStack, Integer> have = take(predicate, true, stack.stackSize);
|
Map<ItemStack, Integer> have = take(predicate, true, stack.stackSize);
|
||||||
if (have.values().stream().mapToInt(Integer::intValue).sum() < stack.stackSize) return false;
|
if (have.values().stream().mapToInt(Integer::intValue).sum() < stack.stackSize) return false;
|
||||||
take(predicate, simulate, stack.stackSize);
|
if (simulate) return true;
|
||||||
|
take(predicate, false, stack.stackSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an IItemSource from inventories associated with given player.
|
||||||
|
* <p>
|
||||||
|
* This will be backed by {@link InventoryUtility}
|
||||||
|
*/
|
||||||
static IItemSource fromPlayer(EntityPlayerMP player) {
|
static IItemSource fromPlayer(EntityPlayerMP player) {
|
||||||
return new IItemSource() {
|
return new IItemSource() {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -71,6 +130,11 @@ public interface IItemSource {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an IItemSource from given inventory
|
||||||
|
* <p>
|
||||||
|
* This will be backed by {@link InventoryUtility}
|
||||||
|
*/
|
||||||
static IItemSource fromInventory(IInventory inv) {
|
static IItemSource fromInventory(IInventory inv) {
|
||||||
return (p, s, c) -> InventoryUtility.takeFromInventory(new InventoryIterable<>(inv), p, s, c, true);
|
return (p, s, c) -> InventoryUtility.takeFromInventory(new InventoryIterable<>(inv), p, s, c, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import static com.gtnewhorizon.structurelib.structure.IStructureWalker.skipBlock
|
|||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLib;
|
import com.gtnewhorizon.structurelib.StructureLib;
|
||||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -55,6 +57,8 @@ public interface IStructureDefinition<T> {
|
|||||||
*/
|
*/
|
||||||
IStructureElement<T>[] getStructureFor(String name);
|
IStructureElement<T>[] getStructureFor(String name);
|
||||||
|
|
||||||
|
boolean isContainedInStructure(String name, int offsetA, int offsetB, int offsetC);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a structure check.
|
* Run a structure check.
|
||||||
* @param object context object. usually multiblock controller.
|
* @param object context object. usually multiblock controller.
|
||||||
@@ -141,7 +145,7 @@ public interface IStructureDefinition<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the multi in creative mode on a best effort basis. Does not guarantee the structure is correct after a
|
* Build the multi in creative mode on a best-effort basis. Does not guarantee the structure is correct after a
|
||||||
* successful call.
|
* successful call.
|
||||||
*
|
*
|
||||||
* @param object context object. usually multiblock controller.
|
* @param object context object. usually multiblock controller.
|
||||||
@@ -258,6 +262,7 @@ public interface IStructureDefinition<T> {
|
|||||||
* @return number of elements built, or -1 if structure done
|
* @return number of elements built, or -1 if structure done
|
||||||
* @see #build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
|
* @see #build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default int survivalBuild(
|
default int survivalBuild(
|
||||||
T object,
|
T object,
|
||||||
ItemStack trigger,
|
ItemStack trigger,
|
||||||
@@ -274,8 +279,78 @@ public interface IStructureDefinition<T> {
|
|||||||
IItemSource source,
|
IItemSource source,
|
||||||
EntityPlayerMP actor,
|
EntityPlayerMP actor,
|
||||||
boolean check) {
|
boolean check) {
|
||||||
SurvivalBuildStructureWalker<T> walker =
|
EntityPlayer realActor;
|
||||||
new SurvivalBuildStructureWalker<>(object, trigger, source, actor, elementBudget, check);
|
if (actor == null) {
|
||||||
|
realActor = ISurvivalConstructable.__get_player();
|
||||||
|
if (realActor == null) throw new IllegalArgumentException();
|
||||||
|
} else {
|
||||||
|
realActor = actor;
|
||||||
|
}
|
||||||
|
return survivalBuild(
|
||||||
|
object,
|
||||||
|
trigger,
|
||||||
|
piece,
|
||||||
|
world,
|
||||||
|
extendedFacing,
|
||||||
|
basePositionX,
|
||||||
|
basePositionY,
|
||||||
|
basePositionZ,
|
||||||
|
basePositionA,
|
||||||
|
basePositionB,
|
||||||
|
basePositionC,
|
||||||
|
elementBudget,
|
||||||
|
ISurvivalBuildEnvironment.create(source, realActor),
|
||||||
|
check);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cause a survival build.
|
||||||
|
*
|
||||||
|
* @param object context object. usually multiblock controller.
|
||||||
|
* @param trigger The trigger item that contains channel data.
|
||||||
|
* @param piece the structure piece's string identifier.
|
||||||
|
* @param world the world object this check takes place in.
|
||||||
|
* @param extendedFacing the current structure's orientation.
|
||||||
|
* @param basePositionX X location of the structure
|
||||||
|
* @param basePositionY Y location of the structure
|
||||||
|
* @param basePositionZ Z location of the structure
|
||||||
|
* @param basePositionA see class javadoc
|
||||||
|
* @param basePositionB see class javadoc
|
||||||
|
* @param basePositionC see class javadoc
|
||||||
|
* @param elementBudget build up to this many elements
|
||||||
|
* @param env build environment.
|
||||||
|
* @param check whether {@link IStructureElement#check(Object, World, int, int, int)} should be called if anything
|
||||||
|
* would be placed. use with caution.
|
||||||
|
* if in doubt, call {@link IStructureDefinition#check(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)}
|
||||||
|
* after this call and set this parameter to false
|
||||||
|
* @return number of elements built, or -1 if structure done
|
||||||
|
* @see #build(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int)
|
||||||
|
*/
|
||||||
|
default int survivalBuild(
|
||||||
|
T object,
|
||||||
|
ItemStack trigger,
|
||||||
|
String piece,
|
||||||
|
World world,
|
||||||
|
ExtendedFacing extendedFacing,
|
||||||
|
int basePositionX,
|
||||||
|
int basePositionY,
|
||||||
|
int basePositionZ,
|
||||||
|
int basePositionA,
|
||||||
|
int basePositionB,
|
||||||
|
int basePositionC,
|
||||||
|
int elementBudget,
|
||||||
|
ISurvivalBuildEnvironment env,
|
||||||
|
boolean check) {
|
||||||
|
SurvivalBuildStructureWalker<T> walker = new SurvivalBuildStructureWalker<>(
|
||||||
|
object,
|
||||||
|
trigger,
|
||||||
|
elementBudget,
|
||||||
|
env,
|
||||||
|
this,
|
||||||
|
piece,
|
||||||
|
extendedFacing,
|
||||||
|
new int[] {basePositionA, basePositionB, basePositionC},
|
||||||
|
check);
|
||||||
StructureUtility.iterateV2(
|
StructureUtility.iterateV2(
|
||||||
getStructureFor(piece),
|
getStructureFor(piece),
|
||||||
world,
|
world,
|
||||||
@@ -341,7 +416,7 @@ public interface IStructureDefinition<T> {
|
|||||||
basePositionA,
|
basePositionA,
|
||||||
basePositionB,
|
basePositionB,
|
||||||
basePositionC,
|
basePositionC,
|
||||||
(e, w, x, y, z) -> e.check(object, w, x, y, z),
|
(e, w, x, y, z, a, b, c) -> e.check(object, w, x, y, z),
|
||||||
"check");
|
"check");
|
||||||
} else {
|
} else {
|
||||||
success = StructureUtility.iterateV2(
|
success = StructureUtility.iterateV2(
|
||||||
@@ -354,7 +429,7 @@ public interface IStructureDefinition<T> {
|
|||||||
basePositionA,
|
basePositionA,
|
||||||
basePositionB,
|
basePositionB,
|
||||||
basePositionC,
|
basePositionC,
|
||||||
skipBlockUnloaded((e, w, x, y, z) -> e.check(object, w, x, y, z)),
|
skipBlockUnloaded((e, w, x, y, z, a, b, c) -> e.check(object, w, x, y, z)),
|
||||||
"check force");
|
"check force");
|
||||||
}
|
}
|
||||||
if (StructureLibAPI.isDebugEnabled() && success) {
|
if (StructureLibAPI.isDebugEnabled() && success) {
|
||||||
@@ -374,7 +449,7 @@ public interface IStructureDefinition<T> {
|
|||||||
basePositionA,
|
basePositionA,
|
||||||
basePositionB,
|
basePositionB,
|
||||||
basePositionC,
|
basePositionC,
|
||||||
ignoreBlockUnloaded((e, w, x, y, z) -> {
|
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
||||||
e.spawnHint(object, world, x, y, z, trigger);
|
e.spawnHint(object, world, x, y, z, trigger);
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
@@ -390,7 +465,7 @@ public interface IStructureDefinition<T> {
|
|||||||
basePositionA,
|
basePositionA,
|
||||||
basePositionB,
|
basePositionB,
|
||||||
basePositionC,
|
basePositionC,
|
||||||
ignoreBlockUnloaded((e, w, x, y, z) -> {
|
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
||||||
e.placeBlock(object, world, x, y, z, trigger);
|
e.placeBlock(object, world, x, y, z, trigger);
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
@@ -402,7 +477,6 @@ public interface IStructureDefinition<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of builder.
|
* Create a new instance of builder.
|
||||||
* @return
|
|
||||||
* @param <T> type of context object
|
* @param <T> type of context object
|
||||||
*/
|
*/
|
||||||
static <T> StructureDefinition.Builder<T> builder() {
|
static <T> StructureDefinition.Builder<T> builder() {
|
||||||
|
|||||||
@@ -4,15 +4,26 @@ import static com.gtnewhorizon.structurelib.StructureLib.LOGGER;
|
|||||||
import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
|
import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||||
|
import com.gtnewhorizon.structurelib.util.ItemStackPredicate;
|
||||||
|
import com.gtnewhorizon.structurelib.util.ItemStackPredicate.NBTMode;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use StructureUtility to instantiate
|
* Use StructureUtility to instantiate. These are the building blocks for your {@link IStructureDefinition}. It represents
|
||||||
|
* what a particular element can be and how this particular element should be autoplaced.
|
||||||
*/
|
*/
|
||||||
public interface IStructureElement<T> {
|
public interface IStructureElement<T> {
|
||||||
boolean check(T t, World world, int x, int y, int z);
|
boolean check(T t, World world, int x, int y, int z);
|
||||||
@@ -24,7 +35,7 @@ public interface IStructureElement<T> {
|
|||||||
/**
|
/**
|
||||||
* Try place the block by taking resource from given IItemSource.
|
* Try place the block by taking resource from given IItemSource.
|
||||||
* <p>
|
* <p>
|
||||||
* You might want to use {@link StructureUtility#survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, EntityPlayerMP)}
|
* You might want to use {@link StructureUtility#survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, net.minecraft.entity.player.EntityPlayer)}
|
||||||
* or its overloads to implement this.
|
* or its overloads to implement this.
|
||||||
*
|
*
|
||||||
* @param trigger trigger item
|
* @param trigger trigger item
|
||||||
@@ -33,7 +44,11 @@ public interface IStructureElement<T> {
|
|||||||
* any filter that chatter might have.
|
* any filter that chatter might have.
|
||||||
* @param chatter send error messages here. Caller will choose an appropriate way to forward it to player if the
|
* @param chatter send error messages here. Caller will choose an appropriate way to forward it to player if the
|
||||||
* other fallbacks also fails.
|
* other fallbacks also fails.
|
||||||
|
* @deprecated caller should call the non deprecated overload. implementor for reusable {@link IStructureElement}
|
||||||
|
* should still implement this. implementor for private implementations can freely ignore this as long as you know
|
||||||
|
* the caller will not call this overload.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default PlaceResult survivalPlaceBlock(
|
default PlaceResult survivalPlaceBlock(
|
||||||
T t,
|
T t,
|
||||||
World world,
|
World world,
|
||||||
@@ -53,6 +68,87 @@ public interface IStructureElement<T> {
|
|||||||
return PlaceResult.SKIP;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simplified version of survivalPlaceBlock. Return null if not implemented.
|
||||||
|
* <p>
|
||||||
|
* <b>BY OVERRIDING THIS TO NULL, YOU ACKNOWLEDGE THAT THE {@link #check(Object, World, int, int, int)} OF THIS
|
||||||
|
* CLASS IS SIDE EFFECT FREE AND CAN HAVE ITS CHECK CALLED WITHOUT BREAKING ANYTHING. OTHERWISE OVERRIDE THE
|
||||||
|
* {@link #survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)} TO PROVIDE A SIDEEFFECT
|
||||||
|
* FREE {@link PlaceResult#SKIP}.</b>
|
||||||
|
* <p>
|
||||||
|
* It should be noticed that this filter is only advisory and the actual {@link #survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
|
||||||
|
* or {@link #check(Object, World, int, int, int)} are free to reject/accept/place blocks not contained in this list,
|
||||||
|
* e.g. when the element can be placed anywhere in the structure, but no more than 3 overall; when the structure
|
||||||
|
* element cannot know all blocks it will accept at the time of calling; when this is backed by a legacy
|
||||||
|
* {@link IStructureElement} that just didn't implement this API.
|
||||||
|
*
|
||||||
|
* @param trigger trigger item
|
||||||
|
* @param env autoplacing environment
|
||||||
|
* @return null if not implemented, otherwise an instance describing what kind of blocks will be placed by {@link #survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
default BlocksToPlace getBlocksToPlace(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try place the block by taking resource from given {@link IItemSource}.
|
||||||
|
* <p>
|
||||||
|
* You might want to use {@link StructureUtility#survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, net.minecraft.entity.player.EntityPlayer)}
|
||||||
|
* or its overloads to implement this.
|
||||||
|
* <p>
|
||||||
|
* The default implementation provided will
|
||||||
|
* <ol>
|
||||||
|
* <li>Get {@link BlocksToPlace} via {@link #getBlocksToPlace(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}. If not null
|
||||||
|
* <ol>
|
||||||
|
* <li>call {@link #check(Object, World, int, int, int)}. If this returns {@code true}, {@link PlaceResult#SKIP} will be returned without further action.</li>
|
||||||
|
* <li>Use the {@link BlocksToPlace} retrieved earlier and passed in {@link IItemSource} to determine an item to place</li>
|
||||||
|
* <li>Hand over control to {@link StructureUtility#survivalPlaceBlock(ItemStack, NBTMode, NBTTagCompound, boolean, World, int, int, int, IItemSource, EntityPlayer, Consumer)}</li>
|
||||||
|
* </ol>
|
||||||
|
* </li>
|
||||||
|
* <li>Call legacy {@link #survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)} if {@code env.getActor()} contains an {@link EntityPlayerMP}</li>
|
||||||
|
* <li>Emit warning under debug mode (or throw exception under panic mode), then return {@link PlaceResult#SKIP}</li>
|
||||||
|
* </ol>
|
||||||
|
* It should be noticed that the default implementation is likely to cause unexpected issues if the
|
||||||
|
* {@link #check(Object, World, int, int, int)} is not side effect free, or is not idempotent.
|
||||||
|
* E.g. the {@link #check(Object, World, int, int, int)} will add current coord to a {@link java.util.List}. As
|
||||||
|
* this method might be invoked at a location that is already accepted, this will cause the machine to have multiple
|
||||||
|
* of this coord in its list.
|
||||||
|
*
|
||||||
|
* @param trigger trigger item
|
||||||
|
* @param env autoplacing environment
|
||||||
|
*/
|
||||||
|
default PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
BlocksToPlace e = getBlocksToPlace(t, world, x, y, z, trigger, env);
|
||||||
|
IItemSource source = env.getSource();
|
||||||
|
EntityPlayer actor = env.getActor();
|
||||||
|
Consumer<IChatComponent> chatter = env.getChatter();
|
||||||
|
if (e != null) {
|
||||||
|
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
|
||||||
|
if (e.getStacks() == null) {
|
||||||
|
ItemStack taken = source.takeOne(e.getPredicate(), true);
|
||||||
|
return StructureUtility.survivalPlaceBlock(
|
||||||
|
taken, NBTMode.EXACT, taken.stackTagCompound, true, world, x, y, z, source, actor, chatter);
|
||||||
|
}
|
||||||
|
for (ItemStack stack : e.getStacks()) {
|
||||||
|
if (!source.takeOne(stack, true)) continue;
|
||||||
|
return StructureUtility.survivalPlaceBlock(
|
||||||
|
stack, NBTMode.EXACT, stack.stackTagCompound, true, world, x, y, z, source, actor, chatter);
|
||||||
|
}
|
||||||
|
return PlaceResult.REJECT;
|
||||||
|
}
|
||||||
|
if (actor instanceof EntityPlayerMP)
|
||||||
|
return survivalPlaceBlock(t, world, x, y, z, trigger, source, (EntityPlayerMP) actor, chatter);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forget the messed up class dependency graph for now. this is just so convenient.
|
* Forget the messed up class dependency graph for now. this is just so convenient.
|
||||||
*/
|
*/
|
||||||
@@ -126,4 +222,82 @@ public interface IStructureElement<T> {
|
|||||||
*/
|
*/
|
||||||
ACCEPT_STOP;
|
ACCEPT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class BlocksToPlace {
|
||||||
|
public static final BlocksToPlace errored = createEmpty();
|
||||||
|
private final Predicate<ItemStack> predicate;
|
||||||
|
private final Iterable<ItemStack> stacks;
|
||||||
|
|
||||||
|
public static BlocksToPlace createEmpty() {
|
||||||
|
return new BlocksToPlace(s -> false, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(ItemStack... stacks) {
|
||||||
|
return create(Arrays.asList(stacks));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(Iterable<ItemStack> stacks) {
|
||||||
|
Predicate<ItemStack> predicate = null;
|
||||||
|
|
||||||
|
for (ItemStack stack : stacks) {
|
||||||
|
ItemStackPredicate p = ItemStackPredicate.from(stack, NBTMode.EXACT);
|
||||||
|
if (predicate == null) predicate = p;
|
||||||
|
else predicate = predicate.or(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BlocksToPlace(predicate, stacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(Block block, int meta) {
|
||||||
|
Item itemBlock = Item.getItemFromBlock(block);
|
||||||
|
if (itemBlock instanceof ISpecialItemBlock) {
|
||||||
|
meta = ((ISpecialItemBlock) itemBlock).getItemMetaFromBlockMeta(block, meta);
|
||||||
|
}
|
||||||
|
return create(itemBlock, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(Item item, int meta) {
|
||||||
|
return new BlocksToPlace(
|
||||||
|
ItemStackPredicate.from(item).setMeta(meta),
|
||||||
|
Collections.singletonList(new ItemStack(item, 1, meta)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(ItemStack itemStack) {
|
||||||
|
return new BlocksToPlace(ItemStackPredicate.from(itemStack), Collections.singletonList(itemStack));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlocksToPlace create(Predicate<ItemStack> predicate) {
|
||||||
|
return new BlocksToPlace(predicate, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlocksToPlace(Predicate<ItemStack> predicate, Iterable<ItemStack> stacks) {
|
||||||
|
this.predicate = predicate;
|
||||||
|
this.stacks = stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the blocks to place filter. This is usually slower as it requires walking through inventories one by one.
|
||||||
|
* <p>
|
||||||
|
* Suitable for use with {@link IItemSource#takeOne(Predicate, boolean)}
|
||||||
|
*
|
||||||
|
* @return a predicate. never null.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Predicate<ItemStack> getPredicate() {
|
||||||
|
return predicate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ItemStacks that this one is known to accept. Can be null if this info is not available at the time
|
||||||
|
* this instance is constructed.
|
||||||
|
* <p>
|
||||||
|
* Suitable for use with {@link IItemSource#takeOne(ItemStack, boolean)}.
|
||||||
|
* <p>
|
||||||
|
* This should be equivalent to the predicate returned from {@link #getPredicate()}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Iterable<ItemStack> getStacks() {
|
||||||
|
return stacks;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
@@ -44,6 +47,23 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
default BlocksToPlace getBlocksToPlace(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
Predicate<ItemStack> predicate = null;
|
||||||
|
List<Iterable<ItemStack>> is = new ArrayList<>();
|
||||||
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
|
BlocksToPlace e = fallback.getBlocksToPlace(t, world, x, y, z, trigger, env);
|
||||||
|
if (e == null) continue;
|
||||||
|
if (predicate == null) predicate = e.getPredicate();
|
||||||
|
else predicate = predicate.or(e.getPredicate());
|
||||||
|
is.add(e.getStacks());
|
||||||
|
}
|
||||||
|
if (predicate == null) return null;
|
||||||
|
return new BlocksToPlace(predicate, Iterables.concat(is));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default PlaceResult survivalPlaceBlock(
|
default PlaceResult survivalPlaceBlock(
|
||||||
T t,
|
T t,
|
||||||
@@ -74,4 +94,28 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
// TODO need reconsider to ensure this is the right course of action
|
// TODO need reconsider to ensure this is the right course of action
|
||||||
return haveSkip ? PlaceResult.SKIP : PlaceResult.REJECT;
|
return haveSkip ? PlaceResult.SKIP : PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
boolean haveSkip = false;
|
||||||
|
List<IChatComponent> bufferedNoise = new ArrayList<>();
|
||||||
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
|
PlaceResult result =
|
||||||
|
fallback.survivalPlaceBlock(t, world, x, y, z, trigger, env.withChatter(bufferedNoise::add));
|
||||||
|
switch (result) {
|
||||||
|
case REJECT:
|
||||||
|
break;
|
||||||
|
case SKIP:
|
||||||
|
haveSkip = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dump all that noise back into upstream
|
||||||
|
bufferedNoise.forEach(env.getChatter());
|
||||||
|
// TODO need reconsider to ensure this is the right course of action
|
||||||
|
return haveSkip ? PlaceResult.SKIP : PlaceResult.REJECT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -30,4 +30,10 @@ public interface IStructureElementCheckOnly<T> extends IStructureElement<T> {
|
|||||||
Consumer<IChatComponent> chatter) {
|
Consumer<IChatComponent> chatter) {
|
||||||
return PlaceResult.SKIP;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return PlaceResult.SKIP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+6
@@ -26,6 +26,12 @@ public interface IStructureElementNoPlacement<T> extends IStructureElement<T> {
|
|||||||
return PlaceResult.REJECT;
|
return PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return PlaceResult.REJECT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default IStructureElementNoPlacement<T> noPlacement() {
|
default IStructureElementNoPlacement<T> noPlacement() {
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ interface IStructureNavigate<T> extends IStructureElement<T> {
|
|||||||
return PlaceResult.SKIP;
|
return PlaceResult.SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return PlaceResult.SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
default boolean isNavigating() {
|
default boolean isNavigating() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,23 +2,25 @@ package com.gtnewhorizon.structurelib.structure;
|
|||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IStructureWalker<T> {
|
interface IStructureWalker<T> {
|
||||||
boolean visit(IStructureElement<T> element, World world, int x, int y, int z);
|
boolean visit(IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c);
|
||||||
|
|
||||||
default boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
default boolean blockNotLoaded(
|
||||||
|
IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T> IStructureWalker<T> ignoreBlockUnloaded(IStructureWalker<T> walker) {
|
static <T> IStructureWalker<T> ignoreBlockUnloaded(IStructureWalker<T> walker) {
|
||||||
return new IStructureWalker<T>() {
|
return new IStructureWalker<T>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
return walker.visit(element, world, x, y, z);
|
return walker.visit(element, world, x, y, z, a, b, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
public boolean blockNotLoaded(
|
||||||
return walker.visit(element, world, x, y, z);
|
IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
|
return walker.visit(element, world, x, y, z, a, b, c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -26,12 +28,13 @@ public interface IStructureWalker<T> {
|
|||||||
static <T> IStructureWalker<T> skipBlockUnloaded(IStructureWalker<T> walker) {
|
static <T> IStructureWalker<T> skipBlockUnloaded(IStructureWalker<T> walker) {
|
||||||
return new IStructureWalker<T>() {
|
return new IStructureWalker<T>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
return walker.visit(element, world, x, y, z);
|
return walker.visit(element, world, x, y, z, a, b, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
public boolean blockNotLoaded(
|
||||||
|
IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Architecture notes: this should never get any callback from survival build. All structure significant code belongs
|
||||||
|
* within the IStructureElement. This will make the user easier to maintain the IStructureDefinition.
|
||||||
|
* Structure Element knows the most about what this structure element should do, not the caller.
|
||||||
|
*/
|
||||||
|
public interface ISurvivalBuildEnvironment {
|
||||||
|
/**
|
||||||
|
* Get the source of the items. This will be invoked exactly once per structure element build.
|
||||||
|
* <p>
|
||||||
|
* If the call chain ever got into the old API, this will be called at least once per {@link IStructureDefinition#survivalBuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int, int, ISurvivalBuildEnvironment, boolean)} call.
|
||||||
|
*/
|
||||||
|
IItemSource getSource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the origin of action. This will be invoked at least once per {@link IStructureDefinition#survivalBuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int, int, ISurvivalBuildEnvironment, boolean)} call.
|
||||||
|
*/
|
||||||
|
EntityPlayer getActor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a default implementation with three parameters all being constants.
|
||||||
|
*
|
||||||
|
* @param source from where to drain resource
|
||||||
|
* @param actor source of action
|
||||||
|
*/
|
||||||
|
static ISurvivalBuildEnvironment create(IItemSource source, EntityPlayer actor) {
|
||||||
|
return new DefaultSurvivalBuildEnvironment(source, actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package com.gtnewhorizon.structurelib.structure;
|
|||||||
/**
|
/**
|
||||||
* Implement this and use {@link StructureUtility#withContext(IStructureElement)} in case you need to record some
|
* Implement this and use {@link StructureUtility#withContext(IStructureElement)} in case you need to record some
|
||||||
* temporary states that don't need to live in your main context, which would usually live for the whole lifetime of the
|
* temporary states that don't need to live in your main context, which would usually live for the whole lifetime of the
|
||||||
* structure than just during structure check. Usually just save some few bytes, but becomes non trivial if you need to
|
* structure than just during structure check. Usually just save some few bytes, but becomes non-trivial if you need to
|
||||||
* record too much stuff.
|
* record too much stuff.
|
||||||
* <p>
|
* <p>
|
||||||
* You will have to reset the context yourself though. The API can't guess when the old context becomes invalid.
|
* You will have to reset the context yourself though. The API can't guess when the old context becomes invalid.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.gtnewhorizon.structurelib.structure;
|
|||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
@@ -38,6 +39,13 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
|||||||
return get(t).spawnHint(t, world, x, y, z, trigger);
|
return get(t).spawnHint(t, world, x, y, z, trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlocksToPlace getBlocksToPlace(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return get(t).getBlocksToPlace(t, world, x, y, z, trigger, env);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlaceResult survivalPlaceBlock(
|
public PlaceResult survivalPlaceBlock(
|
||||||
T t,
|
T t,
|
||||||
@@ -51,4 +59,10 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
|||||||
Consumer<IChatComponent> chatter) {
|
Consumer<IChatComponent> chatter) {
|
||||||
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
|
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
|
||||||
|
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, env);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ package com.gtnewhorizon.structurelib.structure;
|
|||||||
|
|
||||||
import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
|
import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -11,6 +10,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
private final Map<Character, IStructureElement<T>> elements;
|
private final Map<Character, IStructureElement<T>> elements;
|
||||||
private final Map<String, String> shapes;
|
private final Map<String, String> shapes;
|
||||||
private final Map<String, IStructureElement<T>[]> structures;
|
private final Map<String, IStructureElement<T>[]> structures;
|
||||||
|
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
||||||
|
|
||||||
public static <B> Builder<B> builder() {
|
public static <B> Builder<B> builder() {
|
||||||
return new Builder<>();
|
return new Builder<>();
|
||||||
@@ -19,10 +19,12 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
private StructureDefinition(
|
private StructureDefinition(
|
||||||
Map<Character, IStructureElement<T>> elements,
|
Map<Character, IStructureElement<T>> elements,
|
||||||
Map<String, String> shapes,
|
Map<String, String> shapes,
|
||||||
Map<String, IStructureElement<T>[]> structures) {
|
Map<String, IStructureElement<T>[]> structures,
|
||||||
|
Map<String, Set<Vec3Impl>> occupiedSpaces) {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.shapes = shapes;
|
this.shapes = shapes;
|
||||||
this.structures = structures;
|
this.structures = structures;
|
||||||
|
this.occupiedSpaces = occupiedSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<T> {
|
public static class Builder<T> {
|
||||||
@@ -33,11 +35,13 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
private final Map<Vec3Impl, Character> navigates;
|
private final Map<Vec3Impl, Character> navigates;
|
||||||
private final Map<Character, IStructureElement<T>> elements;
|
private final Map<Character, IStructureElement<T>> elements;
|
||||||
private final Map<String, String> shapes;
|
private final Map<String, String> shapes;
|
||||||
|
private final Map<String, Set<Vec3Impl>> occupiedSpaces;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
navigates = new HashMap<>();
|
navigates = new HashMap<>();
|
||||||
elements = new HashMap<>();
|
elements = new HashMap<>();
|
||||||
shapes = new HashMap<>();
|
shapes = new HashMap<>();
|
||||||
|
occupiedSpaces = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Character, IStructureElement<T>> getElements() {
|
public Map<Character, IStructureElement<T>> getElements() {
|
||||||
@@ -49,18 +53,22 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds shape
|
* Adds shape. Shape is a two-dimensional string array. Each <b>character</b> inside any of these strings will
|
||||||
* + is anything but air
|
* be later mapped to a particular type of {@link IStructureElement} as indicated by {@link #addElement(Character, IStructureElement)}.
|
||||||
* - is air checks
|
|
||||||
* space bar is skip
|
|
||||||
* ~ is also skip (but marks controller position, optional and logically it is a space...)
|
|
||||||
* rest needs to be defined
|
|
||||||
* <p>
|
* <p>
|
||||||
* next char is next block(a)
|
* next char is next block(a)
|
||||||
* next string is next line(b)
|
* next string is next line(b)
|
||||||
* next string[] is next slice(c)
|
* next string[] is next slice(c)
|
||||||
* <p>
|
* <p>
|
||||||
* char A000-FFFF range is reserved for generated skips
|
* There are a few special reserved characters that are pre-mapped to some common structure elements
|
||||||
|
* <ul>
|
||||||
|
* <li>+ is anything but air</li>
|
||||||
|
* <li>- is air checks</li>
|
||||||
|
* <li>space bar is skip</li>
|
||||||
|
* <li>~ is also skip (but marks controller position, not optional)</li>
|
||||||
|
* <li>char {@code A000-FFFF} range is reserved for generated skips</li>
|
||||||
|
* </ul>
|
||||||
|
* <p>
|
||||||
*
|
*
|
||||||
* @param name unlocalized/code name
|
* @param name unlocalized/code name
|
||||||
* @param structurePiece generated or written struct - DO NOT STORE IT ANYWHERE, or at least set them to null afterwards
|
* @param structurePiece generated or written struct - DO NOT STORE IT ANYWHERE, or at least set them to null afterwards
|
||||||
@@ -80,22 +88,37 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
}
|
}
|
||||||
builder.setLength(builder.length() - 1);
|
builder.setLength(builder.length() - 1);
|
||||||
}
|
}
|
||||||
|
Set<Vec3Impl> occupiedSpace = new HashSet<>();
|
||||||
|
// these track the global current location
|
||||||
|
int aa = 0, bb = 0, cc = 0;
|
||||||
|
// these track the vec3 towards next meaningful element
|
||||||
int a = 0, b = 0, c = 0;
|
int a = 0, b = 0, c = 0;
|
||||||
|
// I do know these are pretty bad variable naming, but I have no better idea
|
||||||
for (int i = 0; i < builder.length(); i++) {
|
for (int i = 0; i < builder.length(); i++) {
|
||||||
char ch = builder.charAt(i);
|
char ch = builder.charAt(i);
|
||||||
if (ch == ' ' || ch == '~') {
|
if (ch == ' ') {
|
||||||
builder.setCharAt(i, A);
|
builder.setCharAt(i, A);
|
||||||
ch = A;
|
ch = A;
|
||||||
|
} else if (ch == '~') {
|
||||||
|
builder.setCharAt(i, A);
|
||||||
|
ch = A;
|
||||||
|
occupiedSpace.add(Vec3Impl.getFromPool(aa, bb, cc));
|
||||||
}
|
}
|
||||||
if (ch == A) {
|
if (ch == A) {
|
||||||
|
aa++;
|
||||||
a++;
|
a++;
|
||||||
} else if (ch == B) {
|
} else if (ch == B) {
|
||||||
|
aa = 0;
|
||||||
a = 0;
|
a = 0;
|
||||||
|
bb++;
|
||||||
b++;
|
b++;
|
||||||
} else if (ch == C) {
|
} else if (ch == C) {
|
||||||
|
aa = 0;
|
||||||
|
bb = 0;
|
||||||
a = 0;
|
a = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
c++;
|
c++;
|
||||||
|
cc++;
|
||||||
} else if (a != 0 || b != 0 || c != 0) {
|
} else if (a != 0 || b != 0 || c != 0) {
|
||||||
Vec3Impl vec3 = new Vec3Impl(a, b, c);
|
Vec3Impl vec3 = new Vec3Impl(a, b, c);
|
||||||
Character navigate = navigates.get(vec3);
|
Character navigate = navigates.get(vec3);
|
||||||
@@ -105,12 +128,19 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
addElement(navigate, step(vec3));
|
addElement(navigate, step(vec3));
|
||||||
}
|
}
|
||||||
builder.setCharAt(i - 1, navigate);
|
builder.setCharAt(i - 1, navigate);
|
||||||
|
occupiedSpace.add(Vec3Impl.getFromPool(aa, bb, cc));
|
||||||
|
aa++;
|
||||||
a = 0;
|
a = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
c = 0;
|
c = 0;
|
||||||
|
} else {
|
||||||
|
occupiedSpace.add(Vec3Impl.getFromPool(aa, bb, cc));
|
||||||
|
aa++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
occupiedSpaces.put(name, occupiedSpace);
|
||||||
|
|
||||||
String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]", "");
|
String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]", "");
|
||||||
|
|
||||||
if (built.contains("+")) {
|
if (built.contains("+")) {
|
||||||
@@ -123,18 +153,24 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use the unboxed version
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public Builder<T> addElement(Character name, IStructureElement<T> structurePiece) {
|
public Builder<T> addElement(Character name, IStructureElement<T> structurePiece) {
|
||||||
elements.putIfAbsent(name, structurePiece);
|
elements.putIfAbsent(name, structurePiece);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder<T> addElement(char name, IStructureElement<T> structurePiece) {
|
||||||
|
elements.putIfAbsent(name, structurePiece);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public IStructureDefinition<T> build() {
|
public IStructureDefinition<T> build() {
|
||||||
Map<String, IStructureElement<T>[]> structures = compileStructureMap();
|
Map<String, IStructureElement<T>[]> structures = compileStructureMap();
|
||||||
if (StructureLibAPI.isDebugEnabled()) {
|
return new StructureDefinition<>(
|
||||||
return new StructureDefinition<>(new HashMap<>(elements), new HashMap<>(shapes), structures);
|
new HashMap<>(elements), new HashMap<>(shapes), structures, occupiedSpaces);
|
||||||
} else {
|
|
||||||
return structures::get;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -194,4 +230,11 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
|
|||||||
if (elements == null) throw new NoSuchElementException(name);
|
if (elements == null) throw new NoSuchElementException(name);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isContainedInStructure(String name, int offsetA, int offsetB, int offsetC) {
|
||||||
|
Set<Vec3Impl> occupiedSpace = occupiedSpaces.get(name);
|
||||||
|
if (occupiedSpace == null) throw new NoSuchElementException(name);
|
||||||
|
return occupiedSpace.contains(new Vec3Impl(offsetA, offsetB, offsetC));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal bridge class for easing implementation
|
||||||
|
*/
|
||||||
|
abstract class StructureElement_Bridge<T> implements IStructureElement<T> {
|
||||||
|
// seal the deprecated method to prevent accidental overrides
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public final PlaceResult survivalPlaceBlock(
|
||||||
|
T t,
|
||||||
|
World world,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int z,
|
||||||
|
ItemStack trigger,
|
||||||
|
IItemSource s,
|
||||||
|
EntityPlayerMP actor,
|
||||||
|
Consumer<IChatComponent> chatter) {
|
||||||
|
return survivalPlaceBlock(t, world, x, y, z, trigger, AutoPlaceEnvironment.fromLegacy(s, actor, chatter));
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear the default implementation. we don't need that.
|
||||||
|
public abstract PlaceResult survivalPlaceBlock(
|
||||||
|
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
+31
-12
@@ -1,34 +1,53 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
import com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult;
|
import com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
||||||
private final T object;
|
final T object;
|
||||||
private final ItemStack trigger;
|
final ItemStack trigger;
|
||||||
private final IItemSource source;
|
|
||||||
private final EntityPlayerMP actor;
|
|
||||||
private final int elementBudget;
|
private final int elementBudget;
|
||||||
|
private final ISurvivalBuildEnvironment params;
|
||||||
private final boolean check;
|
private final boolean check;
|
||||||
private int built = -1;
|
private int built = -1;
|
||||||
|
|
||||||
|
private final AutoPlaceEnvironment env;
|
||||||
|
|
||||||
public SurvivalBuildStructureWalker(
|
public SurvivalBuildStructureWalker(
|
||||||
T object, ItemStack trigger, IItemSource source, EntityPlayerMP actor, int elementBudget, boolean check) {
|
T object,
|
||||||
|
ItemStack trigger,
|
||||||
|
int elementBudget,
|
||||||
|
ISurvivalBuildEnvironment params,
|
||||||
|
IStructureDefinition<?> definition,
|
||||||
|
String piece,
|
||||||
|
ExtendedFacing facing,
|
||||||
|
int[] baseOffsetABC,
|
||||||
|
boolean check) {
|
||||||
this.object = object;
|
this.object = object;
|
||||||
this.trigger = trigger;
|
this.trigger = trigger;
|
||||||
this.source = source;
|
|
||||||
this.actor = actor;
|
|
||||||
this.elementBudget = elementBudget;
|
this.elementBudget = elementBudget;
|
||||||
|
this.params = params;
|
||||||
this.check = check;
|
this.check = check;
|
||||||
|
|
||||||
|
env = new AutoPlaceEnvironment(
|
||||||
|
params.getActor(),
|
||||||
|
params.getActor()::addChatComponentMessage,
|
||||||
|
definition,
|
||||||
|
piece,
|
||||||
|
facing,
|
||||||
|
baseOffsetABC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||||
PlaceResult placeResult = element.survivalPlaceBlock(
|
env.offsetABC[0] = a;
|
||||||
object, world, x, y, z, trigger, source, actor, actor::addChatComponentMessage);
|
env.offsetABC[1] = b;
|
||||||
|
env.offsetABC[2] = c;
|
||||||
|
env.setSource(params.getSource());
|
||||||
|
PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, env);
|
||||||
if (placeResult != PlaceResult.SKIP && built == -1) built = 0;
|
if (placeResult != PlaceResult.SKIP && built == -1) built = 0;
|
||||||
switch (placeResult) {
|
switch (placeResult) {
|
||||||
case SKIP:
|
case SKIP:
|
||||||
@@ -37,7 +56,7 @@ class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
|||||||
if (check) element.check(object, world, x, y, z);
|
if (check) element.check(object, world, x, y, z);
|
||||||
return ++built < elementBudget;
|
return ++built < elementBudget;
|
||||||
case REJECT:
|
case REJECT:
|
||||||
StructureLibAPI.markHintParticleError(actor, world, x, y, z);
|
StructureLibAPI.markHintParticleError(params.getActor(), world, x, y, z);
|
||||||
return false;
|
return false;
|
||||||
case ACCEPT_STOP:
|
case ACCEPT_STOP:
|
||||||
if (check) element.check(object, world, x, y, z);
|
if (check) element.check(object, world, x, y, z);
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
package com.gtnewhorizon.structurelib.util;
|
package com.gtnewhorizon.structurelib.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import net.minecraft.dispenser.IPosition;
|
import net.minecraft.dispenser.IPosition;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class Vec3Impl implements Comparable<Vec3Impl> {
|
public class Vec3Impl implements Comparable<Vec3Impl> {
|
||||||
public static final Vec3Impl NULL_VECTOR = new Vec3Impl(0, 0, 0);
|
public static final Vec3Impl NULL_VECTOR = new Vec3Impl(0, 0, 0);
|
||||||
|
private static final Map<Vec3Impl, Vec3Impl> pool = new HashMap<>();
|
||||||
private final int val0;
|
private final int val0;
|
||||||
private final int val1;
|
private final int val1;
|
||||||
private final int val2;
|
private final int val2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* THIS WILL CAUSE THIS VECTOR TO PERMANENTLY RESIDE IN STATIC MEMORY. DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE
|
||||||
|
* DOING!!!
|
||||||
|
*/
|
||||||
|
public static Vec3Impl getFromPool(int in0, int in1, int in2) {
|
||||||
|
return pool.computeIfAbsent(new Vec3Impl(in0, in1, in2), Function.identity());
|
||||||
|
}
|
||||||
|
|
||||||
public Vec3Impl(int in0, int in1, int in2) {
|
public Vec3Impl(int in0, int in1, int in2) {
|
||||||
this.val0 = in0;
|
this.val0 = in0;
|
||||||
this.val1 = in1;
|
this.val1 = in1;
|
||||||
|
|||||||
@@ -97,6 +97,18 @@ StructureLib API documentation.
|
|||||||
breaking client code.
|
breaking client code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h2>{@link com.gtnewhorizon.structurelib.StructureEvent}</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 {@link com.gtnewhorizon.structurelib.StructureLibAPI#enableInstrument(Object)}.
|
||||||
|
To receive these events, register an event handler to {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
|
||||||
|
Handlers should filter the events received by {@link com.gtnewhorizon.structurelib.StructureEvent#getInstrumentIdentifier()}.
|
||||||
|
</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>
|
<h1>Important Concepts</h1>
|
||||||
<h2>Context Object</h2>
|
<h2>Context Object</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -231,5 +243,13 @@ public class MyHatchElement<T> implements IStructureElement<T> {
|
|||||||
|
|
||||||
The code for placeBlock() and spawnHint() will be left as an exercise for the reader.
|
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 {@link com.gtnewhorizon.structurelib.StructureEvent}
|
||||||
|
and its subclasses on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS forge main event bus}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Please refer to {@link com.gtnewhorizon.structurelib.StructureEvent} to see what events are available.
|
||||||
|
</p>
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.alignment.enumerable;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class ExtendedFacingTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ensureGetWorldDirectionDoesNotCrashNorReturnNull() {
|
||||||
|
for (ExtendedFacing ef : ExtendedFacing.VALUES) {
|
||||||
|
for (ForgeDirection src : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
|
assertNotNull(ef.getWorldDirection(src));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ensureGetWorldDirectionIsCorrect() {
|
||||||
|
assertEquals(ForgeDirection.DOWN, ExtendedFacing.EAST_NORMAL_NONE.getWorldDirection(ForgeDirection.UP));
|
||||||
|
assertEquals(ForgeDirection.DOWN, ExtendedFacing.NORTH_NORMAL_NONE.getWorldDirection(ForgeDirection.UP));
|
||||||
|
assertEquals(ForgeDirection.NORTH, ExtendedFacing.NORTH_NORMAL_NONE.getWorldDirection(ForgeDirection.NORTH));
|
||||||
|
assertEquals(ForgeDirection.NORTH, ExtendedFacing.NORTH_CLOCKWISE_NONE.getWorldDirection(ForgeDirection.NORTH));
|
||||||
|
assertEquals(ForgeDirection.DOWN, ExtendedFacing.NORTH_CLOCKWISE_NONE.getWorldDirection(ForgeDirection.EAST));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user