Compare commits

...
6 Commits
Author SHA1 Message Date
Glease 23605fc22d fix particles not sorted when rendering
some experimental code left in during initial rework...
2022-09-09 19:48:12 +08:00
Glease 8ee90a7338 fix crash upon opening hologram gui 2022-09-09 18:09:59 +08:00
Glease 9bd19b9254 fix frustrum culling using wrong bounding box 2022-09-09 17:43:12 +08:00
Glease df4c54ea8d address inspections 2022-09-06 16:34:46 +08:00
くぁーりぃ e71edd50b0 Allow client to auto build multiblocks (#12) 2022-09-05 19:42:57 +08:00
iouterandGlease 1b7cee7c4e Update zh_CN.lang (#11)
Co-authored-by: Glease <[email protected]>
2022-09-03 16:14:16 +08:00
16 changed files with 136 additions and 129 deletions

No files matched your search

@@ -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;
}
}
@@ -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(
@@ -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
@@ -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() {}
@@ -11,19 +11,32 @@ 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 * We are probably not going to 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
*/ */
@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.
*
* @return item stack, or null if none matches
*/
default ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate) { default ItemStack takeOne(Predicate<ItemStack> predicate, boolean simulate) {
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.
*
* @return true if at least count amount of items can be/is taken.
*/
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 +46,38 @@ public interface IItemSource {
return true; return true;
} }
/**
* Take exactly one item. ItemStack given must have a stack size of 1.
*
* @return true if found. false otherwise
*/
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.
*
* @return true if enough item can be/has been extracted. false otherwise
*/
default boolean takeAll(ItemStack stack, boolean simulate) { default boolean takeAll(ItemStack stack, boolean simulate) {
// 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 +100,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);
} }
@@ -141,7 +141,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.
@@ -324,7 +324,7 @@ public interface IStructureDefinition<T> {
int basePositionC, int basePositionC,
boolean hintsOnly, boolean hintsOnly,
Boolean checkBlocksIfNotNullForceCheckAllIfTrue) { Boolean checkBlocksIfNotNullForceCheckAllIfTrue) {
if (world.isRemote ^ hintsOnly) { if (!world.isRemote && hintsOnly) {
return false; return false;
} }
@@ -402,7 +402,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() {
@@ -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.
@@ -53,7 +53,7 @@ public class StructureDefinition<T> implements IStructureDefinition<T> {
* + is anything but air * + is anything but air
* - is air checks * - is air checks
* space bar is skip * space bar is skip
* ~ is also skip (but marks controller position, optional and logically it is a space...) * ~ is also skip (but marks controller position, optional. implementation wise it is a space...)
* rest needs to be defined * rest needs to be defined
* <p> * <p>
* next char is next block(a) * next char is next block(a)
@@ -1947,6 +1947,7 @@ public class StructureUtility {
* @deprecated renamed to partitionBy * @deprecated renamed to partitionBy
*/ */
@SafeVarargs @SafeVarargs
@Deprecated
public static <T> IStructureElementDeferred<T> defer( public static <T> IStructureElementDeferred<T> defer(
Function<T, Integer> keyExtractor, IStructureElement<T>... array) { Function<T, Integer> keyExtractor, IStructureElement<T>... array) {
return partitionBy(keyExtractor, array); return partitionBy(keyExtractor, array);
@@ -2015,7 +2016,7 @@ public class StructureUtility {
* @param array all possible structure element * @param array all possible structure element
* @deprecated renamed to partitionBy * @deprecated renamed to partitionBy
*/ */
@SuppressWarnings("unchecked") @Deprecated
public static <T> IStructureElementDeferred<T> defer( public static <T> IStructureElementDeferred<T> defer(
Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) { Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) {
return partitionBy(keyExtractor, array); return partitionBy(keyExtractor, array);
@@ -2036,7 +2037,7 @@ public class StructureUtility {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> IStructureElementDeferred<T> partitionBy( public static <T> IStructureElementDeferred<T> partitionBy(
Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) { Function<T, Integer> keyExtractor, List<IStructureElement<T>> array) {
return defer(keyExtractor, array.toArray(new IStructureElement[0])); return partitionBy(keyExtractor, array.toArray(new IStructureElement[0]));
} }
/** /**
@@ -2568,6 +2569,7 @@ public class StructureUtility {
* @deprecated renamed to partitionBy * @deprecated renamed to partitionBy
*/ */
@SafeVarargs @SafeVarargs
@Deprecated
public static <T> IStructureElementDeferred<T> defer( public static <T> IStructureElementDeferred<T> defer(
Function<T, Integer> keyExtractorCheck, Function<T, Integer> keyExtractorCheck,
BiFunction<T, ItemStack, Integer> keyExtractor, BiFunction<T, ItemStack, Integer> keyExtractor,
@@ -2651,7 +2653,7 @@ public class StructureUtility {
* @param array all possible structure element * @param array all possible structure element
* @deprecated renamed to partitionBy * @deprecated renamed to partitionBy
*/ */
@SuppressWarnings("unchecked") @Deprecated
public static <T> IStructureElementDeferred<T> defer( public static <T> IStructureElementDeferred<T> defer(
Function<T, Integer> keyExtractorCheck, Function<T, Integer> keyExtractorCheck,
BiFunction<T, ItemStack, Integer> keyExtractor, BiFunction<T, ItemStack, Integer> keyExtractor,
@@ -2680,7 +2682,7 @@ public class StructureUtility {
Function<T, Integer> keyExtractorCheck, Function<T, Integer> keyExtractorCheck,
BiFunction<T, ItemStack, Integer> keyExtractor, BiFunction<T, ItemStack, Integer> keyExtractor,
List<IStructureElement<T>> array) { List<IStructureElement<T>> array) {
return defer(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0])); return partitionBy(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0]));
} }
// endregion // endregion
@@ -28,7 +28,7 @@ item.structurelib.constructableTrigger.desc.3= (潜行右键可以直接完成
item.structurelib.constructableTrigger.desc.4=此物品堆叠数量会影响显示的机器等级/模式/类型 item.structurelib.constructableTrigger.desc.4=此物品堆叠数量会影响显示的机器等级/模式/类型
item.structurelib.constructableTrigger.desc.5=按下 §l[左SHIFT]§r 以显示子信道 item.structurelib.constructableTrigger.desc.5=按下 §l[左SHIFT]§r 以显示子信道
item.structurelib.constructableTrigger.desc.lshift.0=包含 %d 个子信道 item.structurelib.constructableTrigger.desc.lshift.0=包含 %d 个子信道
item.structurelib.constructableTrigger.too_fast=请在下一次自动搭建前等待%d毫秒... item.structurelib.constructableTrigger.too_fast=请在下一次自动搭建前等待 %d 毫秒...
item.structurelib.constructableTrigger.gui.key=信道名: item.structurelib.constructableTrigger.gui.key=信道名:
item.structurelib.constructableTrigger.gui.value=值: item.structurelib.constructableTrigger.gui.value=值:
item.structurelib.constructableTrigger.gui.add=添加 item.structurelib.constructableTrigger.gui.add=添加
@@ -39,8 +39,9 @@ item.structurelib.constructableTrigger.gui.wipe=§4全部清空
structurelib.autoplace.built_stat=已放置 %s 个方块 structurelib.autoplace.built_stat=已放置 %s 个方块
structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建! structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建!
structurelib.autoplace.error.not_enabled=§c这个多方块结构不支持在生存模式下自动搭建! structurelib.autoplace.error.not_enabled=§c这个多方块结构不支持在生存模式下自动搭建!
structurelib.autoplace.error.no_simple_block=§c建议放置§r%s§c,但没有找到它 structurelib.autoplace.error.no_simple_block=§c建议放置 §r%s§c ,但没有找到它
structurelib.autoplace.error.no_item_stack=§c建议使用§r%s§c放置方块,但没有找到它 structurelib.autoplace.error.no_item_stack=§c建议使用 §r%s§c 放置方块,但没有找到它
structurelib.autoplace.warning.no_explicit_channel=§6这个结构依赖于不存在的子信道 §r%s§6 。已使用主信道值替代。
structurelib.blockhint.desc.0=帮助你搭建机器 structurelib.blockhint.desc.0=帮助你搭建机器
structurelib.blockhint.0.name=提示方块:1号 structurelib.blockhint.0.name=提示方块:1号