You are not logged in.

  • Login

[Bukkit-Plugin] ArmorStand packets

Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

Dear visitor, welcome to Nitrado.net Prepaid Gameserver Community-Support - Archiv. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

daniel0916

User / Kunde

Posts: 998

  • Send private message

41

Tuesday, May 19th 2015, 10:22pm

Ist doch klar. Im EntitySpawn Packet gibt es nichts mit DataWatcher. Du musst du nur einen Integer schreiben. Setze diesen dann einfach auf 0. Hatte dir doch ein Code Beispiel geschrieben...

Ich habe leider keine Ahnung, ob EntityLiving auch geht, aber der ArmorStand lebt ja nicht...

Edit: Verwende mal als EntityType 30 beim EntityLiving Packet. Habe das beim googeln gefunden. Ob es geht, weiß ich nicht.

This post has been edited 1 times, last edit by "daniel0916" (May 19th 2015, 10:28pm)


ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

42

Wednesday, May 20th 2015, 6:34pm

Ich bekomme keinen error allerdings selebe problem wie zuvor das ich keinen ArmorStand sehe.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package de.Ste3et_C0st.Furniture.Main;

import java.lang.reflect.InvocationTargetException;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;

import de.Ste3et_C0st.Furniture.Main.Type.BodyPart;


public class ArmorStandPacket{

	private Location location;
	private BodyPart part;
	private EulerAngle angle;
	private ItemStack is;
	private boolean mini, invisible;
	private WrappedDataWatcher watcher;
	private PacketContainer container;
	private main plugin;
	
	public Location getLocation(){return this.location;}
	public PacketContainer getContainer(){return this.container;}
	public BodyPart getBodyPart(){return this.part;}
	public ItemStack getItemStack(){return this.is;}
	public EulerAngle getAngle(){return this.angle;}
	public boolean isInvisible(){return this.invisible;}
	public boolean isMini(){return this.mini;}
	
	public ArmorStandPacket(Location l, BodyPart part, EulerAngle angle, ItemStack is, boolean mini, boolean invisible, main plugin){
		this.location = l;
		this.part = part;
		this.angle = angle;
		this.is = is;
		this.mini = mini;
		this.invisible = invisible;
		this.plugin = plugin;
		this.watcher = getDefaultWatcher(l.getWorld(), EntityType.ARMOR_STAND);
		create();
	}

	public WrappedDataWatcher getDefaultWatcher(World world, EntityType type) {
        Entity entity = world.spawnEntity(new Location(world, 0, 256, 0), type);
        WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(entity).deepClone();
        entity.remove();
        return watcher;
    }
	
	@SuppressWarnings("deprecation")
	private void create(){
		PacketContainer container = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
		StructureModifier<Integer> integers = container.getIntegers();
		integers.write(0, 500);
		integers.write(1, (int) EntityType.ARMOR_STAND.getTypeId());
		integers.write(2, getFixedPoint(this.location.getX()));
		integers.write(3, getFixedPoint(this.location.getY()));
		integers.write(4, getFixedPoint(this.location.getZ()));
		integers.write(5, (int) ((this.location.getYaw() * 256.0F) / 360.0F));
		integers.write(6, (int) ((this.location.getPitch() * 256.0F) / 360.0F));
		integers.write(7, 0);
		this.container = container;
		//this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	private int getFixedPoint(Double d){
		return (int) Math.floor(this.location.getX()*32D);
	}
	
	public void send(Player p){
		try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(p, container);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
	}
	
	public void sendAll(){
		try {
            for(Player p : this.location.getWorld().getPlayers()){
            	ProtocolLibrary.getProtocolManager().sendServerPacket(p, container);
            }
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
	}
}

daniel0916

User / Kunde

Posts: 998

  • Send private message

43

Wednesday, May 20th 2015, 6:51pm

Was ist dann die Ausgabe von EntityType.ARMOR_STAND.getTypeId()?

Und hast du das von meinem letzten Post mit dem LivingPacket auch versucht?

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

44

Wednesday, May 20th 2015, 6:56pm

Ich hab doch vor ca 3-4 posts schon geschrieben das alles mit Spawn_Entity_Living geht nur das der ArmorStand nicht genau dort platziert wird wo ich möchte.
Sprich ich steh in der Mitte des Blocks und der Armorstand wird an die Ecke des Blocks gespawnt.

Edit://Ok nun geht es allerdings nun kommt der nächste teil das editieren ^^

Wie mach ich das ich habs nun so :

Source code

1
2
3
4
	public void setArms(boolean b){
		this.watcher.setObject(0x04, b ? (byte) 1 : (byte) 0);
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}


Leider sehe ich keine arme stimmt 0x04 eigentlich ?

This post has been edited 3 times, last edit by "ste3et_c0st" (May 20th 2015, 7:32pm)


daniel0916

User / Kunde

Posts: 998

