Jump to content

Custom fluid tank deleting fluid, or gui not rendering fluid [SOLVED]


Recommended Posts

Posted

So, I have a custom fluid tank, and it seems that it is deleting the fluid when it receives it. Either that, or the gui isnt rendering the fluid correctly. but I think it is the tank deleting the fluid. I am using buildcraft pipes to pump the liquid into the tank.

 

This is my tank methods in the tileentity (very long class, so I am only showing the relevent code)

 

 

        public FluidTank tankInput = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 48);
public FluidTank tankOutput1 = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 12);
public FluidTank tankOutput2 = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 12);
public FluidTank tankOutput3 = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 12);
public FluidTank tankOutput4 = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 12);
public FluidTank tankBiproduct = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * ;


public BlockDistillationChamber blockThis = null;

public String inventoryName;
private ItemStack[] slots = new ItemStack[7];
private FluidStack[] tanks = new FluidStack[6];

public TileEntityDistillationChamberFrame() {

}

//Inventory tank methods

    
    /* IFluidHandler */
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
	return tankInput.drain(maxDrain, doDrain);
}

@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
	if (resource == null) {
		return null;
	} if (tankInput.getFluid() == resource) {
		return tankInput.drain(resource.amount, doDrain);
	}
	return null;
}

@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
	return true;
}

@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
	if (resource == null) {
		return 0;
	}
	return tankInput.fill(resource, doFill);
}

@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
	return true;
}

@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
	return new FluidTankInfo[] { tankInput.getInfo() };
}

public FluidStack getTankInput() {
	return tankInput.getFluid();
}

public float getFluidLevelScaled() {
	float level;
	if (tankInput.getFluid() == null) {
		return 0;
	}
	level = tankInput.getCapacity() / tankInput.getFluid().amount;
	return level;
}

 

 

 

What am I doing wrong?

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

Your client is desynchronized from the server. Use the getDescriptionPacket and the onDataPacket methods.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

So, does that mean that there isn't a problem with the tileentity fluid methods?

 

I'm pretty sure that that isn't the problem, because when I right click on the block with a bucket, it puts I think 1mB of liquid in it, and renders a weird bar in the gui, this is because I havnt done the gui right, and need to finish it (not sure how to) but my point is that it renders something in the gui when clicked with a bucket, but automation like pipes doesnt, so i think there is a problem with the way the tileentity accepts fluids.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

I think it is. In the onBlockActivated, you are probably not checking for which side it is used on, so it updates both the client and the server. But the buildcraft pipes are probably only putting fluids on the server side, but not on the client side. You need to tell the client what fluids the server has.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Also, im still fairly sure that the tileentity isnt working properly, because like I said before, I can only add 1mB of fluid to the tank, even if I click it with the bucket multiple times, it doesnt add anything.

 

You know, a good way to see if it is working would to have a tooltip telling me what fluid exists in the tank. How would I do a tooltip when the player mouses over the tank?

 

Also, my issue with the texture is fixed. your suggestion worked.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

Actually, I think youre right, because I can put 50 universal fluid cells of fluid into the tank, then I can take 50 universal fluid cellls of fluid back out again. Also, after I take everything out with fluid cells, the buildcraft pipes put more in, and I can then take more out with the cells. So I guess it must be the server side client side sync issue. How would I solve this?

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

Here's some psuedo code:

void writeToNBT(NBTTagCompound)
{
    //call super method
    //write tank to nbt using tank.writeToNBT();
}
void readFromNBT(NBTTagCompound)
{
    //call super method
    //read tank from nbt using tank.readFromNBT();
}
Packet getDescriptionPacket()
{
    NBTTagCompound tag =  new NBTTagCompound();
    writeToNBT(tag);
    return new S35PacketUpdateTileEntity(x,y,z,1,tag);
}
void onDataPacket(NetworkManager, S35PacketUpdateTileEntity)
{
    readFromNBT(packet.func_148857_g());
}

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I don't understand.

 

I know what packets are, and what they are for, but that is about it, I dont know how to set them up (I know I should know this, but I am still new to mc modding and java). So far in my mod, I haven't used them, I haven't even got a PacketHandler. Where would this example code go? Im assuming from the nbt methods, that it would go in the tileentity, (just checking though)

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

That code needs to go into your TileEntity. You don't manually have to send them, Minecraft sends them for you. If you want to manually synchronize the TileEntity, use

worldObj.markBlockForUpdate(xCoord,yCoord,zCoord);

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I think now that the way I am rendering the fluid in the gui is wrong... how am I ment to render fluids in a gui?

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

No, the markBlockForUpdate makes Minecraft call the getDescriptionPacket on the server, sends it to the client and calls onDataPacket on the client.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I am not sure if I am rendering fluids correctly in the gui.

 

This is my code so far:

 

 

package net.theepictekkit.generator.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import net.theepictekkit.generator.Reference;
import net.theepictekkit.generator.common.container.ContainerDistillationChamber;
import net.theepictekkit.generator.common.tileentity.TileEntityDistillationChamberFrame;
import net.theepictekkit.generator.utils.RenderUtils;


