Jump to content

Recommended Posts

Posted

Hi,

 

I've got some problems:

 

b9Eh6za.png

 

How can I tell Minecraft to use the block rotations while rendering and how can I tell it to render also the custom model in my inventory?

 

Model code:

 

package com.minecolonies.client.model;

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

public class ModelScarecrowBoth extends ModelBase
{
    //fields
    ModelRenderer Head;
    ModelRenderer Post;
    ModelRenderer LeftArmPeg;
    ModelRenderer RightArmPeg;
    ModelRenderer Torso;
    ModelRenderer RightLegPeg;
    ModelRenderer LeftLegPeg;
    ModelRenderer LeftArm;
    ModelRenderer RightArm;
    ModelRenderer RightLeg;
    ModelRenderer LeftLeg;
    
    public ModelScarecrowBoth()
    {
        textureWidth = 128;
        textureHeight = 64;
        
        Head = new ModelRenderer(this, 0, 0);
        Head.addBox(-8.2F, -35.6F, -4.2F, 8, 8, ;
        Head.setRotationPoint(7F, 24F, -1F);
        Head.setTextureSize(128, 64);
        Head.mirror = true;
        setRotation(Head, 0F, 0.1858931F, -0.1092638F);
        Post = new ModelRenderer(this, 0, 32);
        Post.addBox(-1F, -16F, -1F, 2, 16, 2);
        Post.setRotationPoint(0F, 24F, 0F);
        Post.setTextureSize(128, 64);
        Post.mirror = true;
        setRotation(Post, 0F, 0F, 0F);
        LeftArmPeg = new ModelRenderer(this, 9, 33);
        LeftArmPeg.addBox(23.5F, 1F, -1F, 2, 2, 2);
        LeftArmPeg.setRotationPoint(7F, 24F, 0F);
        LeftArmPeg.setTextureSize(128, 64);
        LeftArmPeg.mirror = true;
        setRotation(LeftArmPeg, 0F, 0F, -1.351339F);
        RightArmPeg = new ModelRenderer(this, 9, 33);
        RightArmPeg.addBox(-28F, 15.8F, -1F, 2, 2, 2);
        RightArmPeg.setRotationPoint(7F, 24F, 0F);
        RightArmPeg.setTextureSize(128, 64);
        RightArmPeg.mirror = true;
        setRotation(RightArmPeg, 0F, 0F, 1.351339F);
        Torso = new ModelRenderer(this, 16, 16);
        Torso.addBox(-10.3F, -27.6F, -2F, 8, 12, 4);
        Torso.setRotationPoint(7F, 24F, 0F);
        Torso.setTextureSize(128, 64);
        Torso.mirror = true;
        setRotation(Torso, 0F, 0F, -0.0349066F);
        RightLegPeg = new ModelRenderer(this, 9, 33);
        RightLegPeg.addBox(-11F, -4F, -1F, 2, 2, 2);
        RightLegPeg.setRotationPoint(7F, 24F, 0F);
        RightLegPeg.setTextureSize(128, 64);
        RightLegPeg.mirror = true;
        setRotation(RightLegPeg, 0F, 0F, 0.0872665F);
        LeftLegPeg = new ModelRenderer(this, 9, 33);
        LeftLegPeg.addBox(-4.5F, -5F, -1F, 2, 2, 2);
        LeftLegPeg.setRotationPoint(7F, 24F, 0F);
        LeftLegPeg.setTextureSize(128, 64);
        LeftLegPeg.mirror = true;
        setRotation(LeftLegPeg, 0F, 0F, -0.0872665F);
        LeftArm = new ModelRenderer(this, 40, 16);
        LeftArm.addBox(22.5F, -10F, -1.99F, 4, 12, 4);
        LeftArm.setRotationPoint(7F, 24F, 0F);
        LeftArm.setTextureSize(128, 64);
        LeftArm.mirror = true;
        setRotation(LeftArm, 0F, 0F, -1.351339F);
        RightArm = new ModelRenderer(this, 40, 16);
        RightArm.addBox(-29F, 4.8F, -1.99F, 4, 12, 4);
        RightArm.setRotationPoint(7F, 24F, 0F);
        RightArm.setTextureSize(128, 64);
        RightArm.mirror = true;
        setRotation(RightArm, 0F, 0F, 1.351339F);
        RightLeg = new ModelRenderer(this, 0, 16);
        RightLeg.addBox(-12F, -15F, -1.99F, 4, 12, 4);
        RightLeg.setRotationPoint(7F, 24F, 0F);
        RightLeg.setTextureSize(128, 64);
        RightLeg.mirror = true;
        setRotation(RightLeg, 0F, 0F, 0.0872665F);
        LeftLeg = new ModelRenderer(this, 0, 16);
        LeftLeg.addBox(-5.5F, -16F, -1.98F, 4, 12, 4);
        LeftLeg.setRotationPoint(7F, 24F, 0F);
        LeftLeg.setTextureSize(128, 64);
        LeftLeg.mirror = true;
        setRotation(LeftLeg, 0F, 0F, -0.0872665F);
    }
    
    public void render(float scaleFactor)
    {
        Head.render(scaleFactor);
        Post.render(scaleFactor);
        LeftArmPeg.render(scaleFactor);
        RightArmPeg.render(scaleFactor);
        Torso.render(scaleFactor);
        RightLegPeg.render(scaleFactor);
        LeftLegPeg.render(scaleFactor);
        LeftArm.render(scaleFactor);
        RightArm.render(scaleFactor);
        RightLeg.render(scaleFactor);
        LeftLeg.render(scaleFactor);
    }
    
    private void setRotation(ModelRenderer model, float x, float y, float z)
    {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
    }
}

 

 

Render code:

 

package com.minecolonies.client.render;

import com.minecolonies.client.model.ModelScarecrowBoth;
import com.minecolonies.lib.Constants;
import com.minecolonies.tileentities.ScarecrowTileEntity;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Class to render the scarecrow.
*/
@SideOnly(Side.CLIENT)
public class TileEntityScarecrowRenderer extends TileEntitySpecialRenderer<ScarecrowTileEntity>
{
    private final ModelScarecrowBoth model;

    public TileEntityScarecrowRenderer() { 
        this.model = new ModelScarecrowBoth();
    }
    
    @Override
    public void renderTileEntityAt(ScarecrowTileEntity te, double posX, double posY, double posZ, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix(); // store the transformation 
        GlStateManager.translate(posX, posY, posZ); // set viewport to tile entity position to render it
        
        /* ============ Rendering Code goes here ============ */
        
        this.bindTexture(this.getResourceLocation(te));
        this.model.render(.0625f);
        
        /* ============ Rendering Code stops here =========== */
        
        GlStateManager.popMatrix(); // restore the transformation, so other renderer's are not messed up
    }
    
    private ResourceLocation getResourceLocation(ScarecrowTileEntity tileentity) { 
        String loc;
        
        if(tileentity.getType())
            loc = "textures/blocks/blockScarecrowPumpkin.png";
        else
            loc = "textures/blocks/blockScarecrowNormal.png";
        
        return new ResourceLocation(Constants.MOD_ID + ":" + loc);
    }
}

 

 

I also hope it's correct how I try getting the texture. Not quite sure about this.

 

Thx in advance.

Bektor

Developer of Primeval Forest.

Posted

Hi,

 

I've got some problems:

 

b9Eh6za.png

 

How can I tell Minecraft to use the block rotations while rendering and how can I tell it to render also the custom model in my inventory?

 

Model code:

 

package com.minecolonies.client.model;

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

public class ModelScarecrowBoth extends ModelBase
{
    //fields
    ModelRenderer Head;
    ModelRenderer Post;
    ModelRenderer LeftArmPeg;
    ModelRenderer RightArmPeg;
    ModelRenderer Torso;
    ModelRenderer RightLegPeg;
    ModelRenderer LeftLegPeg;
    ModelRenderer LeftArm;
    ModelRenderer RightArm;
    ModelRenderer RightLeg;
    ModelRenderer LeftLeg;
    
    public ModelScarecrowBoth()
    {
        textureWidth = 128;
        textureHeight = 64;
        
        Head = new ModelRenderer(this, 0, 0);
        Head.addBox(-8.2F, -35.6F, -4.2F, 8, 8, ;
        Head.setRotationPoint(7F, 24F, -1F);
        Head.setTextureSize(128, 64);
        Head.mirror = true;
        setRotation(Head, 0F, 0.1858931F, -0.1092638F);
        Post = new ModelRenderer(this, 0, 32);
        Post.addBox(-1F, -16F, -1F, 2, 16, 2);
        Post.setRotationPoint(0F, 24F, 0F);
        Post.setTextureSize(128, 64);
        Post.mirror = true;
        setRotation(Post, 0F, 0F, 0F);
        LeftArmPeg = new ModelRenderer(this, 9, 33);
        LeftArmPeg.addBox(23.5F, 1F, -1F, 2, 2, 2);
        LeftArmPeg.setRotationPoint(7F, 24F, 0F);
        LeftArmPeg.setTextureSize(128, 64);
        LeftArmPeg.mirror = true;
        setRotation(LeftArmPeg, 0F, 0F, -1.351339F);
        RightArmPeg = new ModelRenderer(this, 9, 33);
        RightArmPeg.addBox(-28F, 15.8F, -1F, 2, 2, 2);
        RightArmPeg.setRotationPoint(7F, 24F, 0F);
        RightArmPeg.setTextureSize(128, 64);
        RightArmPeg.mirror = true;
        setRotation(RightArmPeg, 0F, 0F, 1.351339F);
        Torso = new ModelRenderer(this, 16, 16);
        Torso.addBox(-10.3F, -27.6F, -2F, 8, 12, 4);
        Torso.setRotationPoint(7F, 24F, 0F);
        Torso.setTextureSize(128, 64);
        Torso.mirror = true;
        setRotation(Torso, 0F, 0F, -0.0349066F);
        RightLegPeg = new ModelRenderer(this, 9, 33);
        RightLegPeg.addBox(-11F, -4F, -1F, 2, 2, 2);
        RightLegPeg.setRotationPoint(7F, 24F, 0F);
        RightLegPeg.setTextureSize(128, 64);
        RightLegPeg.mirror = true;
        setRotation(RightLegPeg, 0F, 0F, 0.0872665F);
        LeftLegPeg = new ModelRenderer(this, 9, 33);
        LeftLegPeg.addBox(-4.5F, -5F, -1F, 2, 2, 2);
        LeftLegPeg.setRotationPoint(7F, 24F, 0F);
        LeftLegPeg.setTextureSize(128, 64);
        LeftLegPeg.mirror = true;
        setRotation(LeftLegPeg, 0F, 0F, -0.0872665F);
        LeftArm = new ModelRenderer(this, 40, 16);
        LeftArm.addBox(22.5F, -10F, -1.99F, 4, 12, 4);
        LeftArm.setRotationPoint(7F, 24F, 0F);
        LeftArm.setTextureSize(128, 64);
        LeftArm.mirror = true;
        setRotation(LeftArm, 0F, 0F, -1.351339F);
        RightArm = new ModelRenderer(this, 40, 16);
        RightArm.addBox(-29F, 4.8F, -1.99F, 4, 12, 4);
        RightArm.setRotationPoint(7F, 24F, 0F);
        RightArm.setTextureSize(128, 64);
        RightArm.mirror = true;
        setRotation(RightArm, 0F, 0F, 1.351339F);
        RightLeg = new ModelRenderer(this, 0, 16);
        RightLeg.addBox(-12F, -15F, -1.99F, 4, 12, 4);
        RightLeg.setRotationPoint(7F, 24F, 0F);
        RightLeg.setTextureSize(128, 64);
        RightLeg.mirror = true;
        setRotation(RightLeg, 0F, 0F, 0.0872665F);
        LeftLeg = new ModelRenderer(this, 0, 16);
        LeftLeg.addBox(-5.5F, -16F, -1.98F, 4, 12, 4);
        LeftLeg.setRotationPoint(7F, 24F, 0F);
        LeftLeg.setTextureSize(128, 64);
        LeftLeg.mirror = true;
        setRotation(LeftLeg, 0F, 0F, -0.0872665F);
    }
    
    public void render(float scaleFactor)
    {
        Head.render(scaleFactor);
        Post.render(scaleFactor);
        LeftArmPeg.render(scaleFactor);
        RightArmPeg.render(scaleFactor);
        Torso.render(scaleFactor);
        RightLegPeg.render(scaleFactor);
        LeftLegPeg.render(scaleFactor);
        LeftArm.render(scaleFactor);
        RightArm.render(scaleFactor);
        RightLeg.render(scaleFactor);
        LeftLeg.render(scaleFactor);
    }
    
    private void setRotation(ModelRenderer model, float x, float y, float z)
    {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
    }
}

 

 

Render code:

 

package com.minecolonies.client.render;

import com.minecolonies.client.model.ModelScarecrowBoth;
import com.minecolonies.lib.Constants;
import com.minecolonies.tileentities.ScarecrowTileEntity;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Class to render the scarecrow.
*/
@SideOnly(Side.CLIENT)
public class TileEntityScarecrowRenderer extends TileEntitySpecialRenderer<ScarecrowTileEntity>
{
    private final ModelScarecrowBoth model;

    public TileEntityScarecrowRenderer() { 
        this.model = new ModelScarecrowBoth();
    }
    
    @Override
    public void renderTileEntityAt(ScarecrowTileEntity te, double posX, double posY, double posZ, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix(); // store the transformation 
        GlStateManager.translate(posX, posY, posZ); // set viewport to tile entity position to render it
        
        /* ============ Rendering Code goes here ============ */
        
        this.bindTexture(this.getResourceLocation(te));
        this.model.render(.0625f);
        
        /* ============ Rendering Code stops here =========== */
        
        GlStateManager.popMatrix(); // restore the transformation, so other renderer's are not messed up
    }
    
    private ResourceLocation getResourceLocation(ScarecrowTileEntity tileentity) { 
        String loc;
        
        if(tileentity.getType())
            loc = "textures/blocks/blockScarecrowPumpkin.png";
        else
            loc = "textures/blocks/blockScarecrowNormal.png";
        
        return new ResourceLocation(Constants.MOD_ID + ":" + loc);
    }
}

 

 

I also hope it's correct how I try getting the texture. Not quite sure about this.

 

Thx in advance.

Bektor

Developer of Primeval Forest.

Posted

How can I tell Minecraft to use the block rotations while rendering
glRotate

.

how can I tell it to render also the custom model in my inventory?
ForgeHooksClient.registerTESRItemStack

.

 

Why is this is a TESR though?

 

What is a TESR? And when I have glRotate, I have to get somehow the rotations from the block itself which where set with a PropertyDirection in the block class.

 

EDIT: When I've got ForgeHooksClient.registerTESRItemStack, do I need any json file? And if I need them, what to put in them?

Developer of Primeval Forest.

Posted

How can I tell Minecraft to use the block rotations while rendering
glRotate

.

how can I tell it to render also the custom model in my inventory?
ForgeHooksClient.registerTESRItemStack

.

 

Why is this is a TESR though?

 

What is a TESR? And when I have glRotate, I have to get somehow the rotations from the block itself which where set with a PropertyDirection in the block class.

 

EDIT: When I've got ForgeHooksClient.registerTESRItemStack, do I need any json file? And if I need them, what to put in them?

Developer of Primeval Forest.

Posted

What is a TESR?

TileEntitySpecialRenderer

 

And when I have glRotate, I have to get somehow the rotations from the block itself which where set with a PropertyDirection in the block class.

Use

World#getBlockState

to get the current state and

IBlockState#getValue

to get the facing from that state.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

What is a TESR?

TileEntitySpecialRenderer

 

And when I have glRotate, I have to get somehow the rotations from the block itself which where set with a PropertyDirection in the block class.

Use

World#getBlockState

to get the current state and

IBlockState#getValue

to get the facing from that state.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Ah, ok.

@diesieben07 It's a TESR because the team I'm working with want's it so and they got only the java code for the model from their modeller.

ForgeHooksClient.registerTESRItemStack is deprecated. Is there a replacement for it, because I don't like deprecated stuff.

 

        EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHutField.FACING);
        
        this.bindTexture(this.getResourceLocation(te));
        GlStateManager.rotate(angle, x, y, z);
        this.model.render(.0625f);

What do I have to put in there now, so in the GlStateManager.rotate method?

Just to mention, the complete model must also always be rotated around 180 degrees cause it's up side down.

 

EDIT: Ok, I've got now jsons because I render it with the rendering class. I've got also that code ForgeHooksClient#registerTESRItemStack as a replacement for the json loading stuff and now it's not drawing in the inventory. :(

Developer of Primeval Forest.

Posted

Ah, ok.

@diesieben07 It's a TESR because the team I'm working with want's it so and they got only the java code for the model from their modeller.

ForgeHooksClient.registerTESRItemStack is deprecated. Is there a replacement for it, because I don't like deprecated stuff.

 

        EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHutField.FACING);
        
        this.bindTexture(this.getResourceLocation(te));
        GlStateManager.rotate(angle, x, y, z);
        this.model.render(.0625f);

What do I have to put in there now, so in the GlStateManager.rotate method?

Just to mention, the complete model must also always be rotated around 180 degrees cause it's up side down.

 

EDIT: Ok, I've got now jsons because I render it with the rendering class. I've got also that code ForgeHooksClient#registerTESRItemStack as a replacement for the json loading stuff and now it's not drawing in the inventory. :(

Developer of Primeval Forest.

Posted

package com.minecolonies.client.render;

import com.minecolonies.blocks.BlockHutField;
import com.minecolonies.client.model.ModelScarecrowBoth;
import com.minecolonies.lib.Constants;
import com.minecolonies.tileentities.ScarecrowTileEntity;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Class to render the scarecrow.
*/
@SideOnly(Side.CLIENT)
public class TileEntityScarecrowRenderer extends TileEntitySpecialRenderer<ScarecrowTileEntity>
{
    private final ModelScarecrowBoth model;

    public TileEntityScarecrowRenderer() { 
        this.model = new ModelScarecrowBoth();
    }
    
    @Override
    public void renderTileEntityAt(ScarecrowTileEntity te, double posX, double posY, double posZ, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix(); // store the transformation 
        GlStateManager.translate(posX, posY, posZ); // set viewport to tile entity position to render it
        
        /* ============ Rendering Code goes here ============ */
        EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHutField.FACING);
        
        this.bindTexture(this.getResourceLocation(te));
        //GlStateManager.rotate(angle, x, y, z);
        this.model.render(.0625f);
        
        /* ============ Rendering Code stops here =========== */
        
        GlStateManager.popMatrix(); // restore the transformation, so other renderer's are not messed up
    }
    
    private ResourceLocation getResourceLocation(ScarecrowTileEntity tileentity) { 
        String loc;
        
        if(tileentity.getType())
            loc = "textures/blocks/blockScarecrowPumpkin.png";
        else
            loc = "textures/blocks/blockScarecrowNormal.png";
        
        return new ResourceLocation(Constants.MOD_ID + ":" + loc);
    }
}

Also, the texture seems also not to be loaded....

 

ClientRegistry.bindTileEntitySpecialRenderer(ScarecrowTileEntity.class, new TileEntityScarecrowRenderer());
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.blockHutField), 0, ScarecrowTileEntity.class);

This is in Client Proxy.

 

Developer of Primeval Forest.

Posted

package com.minecolonies.client.render;

import com.minecolonies.blocks.BlockHutField;
import com.minecolonies.client.model.ModelScarecrowBoth;
import com.minecolonies.lib.Constants;
import com.minecolonies.tileentities.ScarecrowTileEntity;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Class to render the scarecrow.
*/
@SideOnly(Side.CLIENT)
public class TileEntityScarecrowRenderer extends TileEntitySpecialRenderer<ScarecrowTileEntity>
{
    private final ModelScarecrowBoth model;

    public TileEntityScarecrowRenderer() { 
        this.model = new ModelScarecrowBoth();
    }
    
    @Override
    public void renderTileEntityAt(ScarecrowTileEntity te, double posX, double posY, double posZ, float partialTicks, int destroyStage) {
        GlStateManager.pushMatrix(); // store the transformation 
        GlStateManager.translate(posX, posY, posZ); // set viewport to tile entity position to render it
        
        /* ============ Rendering Code goes here ============ */
        EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(BlockHutField.FACING);
        
        this.bindTexture(this.getResourceLocation(te));
        //GlStateManager.rotate(angle, x, y, z);
        this.model.render(.0625f);
        
        /* ============ Rendering Code stops here =========== */
        
        GlStateManager.popMatrix(); // restore the transformation, so other renderer's are not messed up
    }
    
    private ResourceLocation getResourceLocation(ScarecrowTileEntity tileentity) { 
        String loc;
        
        if(tileentity.getType())
            loc = "textures/blocks/blockScarecrowPumpkin.png";
        else
            loc = "textures/blocks/blockScarecrowNormal.png";
        
        return new ResourceLocation(Constants.MOD_ID + ":" + loc);
    }
}

Also, the texture seems also not to be loaded....

 

ClientRegistry.bindTileEntitySpecialRenderer(ScarecrowTileEntity.class, new TileEntityScarecrowRenderer());
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.blockHutField), 0, ScarecrowTileEntity.class);

This is in Client Proxy.

 

Developer of Primeval Forest.

Posted

ClientProxy

package com.minecolonies.proxy;

import com.minecolonies.blocks.ModBlocks;
import com.minecolonies.client.gui.WindowBuildTool;
import com.minecolonies.client.gui.WindowCitizen;
import com.minecolonies.client.render.EmptyTileEntitySpecialRenderer;
import com.minecolonies.client.render.RenderBipedCitizen;
import com.minecolonies.client.render.RenderFishHook;
import com.minecolonies.client.render.TileEntityScarecrowRenderer;
import com.minecolonies.colony.CitizenData;
import com.minecolonies.entity.EntityCitizen;
import com.minecolonies.entity.EntityFishHook;
import com.minecolonies.event.ClientEventHandler;
import com.minecolonies.items.ModItems;
import com.minecolonies.tileentities.ScarecrowTileEntity;
import com.minecolonies.tileentities.TileEntityColonyBuilding;
import com.schematica.client.events.TickHandler;
import com.schematica.client.renderer.RendererSchematicGlobal;
import com.schematica.world.SchematicWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy
{
    private RendererSchematicGlobal rendererSchematicGlobal;
    private SchematicWorld          schematicWorld          = null;

    @Override
    public boolean isClient()
    {
        return true;
    }

    @Override
    public void registerKeyBindings()
    {
//        for(KeyBinding keyBinding : KeyInputHandler.KEY_BINDINGS)
//        {
//            ClientRegistry.registerKeyBinding(keyBinding);
//        }
    }

    @Override
    public void registerEvents()
    {
        super.registerEvents();

        MinecraftForge.EVENT_BUS.register(new ClientEventHandler());

        //Schematica
        MinecraftForge.EVENT_BUS.register(new TickHandler());
        this.rendererSchematicGlobal = new RendererSchematicGlobal();
        MinecraftForge.EVENT_BUS.register(this.rendererSchematicGlobal);
    }

    @Override
    public void registerEntityRendering()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityCitizen.class, RenderBipedCitizen::new);
        RenderingRegistry.registerEntityRenderingHandler(EntityFishHook.class, RenderFishHook::new);

    }

    @Override
    public void registerTileEntityRendering()
    {
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityColonyBuilding.class, new EmptyTileEntitySpecialRenderer());
        ClientRegistry.bindTileEntitySpecialRenderer(ScarecrowTileEntity.class, new TileEntityScarecrowRenderer());
    }

    @Override
    public void showCitizenWindow(CitizenData.View citizen)
    {
        WindowCitizen window = new WindowCitizen(citizen);
        window.open();
    }

    @Override
    public void openBuildToolWindow(BlockPos pos)
    {
        WindowBuildTool window = new WindowBuildTool(pos);
        window.open();
    }

    //Schematica
    @Override
    public void setActiveSchematic(SchematicWorld world)
    {
        this.schematicWorld = world;
    }

    @Override
    public SchematicWorld getActiveSchematic()
    {
        return this.schematicWorld;
    }
    
    @Override
    public void registerRenderer() {
    	super.registerRenderer();
    	
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBaker), 0, new ModelResourceLocation(ModBlocks.blockHutBaker.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBlacksmith), 0, new ModelResourceLocation(ModBlocks.blockHutBlacksmith.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBuilder), 0, new ModelResourceLocation(ModBlocks.blockHutBuilder.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutCitizen), 0, new ModelResourceLocation(ModBlocks.blockHutCitizen.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutFarmer), 0, new ModelResourceLocation(ModBlocks.blockHutFarmer.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutFisherman), 0, new ModelResourceLocation(ModBlocks.blockHutFisherman.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutLumberjack), 0, new ModelResourceLocation(ModBlocks.blockHutLumberjack.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutMiner), 0, new ModelResourceLocation(ModBlocks.blockHutMiner.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutStonemason), 0, new ModelResourceLocation(ModBlocks.blockHutStonemason.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutTownHall), 0, new ModelResourceLocation(ModBlocks.blockHutTownHall.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutWarehouse), 0, new ModelResourceLocation(ModBlocks.blockHutWarehouse.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSubstitution.getRegistryName(), "inventory"));
        //Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutField), 0, new ModelResourceLocation(ModBlocks.blockHutField.getRegistryName(), "inventory"));
    	
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.buildTool, 0, new ModelResourceLocation(ModItems.buildTool.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.caliper, 0, new ModelResourceLocation(ModItems.caliper.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.scanTool, 0, new ModelResourceLocation(ModItems.scanTool.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.supplyChest, 0, new ModelResourceLocation(ModItems.supplyChest.getRegistryName(), "inventory"));
    	ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.blockHutField), 0, ScarecrowTileEntity.class);
    }
}

 

Main class:

package com.minecolonies;

import com.minecolonies.blocks.ModBlocks;
import com.minecolonies.colony.Schematics;
import com.minecolonies.configuration.ConfigurationHandler;
import com.minecolonies.configuration.Configurations;
import com.minecolonies.items.ModItems;
import com.minecolonies.lib.Constants;
import com.minecolonies.network.messages.*;
import com.minecolonies.proxy.IProxy;
import com.minecolonies.util.Log;
import com.minecolonies.util.RecipeHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;


