mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-09 15:04:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c78c61f45e | ||
|
|
fbf8cfd82c |
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
modGroup = com.gtnewhorizon
|
||||
modVersion = 1.0.2
|
||||
modVersion = 1.0.4
|
||||
modBaseName = StructureLib
|
||||
|
||||
forgeVersion = 1.7.10-10.13.4.1614-1.7.10
|
||||
@@ -3,6 +3,7 @@ package com.gtnewhorizon.structurelib;
|
||||
import com.gtnewhorizon.structurelib.alignment.AlignmentMessage;
|
||||
import com.gtnewhorizon.structurelib.block.BlockHint;
|
||||
import com.gtnewhorizon.structurelib.item.ItemBlockHint;
|
||||
import com.gtnewhorizon.structurelib.item.ItemConstructableTrigger;
|
||||
import com.gtnewhorizon.structurelib.item.ItemFrontRotationTool;
|
||||
import com.gtnewhorizon.structurelib.proxy.CommonProxy;
|
||||
import com.gtnewhorizon.structurelib.util.XSTR;
|
||||
@@ -45,6 +46,7 @@ public class StructureLib {
|
||||
static Block blockHint;
|
||||
static Item itemBlockHint;
|
||||
static Item itemFrontRotationTool;
|
||||
static Item itemConstructableTrigger;
|
||||
public static final CreativeTabs creativeTab = new CreativeTabs("structurelib") {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -58,6 +60,7 @@ public class StructureLib {
|
||||
GameRegistry.registerBlock(blockHint = new BlockHint(), ItemBlockHint.class, "blockhint");
|
||||
itemBlockHint = ItemBlock.getItemFromBlock(StructureLibAPI.getBlockHint());
|
||||
GameRegistry.registerItem(itemFrontRotationTool = new ItemFrontRotationTool(), itemFrontRotationTool.getUnlocalizedName());
|
||||
GameRegistry.registerItem(itemConstructableTrigger = new ItemConstructableTrigger(), itemConstructableTrigger.getUnlocalizedName());
|
||||
}
|
||||
|
||||
public static void addClientSideChatMessages(String... messages) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gtnewhorizon.structurelib.item;
|
||||
|
||||
import com.gtnewhorizon.structurelib.StructureLib;
|
||||
import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.gtnewhorizon.structurelib.StructureLib.MOD_ID;
|
||||
import static net.minecraft.util.EnumChatFormatting.BLUE;
|
||||
import static net.minecraft.util.StatCollector.translateToLocal;
|
||||
|
||||
public class ItemConstructableTrigger extends Item {
|
||||
public ItemConstructableTrigger() {
|
||||
setUnlocalizedName("structurelib.constructableTrigger");
|
||||
setTextureName(MOD_ID + ":itemConstructableTrigger");
|
||||
setCreativeTab(StructureLib.creativeTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
return ConstructableUtility.handle(stack, player, world, x, y, z, side);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) {
|
||||
aList.add(translateToLocal("item.structurelib.constructableTrigger.desc.0"));//Triggers Constructable Interface
|
||||
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.1"));//Shows multiblock construction details,
|
||||
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.2"));//just Use on a multiblock controller.
|
||||
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.3"));//(Sneak Use in creative to build)
|
||||
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.4"));//Quantity affects tier/mode/type
|
||||
}
|
||||
}
|
||||
@@ -165,4 +165,8 @@ public interface IStructureDefinition<T> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static <T> StructureDefinition.Builder<T> builder() {
|
||||
return StructureDefinition.builder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gtnewhorizon.structurelib.structure;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* structure than just during structure check. Usually just save some few bytes, but becomes non trivial if you need to
|
||||
* record too much stuff.
|
||||
*
|
||||
* You will have to reset the context yourself though. The API can't guess when the old context becomes invalid.
|
||||
* @param <CTX> the temporary state context
|
||||
*/
|
||||
public interface IWithExtendedContext<CTX> {
|
||||
CTX getCurrentContext();
|
||||
}
|
||||
@@ -13,10 +13,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.*;
|
||||
|
||||
import static java.lang.Integer.MIN_VALUE;
|
||||
|
||||
@@ -558,6 +555,26 @@ public class StructureUtility {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T, E> IStructureElementNoPlacement<T> ofSpecificTileAdder(BiPredicate<T, E> iTileAdder, Class<E> tileClass, Block hintBlock, int hintMeta) {
|
||||
if (iTileAdder == null || hintBlock == null || tileClass == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new IStructureElementNoPlacement<T>() {
|
||||
@Override
|
||||
public boolean check(T t, World world, int x, int y, int z) {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
// This used to check if it's a GT tile. Since this is now an standalone mod we no longer do this
|
||||
return tileClass.isInstance(tileEntity) && iTileAdder.test(t, tileClass.cast(tileEntity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
// No more hatch adder. Implement it via tile adder. We could of course add a wrapper around it in gregtech, but not any more in this standalone mod.
|
||||
|
||||
//endregion
|
||||
@@ -640,6 +657,27 @@ public class StructureUtility {
|
||||
return ofChain(elementChain.toArray(new IStructureElement[0]));
|
||||
}
|
||||
|
||||
// region context
|
||||
public static <CTX, T extends IWithExtendedContext<CTX>, E extends IStructureElement<CTX>> IStructureElement<T> withContext(E elem) {
|
||||
return new IStructureElement<T>() {
|
||||
@Override
|
||||
public boolean check(T t, World world, int x, int y, int z) {
|
||||
return elem.check(t.getCurrentContext(), world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||
return elem.spawnHint(t.getCurrentContext(), world, x, y, z, trigger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||
return elem.placeBlock(t.getCurrentContext(), world, x, y, z, trigger);
|
||||
}
|
||||
};
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region defer
|
||||
|
||||
public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to) {
|
||||
|
||||
@@ -20,6 +20,13 @@ item.structurelib.frontRotationTool.desc.0=Triggers Front Rotation Interface
|
||||
item.structurelib.frontRotationTool.desc.1=Rotates only the front panel,
|
||||
item.structurelib.frontRotationTool.desc.2=which allows structure rotation.
|
||||
|
||||
item.structurelib.constructableTrigger.name=Multiblock Machine Blueprint
|
||||
item.structurelib.constructableTrigger.desc.0=Triggers Constructable Interface
|
||||
item.structurelib.constructableTrigger.desc.1=Shows multiblock construction details,
|
||||
item.structurelib.constructableTrigger.desc.2=just Use on a multiblock controller.
|
||||
item.structurelib.constructableTrigger.desc.3=(Sneak Use in creative to build)
|
||||
item.structurelib.constructableTrigger.desc.4=Quantity affects tier/mode/type
|
||||
|
||||
structurelib.blockhint.desc.0=Helps while building
|
||||
structurelib.blockhint.0.name=Hint 1 dot
|
||||
structurelib.blockhint.1.name=Hint 2 dot
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 667 B |
Reference in new issue
Block a user