Jump to content

That_Martin_Guy

Members
  • Posts

    197
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by That_Martin_Guy

  1. The code I posted was in fact the entire tile entity renderer, minus the class declaration. I have added some small stuff since for testing, but overall its the same and should be very similar to the enchanting table renderer.

    public class ClockworksDoorTileEntityRenderer extends TileEntityRenderer<ClockworksDoorTileEntity>
    {
        private static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");
    
        private final ClockworksDoorModel model;
        private final RenderMaterial doorMaterial;
    
        public ClockworksDoorTileEntityRenderer(TileEntityRendererDispatcher dispatcher)
        {
            super(dispatcher);
    
            model = new ClockworksDoorModel();
    
            doorMaterial = new RenderMaterial(PlayerContainer.BLOCK_ATLAS, TEXTURE);
        }
    
        @Override
        public void render(ClockworksDoorTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
        {
            matrixStack.pushPose();
            IVertexBuilder builder = doorMaterial.buffer(buffer, RenderType::entitySolid);
    
            model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 1, 1, 1, 1);
            matrixStack.popPose();
        }
    }

    The model itself is just a basic model. Not much to showcase, but since I was asked I'll do it anyway.

    public class ClockworksDoorModel extends Model
    {
    	private final ModelRenderer model;
    
    	public ClockworksDoorModel()
    	{
    		super(RenderType::entitySolid);
    		texWidth = 64;
    		texHeight = 64;
    
    		model = new ModelRenderer(this);
    		model.setPos(8, 32, 8);
    		model.texOffs(0, 0).addBox(-8.0F, -32.0F, -8.0F, 16.0F, 32.0F, 3.0F, 0.0F, false);
    	}
    
    	@Override
    	public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder builder, int partialLight, int partialOverlay, float red, float green, float blue, float alpha)
    	{
    		model.render(matrixStack, builder, partialLight, partialOverlay);
    	}
    }

     

  2. I have a tile entity renderer that renders a model. Code looks like this

     

        private static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");
    
        private final ClockworksDoorModel model;
        private final RenderMaterial doorMaterial;
    
        public ClockworksDoorTileEntityRenderer(TileEntityRendererDispatcher dispatcher)
        {
            super(dispatcher);
    
            model = new ClockworksDoorModel();
    
            doorMaterial = new RenderMaterial(PlayerContainer.BLOCK_ATLAS, TEXTURE);
        }
    
        @Override
        public void render(ClockworksDoorTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
        {
            IVertexBuilder builder = doorMaterial.buffer(buffer, RenderType::entityCutoutNoCull);
    
            model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 1, 1, 1, 1);
        }

    In game, however, it has the black and purple missing texture. When examining the log it does not report anything about missing textures if I put the path correctly, so I can only assume it's correctly finding my texture.

  3. 	private final ModelRenderer model;
    
    	public ClockworksKnobModel() {
    		super(RenderType::entityCutoutNoCull);
    		texWidth = 48;
    		texHeight = 48;
    
    		model = new ModelRenderer(this);
    		model.setPos(8.0F, 8, 0);
    		model.texOffs(0, 1).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 1.0F, 0.0F, false);
    		model.texOffs(1, 2).addBox(-0.5F, -4.0F, -2.0F, 1.0F, 5.0F, 2.0F, 0.0F, false);
    	}
    
    	@Override
    	public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
          		model.render(matrixStack, buffer, packedLight, packedOverlay);
    	}

    The rendering code is part of vanilla.

  4. Right now it doesn't crash, but the model is still untextured in game (as in, it's completely black).

     

    public class ClockworksTileEntityRenderer extends TileEntityRenderer<TheClockworksTileEntity>
    {
        public static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");
        private RenderMaterial renderMaterial;
    
        public ClockworksTileEntityRenderer(TileEntityRendererDispatcher p_i226006_1_)
        {
            super(p_i226006_1_);
    
            //Instantiate model
    
            renderMaterial = new RenderMaterial(PlayerContainer.BLOCK_ATLAS, TEXTURE);
        }
    
        @Override
        public void render(TheClockworksTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
        {
            IVertexBuilder builder = renderMaterial.buffer(buffer, RenderType::entityCutout);
          
            model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 0, 0, 0, 0);
        }
    }

     

  5. I have a custom model as a part of a tile entity renderer. I want to give this model a texture. I am struggling a bit with figuring out all the steps required to do this.

     

    I currently have the following code in my tile entity renderer

    public class ClockworksTileEntityRenderer extends TileEntityRenderer<TheClockworksTileEntity>
    {
        public static final ResourceLocation ATLAS_REGION = ResourceHelper.createNew("textures/atlas/test.png");
        public static final ResourceLocation TEXTURE = ResourceHelper.createNew("block/test.png");
        private RenderMaterial renderMaterial;
    
        public ClockworksTileEntityRenderer(TileEntityRendererDispatcher p_i226006_1_)
        {
            super(p_i226006_1_);
    
            //Instantiate model
    
            renderMaterial = new RenderMaterial(ATLAS_REGION, TEXTURE);
        }
    
        @Override
        public void render(TheClockworksTileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
        {
            System.out.println(ATLAS_REGION);
            IVertexBuilder builder = renderMaterial.buffer(buffer, RenderType::entityCutout);
          
            model.renderToBuffer(matrixStack, builder, combinedLight, combinedOverlay, 0, 0, 0, 0);
        }
    }

    When I created this code I crashed with the following message.

     

    I asked on discord if I was missing something and got told I should use the TextureStitchEvent to stitch the texture to the atlas. That code looks like this:

        @SubscribeEvent
        public static void preTextureStitch(TextureStitchEvent.Pre event)
        {
            if(event.getMap().location().equals(ClockworksTileEntityRenderer.ATLAS_REGION))
                event.addSprite(ClockworksTileEntityRenderer.TEXTURE);
        }

    While the event itself runs, the code inside the if statement does not.

     

    Not sure how to proceed.

  6. Just looked at the code for ModelRenderer, sorry for not doing that earlier. It actually rotates around the z-axis first, if I understand it correctly.

     

       public void translateAndRotate(MatrixStack p_228307_1_) {
          p_228307_1_.translate((double)(this.x / 16.0F), (double)(this.y / 16.0F), (double)(this.z / 16.0F));
          if (this.zRot != 0.0F) {
             p_228307_1_.mulPose(Vector3f.ZP.rotation(this.zRot));
          }
    
          if (this.yRot != 0.0F) {
             p_228307_1_.mulPose(Vector3f.YP.rotation(this.yRot));
          }
    
          if (this.xRot != 0.0F) {
             p_228307_1_.mulPose(Vector3f.XP.rotation(this.xRot));
          }
    
       }

     

    I'm not sure how I would go about setting up this parent-child relationship when doing the rotations separately with this knowledge. Not the greatest at this sort of math.

  7. I am rendering a model as part of a tile entity renderer. The model is supposed to be rotated based on the block's facing direction. The kicker is that it's also supposed to be rotated based on a "setting" variable, which can be changed when right clicked.

     

    My solution to the problem is rotating around the Y-axis depending on the direction, and rotate either the X or Z axis (depending on the block's direction) by a certain amount per setting. Implementation looks like the following

    	public void turnToSetting(Direction direction, TheClockworksTileEntity.Setting setting)
    	{
    		switch(direction)
    		{
    			case NORTH:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = setting.rotation;
    				break;
    			case SOUTH:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = -setting.rotation;
    				break;
    			case WEST:
    				group2.xRot = setting.rotation;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = 0;
    				break;
    			case EAST:
    				group2.xRot = -setting.rotation;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = 0;
    				break;
    		}
    	}
    
    	private float rotationFromDirection(Direction direction)
    	{
    		double rotation = 0;
    		switch(direction)
    		{
    			case SOUTH:
    				rotation = Math.PI;
    				break;
    			case EAST:
    				rotation = Math.PI / 2;
    				break;
    			case WEST:
    				rotation = Math.PI * 3 / 2;
    				break;
    		}
    
    		return (float) rotation;
    	}

    In practice this works well when the block is facing north or south, but not when the block is facing east or west. Demonstration here. When observing the way it rotates, it seems like the model's coordinate system has been changed when it was rotated around the Y axis. Therefore I feel like the solution should be to rotate around the Z-axis on the west and east directions. However, this results in the behavior demonstrated here. Code demonstrating that below:

    	public void turnToSetting(Direction direction, TheClockworksTileEntity.Setting setting)
    	{
    		switch(direction)
    		{
    			case NORTH:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = setting.rotation;
    				break;
    			case SOUTH:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = -setting.rotation;
    				break;
    			case WEST:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = setting.rotation;
    				break;
    			case EAST:
    				group2.xRot = 0;
    				group2.yRot = rotationFromDirection(direction);
    				group2.zRot = -setting.rotation;
    				break;
    		}
    	}

    To me this behavior is very similar to rotating on the X-axis. I am confused as to how this is the case.

  8. I am currently rewriting a mod previously written for 1.12 in version 1.15. The mod encouraged giant builds, and I'd really like for the mod to be able to be converted from the old version to the new one. I went onto the discord server and asked how to achieve this and concluded that I was going to use an event to tell the game which old registry name should be matched with which new block (for instance). I therefore tried subscribing to RegistryEvent.MissingMappings in the following way:

     

    @EventBusSubscriber(modid = SCPLockdown.MOD_ID, bus = EventBusSubscriber.Bus.FORGE)
    public class CommonForgeEvents
    {
        @SubscribeEvent
        public static void fixBlockMappings(RegistryEvent.MissingMappings<Block> event)
        {
            System.out.println("Start of blockmappings");
            for(RegistryEvent.MissingMappings.Mapping<Block> blockMapping : event.getMappings())
            {
                System.out.println(blockMapping.id);
            }
        }
    }

    This method does not print at all when I try and convert an old 1.12 world in the 1.15 version, even if I used the MOD bus instead of the FORGE bus. I therefore came to the conclusion that it doesn't fire at all, and I cannot test with it right now.

     

    I also tried matching the registry name from the old version with the new one. This did not work - all of the mods blocks were removed upon convertion, even if the names matched.

  9. I fixed it. Turns out cofh also needs the JEI repository to work. Not having that completely broke the project like I stated earlier...

     

    Working code:

    buildscript {
        repositories {
            jcenter()
            maven { url = "http://files.minecraftforge.net/maven" }
        }
        dependencies {
            classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
        }
    }
    apply plugin: 'net.minecraftforge.gradle.forge'
    //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
    
    
    version = "0.0.1"
    group = "thatmartinguy.brightenup" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
    archivesBaseName = "brightenup"
    
    sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
    compileJava {
        sourceCompatibility = targetCompatibility = '1.8'
    }
    
    minecraft {
        version = "1.12.2-14.23.4.2705"
        runDir = "run"
        
        // the mappings can be changed at any time, and must be in the following format.
        // snapshot_YYYYMMDD   snapshot are built nightly.
        // stable_#            stables are built at the discretion of the MCP team.
        // Use non-default mappings at your own risk. they may not always work.
        // simply re-run your setup task after changing the mappings to update your workspace.
        mappings = "snapshot_20171003"
        // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
    }
    
    repositories {
        maven {
            name = "Covers (COFH)"
            url = "http://maven.covers1624.net/"
        }
        maven {
            name = "JEI Maven"
            url = "http://dvs1.progwml6.com/files/maven"
        }
    }
    
    dependencies {
        compile 'cofh:CoFHCore:1.12.2-4.5.0.+:deobf'
        compile 'cofh:ThermalFoundation:1.12.2-2.5.+:deobf'
    }
    
    processResources {
        // this will ensure that this task is redone when the versions change.
        inputs.property "version", project.version
        inputs.property "mcversion", project.minecraft.version
    
        // replace stuff in mcmod.info, nothing else
        from(sourceSets.main.resources.srcDirs) {
            include 'mcmod.info'
                    
            // replace version and mcversion
            expand 'version':project.version, 'mcversion':project.minecraft.version
        }
            
        // copy everything else except the mcmod.info
        from(sourceSets.main.resources.srcDirs) {
            exclude 'mcmod.info'
        }
    }

     

  10. I am creating a dimension. It's simple for now, only sporting a single biome, but it will be expanded on later. For now, though, I cannot actually enter my dimension.

     

    I register my dimension here, and the world provider is here. To transfer myself to the dimension I use ItemTeleporterTest. I cannot enter the dimension, though. When I right click with the item just reloads the overworld. Using the forge setdim command does the same thing the first time, but after that it tells me it's already in that dimension.

     

    What's the problem here?

     

    EDIT: It seems that setting the biome provider in the constructor was incorrect, and so I moved it to init, which made it work.

  11. My friend is trying to setup a workspace for forge, but he gets the following error every time he runs setupDecompWorkspace;

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Unable to start the daemon process.
    This problem might be caused by incorrect configuration of the daemon.
    For example, an unrecognized jvm option is used.
    Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14/userguide/gradle_daemon.html
    Please read the following process output to find out more:
    -----------------------
    Error occurred during initialization of VM
    Could not reserve enough space for 3145728KB object heap

    According to task manager he has more than 3G (almost 4G) of RAM available, which should be enough according to the gradle properties file;

    # Sets default memory used for gradle commands. Can be overridden by user or command line properties.
    # This is required to provide enough memory for the Minecraft decompilation process.
    org.gradle.jvmargs=-Xmx3G

    Full stacktrace

×
×
  • Create New...

Important Information

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