mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-24 05:44:36 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
392d2ace8a
commit
464e44de85
76 files changed
+1717
-1863
No files matched your search
@@ -1,8 +1,9 @@
|
||||
package com.gtnewhorizon.structurelib.alignment;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
class AlignmentLimits implements IAlignmentLimits {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
public class AlignmentUtility {
|
||||
|
||||
private AlignmentUtility() {}
|
||||
|
||||
public static boolean handle(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.gtnewhorizon.structurelib.alignment;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Direction;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
|
||||
int DIRECTIONS_COUNT = Direction.VALUES.length;
|
||||
int ROTATIONS_COUNT = Rotation.VALUES.length;
|
||||
int FLIPS_COUNT = Flip.VALUES.length;
|
||||
@@ -15,8 +17,8 @@ public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
ExtendedFacing getExtendedFacing();
|
||||
|
||||
/**
|
||||
* Set the facing without additional checks.
|
||||
* Tools altering facing should use {@link #toolSetExtendedFacing(ExtendedFacing)} instead.
|
||||
* Set the facing without additional checks. Tools altering facing should use
|
||||
* {@link #toolSetExtendedFacing(ExtendedFacing)} instead.
|
||||
*/
|
||||
void setExtendedFacing(ExtendedFacing alignment);
|
||||
|
||||
@@ -57,9 +59,8 @@ public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
|
||||
default boolean toolSetDirection(ForgeDirection direction) {
|
||||
if (direction == null || direction == ForgeDirection.UNKNOWN) {
|
||||
for (int i = 0, j = getDirection().ordinal() + 1, valuesLength = Direction.VALUES.length;
|
||||
i < valuesLength;
|
||||
i++) {
|
||||
for (int i = 0, j = getDirection().ordinal() + 1, valuesLength = Direction.VALUES.length; i
|
||||
< valuesLength; i++) {
|
||||
if (toolSetDirection(Direction.VALUES[(j + i) % valuesLength].getForgeDirection())) {
|
||||
return true;
|
||||
}
|
||||
@@ -97,8 +98,11 @@ public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
int rotations = Rotation.VALUES.length;
|
||||
for (int ii = 0, jj = getFlip().ordinal(); ii < flips; ii++) {
|
||||
for (int i = 1, j = getRotation().ordinal(); i < rotations; i++) {
|
||||
if (checkedSetExtendedFacing(ExtendedFacing.of(
|
||||
getDirection(), Rotation.VALUES[(j + i) % rotations], Flip.VALUES[(jj + ii) % flips]))) {
|
||||
if (checkedSetExtendedFacing(
|
||||
ExtendedFacing.of(
|
||||
getDirection(),
|
||||
Rotation.VALUES[(j + i) % rotations],
|
||||
Flip.VALUES[(jj + ii) % flips]))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -140,9 +144,8 @@ public interface IAlignment extends IAlignmentLimits, IAlignmentProvider {
|
||||
|
||||
default boolean toolSetExtendedFacing(ExtendedFacing extendedFacing) {
|
||||
if (extendedFacing == null) {
|
||||
for (int i = 0, j = getExtendedFacing().ordinal() + 1, valuesLength = ExtendedFacing.VALUES.length;
|
||||
i < valuesLength;
|
||||
i++) {
|
||||
for (int i = 0, j = getExtendedFacing().ordinal() + 1, valuesLength = ExtendedFacing.VALUES.length; i
|
||||
< valuesLength; i++) {
|
||||
if (checkedSetExtendedFacing(ExtendedFacing.VALUES[(j + i) % valuesLength])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,16 @@ package com.gtnewhorizon.structurelib.alignment;
|
||||
|
||||
import static com.gtnewhorizon.structurelib.alignment.IAlignment.STATES_COUNT;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
|
||||
|
||||
public interface IAlignmentLimits {
|
||||
|
||||
IAlignmentLimits UNLIMITED = (direction, rotation, flip) -> true;
|
||||
@@ -37,6 +39,7 @@ public interface IAlignmentLimits {
|
||||
}
|
||||
|
||||
class Builder {
|
||||
|
||||
protected final boolean[] validStates = new boolean[STATES_COUNT];
|
||||
|
||||
private Builder() {}
|
||||
@@ -54,15 +57,13 @@ public interface IAlignmentLimits {
|
||||
}
|
||||
|
||||
public Builder deny(ForgeDirection fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allow(ForgeDirection fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = true);
|
||||
return this;
|
||||
}
|
||||
@@ -78,29 +79,25 @@ public interface IAlignmentLimits {
|
||||
}
|
||||
|
||||
public Builder deny(Rotation fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allow(Rotation fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder deny(Flip fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder allow(Flip fd) {
|
||||
ExtendedFacing.getAllWith(fd).stream()
|
||||
.mapToInt(ExtendedFacing::getIndex)
|
||||
ExtendedFacing.getAllWith(fd).stream().mapToInt(ExtendedFacing::getIndex)
|
||||
.forEach(v -> validStates[v] = true);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gtnewhorizon.structurelib.alignment;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IAlignmentProvider {
|
||||
|
||||
@Nullable
|
||||
IAlignment getAlignment();
|
||||
}
|
||||
@@ -2,12 +2,14 @@ package com.gtnewhorizon.structurelib.alignment;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Direction;
|
||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.Direction;
|
||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||
|
||||
public class IntegerAxisSwap {
|
||||
|
||||
private final Vec3Impl forFirstAxis;
|
||||
private final Vec3Impl forSecondAxis;
|
||||
private final Vec3Impl forThirdAxis;
|
||||
@@ -20,61 +22,49 @@ public class IntegerAxisSwap {
|
||||
|| abs(this.forFirstAxis.get1()) + abs(this.forSecondAxis.get1()) + abs(this.forThirdAxis.get1()) != 1
|
||||
|| abs(this.forFirstAxis.get2()) + abs(this.forSecondAxis.get2()) + abs(this.forThirdAxis.get2())
|
||||
!= 1) {
|
||||
throw new IllegalArgumentException("Axis are overlapping/missing! " + forFirstAxis.name()
|
||||
+ " " + forSecondAxis.name()
|
||||
+ " " + forThirdAxis.name());
|
||||
throw new IllegalArgumentException(
|
||||
"Axis are overlapping/missing! " + forFirstAxis
|
||||
.name() + " " + forSecondAxis.name() + " " + forThirdAxis.name());
|
||||
}
|
||||
}
|
||||
|
||||
public Vec3Impl translate(Vec3Impl point) {
|
||||
return new Vec3Impl(
|
||||
forFirstAxis.get0() * point.get0()
|
||||
+ forFirstAxis.get1() * point.get1()
|
||||
forFirstAxis.get0() * point.get0() + forFirstAxis.get1() * point.get1()
|
||||
+ forFirstAxis.get2() * point.get2(),
|
||||
forSecondAxis.get0() * point.get0()
|
||||
+ forSecondAxis.get1() * point.get1()
|
||||
forSecondAxis.get0() * point.get0() + forSecondAxis.get1() * point.get1()
|
||||
+ forSecondAxis.get2() * point.get2(),
|
||||
forThirdAxis.get0() * point.get0()
|
||||
+ forThirdAxis.get1() * point.get1()
|
||||
forThirdAxis.get0() * point.get0() + forThirdAxis.get1() * point.get1()
|
||||
+ forThirdAxis.get2() * point.get2());
|
||||
}
|
||||
|
||||
public Vec3Impl inverseTranslate(Vec3Impl point) {
|
||||
return new Vec3Impl(
|
||||
forFirstAxis.get0() * point.get0()
|
||||
+ forSecondAxis.get0() * point.get1()
|
||||
forFirstAxis.get0() * point.get0() + forSecondAxis.get0() * point.get1()
|
||||
+ forThirdAxis.get0() * point.get2(),
|
||||
forFirstAxis.get1() * point.get0()
|
||||
+ forSecondAxis.get1() * point.get1()
|
||||
forFirstAxis.get1() * point.get0() + forSecondAxis.get1() * point.get1()
|
||||
+ forThirdAxis.get1() * point.get2(),
|
||||
forFirstAxis.get2() * point.get0()
|
||||
+ forSecondAxis.get2() * point.get1()
|
||||
forFirstAxis.get2() * point.get0() + forSecondAxis.get2() * point.get1()
|
||||
+ forThirdAxis.get2() * point.get2());
|
||||
}
|
||||
|
||||
public Vec3 translate(Vec3 point) {
|
||||
return Vec3.createVectorHelper(
|
||||
forFirstAxis.get0() * point.xCoord
|
||||
+ forFirstAxis.get1() * point.yCoord
|
||||
forFirstAxis.get0() * point.xCoord + forFirstAxis.get1() * point.yCoord
|
||||
+ forFirstAxis.get2() * point.zCoord,
|
||||
forSecondAxis.get0() * point.xCoord
|
||||
+ forSecondAxis.get1() * point.yCoord
|
||||
forSecondAxis.get0() * point.xCoord + forSecondAxis.get1() * point.yCoord
|
||||
+ forSecondAxis.get2() * point.zCoord,
|
||||
forThirdAxis.get0() * point.xCoord
|
||||
+ forThirdAxis.get1() * point.yCoord
|
||||
forThirdAxis.get0() * point.xCoord + forThirdAxis.get1() * point.yCoord
|
||||
+ forThirdAxis.get2() * point.zCoord);
|
||||
}
|
||||
|
||||
public Vec3 inverseTranslate(Vec3 point) {
|
||||
return Vec3.createVectorHelper(
|
||||
forFirstAxis.get0() * point.xCoord
|
||||
+ forSecondAxis.get0() * point.yCoord
|
||||
forFirstAxis.get0() * point.xCoord + forSecondAxis.get0() * point.yCoord
|
||||
+ forThirdAxis.get0() * point.zCoord,
|
||||
forFirstAxis.get1() * point.xCoord
|
||||
+ forSecondAxis.get1() * point.yCoord
|
||||
forFirstAxis.get1() * point.xCoord + forSecondAxis.get1() * point.yCoord
|
||||
+ forThirdAxis.get1() * point.zCoord,
|
||||
forFirstAxis.get2() * point.xCoord
|
||||
+ forSecondAxis.get2() * point.yCoord
|
||||
forFirstAxis.get2() * point.xCoord + forSecondAxis.get2() * point.yCoord
|
||||
+ forThirdAxis.get2() * point.zCoord);
|
||||
}
|
||||
|
||||
|
||||
+39
-46
@@ -3,23 +3,27 @@ package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||
import static com.gtnewhorizon.structurelib.util.MiscUtils.getTagKeys;
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
|
||||
/**
|
||||
* Provide accessor methods for channel data from trigger item.
|
||||
*
|
||||
* <a href="{@docRoot}/overview-summary.html#channels">Channels section on overview</a>
|
||||
*/
|
||||
public class ChannelDataAccessor {
|
||||
|
||||
private static final String SECONDARY_HINT_TAG = "channels";
|
||||
|
||||
private ChannelDataAccessor() {}
|
||||
@@ -27,29 +31,25 @@ public class ChannelDataAccessor {
|
||||
/**
|
||||
* Return a trigger item that
|
||||
* <ul>
|
||||
* <li>Still carry all the subchannel in some unspecified ways</li>
|
||||
* <li>Have its master channel data replaced with specified subchannel's data</li>
|
||||
* <li>Still carry all the subchannel in some unspecified ways</li>
|
||||
* <li>Have its master channel data replaced with specified subchannel's data</li>
|
||||
* </ul>
|
||||
*
|
||||
* If given subchannel does not exist, masterStack may or may not be returned to save performance.
|
||||
* Code within StructureLib can depend on this behavior, you cannot.
|
||||
* If given subchannel does not exist, masterStack may or may not be returned to save performance. Code within
|
||||
* StructureLib can depend on this behavior, you cannot.
|
||||
*
|
||||
* @param masterStack trigger item. can be the return value of another {@link #withChannel(ItemStack, String)} call
|
||||
* @param channel subchannel to use. will use current master channel data instead if this channel does not exist
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param channel subchannel to use. will use current master channel data instead if this channel does not exist
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @return a trigger item with new master channel
|
||||
*/
|
||||
public static ItemStack withChannel(ItemStack masterStack, String channel) {
|
||||
if (StringUtils.isEmpty(channel) || masterStack == null) throw new IllegalArgumentException();
|
||||
if (StructureLibAPI.isDebugEnabled()
|
||||
&& !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
if (StructureLibAPI.isDebugEnabled() && !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
throw new IllegalArgumentException("Channel name can be lower case ONLY");
|
||||
if (!masterStack.hasTagCompound()
|
||||
|| !masterStack.stackTagCompound.hasKey(SECONDARY_HINT_TAG, TAG_COMPOUND)
|
||||
|| !masterStack
|
||||
.stackTagCompound
|
||||
.getCompoundTag(SECONDARY_HINT_TAG)
|
||||
.hasKey(channel, NBT.TAG_INT)) return masterStack;
|
||||
if (!masterStack.hasTagCompound() || !masterStack.stackTagCompound.hasKey(SECONDARY_HINT_TAG, TAG_COMPOUND)
|
||||
|| !masterStack.stackTagCompound.getCompoundTag(SECONDARY_HINT_TAG).hasKey(channel, NBT.TAG_INT))
|
||||
return masterStack;
|
||||
ItemStack ret = new ItemStack(
|
||||
masterStack.getItem(),
|
||||
masterStack.stackTagCompound.getCompoundTag(SECONDARY_HINT_TAG).getInteger(channel),
|
||||
@@ -60,6 +60,7 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Check if given trigger item contains any subchannel
|
||||
*
|
||||
* @param masterStack trigger stack to check
|
||||
* @return true if contains any subchannel
|
||||
*/
|
||||
@@ -70,57 +71,47 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Check if given trigger item contains specified subchannel
|
||||
*
|
||||
* @param masterStack trigger stack to check
|
||||
* @param channel channel identifier.
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param channel channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @return true if contains specified subchannel
|
||||
*/
|
||||
public static boolean hasSubChannel(ItemStack masterStack, String channel) {
|
||||
if (StringUtils.isEmpty(channel) || masterStack == null) throw new IllegalArgumentException();
|
||||
if (StructureLibAPI.isDebugEnabled()
|
||||
&& !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
if (StructureLibAPI.isDebugEnabled() && !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
throw new IllegalArgumentException("Channel name can be lower case ONLY");
|
||||
return !channel.isEmpty()
|
||||
&& masterStack.hasTagCompound()
|
||||
return !channel.isEmpty() && masterStack.hasTagCompound()
|
||||
&& masterStack.stackTagCompound.hasKey(SECONDARY_HINT_TAG, TAG_COMPOUND)
|
||||
&& masterStack
|
||||
.stackTagCompound
|
||||
.getCompoundTag(SECONDARY_HINT_TAG)
|
||||
.hasKey(channel, NBT.TAG_INT);
|
||||
&& masterStack.stackTagCompound.getCompoundTag(SECONDARY_HINT_TAG).hasKey(channel, NBT.TAG_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subchannel data from given trigger item. Will use master channel instead if not present.
|
||||
*
|
||||
* @param masterStack trigger stack to query from
|
||||
* @param channel channel identifier.
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param channel channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @return channel data
|
||||
*/
|
||||
public static int getChannelData(ItemStack masterStack, String channel) {
|
||||
if (StringUtils.isEmpty(channel) || masterStack == null) throw new IllegalArgumentException();
|
||||
if (StructureLibAPI.isDebugEnabled()
|
||||
&& !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
if (StructureLibAPI.isDebugEnabled() && !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
throw new IllegalArgumentException("Channel name can be lower case ONLY");
|
||||
if (!masterStack.hasTagCompound()
|
||||
|| !masterStack.stackTagCompound.hasKey(SECONDARY_HINT_TAG, TAG_COMPOUND)
|
||||
|| !masterStack
|
||||
.stackTagCompound
|
||||
.getCompoundTag(SECONDARY_HINT_TAG)
|
||||
.hasKey(channel, NBT.TAG_INT)) return masterStack.stackSize;
|
||||
if (!masterStack.hasTagCompound() || !masterStack.stackTagCompound.hasKey(SECONDARY_HINT_TAG, TAG_COMPOUND)
|
||||
|| !masterStack.stackTagCompound.getCompoundTag(SECONDARY_HINT_TAG).hasKey(channel, NBT.TAG_INT))
|
||||
return masterStack.stackSize;
|
||||
return masterStack.stackTagCompound.getCompoundTag(SECONDARY_HINT_TAG).getInteger(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subchannel data on given trigger item
|
||||
*
|
||||
* @param masterStack trigger stack to check
|
||||
* @param channel channel identifier.
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param data subchannel data. should always be a positive value
|
||||
* @param channel channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param data subchannel data. should always be a positive value
|
||||
*/
|
||||
public static void setChannelData(ItemStack masterStack, String channel, int data) {
|
||||
if (StringUtils.isEmpty(channel) || masterStack == null) throw new IllegalArgumentException();
|
||||
if (StructureLibAPI.isDebugEnabled()
|
||||
&& !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
if (StructureLibAPI.isDebugEnabled() && !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
throw new IllegalArgumentException("Channel name can be lower case ONLY");
|
||||
if (data <= 0) throw new IllegalArgumentException();
|
||||
if (masterStack.stackTagCompound == null) masterStack.stackTagCompound = new NBTTagCompound();
|
||||
@@ -131,14 +122,13 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Clear the given subchannel from given trigger item, if it exists
|
||||
*
|
||||
* @param masterStack trigger stack to unset
|
||||
* @param channel channel identifier.
|
||||
* Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
* @param channel channel identifier. Note: all channel identifiers are supposed to be lower case and not empty.
|
||||
*/
|
||||
public static void unsetChannelData(ItemStack masterStack, String channel) {
|
||||
if (StringUtils.isEmpty(channel) || masterStack == null) throw new IllegalArgumentException();
|
||||
if (StructureLibAPI.isDebugEnabled()
|
||||
&& !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
if (StructureLibAPI.isDebugEnabled() && !channel.toLowerCase(Locale.ROOT).equals(channel))
|
||||
throw new IllegalArgumentException("Channel name can be lower case ONLY");
|
||||
if (masterStack.stackTagCompound == null) masterStack.stackTagCompound = new NBTTagCompound();
|
||||
NBTTagCompound main = masterStack.stackTagCompound;
|
||||
@@ -151,6 +141,7 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Wipe all subchannel data on given trigger item
|
||||
*
|
||||
* @param masterStack trigger stack to wipe
|
||||
*/
|
||||
public static void wipeChannelData(ItemStack masterStack) {
|
||||
@@ -160,10 +151,11 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Iterate over all subchannel data on trigger stack. Does not include master channel!!
|
||||
*
|
||||
* @param masterStack trigger stack to check
|
||||
* @return A java8 stream of pairs. Key is channel identifier and value is channel data. Pairs do not support
|
||||
* mutation nor removal. Can still cause {@link java.util.ConcurrentModificationException} if underlying channel
|
||||
* data is modified while stream is working.
|
||||
* mutation nor removal. Can still cause {@link java.util.ConcurrentModificationException} if underlying
|
||||
* channel data is modified while stream is working.
|
||||
*/
|
||||
public static Stream<Entry<String, Integer>> iterateChannelData(ItemStack masterStack) {
|
||||
if (!hasSubChannel(masterStack)) return Stream.empty();
|
||||
@@ -173,6 +165,7 @@ public class ChannelDataAccessor {
|
||||
|
||||
/**
|
||||
* Get the number of subchannels present on given trigger item. Does not include master channel.
|
||||
*
|
||||
* @param masterStack trigger stack to query from
|
||||
* @return subchannel count
|
||||
*/
|
||||
|
||||
+22
-21
@@ -1,13 +1,7 @@
|
||||
package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||
|
||||
import com.gtnewhorizon.structurelib.ConfigurationHandler;
|
||||
import com.gtnewhorizon.structurelib.StructureLib;
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,6 +11,14 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.structurelib.ConfigurationHandler;
|
||||
import com.gtnewhorizon.structurelib.StructureLib;
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
|
||||
|
||||
public class ConstructableUtility {
|
||||
|
||||
private static final WeakHashMap<EntityPlayerMP, Long> lastUse = new WeakHashMap<>();
|
||||
@@ -24,16 +26,16 @@ public class ConstructableUtility {
|
||||
|
||||
private ConstructableUtility() {}
|
||||
|
||||
public static boolean handle(
|
||||
ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) {
|
||||
public static boolean handle(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ,
|
||||
int aSide) {
|
||||
StructureLibAPI.startHinting(aWorld);
|
||||
boolean ret = handle0(aStack, aPlayer, aWorld, aX, aY, aZ, aSide);
|
||||
StructureLibAPI.endHinting(aWorld);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static boolean handle0(
|
||||
ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide) {
|
||||
private static boolean handle0(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ,
|
||||
int aSide) {
|
||||
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
|
||||
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
|
||||
return aPlayer instanceof EntityPlayerMP;
|
||||
@@ -44,9 +46,10 @@ public class ConstructableUtility {
|
||||
|
||||
long timePast = System.currentTimeMillis() - getLastUseMilis(aPlayer);
|
||||
if (timePast < ConfigurationHandler.INSTANCE.getAutoPlaceInterval()) {
|
||||
aPlayer.addChatComponentMessage(new ChatComponentTranslation(
|
||||
"item.structurelib.constructableTrigger.too_fast",
|
||||
ConfigurationHandler.INSTANCE.getAutoPlaceInterval() - timePast));
|
||||
aPlayer.addChatComponentMessage(
|
||||
new ChatComponentTranslation(
|
||||
"item.structurelib.constructableTrigger.too_fast",
|
||||
ConfigurationHandler.INSTANCE.getAutoPlaceInterval() - timePast));
|
||||
return true;
|
||||
}
|
||||
} else if (!StructureLib.isCurrentPlayer(aPlayer)) {
|
||||
@@ -59,8 +62,7 @@ public class ConstructableUtility {
|
||||
else if (tTileEntity instanceof IConstructable) {
|
||||
constructable = (IConstructable) tTileEntity;
|
||||
} else if (IMultiblockInfoContainer.contains(tTileEntity.getClass())) {
|
||||
ExtendedFacing facing = tTileEntity instanceof IAlignment
|
||||
? ((IAlignment) tTileEntity).getExtendedFacing()
|
||||
ExtendedFacing facing = tTileEntity instanceof IAlignment ? ((IAlignment) tTileEntity).getExtendedFacing()
|
||||
: ExtendedFacing.of(ForgeDirection.getOrientation(aSide));
|
||||
constructable = IMultiblockInfoContainer.<TileEntity>get(tTileEntity.getClass())
|
||||
.toConstructable(tTileEntity, facing);
|
||||
@@ -75,11 +77,10 @@ public class ConstructableUtility {
|
||||
if (aPlayer.capabilities.isCreativeMode) {
|
||||
constructable.construct(aStack, false);
|
||||
} else if (constructable instanceof ISurvivalConstructable) {
|
||||
int built = ((ISurvivalConstructable) constructable)
|
||||
.survivalConstruct(
|
||||
aStack,
|
||||
ConfigurationHandler.INSTANCE.getAutoPlaceBudget(),
|
||||
ISurvivalBuildEnvironment.create(IItemSource.fromPlayer(playerMP), playerMP));
|
||||
int built = ((ISurvivalConstructable) constructable).survivalConstruct(
|
||||
aStack,
|
||||
ConfigurationHandler.INSTANCE.getAutoPlaceBudget(),
|
||||
ISurvivalBuildEnvironment.create(IItemSource.fromPlayer(playerMP), playerMP));
|
||||
if (built > 0) {
|
||||
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.built_stat", built));
|
||||
} else if (built == -1) {
|
||||
|
||||
+4
-1
@@ -1,14 +1,17 @@
|
||||
package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by Tec on 24.03.2017.
|
||||
*/
|
||||
public interface IConstructable {
|
||||
|
||||
void construct(ItemStack stackSize, boolean hintsOnly);
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ import javax.annotation.Nullable;
|
||||
* Implement this interface if this tile entity MIGHT be constructable
|
||||
*/
|
||||
public interface IConstructableProvider {
|
||||
|
||||
/**
|
||||
* @return null if not constructable, an instance otherwise.
|
||||
*/
|
||||
|
||||
+19
-16
@@ -1,19 +1,23 @@
|
||||
package com.gtnewhorizon.structurelib.alignment.constructable;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* To implement IConstructable on not own TileEntities
|
||||
*/
|
||||
public interface IMultiblockInfoContainer<T> {
|
||||
|
||||
HashMap<String, IMultiblockInfoContainer<?>> MULTIBLOCK_MAP = new HashMap<>();
|
||||
|
||||
/**
|
||||
@@ -36,16 +40,13 @@ public interface IMultiblockInfoContainer<T> {
|
||||
void construct(ItemStack stackSize, boolean hintsOnly, T tileEntity, ExtendedFacing aSide);
|
||||
|
||||
/**
|
||||
* 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)}
|
||||
*
|
||||
* @return -1 if done, a helping pointer
|
||||
*/
|
||||
default int survivalConstruct(
|
||||
ItemStack stackSize,
|
||||
int elementBudge,
|
||||
IItemSource source,
|
||||
EntityPlayerMP actorProfile,
|
||||
T tileEntity,
|
||||
ExtendedFacing aSide) {
|
||||
default int survivalConstruct(ItemStack stackSize, int elementBudge, IItemSource source,
|
||||
EntityPlayerMP actorProfile, T tileEntity, ExtendedFacing aSide) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -58,6 +59,7 @@ public interface IMultiblockInfoContainer<T> {
|
||||
*/
|
||||
default IConstructable toConstructable(T tileEntity, ExtendedFacing aSide) {
|
||||
return new IConstructable() {
|
||||
|
||||
@Override
|
||||
public void construct(ItemStack stackSize, boolean hintsOnly) {
|
||||
IMultiblockInfoContainer.this.construct(stackSize, hintsOnly, tileEntity, aSide);
|
||||
@@ -70,12 +72,13 @@ public interface IMultiblockInfoContainer<T> {
|
||||
};
|
||||
}
|
||||
|
||||
static <T> ISurvivalConstructable toConstructable(
|
||||
IMultiblockInfoContainer<T> thiz, T tileEntity, ExtendedFacing aSide) {
|
||||
static <T> ISurvivalConstructable toConstructable(IMultiblockInfoContainer<T> thiz, T tileEntity,
|
||||
ExtendedFacing aSide) {
|
||||
return new ISurvivalConstructable() {
|
||||
|
||||
@Override
|
||||
public int survivalConstruct(
|
||||
ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) {
|
||||
public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source,
|
||||
EntityPlayerMP actor) {
|
||||
return thiz.survivalConstruct(stackSize, elementBudget, source, actor, tileEntity, aSide);
|
||||
}
|
||||
|
||||
|
||||
+19
-12
@@ -1,31 +1,35 @@
|
||||
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.ISurvivalBuildEnvironment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
|
||||
import com.gtnewhorizon.structurelib.structure.IItemSource;
|
||||
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* 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)}
|
||||
* or {@link com.gtnewhorizon.structurelib.structure.IStructureDefinition#survivalBuild(Object, ItemStack, String, World, ExtendedFacing, int, int, int, int, int, int, int, IItemSource, EntityPlayerMP, boolean)}
|
||||
* 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. 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
|
||||
@@ -38,14 +42,16 @@ public interface ISurvivalConstructable extends IConstructable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)}
|
||||
* 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
|
||||
* of elements placed this round
|
||||
*/
|
||||
default int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
|
||||
EntityPlayer actor = env.getActor();
|
||||
@@ -74,5 +80,6 @@ public interface ISurvivalConstructable extends IConstructable {
|
||||
}
|
||||
|
||||
class GlobalStates {
|
||||
|
||||
public static final ThreadLocal<EntityPlayer> entityPlayer = new ThreadLocal<>();
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.gtnewhorizon.structurelib.alignment.enumerable;
|
||||
|
||||
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 com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||
|
||||
public enum Direction {
|
||||
|
||||
DOWN(ForgeDirection.DOWN),
|
||||
UP(ForgeDirection.UP),
|
||||
NORTH(ForgeDirection.NORTH),
|
||||
@@ -18,8 +21,8 @@ public enum Direction {
|
||||
private final ForgeDirection forgeDirection;
|
||||
private final Vec3Impl axisVector;
|
||||
public static final Direction[] VALUES = values();
|
||||
private static final Map<Vec3Impl, Direction> reverseMap =
|
||||
Arrays.stream(VALUES).collect(Collectors.toMap(d -> d.axisVector, Function.identity()));
|
||||
private static final Map<Vec3Impl, Direction> reverseMap = Arrays.stream(VALUES)
|
||||
.collect(Collectors.toMap(d -> d.axisVector, Function.identity()));
|
||||
|
||||
Direction(ForgeDirection forgeDirection) {
|
||||
this.forgeDirection = forgeDirection;
|
||||
|
||||
+29
-26
@@ -6,16 +6,19 @@ import static java.lang.Math.abs;
|
||||
import static java.util.Arrays.stream;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
|
||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizon.structurelib.alignment.IAlignment;
|
||||
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
|
||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||
|
||||
public enum ExtendedFacing {
|
||||
|
||||
DOWN_NORMAL_NONE("down normal none"),
|
||||
DOWN_NORMAL_HORIZONTAL("down normal horizontal"),
|
||||
DOWN_NORMAL_VERTICAL("down normal vertical"),
|
||||
@@ -119,31 +122,31 @@ public enum ExtendedFacing {
|
||||
public static final int STATES_COUNT = VALUES.length;
|
||||
|
||||
static {
|
||||
stream(values())
|
||||
.forEach(extendedFacing ->
|
||||
FOR_FACING.compute(extendedFacing.direction, ((forgeDirection, extendedFacings) -> {
|
||||
if (extendedFacings == null) {
|
||||
extendedFacings = new ArrayList<>();
|
||||
}
|
||||
extendedFacings.add(extendedFacing);
|
||||
return extendedFacings;
|
||||
})));
|
||||
stream(values()).forEach(
|
||||
extendedFacing -> FOR_FACING.compute(extendedFacing.direction, ((forgeDirection, extendedFacings) -> {
|
||||
if (extendedFacings == null) {
|
||||
extendedFacings = new ArrayList<>();
|
||||
}
|
||||
extendedFacings.add(extendedFacing);
|
||||
return extendedFacings;
|
||||
})));
|
||||
}
|
||||
|
||||
private static final Map<String, ExtendedFacing> NAME_LOOKUP =
|
||||
stream(VALUES).collect(toMap(ExtendedFacing::getName2, (extendedFacing) -> extendedFacing));
|
||||
private static final Map<String, ExtendedFacing> NAME_LOOKUP = stream(VALUES)
|
||||
.collect(toMap(ExtendedFacing::getName2, (extendedFacing) -> extendedFacing));
|
||||
private static final EnumMap<ForgeDirection, ImmutableSet<ExtendedFacing>> LOOKUP_BY_DIRECTION = stream(VALUES)
|
||||
.collect(groupingBy(
|
||||
ExtendedFacing::getDirection,
|
||||
() -> new EnumMap<>(ForgeDirection.class),
|
||||
collectingAndThen(toSet(), ImmutableSet::copyOf)));
|
||||
private static final EnumMap<Rotation, ImmutableSet<ExtendedFacing>> LOOKUP_BY_ROTATION = stream(VALUES)
|
||||
.collect(groupingBy(
|
||||
.collect(
|
||||
groupingBy(
|
||||
ExtendedFacing::getDirection,
|
||||
() -> new EnumMap<>(ForgeDirection.class),
|
||||
collectingAndThen(toSet(), ImmutableSet::copyOf)));
|
||||
private static final EnumMap<Rotation, ImmutableSet<ExtendedFacing>> LOOKUP_BY_ROTATION = stream(VALUES).collect(
|
||||
groupingBy(
|
||||
ExtendedFacing::getRotation,
|
||||
() -> new EnumMap<>(Rotation.class),
|
||||
collectingAndThen(toSet(), ImmutableSet::copyOf)));
|
||||
private static final EnumMap<Flip, ImmutableSet<ExtendedFacing>> LOOKUP_BY_FLIP = stream(VALUES)
|
||||
.collect(groupingBy(
|
||||
private static final EnumMap<Flip, ImmutableSet<ExtendedFacing>> LOOKUP_BY_FLIP = stream(VALUES).collect(
|
||||
groupingBy(
|
||||
ExtendedFacing::getFlip,
|
||||
() -> new EnumMap<>(Flip.class),
|
||||
collectingAndThen(toSet(), ImmutableSet::copyOf)));
|
||||
@@ -333,7 +336,7 @@ public enum ExtendedFacing {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates relative to front facing offset to world offset
|
||||
* Translates relative to front facing offset to world offset
|
||||
*
|
||||
* @param abcOffset A,B,C offset (facing relative {@code L-->R,U-->D,F-->B})
|
||||
* @return X, Y, Z offset in world
|
||||
@@ -377,10 +380,10 @@ public enum ExtendedFacing {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates world offset to relative front facing offset
|
||||
* Translates world offset to relative front facing offset
|
||||
*
|
||||
* @param xyzOffset X,Y,Z offset in world
|
||||
* @return A, B, C offset (facing relative {@code L-->R,U-->D,F-->B})
|
||||
* @return A, B, C offset (facing relative {@code L-->R,U-->D,F-->B})
|
||||
*/
|
||||
public Vec3 getOffsetABC(Vec3 xyzOffset) {
|
||||
return integerAxisSwap.translate(xyzOffset);
|
||||
|
||||
@@ -7,9 +7,11 @@ import static java.util.stream.Collectors.toMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum Flip {
|
||||
|
||||
NONE(3, "none"),
|
||||
HORIZONTAL(2, "horizontal"),
|
||||
VERTICAL(1, "vertical"),
|
||||
|
||||
@@ -7,9 +7,11 @@ import static java.util.stream.Collectors.toMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum Rotation {
|
||||
|
||||
NORMAL(2, "normal"),
|
||||
CLOCKWISE(3, "clockwise"),
|
||||
UPSIDE_DOWN(0, "upside down"),
|
||||
@@ -19,8 +21,8 @@ public enum Rotation {
|
||||
private final String name;
|
||||
|
||||
public static final Rotation[] VALUES = values();
|
||||
private static final Map<String, Rotation> NAME_LOOKUP =
|
||||
stream(VALUES).collect(toMap(Rotation::getName2, (rotation) -> rotation));
|
||||
private static final Map<String, Rotation> NAME_LOOKUP = stream(VALUES)
|
||||
.collect(toMap(Rotation::getName2, (rotation) -> rotation));
|
||||
|
||||
Rotation(int oppositeIn, String nameIn) {
|
||||
this.opposite = oppositeIn;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* This package provide a framework for rotating a given block, or a multiblock structure.
|
||||
* <p>
|
||||
* All public stuff in this package and its subpackages are considered part of the public API.
|
||||
* Backwards compatibility is maintained to the maximum extend possible.
|
||||
* All public stuff in this package and its subpackages are considered part of the public API. Backwards compatibility
|
||||
* is maintained to the maximum extend possible.
|
||||
*/
|
||||
package com.gtnewhorizon.structurelib.alignment;
|
||||
Reference in new issue
Block a user