Skip to content

Commit

Permalink
Merge pull request #26 from WildfireRomeo/fabric-1.18.2
Browse files Browse the repository at this point in the history
Port of Forge version to Fabric 1.18.2
  • Loading branch information
WildfireRomeo committed Mar 21, 2022
2 parents 672e1e6 + e8512fb commit 719c6f8
Show file tree
Hide file tree
Showing 40 changed files with 1,618 additions and 1,488 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ classes/
*.ipr
*.iws

#Minecraft
run/
runV2/

# vscode

.settings/
Expand All @@ -24,10 +28,6 @@ bin/
.classpath
.project

# fabric

run/

# macOS

.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.13.3

# Mod Properties
mod_version = 2.8.2
mod_version = 2.9
maven_group = com.wildfiregender.main
archives_base_name = [Fabric] Wildfire Female Gender Mod

Expand Down
25 changes: 24 additions & 1 deletion src/main/java/com/wildfire/api/IGenderArmor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
/*
Wildfire's Female Gender Mod is a female gender mod created for Minecraft.
Copyright (C) 2022 WildfireRomeo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.wildfire.api;

/**
* Expose this as a capability on your chestplates or items that go in the chest slot to configure how it interacts with breast rendering.
*/
public interface IGenderArmor {

/**
* Determines whether this {@link IGenderArmor} "covers" the breasts or if it has an open front ({@code false}) like the elytra.
*
Expand All @@ -11,6 +33,7 @@ public interface IGenderArmor {
default boolean coversBreasts() {
return true;
}

/**
* Determines if this {@link IGenderArmor} should always hide the wearer's breasts when worn even if they have {@code showBreastsInArmor} set to {@code true}. This is
* useful for armors that may have custom rendering that is not compatible with how the breasts render and would just lead to clipping.
Expand Down Expand Up @@ -45,4 +68,4 @@ default float physicsResistance() {
default float tightness() {
return 0;
}
}
}
53 changes: 19 additions & 34 deletions src/main/java/com/wildfire/gui/WildfireButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,47 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.wildfire.gui;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import org.lwjgl.opengl.GL11;

import javax.swing.*;

public class WildfireButton extends ButtonWidget {
public static final ButtonWidget.TooltipSupplier NO_TOOLTIP = (button, matrixStack, mouseX, mouseY) -> {};

public boolean transparent = false;
public WildfireButton(int x, int y, int width, int height, Text message, ButtonWidget.PressAction onPress, ButtonWidget.TooltipSupplier tooltipSupplier) {
super(x, y, width, height, message, onPress, tooltipSupplier);

public WildfireButton(int x, int y, int w, int h, Text text, ButtonWidget.PressAction onPress, ButtonWidget.TooltipSupplier onTooltip) {
super(x, y, w, h, text, onPress, onTooltip);
}
public WildfireButton(int x, int y, int width, int height, Text message, ButtonWidget.PressAction onPress) {
super(x, y, width, height, message, onPress);
public WildfireButton(int x, int y, int w, int h, Text text, ButtonWidget.PressAction onPress) {
this(x, y, w, h, text, onPress, NO_TOOLTIP);
}

@Override
public void render(MatrixStack m, int mouseX, int mouseY, float partialTicks) {
public void renderButton(MatrixStack m, int mouseX, int mouseY, float partialTicks) {
MinecraftClient minecraft = MinecraftClient.getInstance();
TextRenderer font = minecraft.textRenderer;
if(this.visible) {
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int clr = 0x444444 + (84 << 24);
if(this.isHovered()) clr = 0x666666 + (84 << 24);
if(!this.active) clr = 0x222222 + (84 << 24);
if(!transparent) fill(m, x, y, x + getWidth(), y + height, clr);

int clr = 0x444444 + (84 << 24);
if(this.isHovered()) clr = 0x666666 + (84 << 24);
if(!this.active) clr = 0x222222 + (84 << 24);
if(!transparent) fill(m, x, y, x + getWidth(), y + height, clr);
font.draw(m, this.getMessage(), x + (this.width / 2) - (font.getWidth(this.getMessage().getString()) / 2) + 1, y + (int) Math.ceil((float) height / 2f) - font.fontHeight / 2, active?0xFFFFFF:0x666666);
}
if(this.isHovered())
this.renderTooltip(m, mouseX, mouseY);
}
font.draw(m, this.getMessage(), x + (this.width / 2) - (font.getWidth(this.getMessage()) / 2) + 1, y + (int) Math.ceil((float) height / 2f) - font.fontHeight / 2, active ? 0xFFFFFF : 0x666666);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);

public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (this.active && this.visible) {
if (this.isValidClickButton(button)) {
boolean bl = this.clicked(mouseX, mouseY);
if (bl) {
this.playDownSound(MinecraftClient.getInstance().getSoundManager());
this.onClick(mouseX, mouseY);
return true;
}
}

return false;
} else {
return false;
if(this.isHovered()) {
this.renderTooltip(m, mouseX, mouseY);
}
}

public WildfireButton setTransparent(boolean b) {
this.transparent = b;
return this;
}
}
}
61 changes: 33 additions & 28 deletions src/main/java/com/wildfire/gui/WildfirePlayerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.wildfire.gui;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;

import com.mojang.blaze3d.systems.RenderSystem;
import com.wildfire.gui.screen.WildfirePlayerListScreen;
import com.wildfire.gui.screen.WardrobeBrowserScreen;
import com.wildfire.main.WildfireGender;
import com.wildfire.main.GenderPlayer;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
Expand All @@ -38,7 +35,6 @@
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.entity.PlayerModelPart;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -49,6 +45,10 @@
import net.minecraft.util.Identifier;
import net.minecraft.world.GameMode;

import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

public class WildfirePlayerList extends EntryListWidget<WildfirePlayerList.Entry> {
private static final Ordering<PlayerListEntry> ENTRY_ORDERING = Ordering.from(new WildfirePlayerList.EntryOrderComparator());

Expand All @@ -68,7 +68,9 @@ public WildfirePlayerList(WildfirePlayerListScreen parent, int listWidth, int to
this.refreshList();
}

protected int getScrollbarPositionX() {
@Override
protected int getScrollbarPositionX()
{
return parent.width / 2 + 53;
}

Expand Down Expand Up @@ -96,16 +98,13 @@ public void refreshList() {
}

@Override
protected void renderBackground(MatrixStack mStack) {
//this.parent.renderBackground(mStack);
}
protected void renderBackground(MatrixStack mStack) {}

public boolean isLoadingPlayers() {
boolean loadingPlayers = false;
for(int i = 0; i < this.children().size(); i++) {

GenderPlayer aPlr = WildfireGender.getPlayerById(this.children().get(i).nInfo.getProfile().getId());
if(aPlr == null) {
for (Entry child : this.children()) {
GenderPlayer aPlr = WildfireGender.getPlayerById(child.nInfo.getProfile().getId());
if (aPlr == null) {
loadingPlayers = true;
}
}
Expand All @@ -118,34 +117,39 @@ public void appendNarrations(NarrationMessageBuilder builder) {
}

@Environment(EnvType.CLIENT)
public static class Entry extends EntryListWidget.Entry<WildfirePlayerList.Entry> {
public class Entry extends EntryListWidget.Entry<WildfirePlayerList.Entry> {

private final String name;
private final PlayerListEntry nInfo;
public final PlayerListEntry nInfo;
private final WildfireButton btnOpenGUI;

private Entry(final PlayerListEntry nInfo) {
this.nInfo = nInfo;
this.name = nInfo.getProfile().getName();
btnOpenGUI = new WildfireButton(0, 0, 112, 20, new TranslatableText(""), button -> {
btnOpenGUI = new WildfireButton(0, 0, 112, 20, new LiteralText(""), button -> {
GenderPlayer aPlr = WildfireGender.getPlayerById(nInfo.getProfile().getId());
if(aPlr == null) return;

try {
MinecraftClient.getInstance().setScreen(new WardrobeBrowserScreen(parent, nInfo.getProfile().getId()));
} catch(Exception e) {}
} catch(Exception ignored) {}
});
GenderPlayer aPlr = WildfireGender.getPlayerById(nInfo.getProfile().getId());
if(aPlr != null) {
btnOpenGUI.active = !aPlr.lockSettings;
//lock changing client-side if player has gender settings synced.
}
}

public PlayerListEntry getNetworkInfo() {
return nInfo;
}

@Override
public void render(MatrixStack m, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) {
TextRenderer font = MinecraftClient.getInstance().textRenderer;

PlayerEntity playerentity = MinecraftClient.getInstance().world.getPlayerByUuid(nInfo.getProfile().getId());
GenderPlayer aPlr = WildfireGender.getPlayerById(playerentity.getUuid());
GenderPlayer aPlr = WildfireGender.getPlayerById(nInfo.getProfile().getId());
boolean flag1 = false;
RenderSystem.setShaderTexture(0, nInfo.getSkinTexture());
int i3 = 8 + (flag1 ? 8 : 0);
Expand All @@ -161,22 +165,22 @@ public void render(MatrixStack m, int entryIdx, int top, int left, int entryWidt
if(aPlr != null) {
btnOpenGUI.active = !aPlr.lockSettings;

font.draw(m, aPlr.gender.getDisplayName(), left + 23, top + 11, 0xFFFFFF);
if(aPlr.getSyncStatus() == GenderPlayer.SyncStatus.SYNCED) {
font.draw(m, aPlr.getGender().getDisplayName(), left + 23, top + 11, 0xFFFFFF);
if (aPlr.getSyncStatus() == GenderPlayer.SyncStatus.SYNCED) {
RenderSystem.setShaderTexture(0, TXTR_SYNC);
Screen.drawTexture(m, left + 98, top + 11, 12, 8, 0, 0, 12, 8, 12, 8);
if(mouseX > left + 98-2 && mouseY > top + 11-2 && mouseX < left + 98 + 12+2 && mouseY < top + 20) {
if (mouseX > left + 98 - 2 && mouseY > top + 11 - 2 && mouseX < left + 98 + 12 + 2 && mouseY < top + 20) {
parent.setTooltip(new TranslatableText("wildfire_gender.player_list.state.synced"));
}
} else if(aPlr.getSyncStatus() == GenderPlayer.SyncStatus.UNKNOWN) {

} else if (aPlr.getSyncStatus() == GenderPlayer.SyncStatus.UNKNOWN) {
RenderSystem.setShaderTexture(0, TXTR_UNKNOWN);
Screen.drawTexture(m, left + 98, top + 11, 12, 8, 0, 0, 12, 8, 12, 8);
}
} else {
btnOpenGUI.active = false;
font.draw(m, (Formatting.RED + new LiteralText("Too Far Away").getString()), left + 23, top + 11, 0xFFFFFF);
font.draw(m, new TranslatableText("wildfire_gender.label.too_far").formatted(Formatting.RED), left + 23, top + 11, 0xFFFFFF);
}

this.btnOpenGUI.x = left;
this.btnOpenGUI.y = top;
this.btnOpenGUI.render(m, mouseX, mouseY, partialTicks);
Expand All @@ -186,20 +190,21 @@ public void render(MatrixStack m, int entryIdx, int top, int left, int entryWidt
}
}


@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if(this.btnOpenGUI.mouseClicked(mouseX, mouseY, button)) {
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
return this.btnOpenGUI.mouseReleased(mouseX, mouseY, button);
//return super.mouseReleased(mouseX, mouseY, button);
}
}


@Environment(EnvType.CLIENT)
static class EntryOrderComparator implements Comparator<PlayerListEntry> {
private EntryOrderComparator() {
Expand Down

0 comments on commit 719c6f8

Please sign in to comment.