private void inputEventSetup(InputEvent event, JsonObject jsonObject) { float delta = jsonObject.get("delta").getAsFloat(); boolean consumed = jsonObject.get("consumed").getAsBoolean(); EntityRef target = new RecordedEntityRef(jsonObject.get("target").getAsLong(), (LowLevelEntityManager) this.entityManager); JsonObject aux = jsonObject.get("hitNormal").getAsJsonObject(); Vector3f hitNormal = new Vector3f(aux.get("x").getAsFloat(), aux.get("y").getAsFloat(), aux.get("z").getAsFloat()); aux = jsonObject.get("hitPosition").getAsJsonObject(); Vector3f hitPosition = new Vector3f(aux.get("x").getAsFloat(), aux.get("y").getAsFloat(), aux.get("z").getAsFloat()); aux = jsonObject.get("targetBlockPosition").getAsJsonObject(); Vector3i targetBlockPosition = new Vector3i(aux.get("x").getAsInt(), aux.get("y").getAsInt(), aux.get("z").getAsInt()); event.setTargetInfo(target, targetBlockPosition, hitPosition, hitNormal); } }
GsonDeserializationContext deserializationContext = new GsonDeserializationContext(null); if (className.equals(CameraTargetChangedEvent.class.getName())) { EntityRef oldTarget = new RecordedEntityRef(jsonObject.get("OldTarget").getAsLong(), (LowLevelEntityManager) this.entityManager); EntityRef newTarget = new RecordedEntityRef(jsonObject.get("NewTarget").getAsLong(), (LowLevelEntityManager) this.entityManager); result = new CameraTargetChangedEvent(oldTarget, newTarget); } else if (className.equals(PlaySoundEvent.class.getName())) { result = event; } else if (className.equals(AttackEvent.class.getName())) { EntityRef instigator = new RecordedEntityRef(jsonObject.get("instigator").getAsLong(), (LowLevelEntityManager) this.entityManager); EntityRef directCause = new RecordedEntityRef(jsonObject.get("directCause").getAsLong(), (LowLevelEntityManager) this.entityManager); result = new AttackEvent(instigator, directCause); } else if (getInputEventSpecificType(jsonObject, className, deserializationContext) != null) { //input events