  • Send private message

45

Wednesday, May 20th 2015, 7:54pm

Achso, ich dachte es wäre nicht gegangen.

Bei dir fehlt noch das 10 bei setObject.
Oder teste mal:

Java source code

1
this.watcher.setObject(10, 0x04);


Edit: Schau im Bukkit Code bei EntityArmorStand nach.
Hier das für die Arme:

Java source code

1
2
3
4
5
6
7
8
9
10
11
/*     */   public void setArms(boolean flag) {
/* 621 */     byte b0 = this.datawatcher.getByte(10);
/*     */ 
/* 623 */     if (flag)
/* 624 */       b0 = (byte)(b0 | 0x4);
/*     */     else {
/* 626 */       b0 = (byte)(b0 & 0xFFFFFFFB);
/*     */     }
/*     */ 
/* 629 */     this.datawatcher.watch(10, Byte.valueOf(b0));
/*     */   }

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

46

Wednesday, May 20th 2015, 10:06pm

Cool danke geht.

Das hier wäre die neue Classe:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package de.Ste3et_C0st.Furniture.Main;

import java.lang.reflect.InvocationTargetException;

import net.minecraft.server.v1_8_R2.Vector3f;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;

import de.Ste3et_C0st.Furniture.Main.Type.BodyPart;


public class ArmorStandPacket{

	private Integer ID;
	private Location location;
	private BodyPart part;
	private EulerAngle angle;
	private ItemStack is;
	private boolean mini, invisible, arms, basePlate, graviti;
	private WrappedDataWatcher watcher;
	private PacketContainer container;
	
	public Location getLocation(){return this.location;}
	public PacketContainer getContainer(){return this.container;}
	public BodyPart getBodyPart(){return this.part;}
	public ItemStack getItemStack(){return this.is;}
	public EulerAngle getAngle(){return this.angle;}
	public boolean isInvisible(){return this.invisible;}
	public boolean isMini(){return this.mini;}
	public boolean hasArms(){return this.arms;}
	public boolean hasBasePlate(){return this.basePlate;}
	public boolean hasGraviti(){return this.graviti;}
	
	public ArmorStandPacket(Location l, BodyPart part, ItemStack is, int ID){
		this.location = l;
		this.part = part;
		this.is = is;
		this.watcher = getDefaultWatcher(l.getWorld(), EntityType.ARMOR_STAND);
		this.ID = ID;
		create();
	}

	public WrappedDataWatcher getDefaultWatcher(World world, EntityType type) {
        Entity entity = world.spawnEntity(new Location(world, 0, 256, 0), type);
        WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(entity).deepClone();
        entity.remove();
        return watcher;
    }
	

	@SuppressWarnings("deprecation")
	private void create(){
		PacketContainer container = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
		StructureModifier<Integer> integers = container.getIntegers();
		integers.write(0, this.ID);
		integers.write(1, (int) EntityType.ARMOR_STAND.getTypeId());
		integers.write(2, getFixedPoint(this.location.getX()));
		integers.write(3, getFixedPoint(this.location.getY()));
		integers.write(4, getFixedPoint(this.location.getZ()));
		integers.write(5, (int) ((this.location.getYaw() * 256.0F) / 360.0F));
		integers.write(6, (int) ((this.location.getPitch() * 256.0F) / 360.0F));
		integers.write(7, 0);
		container.getDataWatcherModifier().write(0, this.watcher);
		this.container = container;
	}
	