@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION, certificateFingerprint = Constants.FINGERPRINT,
	dependencies = Constants.FORGE_VERSION, acceptedMinecraftVersions = Constants.MC_VERSION)
public class MineColonies
{
    private static          SimpleNetworkWrapper network;

    @Mod.Instance(Constants.MOD_ID)
    public static           MineColonies         instance;

    @SidedProxy(clientSide = Constants.CLIENT_PROXY_LOCATION, serverSide = Constants.SERVER_PROXY_LOCATION)
    public static           IProxy               proxy;

    public static SimpleNetworkWrapper getNetwork()
    {
        return network;
    }

    @Mod.EventHandler
    public void invalidFingerprint(FMLFingerprintViolationEvent event)
    {
        if(Constants.FINGERPRINT.equals("@FINGERPRINT@"))
        {
            Log.logger.error("No Fingerprint. Might not be a valid version!");
        }
    }

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        //not needed, code already in init
        //logger = event.getModLog();

        ConfigurationHandler.init(event.getSuggestedConfigurationFile());

        ModBlocks.init();

        ModItems.init();

        proxy.registerKeyBindings();//Schematica
        
        proxy.registerEntities();

        proxy.registerEntityRendering();
    }

    @Mod.EventHandler
    public void init(FMLInitializationEvent event)
    {
        network = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_NAME);
        //  ColonyView messages
        getNetwork().registerMessage(ColonyViewMessage.class,                ColonyViewMessage.class,                1,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewCitizenViewMessage.class,     ColonyViewCitizenViewMessage.class,     2,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewRemoveCitizenMessage.class,   ColonyViewRemoveCitizenMessage.class,   3,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewBuildingViewMessage.class,    ColonyViewBuildingViewMessage.class,    4,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewRemoveBuildingMessage.class,  ColonyViewRemoveBuildingMessage.class,  5,  Side.CLIENT);
        getNetwork().registerMessage(PermissionsMessage.View.class,          PermissionsMessage.View.class,          6,  Side.CLIENT);
        getNetwork().registerMessage(ColonyStylesMessage.class,              ColonyStylesMessage.class,              7,  Side.CLIENT);
        //  Permission Request messages
        getNetwork().registerMessage(PermissionsMessage.Permission.class,    PermissionsMessage.Permission.class,    10, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.AddPlayer.class,     PermissionsMessage.AddPlayer.class,     11, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.RemovePlayer.class,  PermissionsMessage.RemovePlayer.class,  12, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.SetPlayerRank.class, PermissionsMessage.SetPlayerRank.class, 13, Side.SERVER);
        //  Colony Request messages
        getNetwork().registerMessage(BuildRequestMessage.class,              BuildRequestMessage.class,              20, Side.SERVER);
        getNetwork().registerMessage(OpenInventoryMessage.class,             OpenInventoryMessage.class,             21, Side.SERVER);
        getNetwork().registerMessage(TownHallRenameMessage.class,            TownHallRenameMessage.class,            22, Side.SERVER);
        getNetwork().registerMessage(MinerSetLevelMessage.class,             MinerSetLevelMessage.class,             23, Side.SERVER);
        getNetwork().registerMessage(FarmerCropTypeMessage.class,            FarmerCropTypeMessage.class,            24, Side.SERVER);
        getNetwork().registerMessage(RecallCitizenMessage.class,             RecallCitizenMessage.class,             25, Side.SERVER);
        getNetwork().registerMessage(BuildToolPlaceMessage.class,            BuildToolPlaceMessage.class,            26, Side.SERVER);
        getNetwork().registerMessage(ToggleJobMessage.class,                 ToggleJobMessage.class,                 27, Side.SERVER);
        getNetwork().registerMessage(HireFireMessage.class,                  HireFireMessage.class,                  28, Side.SERVER);

        //Client side only
        getNetwork().registerMessage(BlockParticleEffectMessage.class,       BlockParticleEffectMessage.class,       50, Side.CLIENT);

        proxy.registerTileEntities();

        RecipeHandler.init(Configurations.enableInDevelopmentFeatures, Configurations.supplyChests);

        proxy.registerEvents();

        proxy.registerTileEntityRendering();
        
        proxy.registerRenderer();

        Schematics.init();
    }

    @Mod.EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    }

    /**
     * Returns whether the side is client or not
     *
     * @return      True when client, otherwise false
     */
    public static boolean isClient()
    {
        return proxy.isClient() && FMLCommonHandler.instance().getEffectiveSide().isClient();
    }

    /**
     * Returns whether the side is client or not
     *
     * @return      True when server, otherwise false
     */
    public static boolean isServer()
    {
        return !proxy.isClient() && FMLCommonHandler.instance().getEffectiveSide().isServer();
    }
}

Developer of Primeval Forest.

Posted

ClientProxy

package com.minecolonies.proxy;

