Jump to content

[1.10.2 | 1.11.2] [SOLVED] Energy Capability


Recommended Posts

Posted

Hi.

 

When changing the default EnergyStorage class, so basically implementing my own using IEnergyStorage, do I need to register a new capability for and do I need a new interface for it? Or can I work with the default capability while using my own implementation of EnergyStorage?

 

Thx in advance.

Bektor

Developer of Primeval Forest.

Posted

Hi.

 

When changing the default EnergyStorage class, so basically implementing my own using IEnergyStorage, do I need to register a new capability for and do I need a new interface for it? Or can I work with the default capability while using my own implementation of EnergyStorage?

 

Thx in advance.

Bektor

You do not need to do anything capability related.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Hi.

 

When changing the default EnergyStorage class, so basically implementing my own using IEnergyStorage, do I need to register a new capability for and do I need a new interface for it? Or can I work with the default capability while using my own implementation of EnergyStorage?

 

Thx in advance.

Bektor

You do not need to do anything capability related.

Well, the Forge energy system stuff uses capabilities, so I want to use them, too. I'm just wondering when I'm creating my own EnergyStorage class which is actually a slightly modified version (so it's using IEnergyStorage, but offers also more methods) of EnergyStorage (but does not extend it, it implements the same interface however), if I have to create in that case a new capability and a new interface or not...........

Developer of Primeval Forest.

Posted

Hi.

 

When changing the default EnergyStorage class, so basically implementing my own using IEnergyStorage, do I need to register a new capability for and do I need a new interface for it? Or can I work with the default capability while using my own implementation of EnergyStorage?

 

Thx in advance.

Bektor

You do not need to do anything capability related.

Well, the Forge energy system stuff uses capabilities, so I want to use them, too. I'm just wondering when I'm creating my own EnergyStorage class which is actually a slightly modified version (so it's using IEnergyStorage, but offers also more methods) of EnergyStorage (but does not extend it, it implements the same interface however), if I have to create in that case a new capability and a new interface or not...........

If you are using the forge capability system and that Capability is already registered you do not need to do any capability registering stuff. You can create new implementations whenever you want and use them as long as it ultimately implements IEnergyStorage.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Hi.

 

When changing the default EnergyStorage class, so basically implementing my own using IEnergyStorage, do I need to register a new capability for and do I need a new interface for it? Or can I work with the default capability while using my own implementation of EnergyStorage?

 

Thx in advance.

Bektor

You do not need to do anything capability related.

Well, the Forge energy system stuff uses capabilities, so I want to use them, too. I'm just wondering when I'm creating my own EnergyStorage class which is actually a slightly modified version (so it's using IEnergyStorage, but offers also more methods) of EnergyStorage (but does not extend it, it implements the same interface however), if I have to create in that case a new capability and a new interface or not...........

If you are using the forge capability system and that Capability is already registered you do not need to do any capability registering stuff. You can create new implementations whenever you want and use them as long as it ultimately implements IEnergyStorage.

Ok, thx. This is working, but somehow it does not save the energy. When I reload the world it just starts by 0 again while it was at 250 when I saved the world.

 

TileEntity

 

public class TileEntitySolarPanel extends TileEntity implements ITickable {

private final BaseMPContainer container;

public TileEntitySolarPanel() {
	this.container = new BaseMPContainer();
}

@Override
public void update() {
	if(this.hasWorld()) {
		if(!this.getWorld().provider.hasNoSky() && this.getWorld().canBlockSeeSky(this.getPos().offset(EnumFacing.UP))
				&& this.getWorld().getSkylightSubtracted() == 0 && this.container.getEnergyStored() != this.container.getMaxEnergyStored())
			this.container.receiveEnergy(2, false);

		final TileEntity tileEntity = this.getWorld().getTileEntity(this.getPos().offset(EnumFacing.DOWN));

		if(tileEntity != null && !tileEntity.isInvalid()) {
			if(tileEntity.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)) {
				IEnergyStorage consumer = tileEntity.getCapability(CapabilityEnergy.ENERGY, EnumFacing.UP);

				if(consumer != null)
					this.container.extractEnergy(consumer.receiveEnergy(this.container.getEnergyStored(), false), false);
			}
		}
	}
	System.out.println(this.container.getEnergyStored());
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	return super.writeToNBT(compound);
}

@Override
public SPacketUpdateTileEntity getUpdatePacket() {
	return super.getUpdatePacket();
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	super.onDataPacket(net, pkt);
	this.readFromNBT(pkt.getNbtCompound());
}

@Override
@SuppressWarnings("unchecked")
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
	if(facing == EnumFacing.DOWN && capability == CapabilityEnergy.ENERGY)
		return (T) this.container;

	return super.getCapability(capability, facing);
}

@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
	if(facing == EnumFacing.DOWN && capability == CapabilityEnergy.ENERGY)
		return true;

	return super.hasCapability(capability, facing);
}
}

 

 

