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,66 +228,67 @@ 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()) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 0.0F, 0.125F);
double d0 = player.field_71091_bM + (player.field_71094_bP - player.field_71091_bM) * (double) partialTicks - (player.prevPosX + (player.posX - player.prevPosX) * (double) partialTicks);
double d1 = player.field_71096_bN + (player.field_71095_bQ - player.field_71096_bN) * (double) partialTicks - (player.prevPosY + (player.posY - player.prevPosY) * (double) partialTicks);
double d2 = player.field_71097_bO + (player.field_71085_bR - player.field_71097_bO) * (double) partialTicks - (player.prevPosZ + (player.posZ - player.prevPosZ) * (double) partialTicks);
float f = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
double d3 = (double) MathHelper.sin(f * (float) Math.PI / 180.0F);
double d4 = (double) (-MathHelper.cos(f * (float) Math.PI / 180.0F));
float f1 = (float) d1 * 10.0F;
f1 = MathHelper.clamp_float(f1, -6.0F, 32.0F);
float f2 = (float) (d0 * d3 + d2 * d4) * 100.0F;
float f3 = (float) (d0 * d4 - d2 * d3) * 100.0F;
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);
double d0 = player.field_71091_bM + (player.field_71094_bP - player.field_71091_bM) * (double) partialTicks - (player.prevPosX + (player.posX - player.prevPosX) * (double) partialTicks);
double d1 = player.field_71096_bN + (player.field_71095_bQ - player.field_71096_bN) * (double) partialTicks - (player.prevPosY + (player.posY - player.prevPosY) * (double) partialTicks);
double d2 = player.field_71097_bO + (player.field_71085_bR - player.field_71097_bO) * (double) partialTicks - (player.prevPosZ + (player.posZ - player.prevPosZ) * (double) partialTicks);
float f = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
double d3 = (double) MathHelper.sin(f * (float) Math.PI / 180.0F);
double d4 = (double) (-MathHelper.cos(f * (float) Math.PI / 180.0F));
float f1 = (float) d1 * 10.0F;
f1 = MathHelper.clamp_float(f1, -6.0F, 32.0F);
float f2 = (float) (d0 * d3 + d2 * d4) * 100.0F;
float f3 = (float) (d0 * d4 - d2 * d3) * 100.0F;
if (f2 < 0.0F) {
f2 = 0.0F;
}
if (f2 < 0.0F) {
f2 = 0.0F;
}
float f4 = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * partialTicks;
f1 = f1 + MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * partialTicks) * 6.0F) * 32.0F * f4;
float f4 = player.prevCameraYaw + (player.cameraYaw - player.prevCameraYaw) * partialTicks;
f1 = f1 + MathHelper.sin((player.prevDistanceWalkedModified + (player.distanceWalkedModified - player.prevDistanceWalkedModified) * partialTicks) * 6.0F) * 32.0F * f4;
if (player.isSneaking()) {
f1 += 25.0F;
}
if (player.isSneaking()) {
f1 += 25.0F;
}
GL11.glRotatef(6.0F + f2 / 2.0F + f1, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(f3 / 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f3 / 2.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(6.0F + f2 / 2.0F + f1, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(f3 / 2.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-f3 / 2.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
int colour = cape.getColorFromItemStack(playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.CAPE), 0);
int colour = cape.getColorFromItemStack(playerAether.getAccessoryInventory().getStackInSlot(AccessoryType.CAPE), 0);
float red = ((colour >> 16) & 0xff) / 255F;
float green = ((colour >> 8) & 0xff) / 255F;
float blue = (colour & 0xff) / 255F;
float red = ((colour >> 16) & 0xff) / 255F;
float green = ((colour >> 8) & 0xff) / 255F;
float blue = (colour & 0xff) / 255F;
if (player.hurtTime > 0) {
GL11.glColor3f(1.0F, 0.5F, 0.5F);
} else {
GL11.glColor3f(red, green, blue);
}
if (player.hurtTime > 0) {
GL11.glColor3f(1.0F, 0.5F, 0.5F);
} else {
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);
}
this.modelMisc.renderCloak(scale);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
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

@ -420,4 +420,5 @@ gui.skyroot_bed.respawn_point=Respawn point set
gui.options.perk_customization=Perk Customization...
gui.options.perk_customization.title=Perk Customization
gui.button.halo=Halo:
gui.button.glow=Developer Glow:
gui.button.glow=Developer Glow:
gui.button.aether_cape=Aether Cape:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB