修复块透明度和边界框 (1.10.2)
Fix block transparency and bounding box (1.10.2)
这是我的蜡烛块的样子:
问题是:
- 砂岩不渲染
- 碰撞是一个完整的方块
- 选择框为整块(选择框为灰色线框)
Forge 提供的设置这些边界框的方法已被弃用,并且
this.translucent = true;
this.fullBlock = false;
在构造函数中什么也不做。
更多截图:
BlockCandle.java
:
package com.otabi.firestar.toomuch.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
/**
* Created by firestar115 on 10/22/16.
*/
public class BlockCandle extends BlockBase { // BlockBase only sets registry names and model locations
public BlockCandle() {
super(Material.CAKE, "candle");
this.fullBlock = false;
this.translucent = true;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
return false;
}
}
models/block/candle.json
:
{
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
"textures": {
"0": "toomuch:blocks/candle_base",
"1": "toomuch:blocks/candle_wick"
},
"display": {
"gui": {
"rotation": [ 30, 225, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.625, 0.625, 0.625 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 3, 0 ],
"scale": [ 0.25, 0.25, 0.25 ]
},
"fixed": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.5, 0.5, 0.5 ]
},
"thirdperson_righthand": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 2.5, 0.5 ],
"scale": [ 0.375, 0.375, 0.375 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 2.5, 0.5 ],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 2.5, 0 ],
"scale": [ 0.4, 0.4, 0.4 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 225, 0 ],
"translation": [ 0, 2.5, 0 ],
"scale": [ 0.4, 0.4, 0.4 ]
}
},
"elements": [
{
"name": "Cube",
"from": [ 6.50, 0.00, 6.50 ],
"to": [ 9.50, 8.00, 9.50 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 8.00 ] },
"east": { "texture": "#0", "uv": [ 3.00, 8.00, 6.00, 16.00 ] },
"south": { "texture": "#0", "uv": [ 6.00, 0.00, 9.00, 8.00 ] },
"west": { "texture": "#0", "uv": [ 9.00, 8.00, 12.00, 16.00 ] },
"up": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 3.00 ] },
"down": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 3.00 ] }
}
},
{
"name": "Cube",
"from": [ 7.50, 8.00, 7.50 ],
"to": [ 8.50, 10.00, 8.50 ],
"faces": {
"north": { "texture": "#1", "uv": [ 0.00, 0.00, 1.00, 2.00 ] },
"east": { "texture": "#1", "uv": [ 1.00, 1.00, 2.00, 3.00 ] },
"south": { "texture": "#1", "uv": [ 2.00, 2.00, 3.00, 4.00 ] },
"west": { "texture": "#1", "uv": [ 3.00, 3.00, 4.00, 5.00 ] },
"up": { "texture": "#1", "uv": [ 4.00, 4.00, 5.00, 5.00 ] },
"down": { "texture": "#1", "uv": [ 5.00, 5.00, 6.00, 6.00 ] }
}
}
]
}
blockstates/candle.json
:
{
"forge_marker": 1,
"defaults": {
"textures": {
"0": "toomuch:blocks/candle_base",
"1": "toomuch:blocks/candle_wick"
}
},
"variants": {
"normal": {
"model": "toomuch:candle"
},
"inventory": {
"model": "toomuch:candle"
}
}
}
我正在使用 Forge 1.10.2 12.18.2.2099。
您尝试过添加边界框吗?
public void setBlockBoundsBasedOnState(final IBlockAccess worldIn, final BlockPos pos) {
this.setBlockBounds(0.25f, 0.125f, 0.25f, 0.75f, 0.875f, 0.75f);
}
public void addCollisionBoxesToList(final World worldIn, final BlockPos pos, final IBlockState state, final AxisAlignedBB mask, final List list, final Entity collidingEntity) {
this.setBlockBoundsBasedOnState((IBlockAccess)worldIn, pos);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
1.10 更新
getCollisionBoundingBox(...)
、getSelectedBoundingBox(...)
、isFullCube(...)
和 isOpaqueCube (...)
。
这是我的蜡烛块的样子:
问题是:
- 砂岩不渲染
- 碰撞是一个完整的方块
- 选择框为整块(选择框为灰色线框)
Forge 提供的设置这些边界框的方法已被弃用,并且
this.translucent = true;
this.fullBlock = false;
在构造函数中什么也不做。
更多截图:
BlockCandle.java
:
package com.otabi.firestar.toomuch.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
/**
* Created by firestar115 on 10/22/16.
*/
public class BlockCandle extends BlockBase { // BlockBase only sets registry names and model locations
public BlockCandle() {
super(Material.CAKE, "candle");
this.fullBlock = false;
this.translucent = true;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
return false;
}
}
models/block/candle.json
:
{
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
"textures": {
"0": "toomuch:blocks/candle_base",
"1": "toomuch:blocks/candle_wick"
},
"display": {
"gui": {
"rotation": [ 30, 225, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.625, 0.625, 0.625 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 3, 0 ],
"scale": [ 0.25, 0.25, 0.25 ]
},
"fixed": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.5, 0.5, 0.5 ]
},
"thirdperson_righthand": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 2.5, 0.5 ],
"scale": [ 0.375, 0.375, 0.375 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 2.5, 0.5 ],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 2.5, 0 ],
"scale": [ 0.4, 0.4, 0.4 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 225, 0 ],
"translation": [ 0, 2.5, 0 ],
"scale": [ 0.4, 0.4, 0.4 ]
}
},
"elements": [
{
"name": "Cube",
"from": [ 6.50, 0.00, 6.50 ],
"to": [ 9.50, 8.00, 9.50 ],
"faces": {
"north": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 8.00 ] },
"east": { "texture": "#0", "uv": [ 3.00, 8.00, 6.00, 16.00 ] },
"south": { "texture": "#0", "uv": [ 6.00, 0.00, 9.00, 8.00 ] },
"west": { "texture": "#0", "uv": [ 9.00, 8.00, 12.00, 16.00 ] },
"up": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 3.00 ] },
"down": { "texture": "#0", "uv": [ 0.00, 0.00, 3.00, 3.00 ] }
}
},
{
"name": "Cube",
"from": [ 7.50, 8.00, 7.50 ],
"to": [ 8.50, 10.00, 8.50 ],
"faces": {
"north": { "texture": "#1", "uv": [ 0.00, 0.00, 1.00, 2.00 ] },
"east": { "texture": "#1", "uv": [ 1.00, 1.00, 2.00, 3.00 ] },
"south": { "texture": "#1", "uv": [ 2.00, 2.00, 3.00, 4.00 ] },
"west": { "texture": "#1", "uv": [ 3.00, 3.00, 4.00, 5.00 ] },
"up": { "texture": "#1", "uv": [ 4.00, 4.00, 5.00, 5.00 ] },
"down": { "texture": "#1", "uv": [ 5.00, 5.00, 6.00, 6.00 ] }
}
}
]
}
blockstates/candle.json
:
{
"forge_marker": 1,
"defaults": {
"textures": {
"0": "toomuch:blocks/candle_base",
"1": "toomuch:blocks/candle_wick"
}
},
"variants": {
"normal": {
"model": "toomuch:candle"
},
"inventory": {
"model": "toomuch:candle"
}
}
}
我正在使用 Forge 1.10.2 12.18.2.2099。
您尝试过添加边界框吗?
public void setBlockBoundsBasedOnState(final IBlockAccess worldIn, final BlockPos pos) {
this.setBlockBounds(0.25f, 0.125f, 0.25f, 0.75f, 0.875f, 0.75f);
}
public void addCollisionBoxesToList(final World worldIn, final BlockPos pos, final IBlockState state, final AxisAlignedBB mask, final List list, final Entity collidingEntity) {
this.setBlockBoundsBasedOnState((IBlockAccess)worldIn, pos);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
1.10 更新
getCollisionBoundingBox(...)
、getSelectedBoundingBox(...)
、isFullCube(...)
和 isOpaqueCube (...)
。