Block

 

public class BlockSolarPanel extends Block implements ITileEntityProvider {

public BlockSolarPanel() {
	super(Material.IRON);
	this.isBlockContainer = true;
	this.setHardness(1.5f);
	this.setResistance(10.f);
	this.setLightOpacity(0);

	this.setCreativeTab(ModCreativeTabs.mcpowerTab);
}

@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntitySolarPanel();
}
}

 

 

BaseMPContainer

 

public class BaseMPContainer implements IEnergyStorage, INBTSerializable<NBTTagCompound> {

private int stored;
private int capacity;
private int input;
private int output;

public BaseMPContainer() {
	this(250, 10, 10);
}

public BaseMPContainer(int capacity, int input, int output) {
	this(0, capacity, input, output);
}

public BaseMPContainer(int power, int capacity, int input, int output) {
	this.stored = power;
	this.capacity = capacity;
	this.input = input;
	this.output = output;
}

public BaseMPContainer(NBTTagCompound dataTag) {
	this.deserializeNBT(dataTag);
}

@Override
public NBTTagCompound serializeNBT() {
	final NBTTagCompound dataTag = new NBTTagCompound();

	dataTag.setInteger("JAEStored", this.stored);
	dataTag.setInteger("JAECapacity", this.capacity);
	dataTag.setInteger("JAEInput", this.input);
	dataTag.setInteger("JAEOutput", this.output);

	return dataTag;
}

@Override
public void deserializeNBT(NBTTagCompound nbt) {
	if(nbt.hasKey("JAEStored"))
		this.stored = nbt.getInteger("JAEStored");
	if(nbt.hasKey("JAECapacity"))
		this.capacity = nbt.getInteger("JAECapacity");
	if(nbt.hasKey("JAEInput"))
		this.input = nbt.getInteger("JAEInput");
	if(nbt.hasKey("JAEOutput"))
		this.output = nbt.getInteger("JAEOutput");

	if(this.stored > this.getMaxEnergyStored())
		this.stored = this.getMaxEnergyStored();
}

@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
	final int acceptedPower = Math.min(this.getMaxEnergyStored() - this.getEnergyStored(), Math.min(this.getMaxInput(), maxReceive));

	if(!simulate)
		this.stored += acceptedPower;

	return this.canReceive() ? acceptedPower : 0;
}

@Override
public int extractEnergy(int maxExtract, boolean simulate) {
	final int removedPower = Math.min(this.getEnergyStored(), Math.min(this.getMaxOutput(), maxExtract));

	if(!simulate)
		this.stored -= removedPower;
	return this.canExtract() ? removedPower : 0;
}

@Override
public int getEnergyStored() {
	return this.stored;
}

@Override
public int getMaxEnergyStored() {
	return this.capacity;
}

public void setMaxEnergyStored(int capacity) {
	this.capacity = capacity;

	if(this.stored > capacity)
		this.stored = capacity;
}

public int getMaxInput() {
	return this.input;
}

public void setMaxInput(int input) {
	this.input = input;
}

public int getMaxOutput() {
	return this.output;
}

public void setMaxOutput(int output) {
	this.output = output;
}

@Override
public boolean canExtract() {
	return this.getMaxOutput() > 0 && this.stored > 0;
}

@Override
public boolean canReceive() {
	return this.getMaxInput() > 0;
}
}

 

 

Any ideas? Also open for ideas to improve the code. ;)

Developer of Primeval Forest.

Posted

You dont read and write it in your TE.

Oh yeah, totally forgot and overlooked that. So I basically have to put the container stuff in there like that?:

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	this.container.deserializeNBT(compound);
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	this.container.serializeNBT();
	return super.writeToNBT(compound);
}

Developer of Primeval Forest.

Posted

yes

Ok, I changed it and it does still not work.

	@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	//this.container.setEnergyStored(compound.getInteger("StoredJAE"));
	this.container.deserializeNBT(compound);
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	//compound.setInteger("StoredJAE", this.container.getEnergyStored());
	compound.setTag("StoredJAE", this.container.serializeNBT());
	return super.writeToNBT(compound);
}

