-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from EverPvP/master
Update to 1.9
- Loading branch information
Showing
10 changed files
with
639 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 109 additions & 56 deletions
165
src/main/java/com/comphenix/packetwrapper/WrapperPlayClientUseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,116 @@ | ||
/** | ||
* PacketWrapper - ProtocolLib wrappers for Minecraft packets | ||
* Copyright (C) dmulloy2 <http://dmulloy2.net> | ||
* Copyright (C) Kristian S. Strangeland | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.comphenix.packetwrapper; | ||
|
||
import org.bukkit.util.Vector; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.events.PacketEvent; | ||
import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction; | ||
import org.bukkit.World; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.util.Vector; | ||
|
||
public class WrapperPlayClientUseEntity extends AbstractPacket { | ||
public static final PacketType TYPE = PacketType.Play.Client.USE_ENTITY; | ||
|
||
public WrapperPlayClientUseEntity() { | ||
super(new PacketContainer(TYPE), TYPE); | ||
handle.getModifier().writeDefaults(); | ||
} | ||
|
||
public WrapperPlayClientUseEntity(PacketContainer packet) { | ||
super(packet, TYPE); | ||
} | ||
|
||
/** | ||
* Retrieve Target. | ||
* @return The current Target | ||
*/ | ||
public int getTarget() { | ||
return handle.getIntegers().read(0); | ||
} | ||
|
||
/** | ||
* Set Target. | ||
* @param value - new value. | ||
*/ | ||
public void setTarget(int value) { | ||
handle.getIntegers().write(0, value); | ||
} | ||
|
||
/** | ||
* Retrieve Type. | ||
* <p> | ||
* Notes: 0 = INTERACT, 1 = ATTACK, 2 = INTERACT_AT | ||
* @return The current Type | ||
*/ | ||
public EntityUseAction getType() { | ||
return handle.getEntityUseActions().read(0); | ||
} | ||
|
||
/** | ||
* Set Type. | ||
* @param value - new value. | ||
*/ | ||
public void setType(EntityUseAction value) { | ||
handle.getEntityUseActions().write(0, value); | ||
} | ||
|
||
public Vector getTargetVector() { | ||
return handle.getVectors().read(0); | ||
} | ||
|
||
public void setTargetVector(Vector value) { | ||
handle.getVectors().write(0, value); | ||
} | ||
|
||
} | ||
public static final PacketType TYPE = PacketType.Play.Client.USE_ENTITY; | ||
|
||
public WrapperPlayClientUseEntity() { | ||
super(new PacketContainer(TYPE), TYPE); | ||
handle.getModifier().writeDefaults(); | ||
} | ||
|
||
public WrapperPlayClientUseEntity(PacketContainer packet) { | ||
super(packet, TYPE); | ||
} | ||
|
||
/** | ||
* Retrieve entity ID of the target. | ||
* | ||
* @return The current entity ID | ||
*/ | ||
public int getTargetID() { | ||
return handle.getIntegers().read(0); | ||
} | ||
|
||
/** | ||
* Retrieve the entity that was targeted. | ||
* | ||
* @param world - the current world of the entity. | ||
* @return The targeted entity. | ||
*/ | ||
public Entity getTarget(World world) { | ||
return handle.getEntityModifier(world).read(0); | ||
} | ||
|
||
/** | ||
* Retrieve the entity that was targeted. | ||
* | ||
* @param event - the packet event. | ||
* @return The targeted entity. | ||
*/ | ||
public Entity getTarget(PacketEvent event) { | ||
return getTarget(event.getPlayer().getWorld()); | ||
} | ||
|
||
/** | ||
* Set entity ID of the target. | ||
* | ||
* @param value - new value. | ||
*/ | ||
public void setTargetID(int value) { | ||
handle.getIntegers().write(0, value); | ||
} | ||
|
||
/** | ||
* Retrieve Type. | ||
* | ||
* @return The current Type | ||
*/ | ||
public EntityUseAction getType() { | ||
return handle.getEntityUseActions().read(0); | ||
} | ||
|
||
/** | ||
* Set Type. | ||
* | ||
* @param value - new value. | ||
*/ | ||
public void setType(EntityUseAction value) { | ||
handle.getEntityUseActions().write(0, value); | ||
} | ||
|
||
/** | ||
* Retrieve the target vector. | ||
* <p> | ||
* Notes: Only if {@link #getType()} is {@link EntityUseAction#INTERACT_AT}. | ||
* | ||
* @return The target vector or null | ||
*/ | ||
public Vector getTargetVector() { | ||
return handle.getVectors().read(0); | ||
} | ||
|
||
/** | ||
* Set the target vector. | ||
* | ||
* @param value - new value. | ||
*/ | ||
public void setTargetVector(Vector value) { | ||
handle.getVectors().write(0, value); | ||
} | ||
} |
Oops, something went wrong.