net.minecraft.client.Minecraft Java Examples

The following examples show how to use net.minecraft.client.Minecraft. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownloadInfoHelper.java    From I18nUpdateMod with MIT License 7 votes vote down vote up
public static void init() {
    // 消息通知线程
    new Thread(() -> {
        while (true) {
            if (Minecraft.getMinecraft().player != null) {
                while (!info.isEmpty()) {
                    String theInfo = info.remove();
                    Minecraft.getMinecraft().addScheduledTask(() -> Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("[I18nUpdateMod] " + theInfo)));
                }
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }, "I18n-download-info-Thread").start();
}
 
Example #2
Source File: EntityRocket.java    From AdvancedRocketry with MIT License 7 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void onInventoryButtonPressed(int buttonId) {
	switch(buttonId) {
	case 0:
		PacketHandler.sendToServer(new PacketEntity(this, (byte)EntityRocket.PacketType.DECONSTRUCT.ordinal()));
		break;
	case 1:
		PacketHandler.sendToServer(new PacketEntity(this, (byte)EntityRocket.PacketType.OPENPLANETSELECTION.ordinal()));
		break;
	default:
		PacketHandler.sendToServer(new PacketEntity(this, (byte)(buttonId + BUTTON_ID_OFFSET)));
		//Minecraft.getMinecraft().thePlayer.closeScreen();

		if(buttonId < STATION_LOC_OFFSET) {
			TileEntity tile = storage.getGUItiles().get(buttonId - tilebuttonOffset);
			storage.getBlockState(tile.getPos()).getBlock().onBlockActivated(storage.world, tile.getPos(), storage.getBlockState(tile.getPos()), Minecraft.getMinecraft().player, EnumHand.MAIN_HAND, EnumFacing.DOWN, 0, 0, 0);
		}
	}
}
 
Example #3
Source File: WidgetVerticalScrollbar.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTick){
    GL11.glColor4d(1, 1, 1, 1);
    if(!Mouse.isButtonDown(0)) dragging = false;
    if(!wasClicking && Mouse.isButtonDown(0) && getBounds().contains(mouseX, mouseY)) {
        dragging = true;
    }
    if(!enabled) dragging = false;
    wasClicking = Mouse.isButtonDown(0);
    if(dragging) currentScroll = (float)(mouseY - 7 - getBounds().y) / (getBounds().height - 17);
    currentScroll = MathHelper.clamp_float(currentScroll, 0, 1);
    Minecraft.getMinecraft().getTextureManager().bindTexture(scrollTexture);
    Gui.func_146110_a(x, y, 12, 0, getBounds().width, 1, 26, 15);
    for(int i = 0; i < getBounds().height - 2; i++)
        Gui.func_146110_a(x, y + 1 + i, 12, 1, getBounds().width, 1, 26, 15);
    Gui.func_146110_a(x, y + getBounds().height - 1, 12, 14, getBounds().width, 1, 26, 15);

    if(!enabled) GL11.glColor4d(0.6, 0.6, 0.6, 1);
    Gui.func_146110_a(x + 1, y + 1 + (int)((getBounds().height - 17) * currentScroll), 0, 0, 12, 15, 26, 15);
    GL11.glColor4d(1, 1, 1, 1);
}
 
Example #4
Source File: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static List<CCQuad> applyItemTint(List<CCQuad> quads, ItemStack stack) {
    List<CCQuad> retQuads = new LinkedList<>();
    for (CCQuad quad : quads) {
        int colour = -1;

        if (quad.hasTint()) {
            colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.tintIndex);

            if (EntityRenderer.anaglyphEnable) {
                colour = TextureUtil.anaglyphColor(colour);
            }
            colour = colour | 0xFF000000;
        }
        CCQuad copyQuad = quad.copy();

        Colour c = new ColourARGB(colour);
        for (Colour qC : copyQuad.colours) {
            qC.multiply(c);
        }
        retQuads.add(copyQuad);
    }

    return retQuads;
}
 
Example #5
Source File: EntityBlockRenderer.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public void doRender(EntityBlock entity, double x, double y, double z, float yaw, float partialTicks) {
	final IBlockState blockState = entity.getBlockState();

	if (blockState.getRenderType() != EnumBlockRenderType.INVISIBLE) {
		GlStateManager.pushMatrix();
		GlStateManager.translate(x - 0.5, y, z + 0.5);
		GlStateManager.disableLighting();

		bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

		Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(blockState, entity.getBrightness());

		GlStateManager.enableLighting();
		GlStateManager.popMatrix();
		super.doRender(entity, x, y, z, yaw, partialTicks);
	}
}
 