I also tried it with the setInteger thing, does still not work. Oh and deserializeNBT needs an NBTTAgCompound, so getTag does not work.

Developer of Primeval Forest.

Posted

this does not work?

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        container.deserializeNBT(compound.getCompoundTag("StoredJAE"));
    }

 

what do you meen by

Oh and deserializeNBT needs an NBTTAgCompound, so getTag does not work.
Posted

this does not work?

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);
        container.deserializeNBT(compound.getCompoundTag("StoredJAE"));
    }

 

what do you meen by

Oh and deserializeNBT needs an NBTTAgCompound, so getTag does not work.

Yeah, overread the getCompoundTag. But even when using getCompoundTag, it gives me no errors anymore, but seems not to be able to save and load the data....

 

I'm also wondering from where this comes:

 

 

224

138

226

140

228

142

230

144

232

146

234

148

236

150

238

152

240

242

154

244

156

246

158

248

160

250

162

250

164

250

166

250

168

250

170

250

172

250

250

174

250

176

250

178

250

180

250

182

250

184

250

186

250

188

250

190

250

192

250

194

250

250

196

250

198

250

200

250

202

250

204

250

206

250

208

250

210

250

212

250

214

250

216

250

218

250

220

250

250

222

250

224

250

226

250

228

250

230

250

232

250

234

250

236

250

238

250

240

250

242

250

244

250

246

250

248

250

250

250

 

 

As you can see, the energy reaches 250, goes down again, and then up again etc. ... But I'm not removing energy from the block!

 

@Override
public void update() {
	if(this.hasWorld() && !this.world.isRemote) {
		if(!this.getWorld().provider.hasNoSky() && this.getWorld().canBlockSeeSky(this.getPos().offset(EnumFacing.UP))
				&& this.getWorld().getSkylightSubtracted() == 0 && this.container.getEnergyStored() != this.container.getMaxEnergyStored())
			this.container.receiveEnergy(2, false);

		final TileEntity tileEntity = this.getWorld().getTileEntity(this.getPos().offset(EnumFacing.DOWN));

		if(tileEntity != null && !tileEntity.isInvalid()) {
			if(tileEntity.hasCapability(CapabilityEnergy.ENERGY, EnumFacing.UP)) {
				IEnergyStorage consumer = tileEntity.getCapability(CapabilityEnergy.ENERGY, EnumFacing.UP);

				if(consumer != null)
					this.container.extractEnergy(consumer.receiveEnergy(this.container.getEnergyStored(), false), false);
			}
		}
		System.out.println(this.container.getEnergyStored());
	}
}

@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	//this.container.setEnergyStored(compound.getInteger("StoredJAE"));
	this.container.deserializeNBT(compound.getCompoundTag("StoredJAE"));
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	//compound.setInteger("StoredJAE", this.container.getEnergyStored());
	compound.setTag("StoredJAE", this.container.serializeNBT());
	return super.writeToNBT(compound);
}

To be sure it's not a problem with isRemote stuff, I just added a little check for this, but it's still counting the energy somehow twice.

Developer of Primeval Forest.

Posted

put breakpoints on it and see what it does

Ok, after setting a breakpoint in those two lines:

			this.container.receiveEnergy(2, false); (TileEntity)
	return this.canReceive() ? acceptedPower : 0; (BaseMPcontainer)

So, basically, I found now out that it seems to count perfectly until the number 10 was reached. At this point it starts for an unknown reason again by 2 and then 12 and then 4 and then 14 and then 6 and then 16 .....

I think it's clear what I mean. Oh and directly before the number 10 was reached the world has been fully loaded.

Developer of Primeval Forest.

Posted

Ok, I changed it and it does still not work.

	@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	//this.container.setEnergyStored(compound.getInteger("StoredJAE"));
	this.container.deserializeNBT(compound);
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	//compound.setInteger("StoredJAE", this.container.getEnergyStored());
	compound.setTag("StoredJAE", this.container.serializeNBT());
	return super.writeToNBT(compound);
}

I also tried it with the setInteger thing, does still not work. Oh and deserializeNBT needs an NBTTAgCompound, so getTag does not work.

 

Of course it doesn't work. In writeToNBT, you store the NBTTagCompound created by

this.container.serializeNBT()

in the root TileEntity tag but in the readFromNBT method, you try to deserialize it from the root tag instead of the sub tag.

 

You need to change the line in readFromNBT to:

 

this.container.deserializeNBT(compound.getCompoundTag("StoredJAE"));

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

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

    • 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() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
  • Topics

×
×
  • Create New...

Important Information

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