import com.minecolonies.blocks.ModBlocks;
import com.minecolonies.client.gui.WindowBuildTool;
import com.minecolonies.client.gui.WindowCitizen;
import com.minecolonies.client.render.EmptyTileEntitySpecialRenderer;
import com.minecolonies.client.render.RenderBipedCitizen;
import com.minecolonies.client.render.RenderFishHook;
import com.minecolonies.client.render.TileEntityScarecrowRenderer;
import com.minecolonies.colony.CitizenData;
import com.minecolonies.entity.EntityCitizen;
import com.minecolonies.entity.EntityFishHook;
import com.minecolonies.event.ClientEventHandler;
import com.minecolonies.items.ModItems;
import com.minecolonies.tileentities.ScarecrowTileEntity;
import com.minecolonies.tileentities.TileEntityColonyBuilding;
import com.schematica.client.events.TickHandler;
import com.schematica.client.renderer.RendererSchematicGlobal;
import com.schematica.world.SchematicWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy
{
    private RendererSchematicGlobal rendererSchematicGlobal;
    private SchematicWorld          schematicWorld          = null;

    @Override
    public boolean isClient()
    {
        return true;
    }

    @Override
    public void registerKeyBindings()
    {
//        for(KeyBinding keyBinding : KeyInputHandler.KEY_BINDINGS)
//        {
//            ClientRegistry.registerKeyBinding(keyBinding);
//        }
    }

    @Override
    public void registerEvents()
    {
        super.registerEvents();

        MinecraftForge.EVENT_BUS.register(new ClientEventHandler());

        //Schematica
        MinecraftForge.EVENT_BUS.register(new TickHandler());
        this.rendererSchematicGlobal = new RendererSchematicGlobal();
        MinecraftForge.EVENT_BUS.register(this.rendererSchematicGlobal);
    }

    @Override
    public void registerEntityRendering()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityCitizen.class, RenderBipedCitizen::new);
        RenderingRegistry.registerEntityRenderingHandler(EntityFishHook.class, RenderFishHook::new);

    }

    @Override
    public void registerTileEntityRendering()
    {
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityColonyBuilding.class, new EmptyTileEntitySpecialRenderer());
        ClientRegistry.bindTileEntitySpecialRenderer(ScarecrowTileEntity.class, new TileEntityScarecrowRenderer());
    }

    @Override
    public void showCitizenWindow(CitizenData.View citizen)
    {
        WindowCitizen window = new WindowCitizen(citizen);
        window.open();
    }

    @Override
    public void openBuildToolWindow(BlockPos pos)
    {
        WindowBuildTool window = new WindowBuildTool(pos);
        window.open();
    }

    //Schematica
    @Override
    public void setActiveSchematic(SchematicWorld world)
    {
        this.schematicWorld = world;
    }

    @Override
    public SchematicWorld getActiveSchematic()
    {
        return this.schematicWorld;
    }
    
    @Override
    public void registerRenderer() {
    	super.registerRenderer();
    	
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBaker), 0, new ModelResourceLocation(ModBlocks.blockHutBaker.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBlacksmith), 0, new ModelResourceLocation(ModBlocks.blockHutBlacksmith.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBuilder), 0, new ModelResourceLocation(ModBlocks.blockHutBuilder.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutCitizen), 0, new ModelResourceLocation(ModBlocks.blockHutCitizen.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutFarmer), 0, new ModelResourceLocation(ModBlocks.blockHutFarmer.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutFisherman), 0, new ModelResourceLocation(ModBlocks.blockHutFisherman.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutLumberjack), 0, new ModelResourceLocation(ModBlocks.blockHutLumberjack.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutMiner), 0, new ModelResourceLocation(ModBlocks.blockHutMiner.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutStonemason), 0, new ModelResourceLocation(ModBlocks.blockHutStonemason.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutTownHall), 0, new ModelResourceLocation(ModBlocks.blockHutTownHall.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutWarehouse), 0, new ModelResourceLocation(ModBlocks.blockHutWarehouse.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSubstitution.getRegistryName(), "inventory"));
        //Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutField), 0, new ModelResourceLocation(ModBlocks.blockHutField.getRegistryName(), "inventory"));
    	
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.buildTool, 0, new ModelResourceLocation(ModItems.buildTool.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.caliper, 0, new ModelResourceLocation(ModItems.caliper.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.scanTool, 0, new ModelResourceLocation(ModItems.scanTool.getRegistryName(), "inventory"));
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.supplyChest, 0, new ModelResourceLocation(ModItems.supplyChest.getRegistryName(), "inventory"));
    	ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(ModBlocks.blockHutField), 0, ScarecrowTileEntity.class);
    }
}

 

Main class:

package com.minecolonies;

import com.minecolonies.blocks.ModBlocks;
import com.minecolonies.colony.Schematics;
import com.minecolonies.configuration.ConfigurationHandler;
import com.minecolonies.configuration.Configurations;
import com.minecolonies.items.ModItems;
import com.minecolonies.lib.Constants;
import com.minecolonies.network.messages.*;
import com.minecolonies.proxy.IProxy;
import com.minecolonies.util.Log;
import com.minecolonies.util.RecipeHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;


@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION, certificateFingerprint = Constants.FINGERPRINT,
	dependencies = Constants.FORGE_VERSION, acceptedMinecraftVersions = Constants.MC_VERSION)
public class MineColonies
{
    private static          SimpleNetworkWrapper network;

    @Mod.Instance(Constants.MOD_ID)
    public static           MineColonies         instance;

    @SidedProxy(clientSide = Constants.CLIENT_PROXY_LOCATION, serverSide = Constants.SERVER_PROXY_LOCATION)
    public static           IProxy               proxy;

