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

I developing ServerOnly mod with some commands.

I need to save some data to world (from command), and I need to save data temply with attachment ot the player.

And part 2. How Make mod that installs only to server, without requirement it at Client. Help!

I'm Developing Some mods. It's all.

  • Author

How To Get Entity Player, that Invoked command?

I'm Developing Some mods. It's all.

  • Author

It's commandSender interfase, hot to use IExtendedEntityProperties with it (sample please)

I'm Developing Some mods. It's all.

  • Author

Please, Show full sample how to do it  :(

I'm Developing Some mods. It's all.

  • Author

 

Эх, как же сложно общаться с людьми на другом языке....

 

Must I register this class?

And what supercalss I must to use with myProps class?

 

I'm very stupid

 

I'm Developing Some mods. It's all.

  • Author

I must register Event handler with

    	events = new RealEventHandler();
    	MinecraftForge.ORE_GEN_BUS.register(events);

in my preInit Event, must I register IExtendedEntityProperties?

I'm Developing Some mods. It's all.

  • Author

And how should I do any save/load of data, and Is that code ServerSide?

I'm Developing Some mods. It's all.

  • Author

Ok, now I have This Load Mathod:

 

	@Override
public void readFromNBT(NBTTagCompound nbt) {
	nextQuestId = nbt.getInteger("nextId");
	NBTTagList tl = nbt.getTagList("areas", 0);
	for (int i = 0; i < tl.tagCount(); i++) {
		String name = tl.getCompoundTagAt(i).getString("name");
		List<String> owners = new ArrayList<String>();
		List<String> members = new ArrayList<String>();
		int x1 = tl.getCompoundTagAt(i).getInteger("pos1X");
		int y1 = tl.getCompoundTagAt(i).getInteger("pos1Y");
		int z1 = tl.getCompoundTagAt(i).getInteger("pos1Z");
		int x2 = tl.getCompoundTagAt(i).getInteger("pos2X");
		int y2 = tl.getCompoundTagAt(i).getInteger("pos2Y");
		int z2 = tl.getCompoundTagAt(i).getInteger("pos2Z");
		NBTTagList tlo = tl.getCompoundTagAt(i).getTagList("owners", 0);
		NBTTagList tlm = tl.getCompoundTagAt(i).getTagList("members", 0);
		for (int i1 = 0; i < tlo.tagCount(); i++) {
			owners.add(tl.getCompoundTagAt(i).getString("name"));
		}
		for (int i1 = 0; i < tlm.tagCount(); i++) {
			members.add(tl.getCompoundTagAt(i).getString("name"));
		}

		areas.add(new AreaData(name, owners, members, x1, y1, z1, x2, y2, z2));
	}
}

 

 

How should I save this? I don't find setTagList() in NBTTagCompoud? How I must Do This?

I'm Developing Some mods. It's all.

  • Author

My AreaWorldData class:

 

package com.dcnick.servmod;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraft.world.WorldSavedData;
import net.minecraftforge.common.util.Constants.NBT;

public class AreaWorldData extends WorldSavedData {

public AreaWorldData(String indificator) {
	super(indificator);
}

private static final String IDENTIFIER = "Area";
private int nextQuestId = 0;
private List<AreaData> areas = new ArrayList<AreaData>();

public AreaWorldData() {
	super(IDENTIFIER);
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
	NBTTagList tl = nbt.getTagList("areas",  NBT.TAG_ANY_NUMERIC);
	for (int i = 0; i < tl.tagCount(); i++) {
		String name = tl.getCompoundTagAt(i).getString("name");
		List<String> owners = new ArrayList<String>();
		List<String> members = new ArrayList<String>();
		int x1 = tl.getCompoundTagAt(i).getInteger("pos1X");
		int y1 = tl.getCompoundTagAt(i).getInteger("pos1Y");
		int z1 = tl.getCompoundTagAt(i).getInteger("pos1Z");
		int x2 = tl.getCompoundTagAt(i).getInteger("pos2X");
		int y2 = tl.getCompoundTagAt(i).getInteger("pos2Y");
		int z2 = tl.getCompoundTagAt(i).getInteger("pos2Z");
		NBTTagList tlo = tl.getCompoundTagAt(i).getTagList("owners",  NBT.TAG_ANY_NUMERIC);
		NBTTagList tlm = tl.getCompoundTagAt(i).getTagList("members",  NBT.TAG_ANY_NUMERIC);
		for (int i1 = 0; i < tlo.tagCount(); i++) {
			owners.add(tl.getCompoundTagAt(i).getString("name"));
		}
		for (int i1 = 0; i < tlm.tagCount(); i++) {
			members.add(tl.getCompoundTagAt(i).getString("name"));
		}

		areas.add(new AreaData(name, owners, members, x1, y1, z1, x2, y2, z2));
	}
}

@Override
public void writeToNBT(NBTTagCompound nbt) {
	nbt.setInteger("nextId", nextQuestId);
	NBTTagList tl = new NBTTagList();
	for (int i = 0; i < areas.size(); i++) {
		NBTTagCompound tag = new NBTTagCompound();
		tag.setString("name", this.areas.get(i).name);
		NBTTagList tagLOwner = new NBTTagList();
		NBTTagList tagLMember = new NBTTagList();
		tag.setInteger("pos1X", this.areas.get(i).x1);
		tag.setInteger("pos1Y", this.areas.get(i).y1);
		tag.setInteger("pos1Z", this.areas.get(i).z1);
		tag.setInteger("pos2X", this.areas.get(i).x2);
		tag.setInteger("pos2Y", this.areas.get(i).y2);
		tag.setInteger("pos2Z", this.areas.get(i).z2);
		for (int i1 = 0;
				i1 < this.areas.get(i).owners.size();
				i1++) {
			NBTTagCompound tagO = new NBTTagCompound();
			tagO.setString("name", this.areas.get(i).owners.get(i));
			tagLOwner.appendTag(tagO);
		}
		for (int i1 = 0; i1 < this.areas.get(i).members.size(); i1++) {
			NBTTagCompound tagM = new NBTTagCompound();
			tagM.setString("name", this.areas.get(i).owners.get(i));
			tagLOwner.appendTag(tagM);
		}
		tag.setTag("owners", tagLOwner);
		tag.setTag("members", tagLMember);
		tl.appendTag(tag);
	}
	nbt.setTag("areas", tl);
}

public int registerArea(AreaData area) {
	for (int i = 0; i < areas.size(); i++) {
		if (this.areas.get(i).name == area.name)
		{
			return 1;
		}
	}

	this.areas.add(area);
	this.markDirty();
	return 0;
}

public static AreaWorldData get(World world) {
	AreaWorldData data = (AreaWorldData) world.loadItemData(
			AreaWorldData.class, IDENTIFIER);
	if (data == null) {
		data = new AreaWorldData();
		world.setItemData(IDENTIFIER, data);
	}
	return data;
}

public AreaData getArea(String name) {
	for (int i = 0; i < areas.size(); i++) {
		if (this.areas.get(i).name.compareTo(name) == 0)
		{
			return this.areas.get(i);
		}
	}
	return null;
}

public AreaData getArea(int x, int y, int z) {
	for (int i = 0; i < areas.size(); i++) {
		if (  (((x < this.areas.get(i).x1) && (x > this.areas.get(i).x2)) || ((x > this.areas.get(i).x1) && (x < this.areas.get(i).x2))) 
				&& (((y < this.areas.get(i).y1) && (y > this.areas.get(i).y2)) || ((y > this.areas.get(i).y1) && (y < this.areas.get(i).y2))) 
				&& (((x < this.areas.get(i).z1) && (x > this.areas.get(i).z2)) || ((x > this.areas.get(i).z1) && (x < this.areas.get(i).z2))) )
		{
			return this.areas.get(i);
		}
	}

	return null;
}

}

 

 

I write data with registerArea() method, but getArea() returns null! Help!

I'm Developing Some mods. It's all.

  • Author

I use both versions. Class (command) which I use to call it:

 

package com.dcnick.servmod;

import java.util.ArrayList;
import java.util.List;

import scala.actors.threadpool.Arrays;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChunkCoordinates;

public class AreaCommand implements ICommand {

private List<String> aliases;

protected AreaCommand() {
	aliases = new ArrayList<String>();
	aliases.add("area");
	aliases.add("ar");
}

@Override
public int compareTo(Object arg0) {
	return 0;
}

@Override
public String getCommandName() {
	return "area";
}

@Override
public String getCommandUsage(ICommandSender cs) {
	return "Using: /area [create] [name]";
}

@Override
public List getCommandAliases() {
	return aliases;
}

@Override
public void processCommand(ICommandSender cs, String[] arg) {
	EntityPlayer player;

	if (arg.length < 1) {
		cs.addChatMessage(new ChatComponentText("§4Not Enought Arguments§f"));
		return;
	}

	if (cs instanceof EntityPlayer) {
		player = (EntityPlayer) cs;
	} else {
		cs.addChatMessage(new ChatComponentText("§4Player Only Command§f"));
		return;
	}
	if (arg[0].compareTo("create") == 0)
	{
		if (arg.length < 2) {
			cs.addChatMessage(new ChatComponentText(
					"§4Not Enought Arguments§f"));
			return;
		}
		if (player.getEntityData().getBoolean("pos1") && player.getEntityData().getBoolean("pos2"))
		{
			int x1 = player.getEntityData().getInteger("pos1X");
			int y1 = player.getEntityData().getInteger("pos1Y");
			int z1 = player.getEntityData().getInteger("pos1Z");
			int x2 = player.getEntityData().getInteger("pos2X");
			int y2 = player.getEntityData().getInteger("pos2Y");
			int z2 = player.getEntityData().getInteger("pos2Z");
			String name = arg[1];
			cs.addChatMessage(new ChatComponentText(
					"§fCreating Region named '§e" + name
					+ "§f' with Point1 at (§e" + x1 + "§f,§e" + y1
					+ "§f,§e" + z1 + "§f) and Point2 at (§e" + x2
					+ "§f,§e" + y2 + "§f,§e" + z2 + "§f) ..." + "§f"));
			List<String> owners = new ArrayList<String>();
			owners.add(name);
			AreaWorldData.get(cs.getEntityWorld()).registerArea(new AreaData(name, owners , owners, x1, y1, z1, x2, y2, z2));
		}
		else
		{
			cs.addChatMessage(new ChatComponentText(
					"§4Positions not setted! Use /pos command to do this§f"));
			return;
		}
	}
	else
	if (arg[0].compareTo("info") == 0)
	{
		if (arg.length < 2) {
			cs.addChatMessage(new ChatComponentText(
					"§4Not Enought Arguments§f"));
			return;
		}

		ChunkCoordinates cc = cs.getPlayerCoordinates();
		AreaData ad = AreaWorldData.get(cs.getEntityWorld()).getArea(cc.posX, cc.posY, cc.posZ);
		if (ad != null)
			cs.addChatMessage(new ChatComponentText(
					"§fHere is Region Named '§e" + ad.name + "§f'"));
		else
			cs.addChatMessage(new ChatComponentText(
					"§4Here is No Regions §f"));	
		if ((ad = AreaWorldData.get(cs.getEntityWorld()).getArea(arg[1])) != null)
			cs.addChatMessage(new ChatComponentText(
					"§fHere is Region Named '§e" + ad.name + "§f'"));
		else
			cs.addChatMessage(new ChatComponentText(
					"§4Here is No Regions §f"));
	}
	else
	{
		cs.addChatMessage(new ChatComponentText(
				"§4Error at argument 1 it can be: create, remove, info§f"));
		return;
	}
}

@Override
public boolean canCommandSenderUseCommand(ICommandSender cs) {
	return true;
}

@Override
public List addTabCompletionOptions(ICommandSender cs, String[] ar) {
	return null;
}

@Override
public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) {
	return false;
}

}

 

I'm Developing Some mods. It's all.

  • Author

Ok, I don't know what occurs, but now getArea(String) works normally...

I'm Developing Some mods. It's all.

  • Author

Help me with theese conditions, please. gerArea(int,int,int) must return area in which the transmitting point. Condition

determines is point between points. Help!

I'm Developing Some mods. It's all.

  • Author

I will do checking to no intersecting nareas in registerArea()

I'm Developing Some mods. It's all.

  • Author

Ow, I have other questions now:

[*]

  I need this server Side Events:

 

  [*]Event, when player breaks block

  [*]Event, when player places block

  [*]Event, when player uses block

  [*]Event, when player places minecart

  [*]Event, when player fires TNT (with acces to activatedTNT entity)

 

 

[*]Where I can find server Events?

I'm Developing Some mods. It's all.

  • Author

And now Both getArea() methods works normally, but if I reload Minecraft Areas Are Not Saved...

I'm Developing Some mods. It's all.

  • Author

Ok, I will know and discover it soon. Are you use a new version (I updated gitHub repository: I fix these errors, what you writed me.

I'm Developing Some mods. It's all.

  • Author

I've Updated it again. Please Check (I don't know what is this)

I'm Developing Some mods. It's all.

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.