Skip to content

Commit

Permalink
add nei as runtime
Browse files Browse the repository at this point in the history
make "transpose" not actually transpose but just compact the text
  • Loading branch information
botn365 committed Apr 18, 2024
1 parent 99c42b5 commit 5bf4ad7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
5 changes: 4 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ dependencies {
compileOnly("org.projectlombok:lombok:1.18.22")
annotationProcessor("org.projectlombok:lombok:1.18.24")

compileOnly("mega:carpentersblocks-mc1.7.10:3.3.10-mega:dev")
implementation("codechicken:notenoughitems-mc1.7.10:2.1.6-gtmega:dev")
implementation("codechicken:codechickencore-mc1.7.10:1.3.0-mega:dev")

implementation("mega:carpentersblocks-mc1.7.10:3.3.10-mega:dev")

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
Expand All @@ -31,6 +32,9 @@ public enum Mode {
@SideOnly(Side.CLIENT)
private IIcon eraserIcon;

Vec3Impl pos1;
Vec3Impl pos2;

private static final String TAG_POS_1 = "pos1";
private static final String TAG_POS_2 = "pos2";
private static final String TAG_POS_CONTROLLER = "pos3";
Expand Down Expand Up @@ -82,55 +86,29 @@ public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World wo

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
Mode mode = readModeFromNBT(itemStack);
switch (mode) {
case Build:
case Clear:
case Refresh:
doStuff(itemStack, world, Vec3Impl.NULL_VECTOR, player);
}
doStuff(itemStack, world, Vec3Impl.NULL_VECTOR, player);
return itemStack;
}

private void doStuff(ItemStack itemStack, World world, Vec3Impl pos, EntityPlayer player) {
int index = player.isSneaking() ? 1 : 0;

Mode mode = readModeFromNBT(itemStack);

switch (mode) {
case SetCorners:
writePosToNBT(itemStack, pos, index == 0 ? TAG_POS_1 : TAG_POS_2);

if (world.isRemote) {
StructureLibAPI.hintParticleTinted(world, pos.get0(), pos.get1(), pos.get2(), getBlockHint(), index, new short[]{255, 0, 255});
}
case Refresh:
Vec3Impl pos1 = readPosFromNBT(itemStack, TAG_POS_1);
Vec3Impl pos2 = readPosFromNBT(itemStack, TAG_POS_2);

if (pos1 != null && pos2 != null) {
Box box = new Box(pos1, pos2);
box.drawBoundingBox(world);
}
break;
case SetController:
writePosToNBT(itemStack, pos, TAG_POS_CONTROLLER);
break;
case Build:
writeStructure(itemStack, player);
break;
case Clear:
itemStack.setTagCompound(null);
writeModeToNBT(itemStack, mode);
StructureLib.proxy.clearHints(world);
break;
if (pos1 == null) {
pos1 = pos;
player.addChatMessage(new ChatComponentText("Set Position 1"));
StructureLibAPI.hintParticleTinted(world, pos.get0(), pos.get1(), pos.get2(), getBlockHint(), 0, new short[]{255, 0, 255});
} else if (pos2 == null) {
pos2 = pos;
player.addChatMessage(new ChatComponentText("Set Position 2"));
StructureLibAPI.hintParticleTinted(world, pos.get0(), pos.get1(), pos.get2(), getBlockHint(), 1, new short[]{255, 0, 255});
} else {
writeStructure(itemStack, player,pos1,pos2,pos);
player.addChatMessage(new ChatComponentText("Writing Structure To Logs"));
StructureLib.proxy.clearHints(world);
pos1 = null;
pos2 = null;
}
}

private void writeStructure(ItemStack itemStack, EntityPlayer player) {
Vec3Impl pos1 = readPosFromNBT(itemStack, TAG_POS_1);
Vec3Impl pos2 = readPosFromNBT(itemStack, TAG_POS_2);
Vec3Impl posController = readPosFromNBT(itemStack, TAG_POS_CONTROLLER);
private void writeStructure(ItemStack itemStack, EntityPlayer player,Vec3Impl pos1, Vec3Impl pos2, Vec3Impl posController) {

if (pos1 == null || pos2 == null || posController == null) {
return;
Expand All @@ -140,6 +118,8 @@ private void writeStructure(ItemStack itemStack, EntityPlayer player) {

ExtendedFacing facing = StructureUtility.getExtendedFacingFromLookVector(player.getLookVec());

player.addChatMessage(new ChatComponentText(facing.getName2()));

String structureDefinition = StructureUtility.getPseudoJavaCode(player.getEntityWorld(),
facing,
box,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1419,12 +1419,14 @@ public static String getPseudoJavaCode(World world, ExtendedFacing extendedFacin
.append("new String[][]{\n")
.append(" {\"");
iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ,
basePositionA, basePositionB, basePositionC, true,
basePositionA, basePositionB, basePositionC, false,
sizeA, sizeB, sizeC, ((w, x, y, z) -> {
TileEntity tileEntity = w.getTileEntity(x, y, z);
Block block = w.getBlock(x, y, z);
int metadata = w.getBlockMetadata(x, y, z);
if (tileEntity == null) {
if (x == basePositionX && y == basePositionY && z == basePositionZ) {
builder.append('~');
} else if (tileEntity == null) {
if (block != null && block != Blocks.air) {
builder.append(map.get(block.getUnlocalizedName() + '\0' + block.getDamageValue(world, x, y, z)));
} else {
Expand Down

0 comments on commit 5bf4ad7

Please sign in to comment.