    public static SimpleNetworkWrapper getNetwork()
    {
        return network;
    }

    @Mod.EventHandler
    public void invalidFingerprint(FMLFingerprintViolationEvent event)
    {
        if(Constants.FINGERPRINT.equals("@FINGERPRINT@"))
        {
            Log.logger.error("No Fingerprint. Might not be a valid version!");
        }
    }

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        //not needed, code already in init
        //logger = event.getModLog();

        ConfigurationHandler.init(event.getSuggestedConfigurationFile());

        ModBlocks.init();

        ModItems.init();

        proxy.registerKeyBindings();//Schematica
        
        proxy.registerEntities();

        proxy.registerEntityRendering();
    }

    @Mod.EventHandler
    public void init(FMLInitializationEvent event)
    {
        network = NetworkRegistry.INSTANCE.newSimpleChannel(Constants.MOD_NAME);
        //  ColonyView messages
        getNetwork().registerMessage(ColonyViewMessage.class,                ColonyViewMessage.class,                1,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewCitizenViewMessage.class,     ColonyViewCitizenViewMessage.class,     2,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewRemoveCitizenMessage.class,   ColonyViewRemoveCitizenMessage.class,   3,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewBuildingViewMessage.class,    ColonyViewBuildingViewMessage.class,    4,  Side.CLIENT);
        getNetwork().registerMessage(ColonyViewRemoveBuildingMessage.class,  ColonyViewRemoveBuildingMessage.class,  5,  Side.CLIENT);
        getNetwork().registerMessage(PermissionsMessage.View.class,          PermissionsMessage.View.class,          6,  Side.CLIENT);
        getNetwork().registerMessage(ColonyStylesMessage.class,              ColonyStylesMessage.class,              7,  Side.CLIENT);
        //  Permission Request messages
        getNetwork().registerMessage(PermissionsMessage.Permission.class,    PermissionsMessage.Permission.class,    10, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.AddPlayer.class,     PermissionsMessage.AddPlayer.class,     11, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.RemovePlayer.class,  PermissionsMessage.RemovePlayer.class,  12, Side.SERVER);
        getNetwork().registerMessage(PermissionsMessage.SetPlayerRank.class, PermissionsMessage.SetPlayerRank.class, 13, Side.SERVER);
        //  Colony Request messages
        getNetwork().registerMessage(BuildRequestMessage.class,              BuildRequestMessage.class,              20, Side.SERVER);
        getNetwork().registerMessage(OpenInventoryMessage.class,             OpenInventoryMessage.class,             21, Side.SERVER);
        getNetwork().registerMessage(TownHallRenameMessage.class,            TownHallRenameMessage.class,            22, Side.SERVER);
        getNetwork().registerMessage(MinerSetLevelMessage.class,             MinerSetLevelMessage.class,             23, Side.SERVER);
        getNetwork().registerMessage(FarmerCropTypeMessage.class,            FarmerCropTypeMessage.class,            24, Side.SERVER);
        getNetwork().registerMessage(RecallCitizenMessage.class,             RecallCitizenMessage.class,             25, Side.SERVER);
        getNetwork().registerMessage(BuildToolPlaceMessage.class,            BuildToolPlaceMessage.class,            26, Side.SERVER);
        getNetwork().registerMessage(ToggleJobMessage.class,                 ToggleJobMessage.class,                 27, Side.SERVER);
        getNetwork().registerMessage(HireFireMessage.class,                  HireFireMessage.class,                  28, Side.SERVER);

        //Client side only
        getNetwork().registerMessage(BlockParticleEffectMessage.class,       BlockParticleEffectMessage.class,       50, Side.CLIENT);

        proxy.registerTileEntities();

        RecipeHandler.init(Configurations.enableInDevelopmentFeatures, Configurations.supplyChests);

        proxy.registerEvents();

        proxy.registerTileEntityRendering();
        
        proxy.registerRenderer();

        Schematics.init();
    }

    @Mod.EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    }

    /**
     * Returns whether the side is client or not
     *
     * @return      True when client, otherwise false
     */
    public static boolean isClient()
    {
        return proxy.isClient() && FMLCommonHandler.instance().getEffectiveSide().isClient();
    }

    /**
     * Returns whether the side is client or not
     *
     * @return      True when server, otherwise false
     */
    public static boolean isServer()
    {
        return !proxy.isClient() && FMLCommonHandler.instance().getEffectiveSide().isServer();
    }
}

Developer of Primeval Forest.

Posted

Well, but it does not:

latnT5p.png

 

As you can see there, in the inventory it's rendering a missing texture thing as a block. But it should not be a block and not be a missing texture thing.

And for some reason, I commented out the json file loading, but it's still rendering the chest.

And the 3d model itself is rendered in black instead of using the texture. And no, the texture is not black.

Developer of Primeval Forest.

Posted

Well, but it does not:

latnT5p.png

 

As you can see there, in the inventory it's rendering a missing texture thing as a block. But it should not be a block and not be a missing texture thing.

And for some reason, I commented out the json file loading, but it's still rendering the chest.

And the 3d model itself is rendered in black instead of using the texture. And no, the texture is not black.

Developer of Primeval Forest.

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

    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
    • Okay, but does the modpack works with 1.12 or just with 1.12.2, because I need the Forge client specifically for Minecraft 1.12, not 1.12.2
    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
  • Topics

×
×
  • Create New...

Important Information

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