	public void setSmall(boolean b){
		this.watcher.setObject(10, (byte)(b?1:0));
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	public void setArms(boolean b) {
		byte b0 = this.watcher.getByte(10);

		if (b)
			b0 = (byte)(b0 | 0x4);
		else {
			b0 = (byte)(b0 & 0xFFFFFFFB);
		}
		
		this.watcher.setObject(10, Byte.valueOf(b0));
		this.arms = b;
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	public void setGrafiti(boolean b) {
		byte b0 = this.watcher.getByte(10);

		if (b)
			b0 = (byte)(b0 | 0x02);
		else {
			b0 = (byte)(b0 & 0xFFFFFFFB);
		}
		
		this.watcher.setObject(10, Byte.valueOf(b0));
		this.graviti = b;
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	public void setBasePlate(boolean b) {
		byte b0 = this.watcher.getByte(10);

		if (b)
			b0 = (byte)(b0 | 0x08);
		else {
			b0 = (byte)(b0 & 0xFFFFFFFB);
		}
		
		this.watcher.setObject(10, Byte.valueOf(b0));
		this.basePlate = b;
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	public void setInvisible(boolean b) {
		byte b0 = this.watcher.getByte(0);

		if (b)
			b0 = (byte)(b0 | 0x20);
		else {
			b0 = (byte)(b0 & 0xFFFFFFFB);
		}
		
		this.watcher.setObject(0, Byte.valueOf(b0));
		this.basePlate = b;
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	public void setPose(EulerAngle angle){
		if(angle==null){return;}
		if(this.part==null){return;}
		this.angle = angle;
		Vector3f vector = new Vector3f((float) angle.getX(), (float) angle.getY(), (float) angle.getZ());
		switch (part) {
		case HEAD:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		case BODY:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		case LEFT_ARM:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		case RIGHT_ARM:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		case LEFT_LEG:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		case RIGHT_LEG:
			this.watcher.setObject(11, vector);
			this.container.getDataWatcherModifier().write(0, this.watcher);
			break;
		default:return;
		}
	}
	
	public void setName(String str){
		if(str==null){return;}
		this.watcher.setObject(2, str);
	}
	
	public void setNameVasibility(boolean b){
		this.watcher.setObject(3, (byte)(b?1:0));
		this.container.getDataWatcherModifier().write(0, this.watcher);
	}
	
	
	private int getFixedPoint(Double d){
		return (int) (d*32D);
	}
	
	public void send(Player p){
		try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(p, container);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
	}
	
	public void sendAll(){
		try {
            for(Player p : this.location.getWorld().getPlayers()){
            	ProtocolLibrary.getProtocolManager().sendServerPacket(p, container);
            }
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
	}
}


Aufrufen tu ich das ganze so:

Source code

1
2
3
4
5
6
7
8
9
10
11
Player p = (Player) sender;
Location l = p.getLocation();
ArmorStandPacket armorstand = new ArmorStandPacket(l, BodyPart.HEAD, null, 5887);
armorstand.setArms(true);
armorstand.setBasePlate(false);
armorstand.setSmall(true);
armorstand.setInvisible(false);
armorstand.setName("§cTest");
armorstand.setNameVasibility(true);
armorstand.setPose(Utils.Radtodegress(new EulerAngle(1.56, 0, 0)));
armorstand.send(p);


Mein Problem ist nur ich kann den ArmorStand nicht gleichzeitig klein machen in die arme einschallten und die BasePlate löschen.

This post has been edited 2 times, last edit by "ste3et_c0st" (May 20th 2015, 10:47pm)


ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

47

Thursday, May 21st 2015, 10:12pm

#Push

Bräuchte immer noch Hilfe bei:

- Dem setzen eines Items ich hab das nun so

Source code

1
2
3
4
	public void setItemInHand(ItemStack is){
		StructureModifier<ItemStack> watcher = this.container.getItemModifier();
		watcher.write(0, is);
	}


geht allerdings nicht da kommt leider ein error

Spoiler Spoiler


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[17:42:37] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'furniture' in plugin Furniture v1.8.8.1
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[Spigot:git-Spigot-2ec6f06-7722428]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[Spigot:git-Spigot-2ec6f06-7722428]
	at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1139) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:974) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [Spigot:git-Spigot-2ec6f06-7722428]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_40]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_40]
	at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:712) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [Spigot:git-Spigot-2ec6f06-7722428]
	at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [Spigot:git-Spigot-2ec6f06-7722428]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40]
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.server.v1_8_R2.ItemStack exists in class PacketPlayOutSpawnEntityLiving.
	at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:332) ~[?:?]
	at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:312) ~[?:?]
	at de.Ste3et_C0st.Furniture.Main.ArmorStandPacket.setItemInHand(ArmorStandPacket.java:189) ~[?:?]
	at de.Ste3et_C0st.Furniture.Main.command.onCommand(command.java:83) ~[?:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[Spigot:git-Spigot-2ec6f06-7722428]
	... 15 more



- Auserdem hab ich noch das Problem das verschiedene einstellungen beim armostand sich gegenseitig überschreiben sprich wenn ich in klein machen möchte und arme anzeigen lassen möchte ist er nur klein.

daniel0916

User / Kunde

Posts: 998

  • Send private message

48

Thursday, May 21st 2015, 11:00pm

Weil du bei small auch nicht die bisherigen Sachen dir Holst sondern alles überschreibst.
Sollte doch in der NMS Klasse auch alles drinnen sein.
Ich kann erst später nachsehen.

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

49

Friday, May 22nd 2015, 4:17pm

Wo finde ich die NMS Klassen ?
Hab schon im SourceCode von bukkit/craftbukkit & spigot geschaut bin aber zu blöd dazu sie zu finden.

daniel0916

User / Kunde

Posts: 998

  • Send private message

50

Friday, May 22nd 2015, 5:15pm

net.minecraft.server.version

NMS= Net Minecraft Server

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

51

Saturday, May 23rd 2015, 6:14pm

Zwecks dem ItemStack setzen hab ich nun das hier gefunden:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public ItemStack getEquipment(int i)
  {
    return this.items[i];
  }
  
  public void setEquipment(int i, ItemStack itemstack)
  {
    this.items[i] = itemstack;
  }
  
  public ItemStack[] getEquipment()
  {
    return this.items;
  }
  
  public boolean d(int i, ItemStack itemstack)
  {
    int j;
    int j;
    if (i == 99)
    {
      j = 0;
    }
    else
    {
      j = i - 100 + 1;
      if ((j < 0) || (j >= this.items.length)) {
        return false;
      }
    }
    if ((itemstack != null) && (EntityInsentient.c(itemstack) != j) && ((j != 4) || (!(itemstack.getItem() instanceof ItemBlock)))) {
      return false;
    }
    setEquipment(j, itemstack);
    return true;
  }


Das hilft mir allerdings nicht weiter das hab ich in der EntityArmorStand.class gefunden

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

52

Sunday, May 24th 2015, 6:14pm

#Push

daniel0916

User / Kunde

Posts: 998

  • Send private message

53

Sunday, May 24th 2015, 11:55pm

Ich habe keine Ahnung, wie das bei einem ArmorStand funktioniert. Vielleicht brauchst du das Entity Equipment Packet.

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

54

Monday, May 25th 2015, 5:19pm

So ich hab nun das mit den ENTITY_EQUIPMENT packet probiert allerdings bekomme ich immer noch einen Error Leider
Das hier wäre der code der ArmorStand Datei: LINK

Das hier wäre der error:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
25.05 17:48:58 [Server] INFO at de.Ste3et_C0st.FurnitureTest.test.onCommand(test.java:39) ~[?:?]
25.05 17:48:58 [Server] INFO at de.Ste3et_C0st.FurnitureTest.test.a(test.java:56) ~[?:?]
25.05 17:48:58 [Server] INFO at de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket.setItemInHand(ArmorStandPacket.java:200) ~[?:?]
25.05 17:48:58 [Server] INFO at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:312) ~[?:?]
25.05 17:48:58 [Server] INFO at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:336) ~[?:?]
25.05 17:48:58 [Server] INFO Caused by: com.comphenix.protocol.reflect.FieldAccessException: Field index out of bounds. (Index: 2, Size: 2)
25.05 17:48:58 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_40]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:712) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_40]
25.05 17:48:58 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_40]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:974) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1139) [Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[Spigot:git-Spigot-2ec6f06-7722428]
25.05 17:48:58 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin FurnitureTest v0.1


Das wäre der Code mit dem Ich das ganze aufrufe:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package de.Ste3et_C0st.FurnitureTest;

import java.util.Arrays;
import java.util.List;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.EulerAngle;

import de.Ste3et_C0st.FurnitureLib.main.ArmorStandPacket;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib;
import de.Ste3et_C0st.FurnitureLib.main.FurnitureManager;
import de.Ste3et_C0st.FurnitureLib.main.LocationUtil;
import de.Ste3et_C0st.FurnitureLib.main.ObjectID;
import de.Ste3et_C0st.FurnitureLib.main.Type.BodyPart;

public class test extends JavaPlugin {

	FurnitureLib lib;
	
	public void onEnable(){
		if(getServer().getPluginManager().isPluginEnabled("FurnitureLib")){
			this.lib = (FurnitureLib) getServer().getPluginManager().getPlugin("FurnitureLib");
		}
	}
	
	public void onDisable(){
		
	}
	
	public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args){
	    if(command.getName().equalsIgnoreCase("Test")){
	    	Player p = (Player) sender;
	    	a(p.getLocation(), p);
	    	return true;
	    }
		return false;
	}
	
	public void a(Location loc, Player p){
		ObjectID id = new ObjectID(this.getClass());
		FurnitureManager manager = this.lib.getFurnitureManager();
		LocationUtil lUtil = this.lib.getLocationUtil();
		ArmorStandPacket packet = manager.createArmorStand(loc, BodyPart.HEAD, new ItemStack(Material.DIRT));
		packet.setArms(true);
		packet.setBasePlate(false);
		packet.setSmall(true);
		packet.setName("Test");
		packet.setNameVasibility(true);
		packet.setPose(lUtil.degresstoRad(new EulerAngle(45, 0, 0)));
		packet.setItemInHand(new ItemStack(Material.DIRT), 0);
		manager.addFurniture(id, Arrays.asList(packet));
		List<Player> pList = p.getWorld().getPlayers();
		manager.send(id, pList);
	}
}


