Add Wrench Script (from dev) (#230)
* Create CustomWrench.zs Comes from dev. * Some changes Add GTCEu wrenches to list of wrenches Remove thermal creative blocks from the list of wrenchable items Add Draconic Evolution Energy Source to list of wrenchable items * Update Craft Tweaker The version before was released on Jan 2 2022 * Add thermal and ae2 creative items Re-adds Thermal Creative Items removed Adds AE2 creative energy cell. It can be removed without this using shift-right click with GTCEu wrench and cresent hammer, but not Yeta Wrench or the Redstone Arsenal Wrenches, so I'm adding it.
This commit is contained in:
parent
340f5ad29a
commit
84c38ebd67
@ -211,7 +211,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"projectID": 239197,
|
"projectID": 239197,
|
||||||
"fileID": 3587830,
|
"fileID": 4353149,
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
67
overrides/scripts/CustomWrench.zs
Normal file
67
overrides/scripts/CustomWrench.zs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import crafttweaker.block.IBlock;
|
||||||
|
import crafttweaker.player.IPlayer;
|
||||||
|
import crafttweaker.block.IBlockPattern;
|
||||||
|
import crafttweaker.event.PlayerInteractBlockEvent;
|
||||||
|
|
||||||
|
<ore:wrenchCustom>.add(<thermalfoundation:wrench>,
|
||||||
|
<enderio:item_yeta_wrench>,
|
||||||
|
<redstonearsenal:tool.wrench_flux>,
|
||||||
|
<redstonearsenal:tool.battlewrench_flux>);
|
||||||
|
|
||||||
|
<ore:wrenchCustom>.addAll(<ore:gtceWrenches>);
|
||||||
|
|
||||||
|
static wrenchables as IBlockPattern = <thermalexpansion:tank> as IBlock |
|
||||||
|
<thermalexpansion:cell> as IBlock |
|
||||||
|
<extrautils2:creativeenergy> as IBlock |
|
||||||
|
<extrautils2:passivegenerator:6> as IBlock |
|
||||||
|
<extrautils2:drum:4> as IBlock |
|
||||||
|
<draconicevolution:creative_rf_source> as IBlock |
|
||||||
|
<appliedenergistics2:creative_energy_cell> as IBlock;
|
||||||
|
|
||||||
|
function isNotWrenchable(block as IBlock) as bool {
|
||||||
|
return isNull(block) || // no block
|
||||||
|
!(wrenchables has block); // not wrenchable
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNotWrenching(player as IPlayer) as bool {
|
||||||
|
return isNull(player) || // no player
|
||||||
|
!player.isSneaking || // not sneaking
|
||||||
|
isNull(player.currentItem) || // no item is held
|
||||||
|
!(<ore:wrenchCustom> has player.currentItem); // not a wrench
|
||||||
|
}
|
||||||
|
|
||||||
|
function playerIsNotWrenchingWrenchable(evt as PlayerInteractBlockEvent) as bool {
|
||||||
|
// gracefully handle unusual circumstances
|
||||||
|
if (isNull(evt) || isNull(evt.world) || evt.canceled || evt.useItem == "DENY")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return isNotWrenching(evt.player) || isNotWrenchable(evt.block);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropItem(evt as PlayerInteractBlockEvent) as bool {
|
||||||
|
if (evt.world.remote)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
val stack = evt.world.getPickedBlock(evt.position, evt.player.getRayTrace(4, 0), evt.player);
|
||||||
|
|
||||||
|
if (isNull(stack) || !evt.world.setBlockState(<blockstate:minecraft:air>, evt.position))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// dummy entity to drop the item with
|
||||||
|
val dummy = <entity:minecraft:arrow>.createEntity(evt.world);
|
||||||
|
dummy.posX = evt.x as double + 0.5;
|
||||||
|
dummy.posY = evt.y as double + 0.5;
|
||||||
|
dummy.posZ = evt.z as double + 0.5;
|
||||||
|
|
||||||
|
dummy.dropItem(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
events.onPlayerInteractBlock(function(evt as PlayerInteractBlockEvent) as void {
|
||||||
|
if (playerIsNotWrenchingWrenchable(evt))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (dropItem(evt)) {
|
||||||
|
evt.cancellationResult = "SUCCESS";
|
||||||
|
evt.cancel();
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user