Skip to content
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

Rework Endermen/Zombie pigmen Aggro #7

Merged
merged 10 commits into from
May 28, 2024
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gtnh.settings.blowdryerTag = 0.2.0

# Human-readable mod name, available for mcmod.info population.
modName = AngerMod. Makes your Mobs angry!
modName = AngerMod. Makes your Mobs angry\!

# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
Expand Down Expand Up @@ -33,15 +33,15 @@ 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.
developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
Expand All @@ -61,6 +61,9 @@ 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";
Expand Down Expand Up @@ -114,7 +117,7 @@ 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 the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
Expand All @@ -123,7 +126,7 @@ includeWellKnownRepositories = true
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 +190,3 @@ customArchiveBaseName = AngerMod
# 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.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
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.22'
}


Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Specific configuration for >this< mod
*
*
* @author Namikon
*
*/
Expand Down Expand Up @@ -56,11 +56,10 @@ public AngerModConfig(File pConfigBaseDirectory, String pModCollectionDirectory,
*/
@Override
protected void PreInit() {
BlacklistedBlocks = new ArrayList<MinecraftBlock>();
BlacklistedBlocks = new ArrayList<>();

_mDefaultBlacklistedEndBlocks = new String[] { "gregtech:gt.blockores" };

_mDefaultBlacklistedNetherBlocks = new String[] { "gregtech:gt.blockores", };
_mDefaultBlacklistedNetherBlocks = new String[] { "gregtech:gt.blockores" };

EndermanAggrorange = 16;
PigmenAggrorange = 16;
Expand Down Expand Up @@ -204,7 +203,7 @@ protected void Init() {
/**
* Go ahead and parse the given list of strings to actual instances of MinecraftBlock classes with bound dimension
* ID
*
*
* @param pBlockNames
* @param pDimension
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package com.github.namikon.angermod.events;

import java.util.List;

import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;

import com.github.namikon.angermod.AngerMod;
import com.github.namikon.angermod.auxiliary.MinecraftBlock;
import com.github.namikon.angermod.config.AngerModConfig;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import eu.usrv.yamcore.auxiliary.EntityHelper;

/**
* Class for handling all block-break code that will cause mobs become hostile against the player, depending on the
* configuration
*
*
* @author Namikon
*
*/
Expand All @@ -28,21 +33,16 @@ public BlockBreakEvent(AngerModConfig pCfgMan) {

@SubscribeEvent
public void onBreakBlock(BreakEvent pEvent) {

if (pEvent.getPlayer() instanceof FakePlayer) return;

try {
for (MinecraftBlock tBlock : _mConfig.BlacklistedBlocks) {
if (tBlock.isEqualTo(pEvent)) {
if (pEvent.getPlayer().dimension == -1) // Nether
EntityHelper.DealDamageToEntitiesInRange(
pEvent.getPlayer(),
_mConfig.PigmenAggrorange,
EntityPigZombie.class,
0);
aggroZombiePigmenInRange(pEvent.getPlayer(), _mConfig.PigmenAggrorange);
else if (pEvent.getPlayer().dimension == 1) // End
EntityHelper.DealDamageToEntitiesInRange(
pEvent.getPlayer(),
_mConfig.EndermanAggrorange,
EntityEnderman.class,
0);
aggroEndermenInRange(pEvent.getPlayer(), _mConfig.EndermanAggrorange);
}
}
} catch (Exception e) {
Expand All @@ -52,4 +52,46 @@ else if (pEvent.getPlayer().dimension == 1) // End
AngerMod.Logger.DumpStack("BlockBreakEvent.onBreakBlock.Stack", e);
}
}

@SuppressWarnings("unchecked")
public static void aggroEndermenInRange(EntityPlayer player, int range) {
List nearbyEntities;

int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;

// Define the area to check for entities
AxisAlignedBB tBoundingBox = AxisAlignedBB
.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range);

nearbyEntities = player.worldObj.getEntitiesWithinAABB(EntityEnderman.class, tBoundingBox);

for (Entity entity : (List<Entity>) nearbyEntities) {
if (entity instanceof EntityEnderman enderman) {
enderman.setTarget(player);
enderman.setScreaming(true);
}
}
}

public static void aggroZombiePigmenInRange(EntityPlayer player, int range) {
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;

// Define the area to check for entities
AxisAlignedBB boundingBox = AxisAlignedBB
.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range);

List<Entity> nearbyEntities = player.worldObj.getEntitiesWithinAABB(EntityPigZombie.class, boundingBox);

for (Entity entity : nearbyEntities) {
if (entity instanceof EntityPigZombie zombiePigman) {
zombiePigman.setTarget(player);
zombiePigman.worldObj.playSoundAtEntity(zombiePigman, "mob.zombiepig.zpighurt", 1.0F, 1.0F);
}
}
}

}