use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunnerClient method renderTileEntity.
public static void renderTileEntity(TileEntityRendererDispatcher dispatch, TileEntity tileentityIn, float partialTicks, int destroyStage) {
BlockPos pos = tileentityIn.getPos();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(tileentityIn.getWorld(), pos);
if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null) {
try {
boolean drawingBatchOrig = drawingBatchName.getBoolean(dispatch);
if (drawingBatchOrig) {
dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
dispatch.preDrawBatch();
}
wrapper.wrapping.renderer.setupTranslation(partialTicks);
double playerX = TileEntityRendererDispatcher.instance.staticPlayerX;
double playerY = TileEntityRendererDispatcher.instance.staticPlayerY;
double playerZ = TileEntityRendererDispatcher.instance.staticPlayerZ;
TileEntityRendererDispatcher.instance.staticPlayerX = wrapper.wrapping.renderer.offsetPos.getX();
TileEntityRendererDispatcher.instance.staticPlayerY = wrapper.wrapping.renderer.offsetPos.getY();
TileEntityRendererDispatcher.instance.staticPlayerZ = wrapper.wrapping.renderer.offsetPos.getZ();
if (drawingBatchOrig) {
dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
dispatch.preDrawBatch();
} else {
dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
}
TileEntityRendererDispatcher.instance.staticPlayerX = playerX;
TileEntityRendererDispatcher.instance.staticPlayerY = playerY;
TileEntityRendererDispatcher.instance.staticPlayerZ = playerZ;
wrapper.wrapping.renderer.inverseTransform(partialTicks);
} catch (Exception e) {
e.printStackTrace();
}
} else {
dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunnerClient method onGetPositionEyes.
public static Vec3d onGetPositionEyes(Entity entityFor, float partialTicks) {
Vec3d defaultOutput = entityFor.getPositionEyes(partialTicks);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getShipFixedOnto(entityFor);
if (wrapper != null) {
Vector playerPosition = new Vector(wrapper.wrapping.getLocalPositionForEntity(entityFor));
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RlToWTransform, playerPosition);
Vector playerEyes = new Vector(0, entityFor.getEyeHeight(), 0);
//Remove the original position added for the player's eyes
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWRotation, playerEyes);
//Add the new rotate player eyes to the position
playerPosition.add(playerEyes);
// System.out.println("test");
return playerPosition.toVec3d();
}
return defaultOutput;
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsClient method onDrawBlockHighlightEventFirst.
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onDrawBlockHighlightEventFirst(DrawBlockHighlightEvent event) {
BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
if (pos != null) {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null && wrapper.wrapping.centerCoord != null) {
// GL11.glPushMatrix();
float partialTicks = event.getPartialTicks();
Entity player = Minecraft.getMinecraft().thePlayer;
wrapper.wrapping.renderer.setupTranslation(partialTicks);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
double xOff = (player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getX();
double yOff = (player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getY();
double zOff = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getZ();
vertexbuffer.xOffset += xOff;
vertexbuffer.yOffset += yOff;
vertexbuffer.zOffset += zOff;
}
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsCommon method onRightClick.
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event) {
if (!event.getWorld().isRemote) {
PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
if (physObj != null) {
//Bucket fix, probably not that important
if (event.getEntityPlayer().getHeldItem(event.getHand()) != null && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() instanceof ItemBucket) {
event.setResult(Result.ALLOW);
event.setCanceled(false);
}
if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getEntityPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getEntityPlayer().entityUniqueID.toString()))) {
event.getEntityPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
event.setCanceled(true);
return;
}
}
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsCommon method onRightClickBlock.
@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
if (!event.getWorld().isRemote) {
ItemStack stack = event.getItemStack();
if (stack != null && stack.getItem() instanceof ItemNameTag) {
BlockPos posAt = event.getPos();
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
if (wrapper != null) {
wrapper.setCustomNameTag(stack.getDisplayName());
--stack.stackSize;
event.setCanceled(true);
}
}
}
}
Aggregations