Example #6
Source File: ItemChiselRenderer.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data)
{
    RenderHelper.enableGUIStandardItemLighting();

    renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, stack, 0, 0);

    if(stack.stackTagCompound == null) return;

    ItemStack chiselTarget = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("chiselTarget"));
    if(chiselTarget == null) return;

    GL11.glPushMatrix();
    GL11.glScalef(0.65f, 0.65f, 0.65f);
    GL11.glTranslatef(-8f, -8f, 0.0f);

    renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().renderEngine, chiselTarget, 8, 8);

    GL11.glPopMatrix();
}
 
Example #7
Source File: BowBombModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void sendPacket(EventSendPacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof CPacketPlayerDigging) {
            final Minecraft mc = Minecraft.getMinecraft();

            final CPacketPlayerDigging packet = (CPacketPlayerDigging) event.getPacket();
            if (packet.getAction() == CPacketPlayerDigging.Action.RELEASE_USE_ITEM) {
                if (mc.player.inventory.getCurrentItem().getItem() instanceof ItemBow && mc.player.getItemInUseMaxCount() >= 20) {
                    if (!mc.player.onGround) {
                        mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY - 0.1f, mc.player.posZ, false));
                        mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY - 10000f, mc.player.posZ, true));
                    }
                }
            }
        }
    }
}
 
Example #8
Source File: GuiMSU.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onTooltipEvent(ItemTooltipEvent event)
{
    if (Minecraft.getMinecraft().currentScreen instanceof GuiMSU && event.getEntityPlayer() != null &&
        event.getEntityPlayer().openContainer instanceof ContainerMSU)
    {
        ContainerMSU container = (ContainerMSU) event.getEntityPlayer().openContainer;
        GuiMSU gui = (GuiMSU) Minecraft.getMinecraft().currentScreen;
        Slot slot = gui.getSlotUnderMouse();

        if (slot != null && slot.getHasStack() && container.getCustomInventorySlotRange().contains(slot.slotNumber))
        {
            String size = EUStringUtils.formatNumberWithKSeparators(slot.getStack().getCount());
            event.getToolTip().add(size + " " + I18n.format("enderutilities.tooltip.item.items"));
        }
    }
}
 
Example #9
Source File: IntegrationMorph.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public boolean isMorphed() {
    if(methodHasMorph != null) {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        Boolean result = INJECTOR.invokeMethod(methodHasMorph, player.getCommandSenderName(), true);
        return result != null ? result : false;
    }
    return false;
}
 
Example #10
Source File: MultiTickEffectDispatcher.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void handleWispyLineEffects(World currentRenderWorld, float partialTicks) {
    Tessellator tessellator;
    Iterator<FloatyLineInfo> it = floatyLineInfos.iterator();
    while(it.hasNext()) {
        FloatyLineInfo info = it.next();
        if(info.dimId != currentRenderWorld.provider.dimensionId) {
            it.remove();
            continue;
        }
        info.renderTicks++;
        if(info.renderTicks > info.tickCap) {
            it.remove();
            continue;
        }

        if(info.randomOffset == -1) {
            info.randomOffset = currentRenderWorld.rand.nextInt(20);
        }

        float ticks = Minecraft.getMinecraft().renderViewEntity.ticksExisted + info.randomOffset + partialTicks;
        UtilsFX.drawFloatyLine(info.pedestalX, info.pedestalY, info.pedestalZ, info.originX, info.originY, info.originZ, partialTicks, info.colorAsInt, "textures/misc/wispy.png", -0.02F, Math.min(ticks, 10.0F) / 10.0F);
    }
}
 
Example #11
Source File: ItemQuantumWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (world.isRemote) {
        boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed();
        boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
        boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();

        if (isJumping) player.motionY = 0.85;

        if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode)
            player.motionY *= 0.3;

        if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.1;

        if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode)
            player.motionY = -0.05;

        if (isSneaking && isHoldingJump) player.motionY = 0;

        if (isSneaking && !player.onGround && !isHoldingJump) player.motionY = -0.6;
    }
    if (player.fallDistance > 0.0F) player.fallDistance = 0;
}
 
