Jump to content

[Fixed][1.8.9] Missing OBJ Texture


micdoodle8
 Share

Recommended Posts

Hey there,

 

I can't seem to get the correct texture from the block texture map to display on my OBJ model.

 

1.7.10:

g4GRNZS.png

 

1.8.9:

sUuOPXt.png

 

1.7.10 code:

 

 

@SideOnly(Side.CLIENT)
public class TileEntityMinerBaseRenderer extends TileEntitySpecialRenderer
{
    public static final ResourceLocation minerBaseTexture = new ResourceLocation(AsteroidsModule.ASSET_PREFIX, "textures/model/minerbase.png");
    public static IModelCustom minerBaseModel;

    public TileEntityMinerBaseRenderer()
    {
        TileEntityMinerBaseRenderer.minerBaseModel = AdvancedModelLoader.loadModel(new ResourceLocation(AsteroidsModule.ASSET_PREFIX, "models/minerbase.obj"));
    }

    public void renderModelAt(TileEntityMinerBase tileEntity, double d, double d1, double d2, float f)
    {
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    	if (!tileEntity.isMaster) return;
    	// Texture file
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(TileEntityMinerBaseRenderer.minerBaseTexture);

        int i = tileEntity.getWorldObj().getLightBrightnessForSkyBlocks(tileEntity.xCoord, tileEntity.yCoord + 1, tileEntity.zCoord, 0);
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);

        GL11.glPushMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glTranslatef((float) d + 1F, (float) d1 + 1F, (float) d2 + 1F);
        GL11.glScalef(0.05F, 0.05F, 0.05F);

        switch (tileEntity.facing)
        {
        case 0:
            GL11.glRotatef(180F, 0, 1F, 0);
            break;
        case 1:
            break;
        case 2:
            GL11.glRotatef(270F, 0, 1F, 0);
            break;
        case 3:
            GL11.glRotatef(90F, 0, 1F, 0);
            break;
        }

        TileEntityMinerBaseRenderer.minerBaseModel.renderAll();

        GL11.glPopMatrix();
    }

    @Override
    public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
    {
        this.renderModelAt((TileEntityMinerBase) tileEntity, var2, var4, var6, var8);
    }
}

 

 

 

1.8.9 code:

 

 

@SideOnly(Side.CLIENT)
public class TileEntityMinerBaseRenderer extends TileEntitySpecialRenderer
{
    public static IModel minerBaseModel;
    public static IBakedModel minerBaseModelBaked;

    public IBakedModel getBakedModel()
    {
        if (minerBaseModelBaked == null)
        {
            try
            {
                minerBaseModel = ModelLoaderRegistry.getModel(new ResourceLocation(GalacticraftPlanets.ASSET_PREFIX, "minerbase0.obj"));
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
            Function<ResourceLocation, TextureAtlasSprite> spriteFunction = new Function<ResourceLocation, TextureAtlasSprite>() {
                @Override
                public TextureAtlasSprite apply(ResourceLocation location) {
                    return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
                }
            };
            minerBaseModelBaked = minerBaseModel.bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, spriteFunction);
        }
        return minerBaseModelBaked;
    }

