diff --git a/src/main/java/cam72cam/mod/gui/helpers/GUIHelpers.java b/src/main/java/cam72cam/mod/gui/helpers/GUIHelpers.java index 811a9672..92d42f8f 100644 --- a/src/main/java/cam72cam/mod/gui/helpers/GUIHelpers.java +++ b/src/main/java/cam72cam/mod/gui/helpers/GUIHelpers.java @@ -109,6 +109,19 @@ public static void drawTankBlock(int x, int y, int width, int height, Fluid flui } } + /** Draw a left-aligned shadowed string */ + public static void drawString(String text, int x, int y, int color) { + drawString(text, x, y, color, new Matrix4()); + } + public static void drawString(String text, int x, int y, int color, Matrix4 matrix) { + RenderState state = new RenderState().color(1, 1, 1, 1).alpha_test(true); + state.model_view().multiply(matrix); + try (With ctx = RenderContext.apply(state)) { + GlStateManager.color(1, 1, 1, 0); + Minecraft.getMinecraft().fontRenderer.drawString(text, x, y, color); + } + } + /** Draw a shadowed string offset from the center of coords */ public static void drawCenteredString(String text, int x, int y, int color) { drawCenteredString(text, x, y, color, new Matrix4()); @@ -122,6 +135,11 @@ public static void drawCenteredString(String text, int x, int y, int color, Matr } } + /** Gat a string's internal width for further use */ + public static int getTextWidth(String text) { + return Minecraft.getMinecraft().fontRenderer.getStringWidth(text); + } + /** Screen Width in pixels (std coords) */ public static int getScreenWidth() { return new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); diff --git a/src/main/java/cam72cam/mod/world/World.java b/src/main/java/cam72cam/mod/world/World.java index f6bcb1d0..15ba4057 100644 --- a/src/main/java/cam72cam/mod/world/World.java +++ b/src/main/java/cam72cam/mod/world/World.java @@ -440,12 +440,19 @@ public float getTemperature(Vec3i pos) { /** Drop a stack on the ground at pos */ public void dropItem(ItemStack stack, Vec3i pos) { - dropItem(stack, new Vec3d(pos)); + dropItem(stack, new Vec3d(pos), Vec3d.ZERO); } /** Drop a stack on the ground at pos */ public void dropItem(ItemStack stack, Vec3d pos) { - internal.spawnEntity(new EntityItem(internal, pos.x, pos.y, pos.z, stack.internal)); + dropItem(stack, pos, Vec3d.ZERO); + } + + /** Drop a stack on the ground at pos with velocity */ + public void dropItem(ItemStack stack, Vec3d pos, Vec3d velocity) { + EntityItem entity = new EntityItem(internal, pos.x, pos.y, pos.z, stack.internal); + entity.setVelocity(velocity.x, velocity.y, velocity.z); + internal.spawnEntity(entity); } /** Check if the block is currently in a loaded chunk */