diff options
| author | Roman / Nea <roman.graef@gmail.com> | 2022-04-18 17:33:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-18 17:33:32 +0200 |
| commit | 2692193e54e4dd6c0117dcdb85368dc83bb04f1a (patch) | |
| tree | 96f01454c404ac04a46ea0d9bf684c7dc5619a57 /src | |
| parent | 9fe86ccb4d30b78826e513a6576027ca6e4c1600 (diff) | |
| download | NotEnoughUpdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.tar.gz NotEnoughUpdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.tar.bz2 NotEnoughUpdates-2692193e54e4dd6c0117dcdb85368dc83bb04f1a.zip | |
Mob loot recipe PR (#81)
* entity renderer (somewhat functionaL)
* more modifiers and entities
* Fix cookie fuckup
* add neu repo as resource pack, cause why not at this point
* add tabs, because i can
* add extra skin parts and make less tabs
* hot tall men
* fix texture offsets and also parts:true
* some untested changes
* still broken, but better (just like me (stop being edgy nea ( no u ))))
* stuff (with er skeletons
* niceities
* skytils interop
* horseys
* horseys ouch
* panos
* stupid tests :angery:
* NPE
* add drop chance
* colored leather armo
* finish off
* move shit into hover cause items look pretty terrible
* Update 2.1.md
* better recipe display name
* always show mobs toggle
* moving parts
Diffstat (limited to 'src')
51 files changed, 2199 insertions, 612 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index abe0bdcf..6572431b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -895,12 +895,12 @@ public class NEUManager { String clickcommand = item.get("clickcommand").getAsString(); switch (clickcommand.intern()) { case "viewrecipe": - displayGuiItemRecipe(internalName, null); + displayGuiItemRecipe(internalName); break; case "viewoption": neu.sendChatMessage("/viewpotion " + internalName.split(";")[0].toLowerCase(Locale.ROOT)); } - displayGuiItemRecipe(internalName, ""); + displayGuiItemRecipe(internalName); } public void showRecipe(String internalName) { @@ -990,16 +990,16 @@ public class NEUManager { List<NeuRecipe> usages = getAvailableUsagesFor(internalName); if (usages.isEmpty()) return false; Minecraft.getMinecraft().displayGuiScreen( - new GuiItemRecipe("Item Usages", usages, this)); + new GuiItemRecipe(usages, this)); return true; } - public boolean displayGuiItemRecipe(String internalName, String text) { + public boolean displayGuiItemRecipe(String internalName) { if (!recipesMap.containsKey(internalName)) return false; List<NeuRecipe> recipes = getAvailableRecipesFor(internalName); if (recipes.isEmpty()) return false; Minecraft.getMinecraft().displayGuiScreen( - new GuiItemRecipe(text != null ? text : "Item Recipe", recipes, this)); + new GuiItemRecipe(recipes, this)); return true; } @@ -1010,7 +1010,7 @@ public class NEUManager { public boolean failViewItem(String text) { if (viewItemAttemptID != null && !viewItemAttemptID.isEmpty()) { if (System.currentTimeMillis() - viewItemAttemptTime < 500) { - return displayGuiItemRecipe(viewItemAttemptID, text); + return displayGuiItemRecipe(viewItemAttemptID); } } return false; @@ -1570,4 +1570,10 @@ public class NEUManager { } } } + + public ItemStack createItem(String internalname) { + JsonObject jsonObject = itemMap.get(internalname); + if (jsonObject == null) return null; + return jsonToStack(jsonObject); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 7965abae..8d0955bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1358,7 +1358,7 @@ public class NEUOverlay extends Gui { } if (getSortMode() == SORT_MODE_ALL) { - return !internalname.matches(mobRegex); + return NotEnoughUpdates.INSTANCE.config.itemlist.alwaysShowMonsters || !internalname.matches(mobRegex); } else if (getSortMode() == SORT_MODE_MOB) { return internalname.matches(mobRegex); } else if (getSortMode() == SORT_MODE_PET) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEURepoResourcePack.java b/src/main/java/io/github/moulberry/notenoughupdates/NEURepoResourcePack.java new file mode 100644 index 00000000..2a5cda92 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEURepoResourcePack.java @@ -0,0 +1,75 @@ +package io.github.moulberry.notenoughupdates; + +import com.google.gson.JsonObject; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; + +import java.awt.image.BufferedImage; +import java.io.*; +import java.util.HashSet; +import java.util.Set; + +public class NEURepoResourcePack implements IResourcePack { + + File repoLocation; + Set<String> resourceDomains = new HashSet<>(); + + public NEURepoResourcePack(File repoLocation, String domain) { + this.repoLocation = repoLocation; + resourceDomains.add(domain); + } + + public boolean loadRepoLocation() { + if (repoLocation != null) return true; + NotEnoughUpdates instance = NotEnoughUpdates.INSTANCE; + if (instance == null) return false; + NEUManager manager = instance.manager; + if (manager == null) return false; + repoLocation = manager.repoLocation; + return repoLocation != null; + } + + public File getFileForResource(ResourceLocation loc) { + if (repoLocation == null) { + if (!loadRepoLocation()) + return null; + } + if (!"neurepo".equals(loc.getResourceDomain())) { + return null; + } + return new File(repoLocation, loc.getResourcePath()); + } + + @Override + public InputStream getInputStream(ResourceLocation resourceLocation) throws IOException { + return new BufferedInputStream(new FileInputStream(getFileForResource(resourceLocation))); + } + + @Override + public boolean resourceExists(ResourceLocation resourceLocation) { + File file = getFileForResource(resourceLocation); + return file != null && file.exists(); + } + + @Override + public Set<String> getResourceDomains() { + return resourceDomains; + } + + @Override + public <T extends IMetadataSection> T getPackMetadata(IMetadataSerializer iMetadataSerializer, String s) throws IOException { + return iMetadataSerializer.parseMetadataSection(s, new JsonObject()); + } + + @Override + public BufferedImage getPackImage() throws IOException { + return null; + } + + @Override + public String getPackName() { + return "NEU Repo Resources"; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 0a77c677..6b2fd09e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -35,6 +35,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.Custom import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; +import io.github.moulberry.notenoughupdates.mixins.AccessorMinecraft; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.FuelBar; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; @@ -58,6 +59,7 @@ import net.minecraft.world.biome.BiomeGenJungle; import net.minecraft.world.biome.BiomeGenMesa; import net.minecraft.world.biome.BiomeGenSnow; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -160,6 +162,13 @@ public class NotEnoughUpdates { return this.neuDir; } + public NotEnoughUpdates() { + // Budget Construction Event + ((AccessorMinecraft) FMLClientHandler.instance().getClient()) + .onGetDefaultResourcePacks() + .add(new NEURepoResourcePack(null, "neurepo")); + } + /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. */ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java new file mode 100644 index 00000000..c7b1862e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java @@ -0,0 +1,81 @@ +package io.github.moulberry.notenoughupdates.commands; + +import com.google.common.collect.Lists; +import io.github.moulberry.notenoughupdates.miscfeatures.entityviewer.EntityViewer; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.event.ClickEvent; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +import java.util.Arrays; +import java.util.List; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedDeque; + +public class EntityViewerCommand extends ClientCommandBase { + public EntityViewerCommand() { + super("neushowentity"); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public List<String> getCommandAliases() { + return Lists.newArrayList("neuentityviewer"); + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return EnumChatFormatting.RED + "Use /neushowentity list"; + } + + public void showUsage(ICommandSender sender) { + sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); + } + + private final Queue<EntityViewer> queuedGUIS = new ConcurrentLinkedDeque<>(); + + @SubscribeEvent + public void onTick(TickEvent event) { + if (Minecraft.getMinecraft().currentScreen == null) { + EntityViewer poll = queuedGUIS.poll(); + if (poll == null) return; + Minecraft.getMinecraft().displayGuiScreen(poll); + } + } + + @Override + public void processCommand(ICommandSender sender, String[] strings) throws CommandException { + if (strings.length == 0) { + showUsage(sender); + return; + } + if (strings[0].equals("list")) { + for (String label : EntityViewer.validEntities.keySet()) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + " " + label) + .setChatStyle(new ChatStyle().setChatClickEvent( + new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/neuentityviewer " + label)))); + } + return; + } + EntityLivingBase entityLivingBase; + if (strings[0].startsWith("@")) { + ResourceLocation resourceLocation = new ResourceLocation(strings[0].substring(1)); + entityLivingBase = EntityViewer.constructEntity(resourceLocation); + } else { + entityLivingBase = EntityViewer.constructEntity(strings[0], Arrays.copyOfRange(strings, 1, strings.length)); + } + if (entityLivingBase == null) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not create that entity")); + return; + } + queuedGUIS.add(new EntityViewer(strings[0], entityLivingBase)); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java index 53a7894b..27944c92 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -1,4 +1,4 @@ -package io.github.moulberry.notenoughupdates.commands.dev; + package io.github.moulberry.notenoughupdates.commands.dev; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java new file mode 100644 index 00000000..5884512f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java @@ -0,0 +1,30 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityAgeable; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityArmorStand; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityZombie; + +public class AgeModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + boolean baby = info.has("baby") && info.get("baby").getAsBoolean(); + if (base instanceof EntityAgeable) { + ((AccessorEntityAgeable) base).setGrowingAgeDirect(baby ? -1 : 1); + return base; + } + if (base instanceof EntityZombie) { + ((EntityZombie) base).setChild(baby); + return base; + } + if (base instanceof EntityArmorStand) { + ((AccessorEntityArmorStand) base).setSmallDirect(baby); + return base; + } + System.out.println("Cannot apply age to a non ageable entity: " + base); + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java new file mode 100644 index 00000000..17dce66d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/ChargedModifier.java @@ -0,0 +1,17 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; + +public class ChargedModifier extends EntityViewerModifier { + + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (base instanceof EntityCreeper) { + base.getDataWatcher().updateObject(17, (byte) 1); + return base; + } + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java new file mode 100644 index 00000000..e9075e47 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java @@ -0,0 +1,177 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.*; +import net.minecraft.entity.passive.*; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +public class EntityViewer extends GuiScreen { + + |
