oreveins indicators: use api to replace block instead of chat command.
This commit is contained in:
parent
08e56ccc40
commit
3f08eebabe
3 changed files with 35 additions and 27 deletions
2
index.toml
generated
2
index.toml
generated
|
@ -2405,7 +2405,7 @@ hash = "a07879875ad20ae8e285c3cb39beeee648bd080ec12985b76583ad707a3de3ee"
|
||||||
|
|
||||||
[[files]]
|
[[files]]
|
||||||
file = "scripts/ore_veins/indicators.1.zs"
|
file = "scripts/ore_veins/indicators.1.zs"
|
||||||
hash = "5ddde773d2f8fe5bac324bb03497776b694eadbef6626f23cf7a9e755f4009ee"
|
hash = "36e4b9ee448ad7503f5df16b788e95a0f69bb24a55041c33a87b45c347e57d7f"
|
||||||
|
|
||||||
[[files]]
|
[[files]]
|
||||||
file = "scripts/ore_veins/indicators.2.zs"
|
file = "scripts/ore_veins/indicators.2.zs"
|
||||||
|
|
|
@ -6,7 +6,7 @@ pack-format = "packwiz:1.1.0"
|
||||||
[index]
|
[index]
|
||||||
file = "index.toml"
|
file = "index.toml"
|
||||||
hash-format = "sha256"
|
hash-format = "sha256"
|
||||||
hash = "504d3886965baa0eab50adab674ea9afbcc3ec12472a90c8c91ce91958499dcf"
|
hash = "42ca8e723c1e0761d17e371bcd988f0fe299aa09f3c914f0c1183e7c85099d96"
|
||||||
|
|
||||||
[versions]
|
[versions]
|
||||||
forge = "14.23.5.2860"
|
forge = "14.23.5.2860"
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
#loader contenttweaker
|
#loader contenttweaker
|
||||||
|
|
||||||
|
import crafttweaker.block.IBlock;
|
||||||
|
import crafttweaker.block.IBlockState;
|
||||||
|
import crafttweaker.data.IData;
|
||||||
|
import crafttweaker.world.IBlockPos;
|
||||||
|
import crafttweaker.world.IWorld;
|
||||||
import mods.contenttweaker.Block;
|
import mods.contenttweaker.Block;
|
||||||
|
import mods.contenttweaker.BlockPos;
|
||||||
import mods.contenttweaker.DropHandler;
|
import mods.contenttweaker.DropHandler;
|
||||||
import mods.contenttweaker.ResourceLocation;
|
import mods.contenttweaker.ResourceLocation;
|
||||||
import mods.contenttweaker.VanillaFactory;
|
import mods.contenttweaker.VanillaFactory;
|
||||||
|
import mods.contenttweaker.World;
|
||||||
|
|
||||||
var nugget_table as string[][] = [
|
var nugget_table as string[][] = [
|
||||||
# [name, id, meta]
|
# [name, id, meta]
|
||||||
|
@ -38,24 +45,29 @@ var nugget_table as string[][] = [
|
||||||
["certus_quartz", "appliedenergistics2:material", "0"]
|
["certus_quartz", "appliedenergistics2:material", "0"]
|
||||||
];
|
];
|
||||||
|
|
||||||
function replaceCommand(blockName as string, item as string, meta as string, blockPos as mods.contenttweaker.BlockPos) as string {
|
function replace(
|
||||||
return "execute @a " +
|
item as string,
|
||||||
blockPos.getX() as string + " " +
|
meta as string,
|
||||||
blockPos.getY() as string + " " +
|
blockPos as mods.contenttweaker.BlockPos,
|
||||||
blockPos.getZ() as string + " " +
|
world as World
|
||||||
"detect " +
|
)
|
||||||
blockPos.getX() as string + " " +
|
{
|
||||||
blockPos.getY() as string + " " +
|
if (world.isRemote()) { return null; }
|
||||||
blockPos.getZ() as string + " " +
|
|
||||||
"contenttweaker:" + blockName + " * " +
|
# janky hack, mate
|
||||||
"setblock " +
|
var trueWorld as IWorld = IWorld.getFromID(world.getDimension());
|
||||||
blockPos.getX() as string + " " +
|
|
||||||
blockPos.getY() as string + " " +
|
var nbt as IData = {
|
||||||
blockPos.getZ() as string + " " +
|
Facing: 0 as byte,
|
||||||
"draconicevolution:placed_item " +
|
InventoryStacks: [{
|
||||||
"0 " +
|
id: item as string,
|
||||||
"replace " +
|
Count: 1 as byte,
|
||||||
"{InventoryStacks: [{ id: \"" + item + "\", Count: 1, Damage: " + meta as string + " }]}";
|
Damage: meta as short
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
var position as IBlockPos = crafttweaker.util.Position3f.create(blockPos.getX(), blockPos.getY(), blockPos.getZ()).asBlockPos();
|
||||||
|
trueWorld.setBlockState(<blockstate:draconicevolution:placed_item:facing=down>, nbt, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in nugget_table {
|
for i in nugget_table {
|
||||||
|
@ -77,20 +89,16 @@ for i in nugget_table {
|
||||||
block.setPassable(true);
|
block.setPassable(true);
|
||||||
block.setReplaceable(true);
|
block.setReplaceable(true);
|
||||||
|
|
||||||
# janky hack, mate
|
|
||||||
block.setOnBlockPlace(function(world, blockPos, blockState) {
|
block.setOnBlockPlace(function(world, blockPos, blockState) {
|
||||||
var command as string = replaceCommand(blockName, item, meta, blockPos);
|
replace(item, meta, blockPos, world);
|
||||||
server.commandManager.executeCommand(server, command);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
block.setOnRandomTick(function(world, blockPos, blockState) {
|
block.setOnRandomTick(function(world, blockPos, blockState) {
|
||||||
var command as string = replaceCommand(blockName, item, meta, blockPos);
|
replace(item, meta, blockPos, world);
|
||||||
server.commandManager.executeCommand(server, command);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
block.setOnUpdateTick(function(world, blockPos, blockState) {
|
block.setOnUpdateTick(function(world, blockPos, blockState) {
|
||||||
var command as string = replaceCommand(blockName, item, meta, blockPos);
|
replace(item, meta, blockPos, world);
|
||||||
server.commandManager.executeCommand(server, command);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
block.register();
|
block.register();
|
||||||
|
|
Loading…
Reference in a new issue