Example #12
Source File: ModKeybinds.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onKey(InputEvent.KeyInputEvent event) {
	if (!Keyboard.isCreated()) return;

	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (pearlSwapping.isKeyDown() && player.getHeldItemMainhand().getItem() instanceof IPearlSwappable && !BaublesSupport.getItem(player, IPearlStorageHolder.class).isEmpty()) {
		player.openGui(Wizardry.instance, 1, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
}
 
Example #13
Source File: GuiBookCode.java    From Minecoprocessors with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTicks) {
  if (!player.isEntityAlive() || !ItemBookCode.isBookCode(player.getHeldItem(EnumHand.MAIN_HAND))) {
    Minecraft.getMinecraft().displayGuiScreen(null);
    return;
  }

  // Background.
  GlStateManager.color(1, 1, 1, 1);
  Minecraft.getMinecraft().getTextureManager().bindTexture(LOCATION_BOOK_CODE_BACKGROUND);
  drawTexturedModalRect(guiX, guiY, 0, 0, GUI_WIDTH, GUI_HEIGHT);

  // Check page change button availability.
  buttonPreviousPage.visible = data.getSelectedPage() > 0 && data.getPageCount() > 0;
  buttonNextPage.visible = (data.getSelectedPage() < data.getPageCount() - 1) ||
      (data.getSelectedPage() == data.getPageCount() - 1 && isCurrentProgramNonEmpty());
  buttonDeletePage.visible = data.getPageCount() > 1 || isCurrentProgramNonEmpty();

  super.drawScreen(mouseX, mouseY, partialTicks);

  // Draw current program.
  drawProgram(mouseX, mouseY);

  // Draw page number.
  final String pageInfo = String.format("%d/%d", data.getSelectedPage() + 1, data.getPageCount());
  getFontRenderer().drawString(pageInfo, guiX + PAGE_NUMBER_X - getFontRenderer().getStringWidth(pageInfo) / 2, guiY + PAGE_NUMBER_Y, COLOR_CODE);
}
 
Example #14
Source File: AutoSignModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void displayGui(EventDisplayGui event) {
    if (event.getScreen() != null && event.getScreen() instanceof GuiEditSign) {
        final GuiEditSign gui = (GuiEditSign) event.getScreen();

        final boolean shouldCancel = this.overflow.getValue() ? true : this.lines != null;

        if (gui != null && shouldCancel && gui.tileSign != null) {
            Minecraft.getMinecraft().player.connection.sendPacket(new CPacketUpdateSign(gui.tileSign.getPos(), new TextComponentString[]{new TextComponentString(""), new TextComponentString(""), new TextComponentString(""), new TextComponentString("")}));
            Minecraft.getMinecraft().displayGuiScreen(null);
            event.setCanceled(true);
        }
    }
}
 
Example #15
Source File: AdvancedTextWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected ITextComponent getTextUnderMouse(int mouseX, int mouseY) {
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    Position position = getPosition();
    int selectedLine = (mouseY - position.y) / (fontRenderer.FONT_HEIGHT + 2);
    if (mouseX >= position.x && selectedLine >= 0 && selectedLine < displayText.size()) {
        ITextComponent selectedComponent = displayText.get(selectedLine);
        int mouseOffset = mouseX - position.x;
        int currentOffset = 0;
        for (ITextComponent lineComponent : selectedComponent) {
            currentOffset += fontRenderer.getStringWidth(lineComponent.getUnformattedComponentText());
            if (currentOffset >= mouseOffset) {
                return lineComponent;
            }
        }
    }
    return null;
}
 
Example #16
Source File: OutlineUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public static void checkSetupFBO() {
    // Gets the FBO of Minecraft
    final Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();

    // Check if FBO isn't null
    if(fbo != null) {
        // Checks if screen has been resized or new FBO has been created
        if(fbo.depthBuffer > -1) {
            // Sets up the FBO with depth and stencil extensions (24/8 bit)
            setupFBO(fbo);
            // Reset the ID to prevent multiple FBO's
            fbo.depthBuffer = -1;
        }
    }
}
 
Example #17
Source File: GuiHudConfiguration.java    From Cyberware with MIT License 5 votes vote down vote up
private void drawButtons(IHudElement element, int mouseX, int mouseY)
{
	Minecraft.getMinecraft().getTextureManager().bindTexture(HudHandler.HUD_TEXTURE);
	
	int elemX = getAbsoluteX(sr, element) - 1;
	int elemY = getAbsoluteY(sr, element) - 1;
	
	int buttonsY = (elemY + element.getHeight() + 10 > sr.getScaledHeight()) ? elemY - 11 : (elemY + element.getHeight() + 4);
	int buttonsX = elemX + 5;
	
	boolean showHideHover = false;
	boolean hidden = false;
	if (element.canHide())
	{
		showHideHover = isPointInRegion(buttonsX, buttonsY, 9, 9, mouseX, mouseY);
		hidden = element.isHidden();
		ClientUtils.drawTexturedModalRect(buttonsX, buttonsY, showHideHover ^ hidden ? 125 : 116, 0, 9, 9);
		buttonsX += 11;
	}
	
	boolean upDownHover = isPointInRegion(buttonsX, buttonsY, 9, 9, mouseX, mouseY);
	boolean down = element.getVerticalAnchor() != EnumAnchorVertical.BOTTOM;
	ClientUtils.drawTexturedModalRect(buttonsX, buttonsY, down ^ upDownHover ? 80 : 89, 0, 9, 9);
	buttonsX += 11;

	boolean leftRightHover = isPointInRegion(buttonsX, buttonsY, 9, 9, mouseX, mouseY);
	boolean right = element.getHorizontalAnchor() != EnumAnchorHorizontal.RIGHT;
	ClientUtils.drawTexturedModalRect(buttonsX, buttonsY, right ^ leftRightHover ? 98 : 107, 0, 9, 9);
	buttonsX += 11;
	
	boolean resetHover = isPointInRegion(buttonsX, buttonsY, 9, 9, mouseX, mouseY);
	ClientUtils.drawTexturedModalRect(buttonsX, buttonsY, 134, 0, 9, 9);
	buttonsX += 11;
}
 
Example #18
Source File: GuiUsageRecipe.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static boolean openRecipeGui(String inputId, Object... ingredients) {
    Minecraft mc = Minecraft.getMinecraft();
    GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null;

    TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
    ArrayList<IUsageHandler> handlers = new ArrayList<>();
    for (IUsageHandler usagehandler : usagehandlers) {
        profiler.start(usagehandler.getRecipeName());
        IUsageHandler handler = usagehandler.getUsageHandler(inputId, ingredients);
        if (handler.numRecipes() > 0) {
            handlers.add(handler);
        }
    }
    profiler.end();
    if (handlers.isEmpty()) {
        return false;
    }

    mc.displayGuiScreen(new GuiUsageRecipe(prevscreen, handlers));
    return true;
}
 
Example #19
Source File: FakeChatCommand.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void exec(String input) {
    if (!this.clamp(input, 2)) {
        this.printUsage();
        return;
    }

    final String[] split = input.split(" ");

    final StringBuilder sb = new StringBuilder();

    for (int i = 1; i < split.length; i++) {
        final String s = split[i];
        sb.append(s + (i == split.length - 1 ? "" : " "));
    }

    final String message = sb.toString();
    Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message.replace("&", "\247")));
}
 