ICH HABS HINBEKOMMEN JUHU

This post has been edited 1 times, last edit by "ste3et_c0st" (May 25th 2015, 6:21pm)


daniel0916

User / Kunde

Posts: 998

  • Send private message

55

Monday, May 25th 2015, 7:04pm

Schön, das nun endlich alles klappt.

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

56

Monday, May 25th 2015, 7:07pm

Eine frage noch ich möchte nun die Events abfangen dafür hab ich nun folgenden code: LINK
Der steht in der Main datei ich weiß nicht wieso aber das Event wird nicht gefeuert bin anscheinend doch zu dumm dazu ;(

daniel0916

User / Kunde

Posts: 998

  • Send private message

57

Monday, May 25th 2015, 7:10pm

Du musst erstmal prüfen, ob es das richtige Paket ist.

ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

58

Monday, May 25th 2015, 7:16pm

Ist das das Falsche Packet Event ? PacketType.Play.Client.ENTITY_ACTION
Ich frag es ja schon ab ob es die Selbe Entity Type ID wie ein ArmorStand hat und ob die Entity ID vorhanden ist


Habs selber gefunden es war einfach:


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ProtocolLibrary.getProtocolManager().addPacketListener(
                new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
                    public void onPacketReceiving(PacketEvent event) {
                        if (event.getPacketType() == PacketType.Play.Client.USE_ENTITY) {
                        	Integer PacketID = event.getPacket().getIntegers().read(0);
                            if(getFurnitureManager().isFromPlugin(PacketID)){
                            	ArmorStandPacket asPacket = getFurnitureManager().getArmorStandPacketByID(PacketID);
                            	ObjectID objID = getFurnitureManager().getObjectIDByID(PacketID);
                            	Location loc = asPacket.getLocation();
                            	Player p = event.getPlayer();
                            	EntityUseAction action = event.getPacket().getEntityUseActions().read(0);
                            	switch (action) {
								case ATTACK:
									FurnitureBreakEvent bEvent = new FurnitureBreakEvent(p, asPacket, objID, loc);
									Bukkit.getServer().getPluginManager().callEvent(bEvent);
									break;
								case INTERACT_AT:
									FurnitureClickEvent cEvent = new FurnitureClickEvent(p, asPacket, objID, loc);
									Bukkit.getServer().getPluginManager().callEvent(cEvent);
									break;
								default: break;
								}
                            }
                        }
                    }
        });



Dabei wird die EntityID in eine Liste gespeichert das war alles ^^

Edit:// Wieso verschwienden die ArmorStands sobalt ich das Paket erneut übermittle hat da jemand eine Idee ?

This post has been edited 4 times, last edit by "ste3et_c0st" (May 25th 2015, 10:01pm)


ste3et_c0st

User / Kunde

  • "ste3et_c0st" is male
  • "ste3et_c0st" started this thread

Posts: 245

Location: Regensburg

Occupation: Elektroniker für Maschinen und Antriebstechnik

  • Send private message

59

Tuesday, May 26th 2015, 10:03pm

Ich hab noch ein paar Probleme und zwar wird der ArmorStand unsichtbar sobald mein Chunk Unloadet.
Und außerdem habe ich noch die frage wie ich im nachhinein z.B das Item in der Hand austausche muss ich da einfach das Packet nochmal senden ?

Gebauer_01

User / Kunde

Posts: 2,304

  • Send private message

60

Tuesday, May 26th 2015, 10:13pm

Einfach wieder ein PacketPlayOutEntityEquipment senden.

Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net

Similar threads