block destruction work
This commit is contained in:
parent
df72d51ea2
commit
d0fcded76d
@ -1552,6 +1552,7 @@ Fix bug where inventory items aren't destroying physics on server
|
||||
Align voxel lookups for movement audio and interaction targeting
|
||||
Align block lookups for interaction targeting
|
||||
Cursor logic around blocks
|
||||
Block destruction work
|
||||
|
||||
|
||||
|
||||
|
||||
@ -57,15 +57,11 @@ public class ItemActions {
|
||||
if(cursorPos == null){
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
//tell the server we want the secondary hand item to START doing something
|
||||
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
|
||||
"handRight",
|
||||
ITEM_ACTION_CODE_PRIMARY,
|
||||
ITEM_ACTION_CODE_STATE_ON,
|
||||
cursorPos.x,
|
||||
cursorPos.y,
|
||||
cursorPos.z
|
||||
));
|
||||
|
||||
//send server message if we're not doing a block edit
|
||||
//client sends custom packets for block editing
|
||||
boolean sendServerMessage = true;
|
||||
|
||||
//TODO: do any immediate client side calculations here (ie start playing an animation until we get response from server)
|
||||
if(Globals.playerEntity != null){
|
||||
ClientAttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
|
||||
@ -83,8 +79,27 @@ public class ItemActions {
|
||||
if(data.getClientSidePrimary() != null){
|
||||
ClientScriptUtils.fireSignal(data.getClientSidePrimary());
|
||||
}
|
||||
if(data.getPrimaryUsage() != null){
|
||||
if(data.getPrimaryUsage().getBlockId() != null){
|
||||
sendServerMessage = false;
|
||||
BlockEditing.destroyBlock();
|
||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(AssetDataStrings.INTERACT_SFX_BLOCK_PLACE, VirtualAudioSourceType.CREATURE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(sendServerMessage){
|
||||
//tell the server we want the secondary hand item to START doing something
|
||||
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
|
||||
"handRight",
|
||||
ITEM_ACTION_CODE_PRIMARY,
|
||||
ITEM_ACTION_CODE_STATE_ON,
|
||||
cursorPos.x,
|
||||
cursorPos.y,
|
||||
cursorPos.z
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -23,4 +23,14 @@ public class BlockEditing {
|
||||
ScriptClientVoxelUtils.clientRequestEditBlock(chunkPos, cornerVoxel, type, metadata, blockSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy blocks
|
||||
*/
|
||||
public static void destroyBlock(){
|
||||
Vector3i cornerVoxel = Globals.cursorState.getBlockCornerVoxelPos();
|
||||
int blockSize = Globals.cursorState.getBlockSize();
|
||||
Vector3i chunkPos = Globals.clientWorldData.convertRealToWorldSpace(EntityUtils.getPosition(Globals.playerBlockCursor));
|
||||
ScriptClientVoxelUtils.clientRequestEditBlock(chunkPos, cornerVoxel, (short)0, (short)0, blockSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -69,6 +69,11 @@ public class Item extends CommonEntityType {
|
||||
*/
|
||||
String clientSideSecondary;
|
||||
|
||||
/**
|
||||
* The usage logic for a primary usage of this item
|
||||
*/
|
||||
ItemUsage primaryUsage;
|
||||
|
||||
/**
|
||||
* The usage logic for a secondary usage of this item
|
||||
*/
|
||||
@ -151,6 +156,7 @@ public class Item extends CommonEntityType {
|
||||
usage.setBlockId(blockType.getId());
|
||||
usage.setOnlyOnMouseDown(true);
|
||||
rVal.setSecondaryUsage(usage);
|
||||
rVal.setPrimaryUsage(usage);
|
||||
|
||||
|
||||
//attach common tokens
|
||||
@ -216,6 +222,7 @@ public class Item extends CommonEntityType {
|
||||
public String getClientSideSecondary(){
|
||||
return clientSideSecondary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the secondary usage logic of this item
|
||||
* @return The secondary usage logic
|
||||
@ -232,4 +239,20 @@ public class Item extends CommonEntityType {
|
||||
this.secondaryUsage = secondaryUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the primary usage logic of this item
|
||||
* @return The primary usage logic
|
||||
*/
|
||||
public ItemUsage getPrimaryUsage(){
|
||||
return primaryUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the primary usage logic of this item
|
||||
* @param primaryUsage The primary usage logic
|
||||
*/
|
||||
public void setPrimaryUsage(ItemUsage primaryUsage){
|
||||
this.primaryUsage = primaryUsage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user