    public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float p_180535_8_, int p_180535_9_)
    {
        TileEntityMinerBase minerBase = (TileEntityMinerBase) tile;
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);

        int i = minerBase.getWorld().getLightFor(EnumSkyBlock.SKY, minerBase.getPos().up());
        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);

        GL11.glPushMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glTranslatef((float) x + 1F, (float) y + 1F, (float) z + 1F);
        GL11.glScalef(0.05F, 0.05F, 0.05F);

        switch (minerBase.facing)
        {
        case SOUTH:
            GL11.glRotatef(180F, 0, 1F, 0);
            break;
        case WEST:
            break;
        case NORTH:
            GL11.glRotatef(270F, 0, 1F, 0);
            break;
        case EAST:
            GL11.glRotatef(90F, 0, 1F, 0);
            break;
        }

        RenderHelper.disableStandardItemLighting();
        this.bindTexture(TextureMap.locationBlocksTexture);

        if (Minecraft.isAmbientOcclusionEnabled()) 
        {
            GlStateManager.shadeModel(GL11.GL_SMOOTH);
        } 
        else 
        {
            GlStateManager.shadeModel(GL11.GL_FLAT);
        }

        Tessellator tessellator = Tessellator.getInstance();
        tessellator.getWorldRenderer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
        GlStateManager.translate(-tile.getPos().getX(), -tile.getPos().getY(), -tile.getPos().getZ());
        Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(tile.getWorld(), getBakedModel(), tile.getWorld().getBlockState(tile.getPos()), tile.getPos(), tessellator.getWorldRenderer());
        tessellator.draw();

        RenderHelper.enableStandardItemLighting();
        GL11.glPopMatrix();
    }
}

 

 

 

OBJ File

 

 

mtllib minerbase0.mtl

o dock

v -20.000000 -20.000004 19.999996

v -20.000000 -19.999996 -20.000004

v 20.000000 -19.999996 -20.000004

v 20.000000 -20.000004 19.999996

v -20.000000 19.999996 20.000004

v 20.000000 19.999996 20.000004

v 20.000000 20.000000 -4.374997

v -20.000000 20.000000 -4.374997

v 20.000000 4.374997 20.000000

v -20.000000 4.374997 20.000000

v 20.000000 4.375003 -20.000000

v 18.125000 4.374997 16.875000

v -18.125000 4.374997 16.875000

v -18.125000 14.999997 16.875002

v 18.125000 14.999997 16.875002

v -20.000000 4.375003 -20.000000

v -18.125000 -18.124996 -20.000004

v 18.125000 -18.124996 -20.000004

v 18.125000 15.000002 -9.374997

v -18.125000 15.000002 -9.374997

v 18.125000 4.375003 -20.000000

v -18.125000 4.375003 -20.000000

v -18.125000 -18.125002 16.874996

v 18.125000 -18.125002 16.874996

v 11.250000 15.000002 -9.374997

v 18.125000 11.250002 -13.124998

v 11.911800 11.250002 -13.124998

v 18.125000 4.375001 -6.250000

v 13.125000 4.374997 16.875000

v 13.125000 4.375001 -6.250000

v 11.911800 11.249997 16.875002

v 11.250000 14.999997 16.875002

v 17.500000 -18.124996 -20.000004

v 11.250000 -18.124996 -20.000004

v 11.250000 -16.874996 -20.000002

v 17.500000 -8.124997 -20.000002

v -11.250000 -18.124996 -20.000004

v -11.250000 -16.874996 -20.000002

v -17.500000 -18.124996 -20.000004

v -17.500000 -8.124997 -20.000002

v -16.250000 -6.250001 9.374999

v -10.000000 -15.000002 9.374997

v -10.000000 -15.000000 -1.875003

v -16.250000 -6.250000 -1.875001

v 10.000000 -15.000002 9.374997

v 10.000000 -15.000000 -1.875003

v 16.250000 -6.250001 9.374999

v 16.250000 -6.250000 -1.875001

v -11.250000 -16.874998 -6.250003

v -17.500000 -8.124999 -6.250001

v 11.250000 -16.874998 -6.250003

v 17.500000 -8.124999 -6.250001

v 18.125000 -8.124997 -20.000002

v -18.125000 -8.124997 -20.000002

v -18.125000 -6.250000 -1.875001

v -18.125000 -6.250001 9.374999

v -18.125000 -8.124999 -6.250001

v 18.125000 -6.250001 9.374999

v 18.125000 -6.250000 -1.875001

v 18.125000 -8.124999 -6.250001

v 18.125000 -3.125001 9.374999

v -18.125000 -3.125001 9.374999

