Backported some cape stuff.

This commit is contained in:
bconlon 2020-07-16 22:52:49 -07:00
parent c90077beb5
commit 7d7fceab92
8 changed files with 172 additions and 50 deletions

View file

@ -4,12 +4,13 @@ import java.util.List;
import com.legacy.aether.client.gui.GuiCustomizationScreen;
import com.legacy.aether.client.gui.GuiEnterAether;
import com.legacy.aether.client.gui.button.GuiCustomizationScreenButton;
import com.legacy.aether.client.gui.button.GuiGlowButton;
import com.legacy.aether.client.gui.button.GuiHaloButton;
import com.legacy.aether.client.gui.button.*;
import com.legacy.aether.client.gui.menu.AetherMainMenu;
import com.legacy.aether.client.gui.menu.GuiMenuToggleButton;
import com.legacy.aether.network.packets.PacketCapeChanged;
import com.legacy.aether.network.packets.PacketPerkChanged;
import com.legacy.aether.player.perks.AetherRankings;
import com.legacy.aether.player.perks.util.EnumAetherPerkType;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
@ -31,7 +32,6 @@ import net.minecraftforge.client.event.RenderPlayerEvent.SetArmorModel;
import com.legacy.aether.AetherConfig;
import com.legacy.aether.client.gui.AetherLoadingScreen;
import com.legacy.aether.client.gui.button.GuiAccessoryButton;
import com.legacy.aether.client.renders.entity.PlayerAetherRenderer;
import com.legacy.aether.entities.EntitiesAether;
import com.legacy.aether.items.ItemAetherSpawnEgg;
@ -240,6 +240,15 @@ public class AetherClientEvents {
}
}
}
if (event.gui.getClass() == ScreenChatOptions.class)
{
if (Minecraft.getMinecraft().thePlayer != null)
{
int i = 13;
event.buttonList.add(new GuiCapeButton(event.gui.width / 2 - 155 + i % 2 * 160, event.gui.height / 6 + 24 * (i >> 1)));
}
}
}
@SubscribeEvent
@ -285,6 +294,16 @@ public class AetherClientEvents {
{
Minecraft.getMinecraft().displayGuiScreen(new GuiCustomizationScreen(event.gui));
}
if (event.button.getClass() == GuiCapeButton.class)
{
PlayerAether player = PlayerAether.get(Minecraft.getMinecraft().thePlayer);
boolean enableCape = !player.shouldRenderCape;
player.shouldRenderCape = enableCape;
AetherNetwork.sendToServer(new PacketCapeChanged(player.getEntity().getEntityId(), player.shouldRenderCape));
}
}
@SubscribeEvent

View file

@ -0,0 +1,30 @@
package com.legacy.aether.client.gui.button;
import com.legacy.aether.player.PlayerAether;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
public class GuiCapeButton extends GuiButton
{
public GuiCapeButton(int xPos, int yPos)
{
super(203, xPos, yPos, 150, 20, I18n.format("gui.button.aether_cape"));
}
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
PlayerAether player = PlayerAether.get(mc.thePlayer);
if (player.shouldRenderCape)
{
this.displayString = I18n.format("gui.button.aether_cape") + " " + I18n.format("options.on");
}
else
{
this.displayString = I18n.format("gui.button.aether_cape") + " " + I18n.format("options.off");
}
super.drawButton(mc, mouseX, mouseY);
}
}

View file

@ -228,12 +228,11 @@ public class PlayerAetherRenderer {
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
GL11.glScalef(0.9375F, 0.9375F, 0.9375F);
if (playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.CAPE) != null && !playerAether.getAccessoryInventory().wearingAccessory(new ItemStack(ItemsAether.invisibility_cape))) {
ItemAccessory cape = (ItemAccessory) playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.CAPE).getItem();
if (!player.isInvisible() && !player.getHideCape()) {
if (!player.isInvisible()) {
if (playerAether.shouldRenderCape) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
@ -276,17 +275,19 @@ public class PlayerAetherRenderer {
GL11.glColor3f(red, green, blue);
}
if (player.getUniqueID().toString().equals("47ec3a3b-3f41-49b6-b5a0-c39abb7b51ef")) {
this.mc.getTextureManager().bindTexture(Aether.locate("textures/armor/accessory_swuff.png"));
} else {
this.mc.getTextureManager().bindTexture(cape.texture);
}
GL11.glTranslatef(0.0F, 0.015625F, -0.0625F);
GL11.glScalef(0.8F, 0.9375F, 0.234375F);
this.modelMisc.renderCloak(scale);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
}
}
GL11.glScalef(0.9375F, 0.9375F, 0.9375F);
if (playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.GLOVES) != null) {
ItemAccessory gloves = (ItemAccessory) playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.GLOVES).getItem();

