diff --git a/src/main/java/com/gildedgames/the_aether/AetherConfig.java b/src/main/java/com/gildedgames/the_aether/AetherConfig.java index 03ea237..640f901 100644 --- a/src/main/java/com/gildedgames/the_aether/AetherConfig.java +++ b/src/main/java/com/gildedgames/the_aether/AetherConfig.java @@ -31,6 +31,8 @@ public class AetherConfig { private static boolean sun_altar_multiplayer, repeat_sun_spirit_dialog; + private static boolean aether_start; + public static void init(File location) { File newFile = new File(location + "/aether" + "/AetherI.cfg"); @@ -59,6 +61,8 @@ public class AetherConfig { old_mobs = config.get("Misc", "Enable Legacy Visuals", false).getBoolean(false); + aether_start = config.get("Gameplay", "Spawns Player with Aether Portal Frame", false).getBoolean(false); + max_life_shards = config.get("Gameplay", "Max Life Shards", 10).getInt(10); menu_enabled = config.get("Misc", "Enables the Aether Menu", false).getBoolean(false); @@ -153,4 +157,9 @@ public class AetherConfig { public static boolean repeatSunSpiritDialogue() { return repeat_sun_spirit_dialog; } + + public static boolean shouldAetherStart() + { + return aether_start; + } } \ No newline at end of file diff --git a/src/main/java/com/gildedgames/the_aether/items/ItemAetherPortalFrame.java b/src/main/java/com/gildedgames/the_aether/items/ItemAetherPortalFrame.java new file mode 100644 index 0000000..860622a --- /dev/null +++ b/src/main/java/com/gildedgames/the_aether/items/ItemAetherPortalFrame.java @@ -0,0 +1,111 @@ +package com.gildedgames.the_aether.items; + +import com.gildedgames.the_aether.blocks.BlocksAether; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class ItemAetherPortalFrame extends Item +{ + public ItemAetherPortalFrame() + { + this.setMaxStackSize(1); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int facing, float hitX, float hitY, float hitZ) + { + ItemStack heldItem = player.getHeldItem(); + + int i1 = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (world.isRemote) + { + return true; + } + else + { + if (!player.canPlayerEdit(x, y, z, facing, heldItem)) + { + return false; + } + else + { + if (this.createPortalFrame(world, x, y, z, i1)) + { + if (!player.capabilities.isCreativeMode) + { + heldItem.stackSize--; + } + } + + return true; + } + } + } + + private boolean createPortalFrame(World world, int x, int y, int z, int facing) + { + final int posX = x; + final int posY = world.getBlock(x, y, z).isReplaceable(world,x, y, z) ? y + 1 : y + 2; + final int posZ = z; + + for (int zi = 0; zi < 4; ++zi) + { + for (int yi = -1; yi < 4; ++yi) + { + final int blockX = posX + (facing == 2 || facing == 0 ? zi - 1 : 0); + final int blockY = posY + yi; + final int blockZ = posZ + (facing == 2 || facing == 0 ? 0 : zi - 1); + + if (world.getBlock(blockX, blockY, blockZ) != Blocks.air && !world.getBlock(blockX, blockY, blockZ).isReplaceable(world, blockX, blockY, blockZ)) + { + return false; + } + } + } + + final Block frameBlock = Blocks.glowstone; + + final Block portalBlock = BlocksAether.aether_portal; + + for (int zi = 1; zi < 3; ++zi) + { + for (int yi = -1; yi < 3; ++yi) + { + final int blockX = posX + (facing == 2 || facing == 0 ? zi - 1 : 0); + final int blockY = posY + yi; + final int blockZ = posZ + (facing == 2 || facing == 0 ? 0 : zi - 1); + world.setBlock(blockX, blockY, blockZ, Blocks.air); + } + } + + for (int zi = 0; zi < 4; ++zi) + { + for (int yi = -1; yi < 4; ++yi) + { + final int blockX = posX + (facing == 2 || facing == 0 ? zi - 1 : 0); + final int blockY = posY + yi; + final int blockZ = posZ + (facing == 2 || facing == 0 ? 0 : zi - 1); + world.setBlock(blockX, blockY, blockZ, frameBlock); + } + } + + for (int zi = 1; zi < 3; ++zi) + { + for (int yi = 0; yi < 3; ++yi) + { + final int blockX = posX + (facing == 2 || facing == 0 ? zi - 1 : 0); + final int blockY = posY + yi; + final int blockZ = posZ + (facing == 2 || facing == 0 ? 0 : zi - 1); + world.setBlock(blockX, blockY, blockZ, portalBlock); + } + } + + return true; + } +} diff --git a/src/main/java/com/gildedgames/the_aether/items/ItemsAether.java b/src/main/java/com/gildedgames/the_aether/items/ItemsAether.java index 23530cf..d3dfe16 100644 --- a/src/main/java/com/gildedgames/the_aether/items/ItemsAether.java +++ b/src/main/java/com/gildedgames/the_aether/items/ItemsAether.java @@ -118,6 +118,8 @@ public class ItemsAether { public static Item skyroot_bed_item; + public static Item aether_portal_frame; + public static void initialization() { zanite_gemstone = register("zanite_gemstone", new ItemAether(AetherCreativeTabs.material).setTextureName(Aether.find("misc/zanite_gemstone"))); ambrosium_shard = register("ambrosium_shard", new ItemAmbrosiumShard().setTextureName(Aether.find("misc/ambrosium_shard"))); @@ -269,6 +271,7 @@ public class ItemsAether { skyroot_bed_item = register("skyroot_bed_item", new ItemSkyrootBed().setTextureName(Aether.find("skyroot_bed_item"))); + aether_portal_frame = register("aether_portal_frame", new ItemAetherPortalFrame().setTextureName(Aether.find("aether_portal_frame"))); } public static Item register(String name, Item item) { diff --git a/src/main/java/com/gildedgames/the_aether/network/AetherNetwork.java b/src/main/java/com/gildedgames/the_aether/network/AetherNetwork.java index b175981..8ffd35f 100644 --- a/src/main/java/com/gildedgames/the_aether/network/AetherNetwork.java +++ b/src/main/java/com/gildedgames/the_aether/network/AetherNetwork.java @@ -51,6 +51,7 @@ public class AetherNetwork { INSTANCE.registerMessage(PacketExtendedAttack.class, PacketExtendedAttack.class, discriminant++, Side.SERVER); INSTANCE.registerMessage(PacketSendSeenDialogue.class, PacketSendSeenDialogue.class, discriminant++, Side.CLIENT); + INSTANCE.registerMessage(PacketPortalItem.class, PacketPortalItem.class, discriminant++, Side.CLIENT); } public static void sendToAll(IMessage message) { diff --git a/src/main/java/com/gildedgames/the_aether/network/packets/PacketPortalItem.java b/src/main/java/com/gildedgames/the_aether/network/packets/PacketPortalItem.java new file mode 100644 index 0000000..88929df --- /dev/null +++ b/src/main/java/com/gildedgames/the_aether/network/packets/PacketPortalItem.java @@ -0,0 +1,57 @@ +package com.gildedgames.the_aether.network.packets; + +import com.gildedgames.the_aether.api.AetherAPI; +import com.gildedgames.the_aether.player.PlayerAether; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; + +public class PacketPortalItem extends AetherPacket +{ + private int entityID; + private boolean getPortal; + + public PacketPortalItem() + { + + } + + public PacketPortalItem(EntityPlayer thePlayer, boolean dialogue) + { + this.entityID = thePlayer.getEntityId(); + this.getPortal = dialogue; + } + + @Override + public void fromBytes(ByteBuf buf) + { + this.entityID = buf.readInt(); + this.getPortal = buf.readBoolean(); + } + + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(this.entityID); + buf.writeBoolean(this.getPortal); + } + + @Override + public void handleClient(PacketPortalItem message, EntityPlayer player) + { + if (player != null && player.worldObj != null) + { + EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID); + + if (parent != null) + { + ((PlayerAether) AetherAPI.get(player)).shouldGetPortal = message.getPortal; + } + } + } + + @Override + public void handleServer(PacketPortalItem message, EntityPlayer player) + { + + } +} diff --git a/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java b/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java index 17e2090..c70a003 100644 --- a/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java +++ b/src/main/java/com/gildedgames/the_aether/player/PlayerAether.java @@ -11,13 +11,10 @@ import com.gildedgames.the_aether.api.player.util.IAetherAbility; import com.gildedgames.the_aether.api.player.util.IAetherBoss; import com.gildedgames.the_aether.entities.passive.mountable.EntityParachute; import com.gildedgames.the_aether.inventory.InventoryAccessories; +import com.gildedgames.the_aether.network.packets.*; import com.gildedgames.the_aether.registry.achievements.AchievementsAether; import com.gildedgames.the_aether.items.ItemsAether; import com.gildedgames.the_aether.network.AetherNetwork; -import com.gildedgames.the_aether.network.packets.PacketCapeChanged; -import com.gildedgames.the_aether.network.packets.PacketPerkChanged; -import com.gildedgames.the_aether.network.packets.PacketSendPoisonTime; -import com.gildedgames.the_aether.network.packets.PacketSendSeenDialogue; import com.gildedgames.the_aether.player.perks.AetherRankings; import com.gildedgames.the_aether.player.perks.util.EnumAetherPerkType; import net.minecraft.block.Block; @@ -98,12 +95,15 @@ public class PlayerAether implements IPlayerAether { public boolean isPoisoned = false, isCured = false; + public boolean shouldGetPortal; + public int poisonTime = 0, cureTime = 0; public PlayerAether() { this.shouldRenderHalo = true; this.shouldRenderGlow = false; this.shouldRenderCape = true; + this.shouldGetPortal = true; this.abilities.addAll(Arrays.asList(new AbilityAccessories(this), new AbilityArmor(this), new AbilityFlight(this), new AbilityRepulsion(this))); } @@ -125,6 +125,7 @@ public class PlayerAether implements IPlayerAether { AetherNetwork.sendToAll(new PacketCapeChanged(this.getEntity().getEntityId(), this.shouldRenderCape)); AetherNetwork.sendToAll(new PacketSendPoisonTime(this.getEntity(), this.poisonTime)); AetherNetwork.sendToAll(new PacketSendSeenDialogue(this.getEntity(), this.seenSpiritDialog)); + AetherNetwork.sendToAll(new PacketPortalItem(this.getEntity(), this.shouldGetPortal)); } if (this.isPoisoned) @@ -450,6 +451,7 @@ public class PlayerAether implements IPlayerAether { aetherTag.setInteger("shardCount", this.shardCount); aetherTag.setTag("accessories", this.getAccessoryInventory().writeToNBT(aetherTag)); aetherTag.setBoolean("seen_spirit_dialog", this.seenSpiritDialog); + aetherTag.setBoolean("get_portal", this.shouldGetPortal); if (this.bedLocation != null) { @@ -495,6 +497,11 @@ public class PlayerAether implements IPlayerAether { this.seenSpiritDialog = aetherTag.getBoolean("seen_spirit_dialog"); } + if (aetherTag.hasKey("get_portal")) + { + this.shouldGetPortal = aetherTag.getBoolean("get_portal"); + } + 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"))); @@ -640,4 +647,13 @@ public class PlayerAether implements IPlayerAether { this.isPoisoned = false; this.poisonTime = 0; } + + public void givePortalFrame() + { + if (this.shouldGetPortal) + { + this.player.inventory.addItemStackToInventory(new ItemStack(ItemsAether.aether_portal_frame)); + this.shouldGetPortal = false; + } + } } \ No newline at end of file diff --git a/src/main/java/com/gildedgames/the_aether/player/PlayerAetherEvents.java b/src/main/java/com/gildedgames/the_aether/player/PlayerAetherEvents.java index bf268b8..5aa864e 100644 --- a/src/main/java/com/gildedgames/the_aether/player/PlayerAetherEvents.java +++ b/src/main/java/com/gildedgames/the_aether/player/PlayerAetherEvents.java @@ -1,5 +1,6 @@ package com.gildedgames.the_aether.player; +import com.gildedgames.the_aether.AetherConfig; import com.gildedgames.the_aether.inventory.InventoryAccessories; import com.gildedgames.the_aether.items.ItemsAether; import com.gildedgames.the_aether.registry.achievements.AchievementsAether; @@ -48,6 +49,15 @@ public class PlayerAetherEvents { AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player); playerAether.updateShardCount(playerAether.getShardsUsed()); + + if (!AetherConfig.shouldAetherStart()) + { + playerAether.shouldGetPortal = false; + } + else + { + playerAether.givePortalFrame(); + } } } diff --git a/src/main/resources/assets/aether_legacy/lang/en_US.lang b/src/main/resources/assets/aether_legacy/lang/en_US.lang index abe8fd0..32ac4ed 100644 --- a/src/main/resources/assets/aether_legacy/lang/en_US.lang +++ b/src/main/resources/assets/aether_legacy/lang/en_US.lang @@ -130,6 +130,7 @@ item.enchanted_blueberry.name=Enchanted Berry item.swet_ball.name=Swet Ball item.developer_stick.name=Developer Stick item.skyroot_bed_item.name=Skyroot Bed +item.aether_portal_frame.name=Aether Portal Frame # Block Names tile.aether_portal.name=Aether Portal diff --git a/src/main/resources/assets/aether_legacy/models/item/aether_portal_frame.json b/src/main/resources/assets/aether_legacy/models/item/aether_portal_frame.json new file mode 100644 index 0000000..ef5fffe --- /dev/null +++ b/src/main/resources/assets/aether_legacy/models/item/aether_portal_frame.json @@ -0,0 +1,18 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "aether_legacy:items/aether_portal_frame" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png b/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png new file mode 100644 index 0000000..6cc4c42 Binary files /dev/null and b/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png differ diff --git a/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png.mcmeta b/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/aether_legacy/textures/items/aether_portal_frame.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file