Example #20
Source File: ClientStateMachine.java    From malmo with MIT License 5 votes vote down vote up
@Override
protected void execute()
{
    try
    {
        totalTicks = 0;

        // We need to use the server's MissionHandlers here:
        MissionBehaviour serverHandlers = MissionBehaviour.createServerHandlersFromMissionInit(currentMissionInit());
        if (serverHandlers != null && serverHandlers.worldGenerator != null)
        {
            if (serverHandlers.worldGenerator.createWorld(currentMissionInit()))
            {
                this.worldCreated = true;
                if (Minecraft.getMinecraft().getIntegratedServer() != null)
                    Minecraft.getMinecraft().getIntegratedServer().setOnlineMode(false);
            }
            else
            {
                // World has not been created.
                episodeHasCompletedWithErrors(ClientState.ERROR_CANNOT_CREATE_WORLD, "Server world-creation handler failed to create a world: " + serverHandlers.worldGenerator.getErrorDetails());
            }
        }
    }
    catch (Exception e)
    {
        episodeHasCompletedWithErrors(ClientState.ERROR_CANNOT_CREATE_WORLD, "Server world-creation handler failed to create a world: " + e.getMessage());
    }
}
 
Example #21
Source File: AgentQuitFromTimeUpImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
protected void drawCountDown(int secondsRemaining)
{
       TextComponentString text = new TextComponentString("" + secondsRemaining + "...");
       Style style = new Style();
       style.setBold(true);
       if (secondsRemaining <= 5)
           style.setColor(TextFormatting.RED);

       text.setStyle(style);
       Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
 
Example #22
Source File: SaveGameStructureLoader.java    From BoundingBoxOutlineReloaded with MIT License 5 votes vote down vote up
static void loadSaveGame(String fileName) {
    Minecraft minecraft = Minecraft.getInstance();
    SaveFormat saveLoader = minecraft.getSaveLoader();
    saveHandler = saveLoader.getSaveLoader(fileName, null);
    worldDirectory = saveLoader.func_215781_c().resolve(fileName).toFile();

    for (DimensionId dimensionId : nbtStructureLoaders.keySet()) {
        NBTStructureLoader dimensionProcessor = getNBTStructureLoader(dimensionId);
        dimensionProcessor.configure(saveHandler, worldDirectory);
    }

    loadChunksAroundPlayer();
}
 
Example #23
Source File: CosmeticHat.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void onPlayerRender(RenderPlayerEvent e) {
    Minecraft mc = Minecraft.getMinecraft();
    AbstractClientPlayer player = e.getEntity();
    if (CosmeticsUtil.shouldHide(getPurchaseType())) return;

    if (isPurchasedBy(player.getUniqueID()) && !player.isInvisible()) {
        HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(player.getUniqueID());
        if (packageIfReady.getCachedSettings().getCurrentHatType() != getPurchaseType()) return;

        GlStateManager.pushMatrix();
        GlStateManager.translate(e.getX(), e.getY(), e.getZ());

        double scale = 1.0F;
        double rotate = interpolate(player.prevRotationYawHead, player.rotationYawHead, e.getPartialTicks());
        double rotate1 = interpolate(player.prevRotationPitch, player.rotationPitch, e.getPartialTicks());

        GL11.glScaled(-scale, -scale, scale);
        GL11.glTranslated(0.0, -((player.height - (player.isSneaking() ? .25 : 0)) - .38) / scale, 0.0);
        GL11.glRotated(180.0 + rotate, 0.0, 1.0, 0.0);
        GL11.glRotated(rotate1, 1.0D, 0.0D, 0.0D);
        GlStateManager.translate(0, -.45, 0);

        /* Bind the hat texture and render the model */
        mc.getTextureManager().bindTexture(hatTexture);
        hatModel.render(player, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        GlStateManager.popMatrix();
    }
}
 
Example #24
Source File: AnimationHandler.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setPosition(RenderChunk rc, BlockPos bp) {
    if (!ChunkAnimatorConfig.enabled) return;
    if (Minecraft.getMinecraft().thePlayer != null) {
        boolean flag = true;
        BlockPos zeroedPlayerPosition = Minecraft.getMinecraft().thePlayer.getPosition();
        zeroedPlayerPosition = zeroedPlayerPosition.add(0, -zeroedPlayerPosition.getY(), 0);
        BlockPos zeroedCenteredChunkPos = bp.add(8, -bp.getY(), 8);

        if (ChunkAnimatorConfig.disableAroundPlayer) {
            flag = zeroedPlayerPosition.distanceSq(zeroedCenteredChunkPos) > (64 * 64);
        }

        if (flag) {
            EnumFacing chunkFacing = null;

            if (ChunkAnimatorConfig.mode.equals("From sides")) {
                Vec3i dif = zeroedPlayerPosition.subtract(zeroedCenteredChunkPos);
                int difX = Math.abs(dif.getX());
                int difZ = Math.abs(dif.getZ());
                chunkFacing = getFacing(dif, difX, difZ);
            }

            AnimationData animationData = new AnimationData(-1L, chunkFacing);
            timeStamps.put(rc, animationData);
        }
    }
}
 
Example #25
Source File: Render.java    From mapwriter with MIT License 5 votes vote down vote up
public static void drawCentredString(int x, int y, int colour, String formatString, Object...args) {
	Minecraft mc = Minecraft.getMinecraft();
	//mc.renderEngine.resetBoundTexture();
	FontRenderer fr = mc.fontRenderer;
	String s = String.format(formatString, args);
	int w = fr.getStringWidth(s);
	fr.drawStringWithShadow(s, x - (w / 2), y, colour);
}
 
Example #26
Source File: EasyPlaceUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
private static HitPosition getAdjacentClickPosition(final BlockPos targetPos, Minecraft mc)
{
    World world = mc.world;
    double reach = Math.max(6, mc.playerController.getBlockReachDistance());
    Entity entity = fi.dy.masa.malilib.util.EntityUtils.getCameraEntity();
    RayTraceResult traceVanilla = fi.dy.masa.malilib.util.RayTraceUtils.getRayTraceFromEntity(world, entity, RayTraceFluidHandling.NONE, false, reach);

    if (traceVanilla != null && traceVanilla.typeOfHit == RayTraceResult.Type.BLOCK)
    {
        BlockPos posVanilla = traceVanilla.getBlockPos();

        // If there is a block in the world right behind the targeted schematic block, then use
        // that block as the click position
        if (PlacementUtils.isReplaceable(world, posVanilla, false) == false &&
            targetPos.equals(posVanilla.offset(traceVanilla.sideHit)))
        {
            return HitPosition.of(posVanilla, traceVanilla.hitVec, traceVanilla.sideHit);
        }
    }

    for (EnumFacing side : fi.dy.masa.malilib.util.PositionUtils.ALL_DIRECTIONS)
    {
        BlockPos posSide = targetPos.offset(side);

        if (PlacementUtils.isReplaceable(world, posSide, false) == false)
        {
            Vec3d hitPos = getHitPositionForSidePosition(posSide, side);
            return HitPosition.of(posSide, hitPos, side.getOpposite());
        }
    }

    return null;
}
 
Example #27
Source File: TextureUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Deprecated
public static TextureAtlasSprite[] getIconsForBlock(BlockState state, Direction side) {
    IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state);
    if (model != null) {
        List<BakedQuad> quads = model.getQuads(state, side, new Random(0));
        if (quads != null && quads.size() > 0) {
            TextureAtlasSprite[] sprites = new TextureAtlasSprite[quads.size()];
            for (int i = 0; i < quads.size(); i++) {
                sprites[i] = quads.get(i).func_187508_a();
            }
            return sprites;
        }
    }
    return new TextureAtlasSprite[0];
}
 
Example #28
Source File: Seppuku.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public void unload() {
    this.moduleManager.unload();
    this.apiManager.unload();
    this.commandManager.unload();
    this.friendManager.unload();
    this.waypointManager.unload();
    this.macroManager.unload();
    this.tickRateManager.unload();
    this.chatManager.unload();
    this.ignoredManager.unload();
    this.capeManager.unload();
    this.joinLeaveManager.unload();
    this.hudManager.unload();
    this.animationManager.unload();
    this.notificationManager.unload();
    this.seppukuMainMenu.unload();
    this.cameraManager.unload();

    this.getEventManager().dispatchEvent(new EventUnload());

    ModContainer seppukuModContainer = null;

    for (ModContainer modContainer : Loader.instance().getActiveModList()) {
        if (modContainer.getModId().equals("seppukumod")) {
            seppukuModContainer = modContainer;
        }
    }

    if (seppukuModContainer != null) {
        Loader.instance().getActiveModList().remove(seppukuModContainer);
    }

    Display.setTitle(this.prevTitle);
    Minecraft.getMinecraft().ingameGUI.getChatGUI().clearChatMessages(true);
    System.gc();
}
 
Example #29
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public RenderGlobalSchematic(Minecraft mc)
{
    super(mc);

    this.mc = mc;
    this.renderManager = mc.getRenderManager();

    this.vboEnabled = OpenGlHelper.useVbo();

    if (this.vboEnabled)
    {
        this.renderContainer = new VboRenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryVbo();
    }
    else
    {
        this.renderContainer = new RenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryList();
    }

    BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher();
    this.blockModelShapes = dispatcher.getBlockModelShapes();
    this.blockModelRenderer = new BlockModelRendererSchematic(mc.getBlockColors());
    this.fluidRenderer = ((IMixinBlockRendererDispatcher) dispatcher).getFluidRenderer();

    DataManager.getSchematicPlacementManager().addRebuildListener(this);
}
 
Example #30
Source File: EndPortalRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void bindTexture(ResourceLocation location) {
	TextureManager texturemanager = Minecraft.getMinecraft().renderEngine;

	if (texturemanager != null) {
		texturemanager.bindTexture(location);
	}
}