-
-
Notifications
You must be signed in to change notification settings - Fork 80
Chocolate Factory #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vicente-pixel
wants to merge
13
commits into
Swofty-Developments:master
Choose a base branch
from
vicente-pixel:chocolate-factory
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Chocolate Factory #707
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1f42005
NPCs
vicente-pixel f37e8fe
Factory Menu
vicente-pixel e31b5c3
Upgrades Barn System and More
vicente-pixel 657a7f4
Hoppitys Collection
vicente-pixel 4629d3f
Code Changes
vicente-pixel a128ccf
Fix
vicente-pixel e8c5524
Fix
vicente-pixel d7390bc
StatefulView & Lombok
vicente-pixel b4a3595
Fix
vicente-pixel cc8518d
Fixes
vicente-pixel 09e6a64
Fixes
vicente-pixel 038a322
Hoppity's Egg Hunt
vicente-pixel 11f228f
Fixed Stuff
vicente-pixel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
type.hub/src/main/java/net/swofty/type/hub/hoppity/HoppityEggEntity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package net.swofty.type.hub.hoppity; | ||
|
|
||
| import net.minestom.server.component.DataComponents; | ||
| import net.minestom.server.entity.EntityCreature; | ||
| import net.minestom.server.entity.EntityType; | ||
| import net.minestom.server.entity.PlayerSkin; | ||
| import net.minestom.server.entity.metadata.other.ArmorStandMeta; | ||
| import net.minestom.server.instance.Instance; | ||
| import net.minestom.server.item.ItemStack; | ||
| import net.minestom.server.item.Material; | ||
| import net.minestom.server.network.player.ResolvableProfile; | ||
| import net.swofty.type.skyblockgeneric.chocolatefactory.HoppityEggLocations; | ||
| import net.swofty.type.skyblockgeneric.chocolatefactory.HoppityEggType; | ||
| import org.json.JSONObject; | ||
|
|
||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.Base64; | ||
| import java.util.concurrent.ThreadLocalRandom; | ||
|
|
||
| public class HoppityEggEntity extends EntityCreature { | ||
| private static final float MAX_YAW = 360f; | ||
| private static final double Y_SPAWN_OFFSET = 1.46875; | ||
| private static final String TEXTURE_URL_PREFIX = "http://textures.minecraft.net/texture/"; | ||
|
|
||
|
|
||
| private final HoppityEggLocations location; | ||
| private final HoppityEggType eggType; | ||
|
|
||
| public HoppityEggEntity(HoppityEggLocations location, HoppityEggType eggType) { | ||
| super(EntityType.ARMOR_STAND); | ||
| this.location = location; | ||
| this.eggType = eggType; | ||
|
|
||
| setInvisible(true); | ||
| ArmorStandMeta meta = (ArmorStandMeta) getEntityMeta(); | ||
| meta.setCustomNameVisible(false); | ||
| meta.setHasNoGravity(true); | ||
| meta.setSmall(true); | ||
| meta.setHasNoBasePlate(true); | ||
| meta.setNotifyAboutChanges(false); | ||
|
|
||
| String texturesEncoded = encodeTexture(eggType.getTextureHash()); | ||
| setHelmet(ItemStack.builder(Material.PLAYER_HEAD) | ||
| .set(DataComponents.PROFILE, new ResolvableProfile(new PlayerSkin(texturesEncoded, null))) | ||
| .build()); | ||
| } | ||
|
|
||
| public void spawn(Instance instance) { | ||
| float randomYaw = ThreadLocalRandom.current().nextFloat() * MAX_YAW; | ||
| setInstance(instance, location.getPosition().sub(0, Y_SPAWN_OFFSET, 0).withYaw(randomYaw)); | ||
| } | ||
|
|
||
| private static String encodeTexture(String textureHash) { | ||
| JSONObject json = new JSONObject(); | ||
| json.put("textures", new JSONObject().put("SKIN", | ||
| new JSONObject().put("url", TEXTURE_URL_PREFIX + textureHash))); | ||
| return Base64.getEncoder().encodeToString(json.toString().getBytes(StandardCharsets.UTF_8)); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
type.hub/src/main/java/net/swofty/type/hub/hoppity/HoppityHuntEntityManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package net.swofty.type.hub.hoppity; | ||
|
|
||
| import net.swofty.type.generic.HypixelConst; | ||
| import net.swofty.type.generic.entity.InteractionEntity; | ||
| import net.swofty.type.skyblockgeneric.chocolatefactory.HoppityEggLocations; | ||
| import net.swofty.type.skyblockgeneric.chocolatefactory.HoppityEggType; | ||
| import net.swofty.type.skyblockgeneric.chocolatefactory.HoppityHuntManager; | ||
| import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class HoppityHuntEntityManager { | ||
| private static final float EGG_INTERACTION_WIDTH = 1.0f; | ||
| private static final float EGG_INTERACTION_HEIGHT = 1.0f; | ||
|
|
||
| private final List<HoppityEggEntity> spawnedEggs = new ArrayList<>(); | ||
| private final List<InteractionEntity> spawnedInteractions = new ArrayList<>(); | ||
|
|
||
| public void spawnAllEggs() { | ||
| HoppityHuntManager huntManager = HoppityHuntManager.getInstance(); | ||
| Map<HoppityEggLocations, HoppityEggType> locationEggTypes = huntManager.getLocationEggTypes(); | ||
|
|
||
| for (Map.Entry<HoppityEggLocations, HoppityEggType> entry : locationEggTypes.entrySet()) { | ||
| HoppityEggLocations location = entry.getKey(); | ||
| HoppityEggType eggType = entry.getValue(); | ||
|
|
||
| HoppityEggEntity eggEntity = new HoppityEggEntity(location, eggType); | ||
| eggEntity.spawn(HypixelConst.getInstanceContainer()); | ||
| spawnedEggs.add(eggEntity); | ||
|
|
||
| InteractionEntity interaction = new InteractionEntity(EGG_INTERACTION_WIDTH, EGG_INTERACTION_HEIGHT, (player, event) -> { | ||
| if (player instanceof SkyBlockPlayer skyBlockPlayer) { | ||
| huntManager.claimEgg(skyBlockPlayer, location); | ||
| } | ||
| }); | ||
| interaction.setInstance(HypixelConst.getInstanceContainer(), location.getPosition()); | ||
| spawnedInteractions.add(interaction); | ||
| } | ||
| } | ||
|
|
||
| public void despawnAllEggs() { | ||
| for (HoppityEggEntity egg : spawnedEggs) { | ||
| egg.remove(); | ||
| } | ||
| spawnedEggs.clear(); | ||
|
|
||
| for (InteractionEntity interaction : spawnedInteractions) { | ||
| interaction.remove(); | ||
| } | ||
| spawnedInteractions.clear(); | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
type.hub/src/main/java/net/swofty/type/hub/npcs/ChocolateFactoryRank.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package net.swofty.type.hub.npcs; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import net.swofty.commons.ChatColor; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum ChocolateFactoryRank { | ||
| UNEMPLOYED(0, "Unemployed", ChatColor.RED), | ||
| INTERN(1, "Intern", ChatColor.GRAY), | ||
| EMPLOYEE(20, "Employee", ChatColor.GREEN), | ||
| ASSISTANT(120, "Assistant", ChatColor.BLUE), | ||
| MANAGER(140, "Manager", ChatColor.DARK_PURPLE), | ||
| DIRECTOR(180, "Director", ChatColor.GOLD), | ||
| EXECUTIVE(200, "Executive", ChatColor.LIGHT_PURPLE), | ||
| BOARD_MEMBER(220, "Board Member", ChatColor.AQUA); | ||
|
|
||
| private final int level; | ||
| private final String name; | ||
| private final ChatColor color; | ||
| private static final ChocolateFactoryRank[] RANKS = values(); | ||
|
|
||
| /** | ||
| * Gets the formatted hologram line for this rank using the rank's base level. | ||
| * Format: §7[Lvl X] §{color}RankName | ||
| * For UNEMPLOYED: §cUnemployed (no level) | ||
| */ | ||
| public String getHologramLine() { | ||
| return getHologramLine(level); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the formatted hologram line for this rank with a specific level. | ||
| * Format: §7[Lvl X] §{color}RankName | ||
| * For UNEMPLOYED: §cUnemployed (no level) | ||
| */ | ||
| public String getHologramLine(int actualLevel) { | ||
| if (this == UNEMPLOYED) { | ||
| return color + name; | ||
| } | ||
| return ChatColor.GRAY + "[" + actualLevel + "] " + color + name; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the formatted chat name for this rank. | ||
| * Format: §{color}NpcName | ||
| */ | ||
| public String getChatName(String npcName) { | ||
| return color + npcName; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the rank for a given level. | ||
| * Returns the highest rank the level qualifies for. | ||
| */ | ||
| public static ChocolateFactoryRank fromLevel(int level) { | ||
| ChocolateFactoryRank result = UNEMPLOYED; | ||
| for (ChocolateFactoryRank rank : RANKS) { | ||
| if (level >= rank.level) { | ||
| result = rank; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.