mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-19 19:49:54 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
906961b6c8 | ||
|
|
393045d4f2 | ||
|
|
74baa66f52 | ||
|
|
24928454fd | ||
|
|
34ceda8ccc | ||
|
|
c78c61f45e |
No files matched your search
@@ -0,0 +1,27 @@
|
|||||||
|
# This workflow will build a Java project with Gradle
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||||
|
|
||||||
|
name: Java CI with Gradle
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'adopt'
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
modGroup = com.gtnewhorizon
|
modGroup = com.gtnewhorizon
|
||||||
modVersion = 1.0.3
|
modVersion = 1.0.6
|
||||||
modBaseName = StructureLib
|
modBaseName = StructureLib
|
||||||
|
|
||||||
forgeVersion = 1.7.10-10.13.4.1614-1.7.10
|
forgeVersion = 1.7.10-10.13.4.1614-1.7.10
|
||||||
@@ -41,7 +41,7 @@ public class ClientProxy extends CommonProxy {
|
|||||||
private static IIcon[] createIIconFromBlock(Block block, int meta) {
|
private static IIcon[] createIIconFromBlock(Block block, int meta) {
|
||||||
IIcon[] ret = new IIcon[6];
|
IIcon[] ret = new IIcon[6];
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
block.getIcon(i, meta);
|
ret[i] = block.getIcon(i, meta);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,4 +165,8 @@ public interface IStructureDefinition<T> {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static <T> StructureDefinition.Builder<T> builder() {
|
||||||
|
return StructureDefinition.builder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
||||||
|
private Function<T, IStructureElement<T>> to;
|
||||||
|
private IStructureElement<T> elem;
|
||||||
|
|
||||||
|
public LazyStructureElement(Function<T, IStructureElement<T>> to) {
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IStructureElement<T> get(T t) {
|
||||||
|
if (to != null) {
|
||||||
|
elem = to.apply(t);
|
||||||
|
to = null;
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(T t, World world, int x, int y, int z) {
|
||||||
|
return get(t).check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return get(t).placeBlock(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return get(t).spawnHint(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,15 +5,30 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
|||||||
import com.gtnewhorizon.structurelib.structure.adders.IBlockAdder;
|
import com.gtnewhorizon.structurelib.structure.adders.IBlockAdder;
|
||||||
import com.gtnewhorizon.structurelib.structure.adders.ITileAdder;
|
import com.gtnewhorizon.structurelib.structure.adders.ITileAdder;
|
||||||
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
import com.gtnewhorizon.structurelib.util.Vec3Impl;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
import java.util.function.*;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.BiPredicate;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static java.lang.Integer.MIN_VALUE;
|
import static java.lang.Integer.MIN_VALUE;
|
||||||
|
|
||||||
@@ -172,6 +187,98 @@ public class StructureUtility {
|
|||||||
|
|
||||||
//region block
|
//region block
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denote a block using unlocalized names. This can be useful to get around mod loading order issues.
|
||||||
|
* <p>
|
||||||
|
* While no immediate error will be thrown, client code should ensure said mod is loaded and
|
||||||
|
* said mod is present, otherwise bad things will happen later!
|
||||||
|
*/
|
||||||
|
public static <T> IStructureElement<T> ofBlockUnlocalizedName(String modid, String unlocalizedName, int meta) {
|
||||||
|
if (StringUtils.isBlank(unlocalizedName)) throw new IllegalArgumentException();
|
||||||
|
if (meta < 0) throw new IllegalArgumentException();
|
||||||
|
if (meta > 15) throw new IllegalArgumentException();
|
||||||
|
if (StringUtils.isBlank(modid)) throw new IllegalArgumentException();
|
||||||
|
return new IStructureElement<T>() {
|
||||||
|
private Block block;
|
||||||
|
|
||||||
|
private Block getBlock() {
|
||||||
|
if (block == null)
|
||||||
|
block = GameRegistry.findBlock(modid, unlocalizedName);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(T t, World world, int x, int y, int z) {
|
||||||
|
return world.getBlock(x, y, z) != getBlock() && world.getBlockMetadata(x, y, z) == meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
StructureLibAPI.hintParticle(world, x, y, z, getBlock(), meta);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
world.setBlock(x, y, z, getBlock(), meta, 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similiar to the other overload, but allows client code to specify a fallback in case said block was not found later
|
||||||
|
* when the element got called.
|
||||||
|
*
|
||||||
|
* This is slightly different to using the other overload and another element in a {@link #ofChain(IStructureElement[])},
|
||||||
|
* as that combination would cause crash, where this won't.
|
||||||
|
*/
|
||||||
|
public static <T> IStructureElement<T> ofBlockUnlocalizedName(String modid, String unlocalizedName, int meta, IStructureElement<T> fallback) {
|
||||||
|
if (StringUtils.isBlank(unlocalizedName)) throw new IllegalArgumentException();
|
||||||
|
if (meta < 0) throw new IllegalArgumentException();
|
||||||
|
if (meta > 15) throw new IllegalArgumentException();
|
||||||
|
if (StringUtils.isBlank(modid)) throw new IllegalArgumentException();
|
||||||
|
if (fallback == null) throw new IllegalArgumentException();
|
||||||
|
return new IStructureElement<T>() {
|
||||||
|
private Block block;
|
||||||
|
private boolean initialized;
|
||||||
|
|
||||||
|
private boolean init() {
|
||||||
|
if (!initialized) {
|
||||||
|
block = GameRegistry.findBlock(modid, unlocalizedName);
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
return block != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(T t, World world, int x, int y, int z) {
|
||||||
|
if (init())
|
||||||
|
return world.getBlock(x, y, z) != block && world.getBlockMetadata(x, y, z) == meta;
|
||||||
|
else
|
||||||
|
return fallback.check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
if (init()) {
|
||||||
|
StructureLibAPI.hintParticle(world, x, y, z, block, meta);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return fallback.spawnHint(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
if (init()) {
|
||||||
|
world.setBlock(x, y, z, block, meta, 2);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return fallback.placeBlock(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does not allow Block duplicates (with different meta)
|
* Does not allow Block duplicates (with different meta)
|
||||||
*/
|
*/
|
||||||
@@ -680,6 +787,28 @@ public class StructureUtility {
|
|||||||
|
|
||||||
//region defer
|
//region defer
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to defer, but caches the first returned element returned and won't call it again.
|
||||||
|
* Initialization is not thread safe.
|
||||||
|
*/
|
||||||
|
public static <T> IStructureElementDeferred<T> lazy(Supplier<IStructureElement<T>> to) {
|
||||||
|
if (to == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
return new LazyStructureElement<>(t -> to.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to defer, but caches the first returned element returned and won't call it again.
|
||||||
|
* Initialization is not thread safe.
|
||||||
|
*/
|
||||||
|
public static <T> IStructureElementDeferred<T> lazy(Function<T, IStructureElement<T>> to) {
|
||||||
|
if (to == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
return new LazyStructureElement<>(to);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to) {
|
public static <T> IStructureElementDeferred<T> defer(Supplier<IStructureElement<T>> to) {
|
||||||
if (to == null) {
|
if (to == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
@@ -1307,4 +1436,5 @@ public class StructureUtility {
|
|||||||
}
|
}
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,12 @@ tile.structurelib.blockhint.13.name=Hint air
|
|||||||
tile.structurelib.blockhint.14.name=Hint no air
|
tile.structurelib.blockhint.14.name=Hint no air
|
||||||
tile.structurelib.blockhint.15.name=Hint error
|
tile.structurelib.blockhint.15.name=Hint error
|
||||||
|
|
||||||
item.structurelib.frontRotationTool.name=Front Rotation Tool
|
item.structurelib.frontRotationTool.name=Front Rotation Tool (Standalone)
|
||||||
item.structurelib.frontRotationTool.desc.0=Triggers Front Rotation Interface
|
item.structurelib.frontRotationTool.desc.0=Triggers Front Rotation Interface
|
||||||
item.structurelib.frontRotationTool.desc.1=Rotates only the front panel,
|
item.structurelib.frontRotationTool.desc.1=Rotates only the front panel,
|
||||||
item.structurelib.frontRotationTool.desc.2=which allows structure rotation.
|
item.structurelib.frontRotationTool.desc.2=which allows structure rotation.
|
||||||
|
|
||||||
item.structurelib.constructableTrigger.name=Multiblock Machine Blueprint
|
item.structurelib.constructableTrigger.name=Multiblock Machine Blueprint (Standalone)
|
||||||
item.structurelib.constructableTrigger.desc.0=Triggers Constructable Interface
|
item.structurelib.constructableTrigger.desc.0=Triggers Constructable Interface
|
||||||
item.structurelib.constructableTrigger.desc.1=Shows multiblock construction details,
|
item.structurelib.constructableTrigger.desc.1=Shows multiblock construction details,
|
||||||
item.structurelib.constructableTrigger.desc.2=just Use on a multiblock controller.
|
item.structurelib.constructableTrigger.desc.2=just Use on a multiblock controller.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 667 B |
Reference in new issue
Block a user