Skip to content

Commit b5bafc8

Browse files
committed
Some changes
1 parent 7ac3ba2 commit b5bafc8

File tree

6 files changed

+72
-120
lines changed

6 files changed

+72
-120
lines changed

src/main/resources/forge-1.20.1/variables/blockstate.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ scopes:
1616
set: |
1717
<#include "mcitems.ftl">
1818
${JavaModName}Variables.WorldVariables.get(world).${name} = ${mappedBlockToBlockStateCode(value)};
19-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
19+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
2020
global_map:
2121
init: public BlockState ${var.getName()} = ${generator.map(var.getValue(), "blocksitems")}.defaultBlockState();
2222
read: ${var.getName()} = NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("${var.getName()}"));
@@ -25,36 +25,28 @@ scopes:
2525
set: |
2626
<#include "mcitems.ftl">
2727
${JavaModName}Variables.MapVariables.get(world).${name} = ${mappedBlockToBlockStateCode(value)};
28-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
28+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2929
player_lifetime:
3030
init: public BlockState ${var.getName()} = ${generator.map(var.getValue(), "blocksitems")}.defaultBlockState();
3131
read: ${var.getName()} = NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("${var.getName()}"));
3232
write: nbt.put("${var.getName()}", NbtUtils.writeBlockState(${var.getName()}));
33-
get: |
34-
/*@BlockState*/((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
35-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
33+
get: /*@BlockState*/${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3634
set: |
3735
<#include "mcitems.ftl">
38-
{
39-
BlockState _setval = ${mappedBlockToBlockStateCode(value)};
40-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
41-
capability.${name} = _setval;
42-
capability.syncPlayerVariables(${entity});
36+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).ifPresent(capability -> {</@head>
37+
capability.${name} = ${mappedBlockToBlockStateCode(value)};
38+
<@tail>capability.markSyncDirty();
4339
});
44-
}
40+
}</@tail>
4541
player_persistent:
4642
init: public BlockState ${var.getName()} = ${generator.map(var.getValue(), "blocksitems")}.defaultBlockState();
4743
read: ${var.getName()} = NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("${var.getName()}"));
4844
write: nbt.put("${var.getName()}", NbtUtils.writeBlockState(${var.getName()}));
49-
get: |
50-
/*@BlockState*/((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
51-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
45+
get: /*@BlockState*/${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
5246
set: |
5347
<#include "mcitems.ftl">
54-
{
55-
BlockState _setval = ${mappedBlockToBlockStateCode(value)};
56-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
57-
capability.${name} = _setval;
58-
capability.syncPlayerVariables(${entity});
48+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
49+
capability.${name} = ${mappedBlockToBlockStateCode(value)};
50+
<@tail>capability.markSyncDirty();
5951
});
60-
}
52+
}</@tail>

src/main/resources/forge-1.20.1/variables/direction.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,34 @@ scopes:
1515
get: ${JavaModName}Variables.WorldVariables.get(world).${name}
1616
set: |
1717
${JavaModName}Variables.WorldVariables.get(world).${name} = ${opt.removeParentheses(value)};
18-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
18+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
1919
global_map:
2020
init: public Direction ${var.getName()} = ${generator.map(var.getValue(), "directions")};
2121
read: ${var.getName()} = Direction.from3DDataValue(nbt.getInt("${var.getName()}"));
2222
write: nbt.putInt("${var.getName()}", ${var.getName()}.get3DDataValue());
2323
get: ${JavaModName}Variables.MapVariables.get(world).${name}
2424
set: |
2525
${JavaModName}Variables.MapVariables.get(world).${name} = ${opt.removeParentheses(value)};
26-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
26+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2727
player_lifetime:
2828
init: public Direction ${var.getName()} = ${generator.map(var.getValue(), "directions")};
2929
read: ${var.getName()} = Direction.from3DDataValue(nbt.getInt("${var.getName()}"));
3030
write: nbt.putInt("${var.getName()}", ${var.getName()}.get3DDataValue());
31-
get: |
32-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
33-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
31+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3432
set: |
35-
{
36-
Direction _setval = ${opt.removeParentheses(value)};
37-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
38-
capability.${name} = _setval;
39-
capability.syncPlayerVariables(${entity});
33+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
34+
capability.${name} = ${opt.removeParentheses(value)};
35+
<@tail>capability.markSyncDirty();
4036
});
41-
}
37+
}</@tail>
4238
player_persistent:
4339
init: public Direction ${var.getName()} = ${generator.map(var.getValue(), "directions")};
4440
read: ${var.getName()} = Direction.from3DDataValue(nbt.getInt("${var.getName()}"));
4541
write: nbt.putInt("${var.getName()}", ${var.getName()}.get3DDataValue());
46-
get: |
47-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
48-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
42+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
4943
set: |
50-
{
51-
Direction _setval = ${opt.removeParentheses(value)};
52-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
53-
capability.${name} = _setval;
54-
capability.syncPlayerVariables(${entity});
44+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
45+
capability.${name} = ${opt.removeParentheses(value)};
46+
<@tail>capability.markSyncDirty();
5547
});
56-
}
48+
}</@tail>

src/main/resources/forge-1.20.1/variables/itemstack.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ scopes:
1616
set: |
1717
<#include "mcitems.ftl">
1818
${JavaModName}Variables.WorldVariables.get(world).${name} = ${mappedMCItemToItemStackCode(value, 1)}.copy();
19-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
19+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
2020
global_map:
2121
init: public ItemStack ${var.getName()} = ItemStack.EMPTY;
2222
read: ${var.getName()} = ItemStack.of(nbt.getCompound("${var.getName()}"));
@@ -25,36 +25,28 @@ scopes:
2525
set: |
2626
<#include "mcitems.ftl">
2727
${JavaModName}Variables.MapVariables.get(world).${name} = ${mappedMCItemToItemStackCode(value, 1)}.copy();
28-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
28+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2929
player_lifetime:
3030
init: public ItemStack ${var.getName()} = ItemStack.EMPTY;
3131
read: ${var.getName()} = ItemStack.of(nbt.getCompound("${var.getName()}"));
3232
write: nbt.put("${var.getName()}", ${var.getName()}.save(new CompoundTag()));
33-
get: |
34-
/*@ItemStack*/((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
35-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
33+
get: /*@ItemStack*/${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3634
set: |
3735
<#include "mcitems.ftl">
38-
{
39-
ItemStack _setval = ${mappedMCItemToItemStackCode(value, 1)};
40-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
41-
capability.${name} = _setval.copy();
42-
capability.syncPlayerVariables(${entity});
36+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
37+
capability.${name} = ${mappedMCItemToItemStackCode(value, 1)}.copy();
38+
<@tail>capability.markSyncDirty();
4339
});
44-
}
40+
}</@tail>
4541
player_persistent:
4642
init: public ItemStack ${var.getName()} = ItemStack.EMPTY;
4743
read: ${var.getName()} = ItemStack.of(nbt.getCompound("${var.getName()}"));
4844
write: nbt.put("${var.getName()}", ${var.getName()}.save(new CompoundTag()));
49-
get: |
50-
/*@ItemStack*/((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
51-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
45+
get: /*@ItemStack*/${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
5246
set: |
5347
<#include "mcitems.ftl">
54-
{
55-
ItemStack _setval = ${mappedMCItemToItemStackCode(value, 1)};
56-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
57-
capability.${name} = _setval.copy();
58-
capability.syncPlayerVariables(${entity});
48+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES.ifPresent(capability -> {</@head>
49+
capability.${name} = ${mappedMCItemToItemStackCode(value, 1)}.copy();
50+
<@tail>capability.markSyncDirty();
5951
});
60-
}
52+
}</@tail>

src/main/resources/forge-1.20.1/variables/logic.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,34 @@ scopes:
1515
get: ${JavaModName}Variables.WorldVariables.get(world).${name}
1616
set: |
1717
${JavaModName}Variables.WorldVariables.get(world).${name} = ${opt.removeParentheses(value)};
18-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
18+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
1919
global_map:
2020
init: public boolean ${var.getName()} = ${var.getValue()};
2121
read: ${var.getName()} = nbt.getBoolean("${var.getName()}");
2222
write: nbt.putBoolean("${var.getName()}", ${var.getName()});
2323
get: ${JavaModName}Variables.MapVariables.get(world).${name}
2424
set: |
2525
${JavaModName}Variables.MapVariables.get(world).${name} = ${opt.removeParentheses(value)};
26-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
26+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2727
player_lifetime:
2828
init: public boolean ${var.getName()} = ${var.getValue()};
2929
read: ${var.getName()} = nbt.getBoolean("${var.getName()}");
3030
write: nbt.putBoolean("${var.getName()}", ${var.getName()});
31-
get: |
32-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
33-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
31+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3432
set: |
35-
{
36-
boolean _setval = ${opt.removeParentheses(value)};
37-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
38-
capability.${name} = _setval;
39-
capability.syncPlayerVariables(${entity});
33+
<@head>{${entity}.getData(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
34+
capability.${name} = ${opt.removeParentheses(value)};
35+
<@tail>capability.markSyncDirty();
4036
});
41-
}
37+
}</@tail>
4238
player_persistent:
4339
init: public boolean ${var.getName()} = ${var.getValue()};
4440
read: ${var.getName()} = nbt.getBoolean("${var.getName()}");
4541
write: nbt.putBoolean("${var.getName()}", ${var.getName()});
46-
get: |
47-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
48-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
42+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
4943
set: |
50-
{
51-
boolean _setval = ${opt.removeParentheses(value)};
52-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
53-
capability.${name} = _setval;
54-
capability.syncPlayerVariables(${entity});
44+
<@head>{${entity}.getData(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
45+
capability.${name} = ${opt.removeParentheses(value)};
46+
<@tail>capability.markSyncDirty();
5547
});
56-
}
48+
}</@tail>