v 18.125000 -15.000002 9.374997

v -18.125000 -15.000002 9.374997

v 6.250000 -16.874996 -20.000002

v -6.250000 -16.874996 -20.000002

v -6.250000 -14.999997 -18.125002

v 6.250000 -14.999997 -18.125002

v -6.250000 -16.874998 -6.250003

v -6.250000 -15.000000 -1.875003

v 6.250000 -15.000000 -1.875003

v 6.250000 -16.874998 -6.250003

v 6.875000 -3.125001 9.374999

v -6.875000 -3.125001 9.374999

v -6.875000 6.874999 9.375001

v 6.875000 6.874999 9.375001

v -6.875000 4.374997 16.875000

v -6.875000 6.874997 16.875002

v 6.875000 6.874997 16.875002

v 6.875000 4.374997 16.875000

v -11.250000 15.000002 -9.374997

v -11.911700 11.250002 -13.124998

v -18.125000 11.250002 -13.124998

v -18.125000 4.375001 -6.250000

v -13.125000 4.375001 -6.250000

v -13.125000 4.374997 16.875000

v -11.911800 11.249997 16.875002

v -11.250000 14.999997 16.875002

vt 1.000000 0.386900

vt 1.000000 0.767900

vt 0.666700 0.767900

vt 0.666700 0.386900

vt 0.333300 0.642900

vt 0.000000 0.642900

vt 0.000000 0.410700

vt 0.333300 0.410700

vt 0.666700 0.000000

vt 1.000000 0.000000

vt 1.000000 0.232100

vt 0.666700 0.232100

vt 1.000000 0.381000

vt 0.666700 0.381000

vt 0.333300 0.000000

vt 0.333300 0.232100

vt 0.463500 0.381000

vt 0.343800 0.577400

vt 0.645800 0.577400

vt 0.645800 0.678600

vt 0.343800 0.678600

vt -0.000000 0.000000

vt 0.317700 0.017900

vt 0.015600 0.017900

vt 0.015600 0.363100

vt 0.317700 0.363100

vt -0.000000 0.232100

vt 0.015600 0.232100

vt 0.000000 0.261900

vt 0.015600 0.261900

vt 0.317700 0.232100

vt 0.333300 0.261900

vt 0.317700 0.261900

vt 0.651000 0.684500

vt 0.651000 0.898800

vt 0.958300 0.898800

vt 0.958300 0.684500

vt 0.739600 1.000000

vt 0.958300 1.000000

vt 0.645800 0.928600

vt 0.343800 0.928600

vt 0.260400 0.363100

vt 0.317700 0.327400

vt 0.265600 0.327400

vt 0.208300 0.214300

vt 0.015600 0.214300

vt 0.208300 0.261900

vt 0.015600 0.327400

vt 0.234400 0.363100

vt 0.276000 0.261900

vt 0.020800 0.017900

vt 0.072900 0.017900

vt 0.072900 0.029800

vt 0.020800 0.113100

vt 0.260400 0.017900

vt 0.260400 0.029800

vt 0.312500 0.017900

vt 0.312500 0.113100

vt 0.057300 0.964300

vt 0.130200 0.964300

vt 0.130200 0.857100

vt 0.057300 0.857100

vt 0.307300 0.964300

vt 0.140600 0.964300

vt 0.140600 0.857100

vt 0.307300 0.857100

vt 0.130200 0.815500

vt 0.057300 0.815500

vt 0.317700 0.815500

vt 0.015600 0.113100

vt 0.317700 0.113100

vt 0.041700 0.857100

vt 0.041700 0.964300

vt 0.046900 0.815500

vt 0.041700 0.815500

vt 0.057300 0.684500

vt 0.130200 0.684500

vt 0.317700 0.684500

vt 0.041700 0.684500

vt 0.046900 0.684500

vt 0.343800 0.506000

vt 0.645800 0.506000

vt 0.343800 0.392900

vt 0.645800 0.392900

vt 0.171900 0.654800

vt 0.276000 0.654800

vt 0.276000 0.684500

vt 0.171900 0.684500

vt 0.057300 0.654800

vt 0.020800 0.672600

vt 0.156300 0.672600

vt 0.276000 0.839300

vt 0.171900 0.839300

vt 0.109400 0.047600

vt 0.224000 0.047600

vt 0.224000 0.142900

vt 0.109400 0.142900

vt 0.088500 0.214300

vt 0.109400 0.214300

vt 0.026000 0.142900

vt 0.224000 0.214300

vn 0.000000 -1.000000 -0.000000

vn 0.000000 1.000000 0.000000

vn 0.000000 -0.000000 1.000000

vn 1.000000 0.000000 0.000000

vn 0.000000 0.000000 -1.000000

vn -1.000000 0.000000 0.000000

vn 0.000000 0.707100 -0.707100

vn -0.984800 -0.173800 -0.000000

vn 0.000000 -0.707100 -0.707100

vn 0.813700 0.581200 0.000000

vn -0.813700 0.581200 0.000000

vn 0.733100 0.523700 -0.433900

vn 0.000000 0.919100 -0.393900

vn -0.733100 0.523700 -0.433900

vn 0.984800 -0.173800 0.000000

usemtl MinerBase

s off

f 1/1/1 2/2/1 3/3/1 4/4/1

f 5/5/2 6/6/2 7/7/2 8/8/2

f 1/9/3 4/10/3 9/11/3 10/12/3

f 10/12/3 9/11/3 6/13/3 5/14/3

f 4/9/4 3/15/4 11/16/4 9/12/4

f 9/12/4 11/16/4 7/17/4 6/14/4

f 12/18/5 13/19/5 14/20/5 15/21/5

f 2/15/6 1/9/6 10/12/6 16/16/6

f 16/16/6 10/12/6 5/14/6 8/17/6

f 3/22/5 2/15/5 17/23/5 18/24/5

f 8/8/7 7/7/7 19/25/7 20/26/7

f 11/27/5 3/22/5 18/24/5 21/28/5

f 7/7/7 11/29/7 21/30/7 19/25/7

f 2/15/5 16/16/5 22/31/5 17/23/5

f 16/32/7 8/8/7 20/26/7 22/33/7

f 17/34/4 22/35/4 13/36/4 23/37/4

f 21/35/6 18/34/6 24/37/6 12/36/6

f 22/35/4 20/38/4 14/39/4 13/36/4

f 20/40/1 19/41/1 15/21/1 14/20/1

f 19/38/6 21/35/6 12/36/6 15/39/6

f 25/42/7 19/26/7 26/43/7 27/44/7

f 28/45/1 12/46/1 29/30/1 30/47/1

f 27/44/8 31/48/8 32/25/8 25/49/8

f 31/48/8 27/44/8 30/47/8 29/30/8

f 27/44/9 26/43/9 28/33/9 30/50/9

f 33/51/5 34/52/5 35/53/5 36/54/5

f 34/52/5 37/55/5 38/56/5 35/53/5

f 37/55/5 39/57/5 40/58/5 38/56/5

f 41/59/10 42/60/10 43/61/10 44/62/10

f 42/63/2 45/64/2 46/65/2 43/66/2

f 45/60/11 47/59/11 48/62/11 46/61/11

f 44/62/12 43/61/12 49/67/12 50/68/12

f 43/66/13 46/65/13 51/67/13 49/69/13

f 46/61/14 48/62/14 52/68/14 51/67/14

f 33/51/5 36/54/5 53/70/5 18/24/5

f 40/58/5 39/57/5 17/23/5 54/71/5

f 41/59/2 44/62/2 55/72/2 56/73/2

f 44/62/13 50/74/13 57/75/13 55/72/13

f 48/62/2 47/59/2 58/73/2 59/72/2

