The fence type functions much like the fencing in vanilla Minecraft, in which it attempts to connect to any nearby blocks. Because fences automatically connect to nearby blocks, they don't need to store this behavior in the save files. As a result, they're one of the various types of blocks that can use Damage Values for variants.
It's important to note that when making a texture for the fence, it will always be in the shape of the default fence. If you wanted to make a fence with other shapes like arches or a simple picket fence, you can try using the pane type.
New Wood Fence (CS2 0.9.10)[]
newFence_200.js
id = config.getBlockId("newFenceID"); name = "newWoodFence"; displayName[0] = "New Wood Fence"; material = "wood"; hardness[0] = 3.0; drop[0] = config.getBlockId("newFenceID"); addToCreative[0] = true; creativeTab = "decorations"; textureFileXP[0] = "/tree_side.png"; textureFileXN[0] = "/tree_side.png"; textureFileYP[0] = "/tree_top.png"; textureFileYN[0] = "/tree_top.png"; textureFileZP[0] = "/tree_side.png"; textureFileZN[0] = "/tree_side.png";
mod.js
config.addBlockIdProperty("newFenceID", 200); mod.addBlock("newFence_200.js", "fence");
Fence Block Attributes[]
Required Attributes |
Optional Attributes
|
textureFile and textureIndex
In CS2 versions for 1.4.7 and below, CS2 0.9.9 or below, textureFile was used to specify the texture sheet and textureIndex was used for identifying the specific icon within the texture sheet. If using CS2 0.9.9 or lower, make sure to use both of these attributes.
Example Fence Block[]
name="Glowing Perimeter Fence"; id=215; texturefile="terrain.png"; textureindex=105; type="fence"; material="glass"; stepsound="glass"; hardness=0.3; resistance=1; iddropped=215; opacity=0; light=15; movebypiston=true; harvestlevel=0; toolclass="pickaxe";
Fence Block Attributes[]
Below is a table of attributes available to fence-type blocks, including information on notable attributes.
Required Attributes
|
Optional Attributes |
This must be set to 'fence' in order for the block to function as a fence.
opacity
Setting this attribute to a low value prevents a rather pronounced visual bug. See Importance of the Opacity Attribute below.
Behavior[]
Fences will act as though they are roughly 1.5 blocks in height, despite being only a single block tall. This is to prevent most mobs, including players and animals, from simply jumping over them. In this way fences are an effective way to create a barrier that doesn't also block line of sight.Fences of all types will attempt to connect to blocks adjacent to them. All fences will connect properly to Fence gates. They won't connect to other fences with different block IDs, however they will connect to other damage values of their own ID.