Skip to content

Commit

Permalink
Fix Wilds Witch NEI drop page + modpack loading speed (#23)
Browse files Browse the repository at this point in the history
* Fix Wilds Witch NEI drops + game launch speedup

* Update Entity_SpecialWitch.java

* Use generated tags file

* Add all witches

* Fixes

* Fix

* Use the new api

* 1.62s + 2s

* Update dependencies.gradle

* Update dependencies.gradle

* update

* Use classToIDMapping

* Add additional drops

---------

Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
kuba6000 and Dream-Master authored Aug 22, 2024
1 parent 149c3fc commit 01badf8
Show file tree
Hide file tree
Showing 21 changed files with 334 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
layout.json
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add your dependencies here

dependencies {
api("com.github.GTNewHorizons:waila:1.6.5:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.5.3-GTNH:dev")

api("com.github.GTNewHorizons:waila:1.8.1:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.6.26-GTNH:dev")
compileOnly("com.github.GTNewHorizons:Mobs-Info:0.4.2-GTNH:dev")
}
30 changes: 21 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ channel = stable
mappingsVersion = 12

# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/

# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
Expand All @@ -50,24 +50,27 @@ enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = toast.specialMobs.Tags

# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenVersion = VERSION

# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =

# [DEPRECATED] Mod name replacement token.
gradleTokenModName =

# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =

# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile = _SpecialMobs.java
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
Expand All @@ -77,11 +80,16 @@ apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile =
accessTransformersFile = specialmobs_at.cfg

# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false

# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false

Expand Down Expand Up @@ -114,16 +122,22 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true

# Maven repository to publish the mod to.
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/

# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
Expand Down Expand Up @@ -187,5 +201,3 @@ curseForgeRelations =
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true

# Non-GTNH properties
gradleTokenGroupName =
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
}


4 changes: 1 addition & 3 deletions src/main/java/toast/specialMobs/_SpecialMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* This is the mod class. Everything the mod does is initialized by this class.
*/
@Mod(modid = _SpecialMobs.MODID, name = "Special Mobs", version = _SpecialMobs.VERSION)
@Mod(modid = _SpecialMobs.MODID, name = "Special Mobs", version = Tags.VERSION)
public class _SpecialMobs {
/*
* TO DO *\ >> CURRENT Magma cubes Water guardians (1.8) Shulker (1.9) Check into biome mod compatibility for added
Expand All @@ -42,8 +42,6 @@ public class _SpecialMobs {

/** This mod's id. */
public static final String MODID = "SpecialMobs";
/** This mod's version. */
public static final String VERSION = "GRADLETOKEN_VERSION";

/** If true, this mod starts up in debug mode. */
public static final boolean debug = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package toast.specialMobs.entity.blaze;

import static net.minecraft.entity.EntityList.classToIDMapping;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityBlaze;
Expand Down Expand Up @@ -79,7 +80,7 @@ protected void dropFewItems(boolean hit, int looting) {
}
if (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + looting) > 0) {
this.entityDropItem(
new ItemStack(Items.spawn_egg, 1, EntityList.getEntityID(new EntityBlaze(this.worldObj))),
new ItemStack(Items.spawn_egg, 1, (int) classToIDMapping.get(EntityBlaze.class)),
0.0F);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package toast.specialMobs.entity.cavespider;

import static net.minecraft.entity.EntityList.classToIDMapping;

import java.util.ArrayList;

import javax.annotation.Nonnull;

import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityCaveSpider;
Expand All @@ -12,11 +17,16 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import com.kuba6000.mobsinfo.api.IMobInfoProvider;
import com.kuba6000.mobsinfo.api.MobDrop;

import cpw.mods.fml.common.Optional;
import toast.specialMobs.EffectHelper;
import toast.specialMobs._SpecialMobs;
import toast.specialMobs.entity.SpecialMobData;

public class EntityMotherCaveSpider extends Entity_SpecialCaveSpider {
@Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IMobInfoProvider", modid = "mobsinfo")
public class EntityMotherCaveSpider extends Entity_SpecialCaveSpider implements IMobInfoProvider {

public static final ResourceLocation[] TEXTURES = new ResourceLocation[] {
new ResourceLocation(_SpecialMobs.TEXTURE_PATH + "cavespider/mother.png"),
Expand Down Expand Up @@ -45,10 +55,11 @@ public void adjustTypeAttributes() {
/// Called when this entity is killed.
@Override
protected void dropFewItems(boolean hit, int looting) {
// ALL CHANGES IN HERE MUST BE ALSO MADE IN provideDropsInformation
super.dropFewItems(hit, looting);
if (hit && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + looting) > 0)) {
this.entityDropItem(
new ItemStack(Items.spawn_egg, 1, EntityList.getEntityID(new EntityCaveSpider(this.worldObj))),
new ItemStack(Items.spawn_egg, 1, (int) classToIDMapping.get(EntityCaveSpider.class)),
0.0F);
}

Expand All @@ -71,6 +82,7 @@ protected void dropFewItems(boolean hit, int looting) {
/// Called 2.5% of the time when this entity is killed. 20% chance that superRare == 1, otherwise superRare == 0.
@Override
protected void dropRareDrop(int superRare) {
// ALL CHANGES IN HERE MUST BE ALSO MADE IN provideDropsInformation
ItemStack itemStack;
String name;
if (this.rand.nextBoolean()) {
Expand Down Expand Up @@ -105,6 +117,50 @@ protected void dropRareDrop(int superRare) {
this.entityDropItem(itemStack, 0.0F);
}

@Optional.Method(modid = "mobsinfo")
@Override
public void provideDropsInformation(@Nonnull ArrayList<MobDrop> drops) {
IMobInfoProvider.provideSuperVanillaDrops(drops, EntityCaveSpider.class);
drops.add(
MobDrop.create(new ItemStack(Items.spawn_egg, 1, (int) classToIDMapping.get(EntityCaveSpider.class)))
.withChance(0.3333d).withLooting());
final Item[] armor = { Items.chainmail_helmet, Items.chainmail_chestplate, Items.chainmail_leggings,
Items.chainmail_boots };
final String[] armorNames = { "Helmet", "Chestplate", "Leggings", "Boots" };
final Item[] tools = { Items.stone_sword, Items.bow, Items.stone_pickaxe, Items.stone_axe, Items.stone_shovel };
final String[] toolNames = { "Sword", "Bow", "Pickaxe", "Axe", "Shovel" };
double chance = 0.5d / armor.length;
for (int i = 0; i < armor.length; i++) {
Item item = armor[i];
int mindamage = 26;
int maxdamage = item.getMaxDamage() - 25;
if (mindamage > maxdamage) mindamage = maxdamage;
ItemStack stack = new ItemStack(item);

EffectHelper.setItemName(stack, "Partially Digested " + armorNames[i], 0xa);
EffectHelper.addItemText(stack, "\u00a77\u00a7oIt's a bit slimy...");

drops.add(
MobDrop.create(stack).withType(MobDrop.DropType.Rare).withChance(0.025d * chance)
.withRandomEnchant(30).withRandomDamage(mindamage, maxdamage));
}
chance = 0.5d / tools.length;
for (int i = 0; i < tools.length; i++) {
Item item = tools[i];
int mindamage = 26;
int maxdamage = item.getMaxDamage() - 25;
if (mindamage > maxdamage) mindamage = maxdamage;
ItemStack stack = new ItemStack(item);

EffectHelper.setItemName(stack, "Partially Digested " + toolNames[i], 0xa);
EffectHelper.addItemText(stack, "\u00a77\u00a7oIt's a bit slimy...");

drops.add(
MobDrop.create(stack).withType(MobDrop.DropType.Rare).withChance(0.025d * chance)
.withRandomEnchant(30).withRandomDamage(mindamage, maxdamage));
}
}

/// Saves this entity to NBT.
@Override
public void writeEntityToNBT(NBTTagCompound tag) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package toast.specialMobs.entity.ghast;

import static net.minecraft.entity.EntityList.classToIDMapping;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityGhast;
Expand Down Expand Up @@ -72,9 +73,7 @@ protected void dropFewItems(boolean hit, int looting) {
this.dropItem(Items.emerald, 1);
}
if (hit && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + looting) > 0)) {
this.entityDropItem(
new ItemStack(Items.spawn_egg, 1, EntityList.getEntityID(new EntityGhast(this.worldObj))),
0.0F);
this.entityDropItem(new ItemStack(Items.spawn_egg, 1, (int) classToIDMapping.get(EntityGhast.class)), 0.0F);
}

if (!this.worldObj.isRemote) {
Expand Down
Loading

0 comments on commit 01badf8

Please sign in to comment.