net.minecraft.client.gui.Element Java Examples

The following examples show how to use net.minecraft.client.gui.Element. 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: GameMenuScreenMixin.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private boolean isFeedbackOrBugReportButton(Element element)
{
	if(element == null || !(element instanceof AbstractButtonWidget))
		return false;
	
	AbstractButtonWidget button = (AbstractButtonWidget)element;
	String message = button.getMessage().getString();
	
	return message != null
		&& (message.equals(I18n.translate("menu.sendFeedback"))
			|| message.equals(I18n.translate("menu.reportBugs")));
}
 
Example #2
Source File: DefaultCompressingCategory.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public List<Widget> setupDisplay(DefaultCompressingDisplay recipeDisplay, Rectangle bounds) {
    final Point startPoint = new Point(bounds.getCenterX() - 68, bounds.getCenterY() - 37);

    class BaseWidget extends Widget {
        BaseWidget() {
        }

        public void render(MatrixStack stack, int mouseX, int mouseY, float delta) {
            //super.render(stack, mouseX, mouseY, delta);
            DiffuseLighting.disable();
            MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultCompressingCategory.DISPLAY_TEXTURE);
            this.drawTexture(stack, startPoint.x, startPoint.y, 0, 83, 137, 157);

            int height = MathHelper.ceil((double) (System.currentTimeMillis() / 250L) % 14.0D / 1.0D);
            this.drawTexture(stack, startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height);
            int width = MathHelper.ceil((double) (System.currentTimeMillis() / 250L) % 24.0D / 1.0D);
            this.drawTexture(stack, startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
        }

        @Override
        public List<? extends Element> children() {
            return new ArrayList<>();
        }
    }

    List<Widget> widgets = new LinkedList<>(Collections.singletonList(new BaseWidget()));
    List<List<EntryStack>> input = recipeDisplay.getInputEntries();
    List<Slot> slots = Lists.newArrayList();

    // 3x3 grid
    // Output
    int i;
    for (i = 0; i < 3; ++i) {
        for (int x = 0; x < 3; ++x) {
            slots.add(Widgets.createSlot(new Point(startPoint.x + (x * 18) + 1, startPoint.y + (i * 18) + 1)));
        }
    }
    for (i = 0; i < input.size(); ++i) {
        if (!input.get(i).isEmpty()) {
            slots.get(this.getSlotWithSize(recipeDisplay, i)).entries(input.get(i));
        }
    }

    widgets.addAll(slots);
    widgets.add(Widgets.createSlot(new Point(startPoint.x + 120, startPoint.y + (18) + 3)).entries(new ArrayList<>(Objects.requireNonNull(recipeDisplay).getOutputEntries())));

    widgets.add(Widgets.createSlot(new Point(startPoint.x + (2 * 18) + 1, startPoint.y + (18 * 3) + 4)).entries(AbstractFurnaceBlockEntity.createFuelTimeMap().keySet().stream().map(EntryStack::create).collect(Collectors.toList())));
    return widgets;
}
 
Example #3
Source File: DefaultFabricationCategory.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
public List<Widget> setupDisplay(DefaultFabricationDisplay recipeDisplay, Rectangle bounds) {
    final Point startPoint = new Point(bounds.getCenterX() - 81, bounds.getCenterY() - 41);

    class BaseWidget extends Widget {
        private BaseWidget() {
        }

        public void render(MatrixStack stack, int mouseX, int mouseY, float delta) {
            //super.render(mouseX, mouseY, delta);
            DiffuseLighting.disable();
            MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultFabricationCategory.DISPLAY_TEXTURE);
            this.drawTexture(stack, startPoint.x, startPoint.y, 0, 0, 162, 82);

            int height = MathHelper.ceil((double) (System.currentTimeMillis() / 250L) % 14.0D / 1.0D);
            this.drawTexture(stack, startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height);
            int width = MathHelper.ceil((double) (System.currentTimeMillis() / 250L) % 24.0D / 1.0D);
            this.drawTexture(stack, startPoint.x + 24, startPoint.y + 18, 82, 91, width, 17);
        }

        @Override
        public List<? extends Element> children() {
            return new ArrayList<>();
        }
    }

    List<Widget> widgets = new LinkedList<>();
    widgets.add(new BaseWidget());

    // Diamond input
    // Silicon
    // Silicon
    // Redstone
    // User input
    // Output
    widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entry(EntryStack.create(new ItemStack(Items.DIAMOND))));
    widgets.add(Widgets.createSlot(new Point(startPoint.x + (18 * 7) + 1, startPoint.y + 1)).entries(recipeDisplay.getInput().get(0)));

    widgets.add(Widgets.createSlot(new Point(startPoint.x + (18 * 3) + 1, startPoint.y + 47)).entry(EntryStack.create(new ItemStack(GalacticraftItems.RAW_SILICON))));
    widgets.add(Widgets.createSlot(new Point(startPoint.x + (18 * 3) + 1, startPoint.y + 47 + 18)).entry(EntryStack.create(new ItemStack(GalacticraftItems.RAW_SILICON))));
    widgets.add(Widgets.createSlot(new Point(startPoint.x + (18 * 6) + 1, startPoint.y + 47)).entry(EntryStack.create(new ItemStack(Items.REDSTONE))));

    widgets.add(Widgets.createSlot(new Point(startPoint.x + (18 * 8) + 1, startPoint.y + 47 + 18)).entries(recipeDisplay.getOutputEntries()));
    return widgets;
}
 
Example #4
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<? extends Element> children()
{
	return Collections.emptyList();
}
 
Example #5
Source File: MixinKeyboard.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "method_1458", at = @At("HEAD"), cancellable = true)
private static void preCharTyped(Element element, int character, int mods, CallbackInfo info) {
	if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) character, mods))) {
		info.cancel();
	}
}
 
Example #6
Source File: MixinKeyboard.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Redirect(method = "method_1458", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Element;charTyped(CI)Z"))
private static boolean charTyped(Element element, char character, int mods) {
	return element.charTyped(character, mods) || MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods));
}
 
Example #7
Source File: MixinKeyboard.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "method_1473", at = @At("HEAD"), cancellable = true)
private static void preCharTyped(Element element, char character, int mods, CallbackInfo info) {
	if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Pre((Screen) element, (char) character, mods))) {
		info.cancel();
	}
}
 
Example #8
Source File: MixinKeyboard.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Redirect(method = "method_1473", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Element;charTyped(CI)Z"))
private static boolean charTyped2(Element element, char character, int mods) {
	return element.charTyped(character, mods) || MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.KeyboardCharTypedEvent.Post((Screen) element, character, mods));
}
 
Example #9
Source File: MixinMouse.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "method_1602", at = @At("HEAD"), cancellable = true)
private void preMouseDragged(Element element, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo info) {
	if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Pre((Screen) element, mouseX, mouseY, activeButton, deltaX, deltaY))) {
		info.cancel();
	}
}
 
Example #10
Source File: MixinMouse.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "method_1602", at = @At("RETURN"))
private void postMouseDragged(Element element, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo info) {
	MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseDragEvent.Post((Screen) element, mouseX, mouseY, activeButton, deltaX, deltaY));
}