src/main/resources/forge-1.20.1/variables/number.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,34 @@ scopes:
1515
get: ${JavaModName}Variables.WorldVariables.get(world).${name}
1616
set: |
1717
${JavaModName}Variables.WorldVariables.get(world).${name} = ${opt.removeParentheses(value)};
18-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
18+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
1919
global_map:
2020
init: public double ${var.getName()} = ${var.getValue()};
2121
read: ${var.getName()} = nbt.getDouble("${var.getName()}");
2222
write: nbt.putDouble("${var.getName()}", ${var.getName()});
2323
get: ${JavaModName}Variables.MapVariables.get(world).${name}
2424
set: |
2525
${JavaModName}Variables.MapVariables.get(world).${name} = ${opt.removeParentheses(value)};
26-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
26+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2727
player_lifetime:
2828
init: public double ${var.getName()} = ${var.getValue()};
2929
read: ${var.getName()} = nbt.getDouble("${var.getName()}");
3030
write: nbt.putDouble("${var.getName()}", ${var.getName()});
31-
get: |
32-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
33-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
31+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3432
set: |
35-
{
36-
double _setval = ${opt.removeParentheses(value)};
37-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
38-
capability.${name} = _setval;
39-
capability.syncPlayerVariables(${entity});
33+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
34+
capability.${name} = ${opt.removeParentheses(value)};
35+
<@tail>capability.markSyncDirty();
4036
});
41-
}
37+
}</@tail>
4238
player_persistent:
4339
init: public double ${var.getName()} = ${var.getValue()};
4440
read: ${var.getName()} = nbt.getDouble("${var.getName()}");
4541
write: nbt.putDouble("${var.getName()}", ${var.getName()});
46-
get: |
47-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
48-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
42+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
4943
set: |
50-
{
51-
double _setval = ${opt.removeParentheses(value)};
52-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
53-
capability.${name} = _setval;
54-
capability.syncPlayerVariables(${entity});
44+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).ifPresent(capability -> {</@head>
45+
capability.${name} = ${opt.removeParentheses(value)};
46+
<@tail>capability.markSyncDirty();
5547
});
56-
}
48+
}</@tail>

src/main/resources/forge-1.20.1/variables/string.yaml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,34 @@ scopes:
1515
get: ${JavaModName}Variables.WorldVariables.get(world).${name}
1616
set: |
1717
${JavaModName}Variables.WorldVariables.get(world).${name} = ${opt.removeParentheses(value)};
18-
${JavaModName}Variables.WorldVariables.get(world).syncData(world);
18+
<@tail>${JavaModName}Variables.WorldVariables.get(world).markSyncDirty();</@tail>
1919
global_map:
2020
init: public String ${var.getName()} = "${JavaConventions.escapeStringForJava(var.getValue())}";
2121
read: ${var.getName()} = nbt.getString("${var.getName()}");
2222
write: nbt.putString("${var.getName()}", ${var.getName()});
2323
get: ${JavaModName}Variables.MapVariables.get(world).${name}
2424
set: |
2525
${JavaModName}Variables.MapVariables.get(world).${name} = ${opt.removeParentheses(value)};
26-
${JavaModName}Variables.MapVariables.get(world).syncData(world);
26+
<@tail>${JavaModName}Variables.MapVariables.get(world).markSyncDirty();</@tail>
2727
player_lifetime:
2828
init: public String ${var.getName()} = "${JavaConventions.escapeStringForJava(var.getValue())}";
2929
read: ${var.getName()} = nbt.getString("${var.getName()}");
3030
write: nbt.putString("${var.getName()}", ${var.getName()});
31-
get: |
32-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
33-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
31+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
3432
set: |
35-
{
36-
String _setval = ${opt.removeParentheses(value)};
37-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
38-
capability.${name} = _setval;
39-
capability.syncPlayerVariables(${entity});
33+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES);</@head>
34+
capability.${name} = ${opt.removeParentheses(value)};
35+
<@tail>capability.markSyncDirty();
4036
});
41-
}
37+
}</@tail>
4238
player_persistent:
4339
init: public String ${var.getName()} = "${JavaConventions.escapeStringForJava(var.getValue())}";
4440
read: ${var.getName()} = nbt.getString("${var.getName()}");
4541
write: nbt.putString("${var.getName()}", ${var.getName()});
46-
get: |
47-
((${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null)
48-
.orElseGet(${JavaModName}Variables.PlayerVariables::new)).${name})
42+
get: ${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES).orElseGet(${JavaModName}Variables.PlayerVariables::new).${name}
4943
set: |
50-
{
51-
String _setval = ${opt.removeParentheses(value)};
52-
${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
53-
capability.${name} = _setval;
54-
capability.syncPlayerVariables(${entity});
44+
<@head>{${entity}.getCapability(${JavaModName}Variables.PLAYER_VARIABLES);</@head>
45+
capability.${name} = ${opt.removeParentheses(value)};
46+
<@tail>capability.markSyncDirty();
5547
});
56-
}
48+
}</@tail>

0 commit comments

Comments
 (0)