f 52/74/13 48/62/13 59/72/13 60/75/13

f 51/67/11 52/68/11 36/76/11 35/77/11

f 49/69/2 51/67/2 35/77/2 38/78/2

f 50/68/10 49/67/10 38/77/10 40/76/10

f 52/74/2 60/75/2 53/79/2 36/80/2

f 57/75/2 50/74/2 40/80/2 54/79/2

f 20/26/7 81/42/7 82/44/7 83/43/7

f 13/46/1 84/45/1 85/47/1 86/30/1

f 86/30/15 85/47/15 82/44/15 87/48/15

f 81/49/15 88/25/15 87/48/15 82/44/15

f 83/43/9 82/44/9 85/50/9 84/33/9

s 1

f 12/18/7 61/81/7 62/82/7 13/19/7

f 61/81/5 63/83/5 64/84/5 62/82/5

f 65/85/7 66/86/7 67/87/7 68/88/7

f 69/89/6 70/90/6 67/91/6 66/85/6

f 70/92/2 71/93/2 68/88/2 67/87/2

f 71/90/4 72/89/4 65/85/4 68/91/4

f 73/94/5 74/95/5 75/96/5 76/97/5

f 77/98/6 78/99/6 75/97/6 74/100/6

f 78/99/2 79/101/2 76/96/2 75/97/2

f 79/99/4 80/98/4 73/100/4 76/97/4

 

 

 

Material File

 

 

newmtl MinerBase

map_Kd galacticraftplanets:blocks/minerbase

 

 

 

If anyone has any ideas about why the texture is not being mapped properly, it would be much appreciated.

Link to comment
Share on other sites

Greetings. I am thinking you need to register your textures. Everything else looks good as far as I can tell. In 1.8.9 we need to @SubscribeEvent the client side event: "TextureStitchEvent" and then you can register your textures in that.

For example:

event.map.registerSprite(new ResourceLocation("bibliocraft:models/bookcase_books"));

 

Hope that helps.

 

 

Link to comment
Share on other sites