public class GuiDistillationChamber extends GuiContainer {

private TileEntityDistillationChamberFrame tileEntity;

private final String modid = Reference.MODID;
private final ResourceLocation texture = new ResourceLocation (modid + ":" + "textures/gui/guiDistillationChamber.png");

public GuiDistillationChamber(InventoryPlayer invPlayer, TileEntityDistillationChamberFrame tileEntityDistillationChamberFrame) {
	super(new ContainerDistillationChamber(invPlayer, tileEntityDistillationChamberFrame));

	this.tileEntity = tileEntityDistillationChamberFrame;

	this.xSize = 256; //276
	this.ySize = 183; //183
}

@Override
protected void drawGuiContainerForegroundLayer(int x, int y) {

	fontRendererObj.drawString("Distillation Chamber", 8, 3, 4210752, false);
	fontRendererObj.drawString("Inventory", 8, 90, 4210752, false);

	FluidStack fluidStack = tileEntity.getTankInfo(null)[0].fluid;
	String str = "";

	if (tileEntity.getTankInput() != null && tileEntity.getTankInput().getFluid() != null) {
	str = tileEntity.getTankInput().toString() + ", " + tileEntity.getTankInput().amount;
	} else {
		str = "No fluid stored!";
	}
	fontRendererObj.drawString("Current Fluid Stored: " + str, 180, 100, 0, false);
}

public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {
	if (fluid == null || fluid.getFluid() == null) {
		return;
	}
	IIcon icon = fluid.getFluid().getIcon(fluid);
	mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
	RenderUtils.setGLColorFromInt(fluid.getFluid().getColor(fluid));
	int fullX = width / 16;
	int fullY = height / 16;
	int lastX = width - fullX * 16;
	int lastY = height - fullY * 16;
	int level = fluid.amount * height / maxCapacity;
	int fullLvl = (height - level) / 16;
	int lastLvl = (height - level) - fullLvl * 16;
	for (int i = 0; i < fullX; i++) {
		for (int j = 0; j < fullY; j++) {
			if (j >= fullLvl) {
				drawFluidBox(icon, x + i * 16, y + j * 16, 16, 16, j == fullLvl ? lastLvl : 0);
			}
		}
	}
	for (int i = 0; i < fullX; i++) {
		drawFluidBox(icon, x + i * 16, y + fullY * 16, 16, lastY, fullLvl == fullY ? lastLvl : 0);
	}
	for (int i = 0; i < fullY; i++) {
		if (i >= fullLvl) {
			drawFluidBox(icon, x + fullX * 16, y + i * 16, lastX, 16, i == fullLvl ? lastLvl : 0);
		}
	}
	drawFluidBox(icon, x + fullX * 16, y + fullY * 16, lastX, lastY, fullLvl == fullY ? lastLvl : 0);
}

private void drawFluidBox(IIcon icon, int x, int y, int width, int height, int cut) {
	Tessellator tess = Tessellator.instance;
	tess.startDrawingQuads();
	tess.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getInterpolatedV(height));
	tess.addVertexWithUV(x + width, y + height, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(height));
	tess.addVertexWithUV(x + width, y + cut, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(cut));
	tess.addVertexWithUV(x, y + cut, zLevel, icon.getMinU(), icon.getInterpolatedV(cut));
	tess.draw();
}

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {

	Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
	drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

	float fluidLvl = tileEntity.getFluidLevelScaled();

	//this.drawTexturedModalRect(guiLeft + 15, guiTop + 70, 1, 56, 16, Math.round(fluidLvl) * 56);
	this.drawFluid(tileEntity.getTankInput(), guiLeft + 15, guiTop + 70, 16, 56, tileEntity.tankInput.getCapacity());
}
}

 

 

 

Now, I dont know if this is the correct way to render the fluids, I looked at how buildcraft rendered fluids in the combustune engine to figure out what I have so far, but I don't know if I have missed anything, what they have is spread across several classes. Buildcraft github: https://github.com/BuildCraft/BuildCraft/tree/6.1.x/common/buildcraft/energy

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

You do this

[url=www.google.com]Word you want to be highlighted here![/url]

That's gonna result in this:

Word you want to be highlighted here!

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Here's some psuedo code:

void writeToNBT(NBTTagCompound)
{
    //call super method
    //write tank to nbt using tank.writeToNBT();
}
void readFromNBT(NBTTagCompound)
{
    //call super method
    //read tank from nbt using tank.readFromNBT();
}
Packet getDescriptionPacket()
{
    NBTTagCompound tag =  new NBTTagCompound();
    writeToNBT(tag);
    return new S35PacketUpdateTileEntity(x,y,z,1,tag);
}
void onDataPacket(NetworkManager, S35PacketUpdateTileEntity)
{
    readFromNBT(packet.func_148857_g());
}

 

Where would I put this? in the tileentity? where in the tileentity? anywhere? what do I have to change, I dont understand packets as I said before.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Posted

Okay.... so, I have finally got this fluid drawing in the gui working, now to add multiple tanks... how do I make it so that if I put a certain fluid in a certain tank, it uses up some of that fluid to fill the other 5 tanks each with a different fluid? basically a fluid recipe

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

  • 4 weeks later...
Posted

What if I were to use an A-Star path finding algorithm? Something that actually has tutorials. Currently, this energy grid system has no tutorials. So with A-Star, I could restrict it to the cables. Think this will work?

 

Well... This is awkward. Wrong topic xD I accidently clicked on the wrong faverouts tab as I save my posts to faverouts. This was ment to be in my scanning down a line of blocks topic.

Ignore this.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

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.