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.

Leaderboard

Popular Content

Showing content with the highest reputation on 01/29/22 in Posts

  1. you can simply create a new instance and store it in a final field, then override addAdditionalSaveData and readAdditionalSaveData to serialize and deserialize the Inventory
  2. in AttachCapabilitiesEvent you need a ICapabilityProvider which holds your Capability
  3. Thank you for the help. I got it to work with packets. I'll put the code below for any future googlers @Override public void onUpdate() { setFuse(--this.fuse); if (getFuse() <= 0) { this.setDead(); if (!this.world.isRemote) { world.setBlockState(pos, Blocks.AIR.getDefaultState()); world.createExplosion(null, this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, 4.f, true); } } else { ParticlePacket particlePacket = new ParticlePacket(this.posX, this.posY, this.posZ); NetworkRegistry.TargetPoint target = new TargetPoint(world.provider.getDimension(), this.posX + 0.5D, this.posY + 1.0D, this.posZ + 0.5D, 20.d); CommonProxy.simpleNetworkWrapper.sendToAllAround(particlePacket, target); } if(world.getBlockState(pos).getBlock() instanceof BlockAir) { this.setDead(); } } //Message and client handler public class ParticlePacket implements IMessage { private boolean messageValid; private double x, y, z; public ParticlePacket() { this.messageValid = false; } public ParticlePacket(double x, double y, double z) { this.x = x; this.y = y; this.z = z; this.messageValid = true; } @Override public void fromBytes(ByteBuf buf) { try { this.x = buf.readDouble(); this.y = buf.readDouble(); this.z = buf.readDouble(); } catch(IndexOutOfBoundsException ioe) { return; } } @Override public void toBytes(ByteBuf buf) { if(!this.messageValid) return; buf.writeDouble(x); buf.writeDouble(y); buf.writeDouble(z); } public static class Handler implements IMessageHandler<ParticlePacket, IMessage> { @Override public IMessage onMessage(ParticlePacket message, MessageContext ctx) { if(!message.messageValid && ctx.side != Side.CLIENT) { return null; } Minecraft minecraft = Minecraft.getMinecraft(); final WorldClient worldClient = minecraft.world; minecraft.addScheduledTask(() -> processMessage(message, worldClient)); return null; } void processMessage(ParticlePacket message, WorldClient worldClient) { worldClient.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, message.x + 0.5D, message.y + 1.0D, message.z + 0.5D, 0.0D, 0.0D, 0.0D); } } } //ClientProxy public static void preInitClientOnly() { CommonProxy.simpleNetworkWrapper.registerMessage(ParticlePacket.Handler.class, ParticlePacket.class, CommonProxy.FUSE_SMOKE, Side.CLIENT); } //CommonProxy public static final byte FUSE_SMOKE = 88; public static SimpleNetworkWrapper simpleNetworkWrapper; public static void preInitCommon() { simpleNetworkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("TestChannel"); simpleNetworkWrapper.registerMessage(ServerHandlerDummy.class, ParticlePacket.class, FUSE_SMOKE, Side.SERVER); } //Server handler public class ServerHandlerDummy implements IMessageHandler<ParticlePacket, IMessage> { @Override public IMessage onMessage(ParticlePacket message, MessageContext ctx) { return null; } }

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.