-
Notifications
You must be signed in to change notification settings - Fork 10
TileEntity
youyihj edited this page Dec 2, 2023
·
4 revisions
@Since 1.4.0
Tile Entities allow blocks to contain data more than 4 bits, and execute some code every tick. All powerful blocks use tile entity. ContentTweaker supports Tile Entity, however, which is broken. ZenUtils add its own system to fix it.
import mods.zenutils.cotx.TileEntity;
- ITileEntityTick onTick (default
function(tileEntity, world, pos) {}
)
- register() to register the tile entity
The function with the following parameters (in this order) will be called every tick.
- TileEntityInGame tileEntity
- IWorld world
- IBlockPos pos
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.zenutils.cotx.Block;
import crafttweaker.data.IData;
val te = VanillaFactory.createActualTileEntity(1);
te.onTick = function(tileEntity, world, pos) {
if (world.remote) return;
val data as IData = tileEntity.data;
if (!isNull(data) && data has "time") {
tileEntity.updateCustomData({time: data.time.asInt() + 1});
if (data.time.asInt() % 100 == 0) {
val player = world.getClosestPlayer(pos.x, pos.y, pos.z, 64, false);
if (isNull(player)) return;
player.sendChat("xxx");
}
} else {
tileEntity.updateCustomData({time: 1});
// Equivilant to
// tileEntity.data = tileEntity.data + {time: 1};
}
};
te.register();
val block = VanillaFactory.createExpandBlock("test", <blockmaterial:wood>);
block.tileEntity = te;
block.register();
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils