Jump to content

Good tutorial for hand-coding JSON block models?


JaredBGreat

Recommended Posts

Since there doesn't seem to be any software for changing Java model classes to JSON, is there a good does anyone know of a good tutorial on how to write JSON block models? Specifically, I'm needing to translate this:

 

package com.gw.dm.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelBladeTrap extends ModelBase {

	ModelRenderer Base;
	ModelRenderer BotSpikeB;
	ModelRenderer BotSpikeC;
	ModelRenderer BotSpikeD;
	ModelRenderer BotSpikeA;
	ModelRenderer TopSpikeA;
	ModelRenderer TopSpikeC;
	ModelRenderer TopSpikeD;
	ModelRenderer TopSpikeB;
	ModelRenderer RerSpikeB;
	ModelRenderer RerSpikeC;
	ModelRenderer RerSpikeD;
	ModelRenderer RerSpikeA;
	ModelRenderer FrnSpikeA;
	ModelRenderer FrnSpikeC;
	ModelRenderer FrnSpikeD;
	ModelRenderer FrnSpikeB;
	ModelRenderer LftSpikeB;
	ModelRenderer LftSpikeC;
	ModelRenderer LftSpikeD;
	ModelRenderer LftSpikeA;
	ModelRenderer RitSpikeD;
	ModelRenderer RitSpikeC;
	ModelRenderer RitSpikeA;
	ModelRenderer RitSpikeB;


	public ModelBladeTrap() {
		textureWidth = 64;
		textureHeight = 32;

		Base = new ModelRenderer(this, 0, 0);
		Base.addBox(-2.5F, -2.5F, -2.5F, 5, 5, 5);
		Base.setRotationPoint(0F, 16.5F, 0F);
		Base.setTextureSize(64, 32);
		Base.mirror = true;
		setRotation(Base, 0F, 0F, 0F);

		BotSpikeB = new ModelRenderer(this, 2, 12);
		BotSpikeB.addBox(-0.5F, 0F, -0.5F, 1, 4, 1);
		BotSpikeB.setRotationPoint(1.5F, 19F, -1.5F);
		BotSpikeB.setTextureSize(64, 32);
		BotSpikeB.mirror = true;
		setRotation(BotSpikeB, 0F, 0F, 0F);

		BotSpikeC = new ModelRenderer(this, 2, 12);
		BotSpikeC.addBox(-0.5F, 0F, -0.5F, 1, 4, 1);
		BotSpikeC.setRotationPoint(-1.5F, 19F, 1.5F);
		BotSpikeC.setTextureSize(64, 32);
		BotSpikeC.mirror = true;
		setRotation(BotSpikeC, 0F, 0F, 0F);

		BotSpikeD = new ModelRenderer(this, 2, 12);
		BotSpikeD.addBox(-0.5F, 0F, -0.5F, 1, 4, 1);
		BotSpikeD.setRotationPoint(-1.5F, 19F, -1.5F);
		BotSpikeD.setTextureSize(64, 32);
		BotSpikeD.mirror = true;
		setRotation(BotSpikeD, 0F, 0F, 0F);

		BotSpikeA = new ModelRenderer(this, 2, 12);
		BotSpikeA.addBox(-0.5F, 0F, -0.5F, 1, 4, 1);
		BotSpikeA.setRotationPoint(1.5F, 19F, 1.5F);
		BotSpikeA.setTextureSize(64, 32);
		BotSpikeA.mirror = true;
		setRotation(BotSpikeA, 0F, 0F, 0F);

		TopSpikeA = new ModelRenderer(this, 0, 11);
		TopSpikeA.addBox(-0.5F, -4F, -0.5F, 1, 4, 1);
		TopSpikeA.setRotationPoint(1.5F, 14F, 1.5F);
		TopSpikeA.setTextureSize(64, 32);
		TopSpikeA.mirror = true;
		setRotation(TopSpikeA, 0F, 0F, 0F);

		TopSpikeC = new ModelRenderer(this, 0, 11);
		TopSpikeC.addBox(-0.5F, -4F, -0.5F, 1, 4, 1);
		TopSpikeC.setRotationPoint(-1.5F, 14F, 1.5F);
		TopSpikeC.setTextureSize(64, 32);
		TopSpikeC.mirror = true;
		setRotation(TopSpikeC, 0F, 0F, 0F);

		TopSpikeD = new ModelRenderer(this, 0, 11);
		TopSpikeD.addBox(-0.5F, -4F, -0.5F, 1, 4, 1);
		TopSpikeD.setRotationPoint(-1.5F, 14F, -1.5F);
		TopSpikeD.setTextureSize(64, 32);
		TopSpikeD.mirror = true;
		setRotation(TopSpikeD, 0F, 0F, 0F);

		TopSpikeB = new ModelRenderer(this, 0, 11);
		TopSpikeB.addBox(-0.5F, -4F, -0.5F, 1, 4, 1);
		TopSpikeB.setRotationPoint(1.5F, 14F, -1.5F);
		TopSpikeB.setTextureSize(64, 32);
		TopSpikeB.mirror = true;
		setRotation(TopSpikeB, 0F, 0F, 0F);

		RerSpikeB = new ModelRenderer(this, 2, 12);
		RerSpikeB.addBox(-4F, -0.5F, -0.5F, 4, 1, 1);
		RerSpikeB.setRotationPoint(-2F, 18F, 1.5F);
		RerSpikeB.setTextureSize(64, 32);
		RerSpikeB.mirror = true;
		setRotation(RerSpikeB, 0F, 0F, 0F);

		RerSpikeC = new ModelRenderer(this, 2, 12);
		RerSpikeC.addBox(-4F, -0.5F, -0.5F, 4, 1, 1);
		RerSpikeC.setRotationPoint(-2F, 15F, -1.5F);
		RerSpikeC.setTextureSize(64, 32);
		RerSpikeC.mirror = true;
		setRotation(RerSpikeC, 0F, 0F, 0F);

		RerSpikeD = new ModelRenderer(this, 2, 12);
		RerSpikeD.addBox(-4F, -0.5F, -0.5F, 4, 1, 1);
		RerSpikeD.setRotationPoint(-2F, 18F, -1.5F);
		RerSpikeD.setTextureSize(64, 32);
		RerSpikeD.mirror = true;
		setRotation(RerSpikeD, 0F, 0F, 0F);

		RerSpikeA = new ModelRenderer(this, 2, 12);
		RerSpikeA.addBox(-4F, -0.5F, -0.5F, 4, 1, 1);
		RerSpikeA.setRotationPoint(-2F, 15F, 1.5F);
		RerSpikeA.setTextureSize(64, 32);
		RerSpikeA.mirror = true;
		setRotation(RerSpikeA, 0F, 0F, 0F);

		FrnSpikeA = new ModelRenderer(this, 2, 12);
		FrnSpikeA.addBox(0F, -0.5F, -0.5F, 4, 1, 1);
		FrnSpikeA.setRotationPoint(2F, 15F, 1.5F);
		FrnSpikeA.setTextureSize(64, 32);
		FrnSpikeA.mirror = true;
		setRotation(FrnSpikeA, 0F, 0F, 0F);

		FrnSpikeC = new ModelRenderer(this, 2, 12);
		FrnSpikeC.addBox(0F, -0.5F, -0.5F, 4, 1, 1);
		FrnSpikeC.setRotationPoint(2F, 15F, -1.5F);
		FrnSpikeC.setTextureSize(64, 32);
		FrnSpikeC.mirror = true;
		setRotation(FrnSpikeC, 0F, 0F, 0F);

		FrnSpikeD = new ModelRenderer(this, 2, 12);
		FrnSpikeD.addBox(0F, -0.5F, -0.5F, 4, 1, 1);
		FrnSpikeD.setRotationPoint(2F, 18F, -1.5F);
		FrnSpikeD.setTextureSize(64, 32);
		FrnSpikeD.mirror = true;
		setRotation(FrnSpikeD, 0F, 0F, 0F);

		FrnSpikeB = new ModelRenderer(this, 2, 12);
		FrnSpikeB.addBox(0F, -0.5F, -0.5F, 4, 1, 1);
		FrnSpikeB.setRotationPoint(2F, 18F, 1.5F);
		FrnSpikeB.setTextureSize(64, 32);
		FrnSpikeB.mirror = true;
		setRotation(FrnSpikeB, 0F, 0F, 0F);

		LftSpikeB = new ModelRenderer(this, 2, 12);
		LftSpikeB.addBox(-0.5F, -0.5F, -4F, 1, 1, 4);
		LftSpikeB.setRotationPoint(1.5F, 15F, -2F);
		LftSpikeB.setTextureSize(64, 32);
		LftSpikeB.mirror = true;
		setRotation(LftSpikeB, 0F, 0F, 0F);

		LftSpikeC = new ModelRenderer(this, 2, 12);
		LftSpikeC.addBox(-0.5F, -0.5F, -4F, 1, 1, 4);
		LftSpikeC.setRotationPoint(-1.5F, 18F, -2F);
		LftSpikeC.setTextureSize(64, 32);
		LftSpikeC.mirror = true;
		setRotation(LftSpikeC, 0F, 0F, 0F);

		LftSpikeD = new ModelRenderer(this, 2, 12);
		LftSpikeD.addBox(-0.5F, -0.5F, -4F, 1, 1, 4);
		LftSpikeD.setRotationPoint(1.5F, 18F, -2F);
		LftSpikeD.setTextureSize(64, 32);
		LftSpikeD.mirror = true;
		setRotation(LftSpikeD, 0F, 0F, 0F);

		LftSpikeA = new ModelRenderer(this, 2, 12);
		LftSpikeA.addBox(-0.5F, -0.5F, -4F, 1, 1, 4);
		LftSpikeA.setRotationPoint(-1.5F, 15F, -2F);
		LftSpikeA.setTextureSize(64, 32);
		LftSpikeA.mirror = true;
		setRotation(LftSpikeA, 0F, 0F, 0F);

		RitSpikeD = new ModelRenderer(this, 2, 12);
		RitSpikeD.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
		RitSpikeD.setRotationPoint(1.5F, 18F, 2F);
		RitSpikeD.setTextureSize(64, 32);
		RitSpikeD.mirror = true;
		setRotation(RitSpikeD, 0F, 0F, 0F);

		RitSpikeC = new ModelRenderer(this, 2, 12);
		RitSpikeC.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
		RitSpikeC.setRotationPoint(-1.5F, 18F, 2F);
		RitSpikeC.setTextureSize(64, 32);
		RitSpikeC.mirror = true;
		setRotation(RitSpikeC, 0F, 0F, 0F);

		RitSpikeA = new ModelRenderer(this, 2, 12);
		RitSpikeA.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
		RitSpikeA.setRotationPoint(-1.5F, 15F, 2F);
		RitSpikeA.setTextureSize(64, 32);
		RitSpikeA.mirror = true;
		setRotation(RitSpikeA, 0F, 0F, 0F);

		RitSpikeB = new ModelRenderer(this, 2, 12);
		RitSpikeB.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
		RitSpikeB.setRotationPoint(1.5F, 15F, 2F);
		RitSpikeB.setTextureSize(64, 32);
		RitSpikeB.mirror = true;
		setRotation(RitSpikeB, 0F, 0F, 0F);
	}


	@Override	
	public void render(Entity entity, float limbSwing, float limbSwingAmount,
	                   float ageInTicks, float netHeadYaw, float headPitch, float scale) {
		super.render(entity, limbSwing, limbSwingAmount, ageInTicks, 
				netHeadYaw, headPitch, scale);
		setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, 
				netHeadYaw, headPitch, scale, entity);
		Base.render(scale);
		BotSpikeB.render(scale);
		BotSpikeC.render(scale);
		BotSpikeD.render(scale);
		BotSpikeA.render(scale);
		TopSpikeA.render(scale);
		TopSpikeC.render(scale);
		TopSpikeD.render(scale);
		TopSpikeB.render(scale);
		RerSpikeB.render(scale);
		RerSpikeC.render(scale);
		RerSpikeD.render(scale);
		RerSpikeA.render(scale);
		FrnSpikeA.render(scale);
		FrnSpikeC.render(scale);
		FrnSpikeD.render(scale);
		FrnSpikeB.render(scale);
		LftSpikeB.render(scale);
		LftSpikeC.render(scale);
		LftSpikeD.render(scale);
		LftSpikeA.render(scale);
		RitSpikeD.render(scale);
		RitSpikeC.render(scale);
		RitSpikeA.render(scale);
		RitSpikeB.render(scale);
	}


	private void setRotation(ModelRenderer model, float x, float y, float z) {
		model.rotateAngleX = x;
		model.rotateAngleY = y;
		model.rotateAngleZ = z;
	}


	@Override
	public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity ent) {
		super.setRotationAngles(f, f1, f2, f3, f4, f5, ent);
	}
	
	
	public void renderAllTE(float scale) {
		Base.render(scale);
		BotSpikeB.render(scale);
		BotSpikeC.render(scale);
		BotSpikeD.render(scale);
		BotSpikeA.render(scale);
		TopSpikeA.render(scale);
		TopSpikeC.render(scale);
		TopSpikeD.render(scale);
		TopSpikeB.render(scale);
		RerSpikeB.render(scale);
		RerSpikeC.render(scale);
		RerSpikeD.render(scale);
		RerSpikeA.render(scale);
		FrnSpikeA.render(scale);
		FrnSpikeC.render(scale);
		FrnSpikeD.render(scale);
		FrnSpikeB.render(scale);
		LftSpikeB.render(scale);
		LftSpikeC.render(scale);
		LftSpikeD.render(scale);
		LftSpikeA.render(scale);
		RitSpikeD.render(scale);
		RitSpikeC.render(scale);
		RitSpikeA.render(scale);
		RitSpikeB.render(scale);
	}

}

 

Into something that can render as a block.  I've tried using a TESR to render it through its tile entity, but haven't gotten anywhere with that -- also, its not really animated, so a basic block model is probably more appropriate.  The catch is, the block needs to look just like the entity it spawns ("turns into" for the player), so maybe if I could just create a JSON file based on the same numbers that would be best.  Only problem is I don't really know how, and otherwise I'll have to wait for someone else to (maybe) create a model of fix the TESR code.  Any ideas where to start for learning this?  (Or is this a silly idea?)

 

Thanks!

Developer of Doomlike Dungeons.

Link to comment
Share on other sites

Posting a picture of what it looks like would probably be more helpful.

In any case, I suggest using a tool like Blockbench or MrCrayfish. There are a few others as well.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Well, the new version (1.12.2, and also 1.7.10) looks like this as a mob:

2018-07-15_19.08.10.png

 

But maybe I'm being too picky -- the in the classic 1.6.4 version the mob and block didn't actually look alike at all (though I'd still find it preferable):

2018-07-15_19.06.24.png

 

BTW, I didn't think any of those tool could convert Java class, and didn't really think they liked raw numeric input.  I've looked at and down loaded Mr. Crayfishes a while back, but never really used except once as a test.

 

Thanks.

Developer of Doomlike Dungeons.

Link to comment
Share on other sites

15 minutes ago, JaredBGreat said:

I didn't think any of those tool could convert Java class

They can't, but that mob looks pretty easy to rebuild as a model in one of them.

Looks like the model could be done in *counts* 13 cuboids. Once for the central body and then 4 for each of the 3 axises (they'd be long, so rather than 24 spikes, you'd make 12 rods).

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.