Skip to content

Commit

Permalink
Door and fence gate support
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldorion committed Jun 6, 2021
1 parent fb2f944 commit cc7bcf8
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 4 deletions.
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* Added support for block generation parameters
* Added support for all plant generation types and parameters
* Added new world procedure blocks: get logic game rule, get number game rule, set logic game rule and set number game rule
* Added complete support for Tick randomly
* Added complete support for Tick randomly
* Added a new block trigger: Update tick
* Updated the tag mod element to support entities
* [#104] Added full support for the stair block base
* Added new block bases: [#104] Stairs, door,fence, fence gate
* [Bugfix #110] GROUND and PLANT step sounds had the wrong sound.
* [Bugfix] Transparency on custom plants was black.
* [Bugfix] Update tick trigger for plants caused a build error.
Expand Down
55 changes: 55 additions & 0 deletions src/fabric-1.16.5/block.definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,61 @@ templates:
writer: json
name: "@MODASSETSROOT/models/block/@registryname_noside_alt.json"

# TX: Door templates
- template: json/txblock/pane_item.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/models/item/@registryname.json"
- template: json/txblock/door_states.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/blockstates/@registryname.json"
- template: json/txblock/door_top.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_top.json"
- template: json/txblock/door_top_hinge.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_top_hinge.json"
- template: json/txblock/door_bottom.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_bottom.json"
- template: json/txblock/door_bottom_hinge.json.ftl
condition: "blockBase %= Door"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_bottom_hinge.json"

# TX: FenceGate templates
- template: json/txblock/fence_gate_item.json.ftl
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/models/item/@registryname.json"
- template: json/txblock/fence_gate_states.json.ftl
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/blockstates/@registryname.json"
- template: json/txblock/fence_gate.json.ftl
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/models/block/@registryname.json"
- template: json/txblock/fence_gate_open.json.ftl
deleteWhenConditionFalse: true
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_open.json"
- template: json/txblock/fence_gate_wall.json.ftl
deleteWhenConditionFalse: true
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_wall.json"
- template: json/txblock/fence_gate_wall_open.json.ftl
deleteWhenConditionFalse: true
condition: "blockBase %= FenceGate"
writer: json
name: "@MODASSETSROOT/models/block/@registryname_wall_open.json"

localizationkeys:
- key: block.@modid.@registryname
mapto: name
26 changes: 24 additions & 2 deletions src/fabric-1.16.5/templates/block.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public class ${name}Block extends
<#if data.hasGravity>
FallingBlock
<#elseif data.blockBase?has_content>
<#if data.blockBase == "TrapDoor">
TrapdoorBlock
<#else>
${data.blockBase}Block
</#if>
<#else>
Block
</#if>{
Expand Down Expand Up @@ -113,6 +117,14 @@ public class ${name}Block extends
</#if>
}

<#if data.blockBase?has_content && data.blockBase == "Fence">
@Override public boolean canConnect(BlockState state, boolean checkattach, Direction face) {
boolean flag = state.getBlock() instanceof FenceBlock && state.getMaterial() == this.material;
boolean flag1 = state.getBlock() instanceof FenceGateBlock && FenceGateBlock.canWallConnect(state, face);
return !cannotConnect(state.getBlock()) && checkattach || flag || flag1;
}
</#if>

<#if data.specialInfo?has_content>
@Override
@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -242,6 +254,11 @@ public class ${name}Block extends
<#elseif data.customDrop?? && !data.customDrop.isEmpty()>
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
<#if data.blockBase?has_content && data.blockBase == "Door">
if(state.get(Properties.DOUBLE_BLOCK_HALF) != DoubleBlockHalf.LOWER)
return Collections.emptyList();
</#if>

List<ItemStack> dropsOriginal = super.getDroppedStacks(state, builder);
if(!dropsOriginal.isEmpty())
return dropsOriginal;
Expand All @@ -259,6 +276,11 @@ public class ${name}Block extends
<#else>
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder){
<#if data.blockBase?has_content && data.blockBase == "Door">
if(state.get(Properties.DOUBLE_BLOCK_HALF) != DoubleBlockHalf.LOWER)
return Collections.emptyList();
</#if>

List<ItemStack> dropsOriginal = super.getDroppedStacks(state, builder);
if(!dropsOriginal.isEmpty())
return dropsOriginal;
Expand All @@ -267,10 +289,10 @@ public class ${name}Block extends
</#if>
</#if>

<#if (hasProcedure(data.onTickUpdate) && !data.tickRandomly) || hasProcedure(data.onBlockAdded) ) >
<#if (hasProcedure(data.onTickUpdate) && !data.tickRandomly) || hasProcedure(data.onBlockAdded)>
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
super.onBlockAdded(state, world, pos, oldState, moving);
super.onBlockAdded(state, world, pos, oldState, notify);
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Expand Down
8 changes: 8 additions & 0 deletions src/fabric-1.16.5/templates/json/txblock/door_bottom.json.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/door_bottom",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"bottom": "${modid}:blocks/${data.texture}",
"top": "${modid}:blocks/${data.textureTop?has_content?then(data.textureTop, data.texture)}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/door_bottom_rh",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"bottom": "${modid}:blocks/${data.texture}",
"top": "${modid}:blocks/${data.textureTop?has_content?then(data.textureTop, data.texture)}"
}
}
124 changes: 124 additions & 0 deletions src/fabric-1.16.5/templates/json/txblock/door_states.json.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"variants": {
"facing=east,half=lower,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_bottom"
},
"facing=south,half=lower,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_bottom",
"y": 90
},
"facing=west,half=lower,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_bottom",
"y": 180
},
"facing=north,half=lower,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_bottom",
"y": 270
},
"facing=east,half=lower,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_bottom_hinge"
},
"facing=south,half=lower,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 90
},
"facing=west,half=lower,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 180
},
"facing=north,half=lower,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 270
},
"facing=east,half=lower,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 90
},
"facing=south,half=lower,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 180
},
"facing=west,half=lower,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_bottom_hinge",
"y": 270
},
"facing=north,half=lower,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_bottom_hinge"
},
"facing=east,half=lower,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_bottom",
"y": 270
},
"facing=south,half=lower,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_bottom"
},
"facing=west,half=lower,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_bottom",
"y": 90
},
"facing=north,half=lower,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_bottom",
"y": 180
},
"facing=east,half=upper,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_top"
},
"facing=south,half=upper,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_top",
"y": 90
},
"facing=west,half=upper,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_top",
"y": 180
},
"facing=north,half=upper,hinge=left,open=false": {
"model": "${modid}:block/${registryname}_top",
"y": 270
},
"facing=east,half=upper,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_top_hinge"
},
"facing=south,half=upper,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 90
},
"facing=west,half=upper,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 180
},
"facing=north,half=upper,hinge=right,open=false": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 270
},
"facing=east,half=upper,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 90
},
"facing=south,half=upper,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 180
},
"facing=west,half=upper,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_top_hinge",
"y": 270
},
"facing=north,half=upper,hinge=left,open=true": {
"model": "${modid}:block/${registryname}_top_hinge"
},
"facing=east,half=upper,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_top",
"y": 270
},
"facing=south,half=upper,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_top"
},
"facing=west,half=upper,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_top",
"y": 90
},
"facing=north,half=upper,hinge=right,open=true": {
"model": "${modid}:block/${registryname}_top",
"y": 180
}
}
}
8 changes: 8 additions & 0 deletions src/fabric-1.16.5/templates/json/txblock/door_top.json.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/door_top",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"bottom": "${modid}:blocks/${data.texture}",
"top": "${modid}:blocks/${data.textureTop?has_content?then(data.textureTop, data.texture)}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/door_top_rh",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"bottom": "${modid}:blocks/${data.texture}",
"top": "${modid}:blocks/${data.textureTop?has_content?then(data.textureTop, data.texture)}"
}
}
7 changes: 7 additions & 0 deletions src/fabric-1.16.5/templates/json/txblock/fence_gate.json.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "block/template_fence_gate",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"texture": "${modid}:blocks/${data.texture}"
}
}
14 changes: 14 additions & 0 deletions src/fabric-1.16.5/templates/json/txblock/fence_gate_item.json.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<#-- @formatter:off -->
<#if data.itemTexture?has_content>
{
"parent": "item/generated",
"textures": {
"layer0": "${modid}:items/${data.itemTexture}"
}
}
<#else>
{
"parent": "${modid}:block/${registryname}"
}
</#if>
<#-- @formatter:on -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "block/template_fence_gate_open",
"textures": {
<#if data.particleTexture?has_content>"particle": "${modid}:blocks/${data.particleTexture}",</#if>
"texture": "${modid}:blocks/${data.texture}"
}
}
Loading

0 comments on commit cc7bcf8

Please sign in to comment.