Bloc Orientable (TileEntity)
-
Pfioouuu… Sérieusement ?
Comment je fait ça ?
Je les empile ?
Comment le jeu va savoir la quelle est pour quelle orientation ?
La Pumpkin ou le four , ils ont pas ça dans leur .json ! -
Si :
{ "parent": "block/orientable", // C'est ici qu'il faut regarder ! "textures": { "top": "blocks/pumpkin_top", "front": "blocks/pumpkin_face_off", "side": "blocks/pumpkin_side" } }Oh tiens, un fichier JSON tout fait pour les développeurs (orientable.json):
{ "parent": "block/cube", "textures": { "particle": "#front", "down": "#top", "up": "#top", "north": "#front", "east": "#side", "south": "#side", "west": "#side" } } -
Oui, mais ça ne m’aide pas… Ou je suis vraiment très con (Ce qui est le cas)
Mon .json n’a pas de “parent”, c’est un .json custom
:::
{
“textures”: {
“0”: “ut:blocks/back”,
“1”: “ut:blocks/sides”,
“2”: “ut:blocks/front”,
“3”: “ut:blocks/cobblestone”,
“4”: “ut:blocks/planks_oak”,
“5”: “ut:blocks/iron_block”
},
“elements”: [
{
“name”: “Base”,
“from”: [
0.0,
0.0,
0.0
],
“to”: [
16.0,
16.0,
16.0
],
“faces”: {
“north”: {
“texture”: “#0”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
},
“east”: {
“texture”: “#1”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
},
“south”: {
“texture”: “#2”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
},
“west”: {
“texture”: “#1”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
},
“up”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
},
“down”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
16.0,
16.0
]
}
}
},
{
“name”: “Remblais 2”,
“from”: [
0.0,
16.0,
0.0
],
“to”: [
16.0,
19.0,
3.0
],
“faces”: {
“north”: {
“texture”: “#3”,
“uv”: [
0.0,
3.0,
16.0,
6.0
]
},
“east”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
3.0,
3.0
]
},
“south”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
3.0
]
},
“west”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
3.0,
3.0
]
},
“up”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
3.0
]
},
“down”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
3.0
]
}
}
},
{
“name”: “Remblais 1”,
“from”: [
0.0,
19.0,
0.0
],
“to”: [
16.0,
22.0,
2.0
],
“faces”: {
“north”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
3.0
]
},
“east”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
2.0,
3.0
]
},
“south”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
3.0
]
},
“west”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
2.0,
3.0
]
},
“up”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
2.0
]
},
“down”: {
“texture”: “#3”,
“uv”: [
0.0,
0.0,
16.0,
2.0
]
}
}
},
{
“name”: “Manche Marteau”,
“from”: [
7.0,
13.0,
0.0
],
“to”: [
9.0,
18.0,
2.0
],
“rotation”: {
“origin”: [
7.0,
14.0,
8.0
],
“axis”: “x”,
“angle”: 45.0
},
“faces”: {
“north”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
4.0,
11.0
]
},
“east”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
3.0,
11.0
]
},
“south”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
3.0,
11.0
]
},
“west”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
5.0,
11.0
]
},
“up”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
-1.0,
5.0
]
},
“down”: {
“texture”: “#4”,
“uv”: [
0.0,
0.0,
2.0,
2.0
]
}
}
},
{
“name”: “Tête marteau”,
“from”: [
6.0,
18.0,
-1.0
],
“to”: [
10.0,
21.0,
5.0
],
“rotation”: {
“origin”: [
8.0,
15.0,
8.0
],
“axis”: “x”,
“angle”: 45.0
},
“faces”: {
“north”: {
“texture”: “#5”,
“uv”: [
3.0,
3.0,
7.0,
6.0
]
},
“east”: {
“texture”: “#5”,
“uv”: [
8.0,
3.0,
14.0,
6.0
]
},
“south”: {
“texture”: “#5”,
“uv”: [
3.0,
3.0,
7.0,
6.0
]
},
“west”: {
“texture”: “#5”,
“uv”: [
3.0,
3.0,
9.0,
6.0
]
},
“up”: {
“texture”: “#5”,
“uv”: [
3.0,
3.0,
7.0,
9.0
]
},
“down”: {
“texture”: “#5”,
“uv”: [
3.0,
3.0,
7.0,
9.0
]
}
}
}
]
}
:::
Dois-je en ajouter un ? -
Qu’est-ce que ton block représente ?
-
Un bloc normal, avec deux sorte de… Barrières , et un marteau
Screen : ( Sur Modelcreator, car mon Minecraft preend 5 ans a se lancer )
http://www.noelshack.com/2015-24-1433945128-qsdsefrgtyuicaco-p.png -
Il faut faire le model de base (commence par le sens que tu veux) et ensuite recopie le model pour chaque orientation.
PS : je pense que tu devrais pouvoir alléger ton model, les logiciels ne sont pas toujours bien optimisés.
-
Oui, j’avais compris, mais comment je fais pour les stocker ?
J’en crée un qui s’apelle platecrafter, un autre platecrafter_north, un autre platecrafter_south ect ?
EDIT : Je vais tester un truc, je vais voir si c’est concluant
EDIT² : Je ne vais pas tester mon hypothèse 1, mais une autre -
-
Euh… En quoi cela m’aide ? Ça m’apprend juste a faire un Model, mais pas a faire un model ‘rotatif’
-
Tu cherches à faire le fichier json non ?
-
Oui, mais a faire un sorte qu’il puisse être tourné, qu’il soit orientable, il est déjà fait mon .json
-
Apparemment non :
[09:31:35] [Client thread/ERROR] [FML]: Model definition for location ut:platecrafter#facing=east not found [09:31:35] [Client thread/ERROR] [FML]: Model definition for location ut:platecrafter#facing=south not found [09:31:35] [Client thread/ERROR] [FML]: Model definition for location ut:platecrafter#facing=north not found [09:31:35] [Client thread/ERROR] [FML]: Model definition for location ut:platecrafter#facing=west not found -
Bah il est fait, mais faut faire en sorte qu’il puisse se tourner, et sa, je ne sais pas comment faire
Rappel : Ce n’est pas un .json normal -
Pourquoi ne serait-il pas “normal” ?
-
Ce que je veut dire , c’est que ce n’est pas un simple bloc, c’est un model custom
-
Oui, et alors ?
-
Un cube et un model sont tous deux des blocs, ils peuvent donc être tous les deux orientables de la même manière, ça ne diffère pas entre les deux.
-
J’ai changé d’avis à propos du bloc. Pour facilité le GUI, j’ai fait un TileEntity
Je vais essayer de suivre le tuto de robin, et si ça ne fonctionne pas, je reviendrai ici
-
Comme dit précédament, j’ai crée une TileEntity, et j’ai également prévu de revenir sur ce forum, si un nouveau problème se présentait.
Or, un vient de pointer son nez
Classe du blocpackage eryah.usefulthings.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import eryah.usefulthings.Reference; import eryah.usefulthings.UsefulthingsMod; import eryah.usefulthings.tileentity.TileEntityPlateCrafter; public class PlateCrafter extends BlockContainer { public static Block platecrafter; public PlateCrafter(Material material) { super(material); } @Override public TileEntity createNewTileEntity(World world, int metadata) //Instancie le TileEntity { return new TileEntityPlateCrafter(); } public boolean hasTileEntity(int metadata) //Permet de savoir si le bloc a un TileEntity { return true; } public static void init() { platecrafter = new PlateCrafter(Material.rock).setUnlocalizedName("platecrafter").setCreativeTab(UsefulthingsMod.UTTab); } public static void register() { GameRegistry.registerBlock(platecrafter, platecrafter.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(platecrafter); } public static void registerRender(Block block) { Item item = Item.getItemFromBlock(block); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return -1; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return side == 3 && metadata == 0 ? this.blockIcon2 : (side == 4 && metadata == 1 ? this.blockIcon2 : (side == 2 && metadata == 2 ? this.blockIcon2 : (side == 5 && metadata == 3 ? this.blockIcon2 : this.blockIcon))); } public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote) { int direction = world.getBlockMetadata(x, y, z) + 1; if(direction > 3) { direction = 0; } world.setBlockMetadataWithNotify(x, y, z, direction, 3); return true; } return false; } public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { return new ForgeDirection[] {ForgeDirection.UP, ForgeDirection.DOWN}; } }Il y des erreurs un peut partout
- setBlockMetadataWithNotify - The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World
- IIcon - IIcon cannot be resolved to a type
- blockIcon2 - blockIcon2 cannot be resolved or is not a field
- blockIcon - blockIcon cannot be resolved or is not a field
- ForgeDirection - ForgeDirection cannot be resolved to a variable
- getBlockMetadata - The method getBlockMetadata(int, int, int) is undefined for the type World
- setBlockMetadataWithNotify - The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World
-
@‘Eryah’:
Comme dit précédament, j’ai crée une TileEntity, et j’ai également prévu de revenir sur ce forum, si un nouveau problème se présentait.
Or, un vient de pointer son nez
Classe du blocpackage eryah.usefulthings.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import eryah.usefulthings.Reference; import eryah.usefulthings.UsefulthingsMod; import eryah.usefulthings.tileentity.TileEntityPlateCrafter; public class PlateCrafter extends BlockContainer { public static Block platecrafter; public PlateCrafter(Material material) { super(material); } @Override public TileEntity createNewTileEntity(World world, int metadata) //Instancie le TileEntity { return new TileEntityPlateCrafter(); } public boolean hasTileEntity(int metadata) //Permet de savoir si le bloc a un TileEntity { return true; } public static void init() { platecrafter = new PlateCrafter(Material.rock).setUnlocalizedName("platecrafter").setCreativeTab(UsefulthingsMod.UTTab); } public static void register() { GameRegistry.registerBlock(platecrafter, platecrafter.getUnlocalizedName().substring(5)); } public static void registerRenders() { registerRender(platecrafter); } public static void registerRender(Block block) { Item item = Item.getItemFromBlock(block); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory")); } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return -1; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return side == 3 && metadata == 0 ? this.blockIcon2 : (side == 4 && metadata == 1 ? this.blockIcon2 : (side == 2 && metadata == 2 ? this.blockIcon2 : (side == 5 && metadata == 3 ? this.blockIcon2 : this.blockIcon))); } public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote) { int direction = world.getBlockMetadata(x, y, z) + 1; if(direction > 3) { direction = 0; } world.setBlockMetadataWithNotify(x, y, z, direction, 3); return true; } return false; } public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { return new ForgeDirection[] {ForgeDirection.UP, ForgeDirection.DOWN}; } }Il y des erreurs un peut partout
- setBlockMetadataWithNotify - The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World
- IIcon - IIcon cannot be resolved to a type
- blockIcon2 - blockIcon2 cannot be resolved or is not a field
- blockIcon - blockIcon cannot be resolved or is not a field
- ForgeDirection - ForgeDirection cannot be resolved to a variable
- getBlockMetadata - The method getBlockMetadata(int, int, int) is undefined for the type World
- setBlockMetadataWithNotify - The method setBlockMetadataWithNotify(int, int, int, int, int) is undefined for the type World
Tu peux résoudre toutes ces erreurs grâce à eclipse. IL te propose des solutions, prends-les car si il faut tout te corriger, crois-moi que ça va prendre du temps. La plupart de ces erreurs sont des soucis d’import. Ensuite pour le reste je crois que les méthodes que tu as réécris n’ont pas les bons arguments.