Thank you, it was a combination of not stitching the texture into the block map, and the texture not being square. The non-square texture worked in <1.8 but the error got lost in the log with a lot of other problems on the go.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).
    • I was trying to change item models with Model backer and ItemOverrides but it's too annoying so I looked for alternative ways: but for that I need to make many items, in this case for each model one item, however each item would have five models and I want to make about 30 items. That way I would have to make 600 items? this is a lot, can the forge handle it?
    • I originally posted here in error, as the issue I was having was for fabric, not forge, so I don't know anything about your issue but I solved my issue by downgrading my graphics drivers, here's a link to a post I made on Minecraft forum, I made an edit on the post with the solution that worked for me:   https://www.minecraftforum.net/forums/support/java-edition-support/3164709-solved-minecraft-fabric-modpack-crash-when#c4
    • 20:14:21.373 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Found mod file forge-1.19.2-43.1.43-universal.jar of type MOD with provider net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator@5c92166b 20:14:21.386 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Failed to build unique mod list after mod discovery. net.minecraftforge.fml.loading.EarlyLoadingException: Duplicate mods found at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.UniqueModListBuilder.buildUniqueList(UniqueModListBuilder.java:78) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:105) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:166) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLServiceProvider.beginScanning(FMLServiceProvider.java:86) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:112) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:100) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:102) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:55) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:87) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) 20:14:21.399 net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer main Mod Discovery failed. Skipping dependency discovery. 20:14:21.990 launcher main Exception in thread "main" java.lang.IllegalStateException: Failed to find system mod: minecraft at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.detectSystemMods(ModSorter.java:181) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.buildUniqueList(ModSorter.java:145) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.ModSorter.sort(ModSorter.java:53) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.moddiscovery.ModValidator.stage2Validation(ModValidator.java:101) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLLoader.completeScan(FMLLoader.java:175) at MC-BOOTSTRAP/fmlloader@1.19.2-43.1.43/net.minecraftforge.fml.loading.FMLServiceProvider.completeScan(FMLServiceProvider.java:91) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServiceDecorator.onCompleteScan(TransformationServiceDecorator.java:174) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.lambda$triggerScanCompletion$24(TransformationServicesHandler.java:145) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.TransformationServicesHandler.triggerScanCompletion(TransformationServicesHandler.java:147) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:94) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) 20:14:21.990 monitor Process Monitor Process crashed with exit code 1
    • I am created a packet that spawns 3 golems and adds a timer to their persistant data along with the name of the owner who spawned them. public boolean handle(Supplier<NetworkEvent.Context> supplier){ NetworkEvent.Context context = supplier.get(); context.enqueueWork(()-> { Player p = context.getSender(); if(p.getPersistentData().contains(XprtData.SALUS_CLASS)){ if(!p.getPersistentData().contains(XprtData.SALUS_DEFENDER_TIMER)){ for(int i=0;i<3;i++){ IronGolem golem = (IronGolem) EntityType.IRON_GOLEM.spawn(p.createCommandSourceStack().getLevel(), null, null, p.blockPosition(), MobSpawnType.MOB_SUMMONED, true, false); golem.getPersistentData().putInt(XprtData.SALUS_DEFENDER_TIMER, Utils.Seconds(50)); golem.getPersistentData().putString(XprtData.SALUS_DEFENDER_OWNER, p.getScoreboardName()); golem.setCustomName(Component.literal(ChatFormatting.GOLD + "" + p.getScoreboardName() + "'s Defender")); } p.getPersistentData().putInt(XprtData.SALUS_DEFENDER_TIMER, Utils.Seconds(5)); } else { int time = p.getPersistentData().getInt(XprtData.SALUS_DEFENDER_TIMER); Utils.Message(p, ChatFormatting.RED + "You cannot summon defenders right now, " + Utils.TicksToSeconds(time) + " seconds remaining."); } } }); return true; } the problem is when I call upon their data in an external class here @SubscribeEvent public static void onLivingTick(LivingEvent.LivingTickEvent e){ LivingEntity entity = e.getEntity(); if(entity instanceof IronGolem){ if(entity.getPersistentData().contains(XprtData.SALUS_DEFENDER_TIMER)){ Mob mob = (Mob)entity; for(LivingEntity target : Utils.getNear(entity, 8)){ if(target instanceof Player || target instanceof Villager || target instanceof Wolf || target instanceof IronGolem){ mob.setTarget(null); } else { mob.setTarget(target); } } } if(entity.getPersistentData().contains(XprtData.SALUS_DEFENDER_OWNER)){ String owner = entity.getPersistentData().getString(XprtData.SALUS_DEFENDER_OWNER); for(String pNames : entity.getServer().getPlayerNames()){ if(pNames.equals(owner)){ Player p = entity.getServer().getPlayerList().getPlayerByName(owner); if(entity.distanceTo(p) >= 7f){ entity.teleportTo(p.getBlockX(), p.getBlockY()+1, p.getBlockZ()); } } } } } } neither XprtData.SALUS_DEFENDER_TIMER nor XprtData.SALUS_DEFENDER_OWNER contain any data, for the timer it starts off at 0 when it should be (22*50) and defender owner should contain the players name which instead contains a blank.   This isnt my first time doing something like this, ive done it will illagers and it worked perfectly but when it comes to golems it doesnt work at all. I could do with it the timer killing them at -(22*50) but it wont help that i still need the owners name to teleport them to the owner if they move to far away. Any Ideas? Im calling this packet from a keybind by the way   EDIT:  I figured out the issue, I guess when the packet is received by server and the entity is created there is a delay before the persistant data is created I guess, im not too sure...  Anyways I fixed it by just calling the persistant data twice 
  • Topics

×
×
  • Create New...

Important Information

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