Skip to content

Commit

Permalink
Fix #424
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldorion committed Jun 21, 2023
1 parent aae75d6 commit 05b22fa
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelogs:

## 1.9.3
* [Bugfix #423] The world dependency failed to compile in some cases

## 1.9.2
* Updated Fabric API to 0.83.1, so it always works

Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.20.1/procedures/deal_damage.java.ftl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
Entity _entToDamage = ${input$entity};
_entToDamage.hurt(new DamageSource(
_entToDamage.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(
_entToDamage.level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(
<#if field$damagesource?has_content>
${generator.map(field$damagesource, "damagesources")}
<#else>
Expand Down
8 changes: 4 additions & 4 deletions src/fabric-1.20.1/procedures/shoot_arrow.java.ftl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<#assign projectile = generator.map(field$rangeditem, "projectiles", 0)>
if (${input$entity} instanceof LivingEntity _ent_sa && !_ent_sa.level.isClientSide()) {
if (${input$entity} instanceof LivingEntity _ent_sa && !_ent_sa.level().isClientSide()) {
<#if field$rangeditem?has_content && field$rangeditem?starts_with("CUSTOM:")>
${projectile}.shoot(_ent_sa.level, _ent_sa, _ent_sa.level.getRandom(), ${opt.toFloat(input$speed)}, ${opt.toFloat(input$damage)}, ${opt.toInt(input$knockback)});
${projectile}.shoot(_ent_sa.level(), _ent_sa, _ent_sa.level().getRandom(), ${opt.toFloat(input$speed)}, ${opt.toFloat(input$damage)}, ${opt.toInt(input$knockback)});
<#else>
AbstractArrow entityToSpawn = new ${projectile}(_ent_sa.level, _ent_sa);
AbstractArrow entityToSpawn = new ${projectile}(_ent_sa.level(), _ent_sa);
entityToSpawn.shoot(_ent_sa.getLookAngle().x, _ent_sa.getLookAngle().y, _ent_sa.getLookAngle().z, ${opt.toFloat(input$speed)}, 0);
entityToSpawn.setBaseDamage(${opt.toFloat(input$damage)});
<#if input$knockback != "/*@int*/0">
entityToSpawn.setKnockback(${opt.toInt(input$knockback)});
</#if>
_ent_sa.level.addFreshEntity(entityToSpawn);
_ent_sa.level().addFreshEntity(entityToSpawn);
</#if>
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class ${name}Entity extends AbstractArrow implements ItemSupplier {
double x = this.getX();
double y = this.getY();
double z = this.getZ();
Level world = this.level;
Level world = this.level();
<@procedureOBJToCode data.onBulletHitsPlayer/>
}
</#if>
Expand All @@ -84,7 +84,7 @@ public class ${name}Entity extends AbstractArrow implements ItemSupplier {
double x = this.getX();
double y = this.getY();
double z = this.getZ();
Level world = this.level;
Level world = this.level();
<@procedureOBJToCode data.onBulletHitsEntity/>
}
</#if>
Expand All @@ -95,7 +95,7 @@ public class ${name}Entity extends AbstractArrow implements ItemSupplier {
double x = blockHitResult.getBlockPos().getX();
double y = blockHitResult.getBlockPos().getY();
double z = blockHitResult.getBlockPos().getZ();
Level world = this.level;
Level world = this.level();
Entity entity = this.getOwner();
Entity immediatesourceentity = this;
<@procedureOBJToCode data.onBulletHitsBlock/>
Expand All @@ -109,7 +109,7 @@ public class ${name}Entity extends AbstractArrow implements ItemSupplier {
double x = this.getX();
double y = this.getY();
double z = this.getZ();
Level world = this.level;
Level world = this.level();
Entity entity = this.getOwner();
Entity immediatesourceentity = this;
<@procedureOBJToCode data.onBulletFlyingTick/>
Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.20.1/triggers/chat_sent.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public ${name}Procedure() {
dependencies.put("x", sender.getX());
dependencies.put("y", sender.getY());
dependencies.put("z", sender.getZ());
dependencies.put("world", sender.level);
dependencies.put("world", sender.level());
dependencies.put("text", message);
execute(dependencies);
});
Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.20.1/triggers/command_executed.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public ${name}Procedure() {
dependencies.put("x", source.getEntity().getX());
dependencies.put("y", source.getEntity().getY());
dependencies.put("z", source.getEntity().getZ());
dependencies.put("world", source.getEntity().level);
dependencies.put("world", source.getEntity().level());
dependencies.put("command", message);
execute(dependencies);
});
Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.20.1/triggers/player_respawn.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public ${name}Procedure() {
dependencies.put("x", newPlayer.getX());
dependencies.put("y", newPlayer.getY());
dependencies.put("z", newPlayer.getZ());
dependencies.put("world", newPlayer.level);
dependencies.put("world", newPlayer.level());
dependencies.put("entity", newPlayer);
dependencies.put("oldEntity", oldPlayer);
execute(dependencies);
Expand Down
4 changes: 2 additions & 2 deletions src/fabric-1.20.1/utils/aiconditions.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
double y = ${name}Entity.this.getY();
double z = ${name}Entity.this.getZ();
Entity entity = ${name}Entity.this;
Level world = ${name}Entity.this.level;
Level world = ${name}Entity.this.level();
return super.canUse() && <@procedureOBJToConditionCode conditions[0]/>;
}
</#if>
Expand All @@ -21,7 +21,7 @@
double y = ${name}Entity.this.getY();
double z = ${name}Entity.this.getZ();
Entity entity = ${name}Entity.this;
Level world = ${name}Entity.this.level;
Level world = ${name}Entity.this.level();
return super.canContinueToUse() && <@procedureOBJToConditionCode conditions[0]/>;
}
</#if>
Expand Down

0 comments on commit 05b22fa

Please sign in to comment.