View file

@ -43,6 +43,9 @@ public class AetherNetwork {
INSTANCE.registerMessage(PacketSendEternalDay.class, PacketSendEternalDay.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketSendShouldCycle.class, PacketSendShouldCycle.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketSendTime.class, PacketSendTime.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketCapeChanged.class, PacketCapeChanged.class, discriminant++, Side.SERVER);
INSTANCE.registerMessage(PacketCapeChanged.class, PacketCapeChanged.class, discriminant++, Side.CLIENT);
}
public static void sendToAll(IMessage message) {

View file

@ -0,0 +1,59 @@
package com.legacy.aether.network.packets;
import com.legacy.aether.player.PlayerAether;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
public class PacketCapeChanged extends AetherPacket<PacketCapeChanged>
{
public int entityID;
public boolean renderCape;
public PacketCapeChanged() {
}
public PacketCapeChanged(int entityID, boolean info) {
this.entityID = entityID;
this.renderCape = info;
}
@Override
public void fromBytes(ByteBuf buf) {
this.entityID = buf.readInt();
this.renderCape = buf.readBoolean();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.entityID);
buf.writeBoolean(this.renderCape);
}
@Override
public void handleClient(PacketCapeChanged message, EntityPlayer player) {
if (player != null && player.worldObj != null) {
EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID);
if (parent != null) {
PlayerAether instance = PlayerAether.get(parent);
instance.shouldRenderCape = message.renderCape;
}
}
}
@Override
public void handleServer(PacketCapeChanged message, EntityPlayer player) {
if (player != null && player.worldObj != null && !player.worldObj.isRemote) {
EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID);
if (parent != null) {
PlayerAether instance = PlayerAether.get(parent);
instance.shouldRenderCape = message.renderCape;
}
}
}
}

View file

@ -8,6 +8,7 @@ import com.legacy.aether.Aether;
import com.legacy.aether.entities.passive.mountable.EntityParachute;
import com.legacy.aether.items.ItemsAether;
import com.legacy.aether.network.AetherNetwork;
import com.legacy.aether.network.packets.PacketCapeChanged;
import com.legacy.aether.network.packets.PacketPerkChanged;
import com.legacy.aether.player.perks.AetherRankings;
import com.legacy.aether.player.perks.util.EnumAetherPerkType;
@ -66,7 +67,7 @@ public class PlayerAether implements IPlayerAether {
public DonatorMoaSkin donatorMoaSkin = new DonatorMoaSkin();
public boolean shouldRenderHalo, shouldRenderGlow;
public boolean shouldRenderHalo, shouldRenderGlow, shouldRenderCape;
private boolean isJumping;
@ -95,6 +96,7 @@ public class PlayerAether implements IPlayerAether {
public PlayerAether() {
this.shouldRenderHalo = true;
this.shouldRenderGlow = false;
this.shouldRenderCape = true;
this.abilities.addAll(Arrays.<IAetherAbility>asList(new AbilityAccessories(this), new AbilityArmor(this), new AbilityFlight(this), new AbilityRepulsion(this)));
}
@ -114,6 +116,7 @@ public class PlayerAether implements IPlayerAether {
{
AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Halo, this.shouldRenderHalo));
AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Glow, this.shouldRenderGlow));
AetherNetwork.sendToAll(new PacketCapeChanged(this.getEntity().getEntityId(), this.shouldRenderCape));
}
for (int i = 0; i < this.getAbilities().size(); ++i) {
@ -386,6 +389,7 @@ public class PlayerAether implements IPlayerAether {
aetherTag.setBoolean("glow", this.shouldRenderGlow);
}
aetherTag.setBoolean("cape", this.shouldRenderCape);
aetherTag.setInteger("shardCount", this.shardCount);
aetherTag.setTag("accessories", this.getAccessoryInventory().writeToNBT(aetherTag));
@ -413,6 +417,11 @@ public class PlayerAether implements IPlayerAether {
this.shouldRenderGlow = aetherTag.getBoolean("glow");
}
if (aetherTag.hasKey("cape"))
{
this.shouldRenderCape = aetherTag.getBoolean("cape");
}
this.updateShardCount(aetherTag.getInteger("shardCount"));
this.getAccessoryInventory().readFromNBT(aetherTag.getTagList("accessories", 10));
this.setBedLocation(new ChunkCoordinates(aetherTag.getInteger("bedX"), aetherTag.getInteger("bedY"), aetherTag.getInteger("bedZ")));

View file

@ -421,3 +421,4 @@ gui.options.perk_customization=Perk Customization...
gui.options.perk_customization.title=Perk Customization
gui.button.halo=Halo:
gui.button.glow=Developer Glow:
gui.button.aether_cape=Aether Cape:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB