Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<#include "mcitems.ftl">
/*@BlockState*/(new Object() {
public BlockState with(BlockState _bs, String _property, int _newValue) {
Property<?> _prop = _bs.getBlock().getStateDefinition().getProperty(_property);
return _prop instanceof IntegerProperty _ip && _prop.getPossibleValues().contains(_newValue) ? _bs.setValue(_ip, _newValue) : _bs;
}}.with(${mappedBlockToBlockStateCode(input$block)}, ${input$property}, ${opt.toInt(input$value)}))
<@addTemplate file="utils/blockstate_props/with_integer_property.java.ftl"/>
/*@BlockState*/(blockStateWithInt(${mappedBlockToBlockStateCode(input$block)}, ${input$property}, ${opt.toInt(input$value)}))
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
(new Object(){
public boolean checkGamemode(Entity _ent){
if(_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.${generator.map(field$gamemode, "gamemodes")};
} else if(_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null
&& Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.${generator.map(field$gamemode, "gamemodes")};
}
return false;
}
}.checkGamemode(${input$entity}))
<@addTemplate file="utils/entity/entity_checkgamemode.java.ftl"/>
(getEntityGameType(${input$entity}) == GameType.${generator.map(field$gamemode, "gamemodes")})
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
<#-- @formatter:off -->
(new Object(){
public String getResult(Entity _ent, String _command) {
StringBuilder _result = new StringBuilder();
if(!_ent.level().isClientSide() && _ent.getServer() != null) {
CommandSource _dataConsumer = new CommandSource() {
@Override public void sendSystemMessage(Component message) {
_result.append(message.getString());
}

@Override public boolean acceptsSuccess() {
return true;
}

@Override public boolean acceptsFailure() {
return true;
}

@Override public boolean shouldInformAdmins() {
return false;
}
};
_ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(
_dataConsumer, _ent.position(), _ent.getRotationVector(),
_ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4,
_ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent
), _command);
}
return _result.toString();
}
}.getResult(${input$entity}, ${input$command}))
<#-- @formatter:on -->
<@addTemplate file="utils/entity/entity_execute_command_result.java.ftl"/>
(executeCommandGetResult(${input$entity}, ${input$command}))
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
/*@int*/(new Object(){
public int getScore(String score, Entity _ent){
Scoreboard _sc = _ent.level().getScoreboard();
Objective _so = _sc.getObjective(score);
if (_so != null)
return _sc.getOrCreatePlayerScore(_ent.getScoreboardName(), _so).getScore();
return 0;
}
}.getScore(${input$score}, ${input$entity}))
<@addTemplate file="utils/entity/entity_get_scoreboard_score.java.ftl"/>
/*@int*/(getEntityScore(${input$score}, ${input$entity}))
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<#include "mcitems.ftl">
/*@ItemStack*/(new Object(){
public ItemStack getItemStack(int sltid, Entity entity) {
AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
entity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
_retval.set(capability.getStackInSlot(sltid).copy());
});
return _retval.get();
}
}.getItemStack(${opt.toInt(input$slotid)}, ${input$entity}))
/*@ItemStack*/(${input$entity}.getCapability(ForgeCapabilities.ITEM_HANDLER, null) instanceof IItemHandlerModifiable _modHandler ? _modHandler.getStackInSlot(${opt.toInt(input$slotid)}).copy() : ItemStack.EMPTY)
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<#include "mcelements.ftl">
(new Object() {
public boolean hasRecipe(Entity _ent, ResourceLocation recipe) {
if (_ent instanceof ServerPlayer _player)
return _player.getRecipeBook().contains(recipe);
else if (_ent.level().isClientSide() && _ent instanceof LocalPlayer _player)
return _player.getRecipeBook().contains(recipe);
return false;
}
}.hasRecipe(${input$entity}, ${toResourceLocation(input$recipe)}))
<@addTemplate file="utils/entity/entity_has_recipe.java.ftl"/>
(hasEntityRecipe(${input$entity}, ${toResourceLocation(input$recipe)}))
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
(new Object() {
public double getSubmergedHeight(Entity _entity) {
for (FluidType fluidType : ForgeRegistries.FLUID_TYPES.get().getValues()) {
if (_entity.level().getFluidState(_entity.blockPosition()).getFluidType() == fluidType)
return _entity.getFluidTypeHeight(fluidType);
}
return 0;
}
}.getSubmergedHeight(${input$entity}))
<@addTemplate file="utils/entity/entity_submerged_height.java.ftl"/>
(getEntitySubmergedHeight(${input$entity}))
Original file line number Diff line number Diff line change
@@ -1,28 +1,2 @@
<#-- @formatter:off -->
(new Object(){
public String getResult(LevelAccessor world, Vec3 pos, String _command) {
StringBuilder _result = new StringBuilder();
if (world instanceof ServerLevel _level) {
CommandSource _dataConsumer = new CommandSource() {
@Override public void sendSystemMessage(Component message) {
_result.append(message.getString());
}

@Override public boolean acceptsSuccess() {
return true;
}

@Override public boolean acceptsFailure() {
return true;
}

@Override public boolean shouldInformAdmins() {
return false;
}
};
_level.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(_dataConsumer, pos, Vec2.ZERO, _level, 4, "", Component.literal(""), _level.getServer(), null), _command);
}
return _result.toString();
}
}.getResult(world, new Vec3(${input$x}, ${input$y}, ${input$z}), ${input$command}))
<#-- @formatter:on -->
<@addTemplate file="utils/world/execute_command_result.java.ftl"/>
(executeCommandGetResult(world, new Vec3(${input$x}, ${input$y}, ${input$z}), ${input$command}))
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
(new Object() {
public double getX() {
try {
return BlockPosArgument.getLoadedBlockPos(arguments, "${field$param}").getX();
} catch (CommandSyntaxException e) {
e.printStackTrace();
return 0;
}
}
}.getX())
<@addTemplate file="utils/command/get_command_parameter_blockpos.java.ftl"/>
/*@int*/(commandParameterBlockPos(arguments, "${field$param}").getX())
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
(new Object() {
public double getY() {
try {
return BlockPosArgument.getLoadedBlockPos(arguments, "${field$param}").getY();
} catch (CommandSyntaxException e) {
e.printStackTrace();
return 0;
}
}
}.getY())
<@addTemplate file="utils/command/get_command_parameter_blockpos.java.ftl"/>
/*@int*/(commandParameterBlockPos(arguments, "${field$param}").getY())
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
(new Object() {
public double getZ() {
try {
return BlockPosArgument.getLoadedBlockPos(arguments, "${field$param}").getZ();
} catch (CommandSyntaxException e) {
e.printStackTrace();
return 0;
}
}
}.getZ())
<@addTemplate file="utils/command/get_command_parameter_blockpos.java.ftl"/>
/*@int*/(commandParameterBlockPos(arguments, "${field$param}").getZ())
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
(new Object() {
public Entity getEntity() {
try {
return EntityArgument.getEntity(arguments, "${field$param}");
} catch (CommandSyntaxException e) {
e.printStackTrace();
return null;
}
}
}.getEntity())
<@addTemplate file="utils/command/get_command_parameter_entity.java.ftl"/>
(commandParameterEntity(arguments, "${field$param}"))
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
(new Object() {
public String getMessage() {
try {
return MessageArgument.getMessage(arguments, "${field$param}").getString();
} catch (CommandSyntaxException ignored) {
return "";
}
}
}).getMessage()
<@addTemplate file="utils/command/get_command_parameter_message.java.ftl"/>
(commandParameterMessage(arguments, "${field$param}"))
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
/*@int*/(new Object(){
public int getAmount(int sltid) {
if(entity instanceof Player player && player.containerMenu instanceof ${JavaModName}Menus.MenuAccessor _menu) {
ItemStack stack = _menu.getSlots().get(sltid).getItem();
if(stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount(${opt.toInt(input$slotid)}))
<@addTemplate file="utils/gui_get_amount_inslot.java.ftl"/>
/*@int*/(getAmountInGUISlot(${input$entity}, ${opt.toInt(input$slotid)}))
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<#include "mcitems.ftl">
/*@ItemStack*/(new Object(){
public ItemStack getItemStack(int sltid, ItemStack _isc) {
AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
_isc.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
_retval.set(capability.getStackInSlot(sltid).copy());
});
return _retval.get();
}
}.getItemStack(${opt.toInt(input$slotid)}, ${mappedMCItemToItemStackCode(input$item, 1)}))
<@addTemplate file="utils/itemhandler_get_slot.java.ftl"/>
/*@ItemStack*/(getItemStackFromItemStackSlot(${opt.toInt(input$slotid)}, ${mappedMCItemToItemStackCode(input$item, 1)}))
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<#assign projectile = generator.map(field$projectile, "projectiles", 1)>
<#assign hasShooter = (input$shooter != "null")>
<#assign isPiercing = (input$piercing != "/*@int*/0")>
new Object() {
public Projectile getArrow(Level level<#if hasShooter>, Entity shooter</#if>, float damage, int knockback<#if isPiercing>, byte piercing</#if>) {
AbstractArrow entityToSpawn = new ${generator.map(field$projectile, "projectiles", 0)}(${projectile}, level);
<#if hasShooter>entityToSpawn.setOwner(shooter);</#if>
entityToSpawn.setBaseDamage(damage);
entityToSpawn.setKnockback(knockback);
<#if field$projectile?starts_with("CUSTOM:")>entityToSpawn.setSilent(true);</#if>
<#if isPiercing>entityToSpawn.setPierceLevel(piercing);</#if>
<#if field$fire == "TRUE">entityToSpawn.setSecondsOnFire(100);</#if>
<#if field$particles == "TRUE">entityToSpawn.setCritArrow(true);</#if>
<#if field$pickup != "DISALLOWED">entityToSpawn.pickup = AbstractArrow.Pickup.${field$pickup};</#if>
return entityToSpawn;
}
}.getArrow(projectileLevel<#if hasShooter>, ${input$shooter}</#if>, ${opt.toFloat(input$damage)}, ${opt.toInt(input$knockback)}<#if isPiercing>, (byte) ${input$piercing}</#if>)
<@addTemplate file="utils/projectiles/arrow.java.ftl"/>
<#if (input$knockback == "/*@int*/0") && (input$piercing == "/*@int*/0")>
initArrowProjectile(new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, projectileLevel),
${input$shooter}, ${opt.toFloat(input$damage)}, ${field$projectile?starts_with("CUSTOM:")}, ${field$fire == "TRUE"}, ${field$particles == "TRUE"},
AbstractArrow.Pickup.${field$pickup})
<#elseif field$projectile?starts_with("CUSTOM:")>
<@addTemplate file="utils/projectiles/arrow_weapon.java.ftl"/>
initArrowProjectile(createArrowWeaponItemStack(new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, 0, 0, 0, projectileLevel),
${opt.toInt(input$knockback)}, (byte) ${input$piercing}), ${input$shooter}, ${opt.toFloat(input$damage)},
true, ${field$fire == "TRUE"}, ${field$particles == "TRUE"}, AbstractArrow.Pickup.${field$pickup})
<#else>
<@addTemplate file="utils/projectiles/arrow_weapon.java.ftl"/>
initArrowProjectile(createArrowWeaponItemStack(new ${generator.map(field$projectile, "projectiles", 0)}(projectileLevel, 0, 0, 0),
${opt.toInt(input$knockback)}, (byte) ${input$piercing}), ${input$shooter}, ${opt.toFloat(input$damage)},
false, ${field$fire == "TRUE"}, ${field$particles == "TRUE"}, AbstractArrow.Pickup.${field$pickup})
</#if>
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<#assign hasShooter = (input$shooter != "null")>
<#assign hasAcceleration = (input$ax != "/*@int*/0") || (input$ay != "/*@int*/0") || (input$az != "/*@int*/0")>
<#if (!hasShooter) && (!hasAcceleration)>
<#if (input$shooter == "null") && ((input$ax == "/*@int*/0") && (input$ay == "/*@int*/0") && (input$az == "/*@int*/0"))>
new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, projectileLevel)
<#else>
new Object() {
public Projectile getFireball(Level level<#if hasShooter>, Entity shooter</#if><#if hasAcceleration>, double ax, double ay, double az</#if>) {
AbstractHurtingProjectile entityToSpawn = new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, level);
<#if hasShooter>entityToSpawn.setOwner(shooter);</#if>
<#if hasAcceleration>
entityToSpawn.xPower = ax;
entityToSpawn.yPower = ay;
entityToSpawn.zPower = az;
</#if>
return entityToSpawn;
}
}.getFireball(projectileLevel<#if hasShooter>, ${input$shooter}</#if><#if hasAcceleration>, ${input$ax}, ${input$ay}, ${input$az}</#if>)
<@addTemplate file="utils/projectiles/projectile.java.ftl"/>
initProjectileProperties(new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, projectileLevel), ${input$shooter}, new Vec3(${input$ax}, ${input$ay}, ${input$az}))
</#if>
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
<#assign hasShooter = (input$shooter != "null")>
<#assign hasAcceleration = (input$ax != "/*@int*/0") || (input$ay != "/*@int*/0") || (input$az != "/*@int*/0")>
new Object() {
public Projectile getPotion(Level level<#if hasShooter>, Entity shooter</#if><#if hasAcceleration>, double ax, double ay, double az</#if>) {
ThrownPotion entityToSpawn = new ThrownPotion(EntityType.POTION, level);
entityToSpawn.setItem(PotionUtils.setPotion(Items.${field$potionType}.getDefaultInstance(), ${generator.map(field$potion, "potions")}));
<#if hasShooter>entityToSpawn.setOwner(shooter);</#if>
<#if hasAcceleration>
entityToSpawn.setDeltaMovement(new Vec3(ax, ay, az));
entityToSpawn.hasImpulse = true;
</#if>
return entityToSpawn;
}
}.getPotion(projectileLevel<#if hasShooter>, ${input$shooter}</#if><#if hasAcceleration>, ${input$ax}, ${input$ay}, ${input$az}</#if>)
<@addTemplate file="utils/projectiles/potion.java.ftl"/>
createPotionProjectile(projectileLevel, PotionUtils.setPotion(Items.${field$potionType}.getDefaultInstance(), ${generator.map(field$potion, "potions")}), ${input$shooter}, new Vec3(${input$ax}, ${input$ay}, ${input$az}))
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<#if input$shooter == "null">
new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, projectileLevel)
<#else>
new Object() {
public Projectile getProjectile(Level level, Entity shooter) {
Projectile entityToSpawn = new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, level);
entityToSpawn.setOwner(shooter);
return entityToSpawn;
}
}.getProjectile(projectileLevel, ${input$shooter})
<@addTemplate file="utils/projectiles/projectile.java.ftl"/>
initProjectileProperties(new ${generator.map(field$projectile, "projectiles", 0)}(${generator.map(field$projectile, "projectiles", 1)}, projectileLevel), ${input$shooter}, Vec3.ZERO)
</#if>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private static BlockPos commandParameterBlockPos(CommandContext<CommandSourceStack> arguments, String parameter) {
try {
return BlockPosArgument.getLoadedBlockPos(arguments, parameter);
} catch (CommandSyntaxException e) {
e.printStackTrace();
return new BlockPos(0, 0, 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private static Entity commandParameterEntity(CommandContext<CommandSourceStack> arguments, String parameter) {
try {
return EntityArgument.getEntity(arguments, parameter);
} catch (CommandSyntaxException e) {
e.printStackTrace();
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
private static String commandParameterMessage(CommandContext<CommandSourceStack> arguments, String parameter) {
try {
return MessageArgument.getMessage(arguments, parameter).getString();
} catch (CommandSyntaxException e) {
e.printStackTrace();
return "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
private static GameType getEntityGameType(Entity entity){
if(entity instanceof ServerPlayer serverPlayer) {
return serverPlayer.gameMode.getGameModeForPlayer();
} else if(entity instanceof Player player && player.level().isClientSide()) {
PlayerInfo playerInfo = Minecraft.getInstance().getConnection().getPlayerInfo(player.getGameProfile().getId());
if (playerInfo != null)
return playerInfo.getGameMode();
}
return null;
}
Loading