Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey there!

 

So I've created a 'particle' that allows me to render a block and shoot it to a different position. However I'm having issues with getting this to work.. I have all the components need for the particle (rendering, packet, etc), so it left me to believe its something to do with how I'm rendering the block.. Maybe I'm using particles wrong? A TESR would not work due to it disappear when the block is not in view.. Here is my code:

 

The Renderer (within a util class)

    @SideOnly(Side.CLIENT)
    public static void renderVoidCubes(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(firstX, firstY, firstZ);

        double frame = Minecraft.getSystemTime()/800d;

        GlStateManager.scale(.5, .5, .5);

        GlStateManager.translate(secondX, secondY, secondZ);

        GlStateManager.translate(0, ((frame *10)%firstY), 0);

        ResourceUtil.renderBlockInWorld(Blocks.DIRT, 0);

        GlStateManager.popMatrix();
    }

 

The client time / server time senders:


    @SideOnly(Side.CLIENT)
    public static void spawnVoidCubesWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ) {
        Minecraft mc = Minecraft.getMinecraft();

        if(mc.player.getDistance(startX, startY, startZ) <= 64 || mc.player.getDistance(endX, endY, endZ) <= 64){
            Particle fx = new ParticleVoidCube(mc.world, startX, startY, startZ, endX, endY, endZ);
            mc.effectRenderer.addEffect(fx);
        }
    }

    public static void spawnVoidCubesWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ){
        if(!world.isRemote){
            NBTTagCompound data = new NBTTagCompound();
            data.setDouble("StartX", startX);
            data.setDouble("StartY", startY);
            data.setDouble("StartZ", startZ);
            data.setDouble("EndX", endX);
            data.setDouble("EndY", endY);
            data.setDouble("EndZ", endZ);
            PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.VOID_PARTICLE_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96));
        }
    }

 

Particle Class

@SideOnly(Side.CLIENT)
public class ParticleVoidCube extends Particle {
    private final double endX;
    private final double endY;
    private final double endZ;

    public ParticleVoidCube(World world, double startX, double startY, double startZ, double endX, double endY, double endZ) {
        super(world, startX, startY, startZ);
        this.endX = endX;
        this.endY = endY;
        this.endZ = endZ;
    }

    @Override
    public void renderParticle(VertexBuffer buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ){
        ResourceUtil.renderVoidCubes(this.posX+0.5, this.posY+0.5, this.posZ+0.5, this.endX+0.5, this.endY+0.5, this.endZ+0.5);
    }

    @Override
    public int getFXLayer(){
        return 3;
    }
}

 

The network:

    public static final IDataHandler VOID_PARTICLE_HANDLER = new IDataHandler() {
        @Override
        @SideOnly(Side.CLIENT)
        public void handleData(NBTTagCompound compound, MessageContext context) {
            Minecraft mc = Minecraft.getMinecraft();

            double inX = compound.getDouble("InX")+0.5;
            double inY = compound.getDouble("InY")+0.78;
            double inZ = compound.getDouble("InZ")+0.5;

            double outX = compound.getDouble("OutX")+0.5;
            double outY = compound.getDouble("OutY")+0.525;
            double outZ = compound.getDouble("OutZ")+0.5;

            if(mc.player.getDistance(outX, outY, outZ) <= 16){
                Particle fx = new ParticleVoidCube(mc.world, outX, outY, outZ, inX, inY, inZ);
                mc.effectRenderer.addEffect(fx);
            }
        }
    };

 

Thanks!

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.