Skip to content

Commit

Permalink
fix: Trial Possession Fix (#1200) - thanks @Eqis-Edu
Browse files Browse the repository at this point in the history
* Wild Slime now work, trial horde mobs invulnerability to others

* Horde Creeper Invulnerable to explosions
  • Loading branch information
Eqis-Edu authored and klikli-dev committed Aug 30, 2024
1 parent 0d9bf0a commit fca50c5
Show file tree
Hide file tree
Showing 17 changed files with 299 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"values": [
"occultism:wild_bogged",
"occultism:wild_cave_spider",
"occultism:wild_husk",
"occultism:wild_silverfish",
"occultism:wild_skeleton",
"occultism:wild_slime",
"occultism:wild_spider",
"occultism:wild_stray",
"occultism:wild_zombie",
"occultism:possessed_strong_breeze",
"occultism:possessed_breeze",
"occultism:possessed_weak_breeze"
]
}
2 changes: 1 addition & 1 deletion src/main/java/com/klikli_dev/occultism/Occultism.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void onEntityAttributeCreation(final EntityAttributeCreationEvent event)
event.put(OccultismEntities.WILD_SILVERFISH.get(), WildSilverfishEntity.createAttributes().build());
event.put(OccultismEntities.WILD_SPIDER_TYPE.get(), WildSpiderEntity.createAttributes().build());
event.put(OccultismEntities.WILD_BOGGED_TYPE.get(), WildBoggedEntity.createAttributes().build());
event.put(OccultismEntities.WILD_SLIME_TYPE.get(), WildSlimeEntity.createAttributes().build()); //Wild Slime Attributes error, changed to vanilla slimes
event.put(OccultismEntities.WILD_SLIME_TYPE.get(), WildSlimeEntity.createAttributes().build());
event.put(OccultismEntities.WILD_HUSK_TYPE.get(), WildHuskEntity.createAttributes().build());
event.put(OccultismEntities.WILD_STRAY_TYPE.get(), WildStrayEntity.createAttributes().build());
event.put(OccultismEntities.WILD_CAVE_SPIDER_TYPE.get(), WildCaveSpiderEntity.createAttributes().build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismEntities;
import com.klikli_dev.occultism.registry.OccultismTags;
import com.klikli_dev.occultism.util.TextUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnGroupData;
Expand Down Expand Up @@ -69,7 +73,7 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc
}

for (int i = 0; i < 5; i++) {
WildBoggedEntity entity = OccultismEntities.WILD_BOGGED.get().create(this.level());
WildStrayEntity entity = OccultismEntities.WILD_STRAY.get().create(this.level());
EventHooks.finalizeMobSpawn(entity, level, difficultyIn, reason, spawnDataIn);

double offsetX = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
Expand All @@ -81,23 +85,35 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc
}

for (int i = 0; i < 5; i++) {
//WildSlimeEntity entity = OccultismEntities.WILD_SLIME.get().create(this.level());
//Wild Slime Attributes error, changed to vanilla slimes but now gets unintended slimeball
Slime entity = EntityType.SLIME.create(this.level());
WildCaveSpiderEntity entity = OccultismEntities.WILD_CAVE_SPIDER.get().create(this.level());
EventHooks.finalizeMobSpawn(entity, level, difficultyIn, reason, spawnDataIn);

double offsetX = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
double offsetZ = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
entity.absMoveTo(this.getBlockX() + offsetX, this.getBlockY() + 1.5, this.getBlockZ() + offsetZ,
level.getRandom().nextInt(360), 0);
entity.setCustomName(Component.literal(TextUtil.generateName()));
entity.setSize(7,true); //Haha bigger slimes
level.addFreshEntity(entity);
}

return super.finalizeSpawn(level, difficultyIn, reason, spawnDataIn);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismEntities;
import com.klikli_dev.occultism.registry.OccultismTags;
import com.klikli_dev.occultism.util.TextUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnGroupData;
Expand Down Expand Up @@ -55,7 +59,7 @@ public static AttributeSupplier.Builder createAttributes() {
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficultyIn, MobSpawnType reason,
@Nullable SpawnGroupData spawnDataIn) {

for (int i = 0; i < 3; i++) {
for (int i = 0; i < 7; i++) {
WildHuskEntity entity = OccultismEntities.WILD_HUSK.get().create(this.level());
EventHooks.finalizeMobSpawn(entity, level, difficultyIn, reason, spawnDataIn);

Expand All @@ -68,7 +72,7 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc
}

for (int i = 0; i < 7; i++) {
WildStrayEntity entity = OccultismEntities.WILD_STRAY.get().create(this.level());
WildBoggedEntity entity = OccultismEntities.WILD_BOGGED.get().create(this.level());
EventHooks.finalizeMobSpawn(entity, level, difficultyIn, reason, spawnDataIn);

double offsetX = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
Expand All @@ -80,20 +84,36 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc
}

for (int i = 0; i < 7; i++) {
WildCaveSpiderEntity entity = OccultismEntities.WILD_CAVE_SPIDER.get().create(this.level());
WildSlimeEntity entity = OccultismEntities.WILD_SLIME.get().create(this.level());
EventHooks.finalizeMobSpawn(entity, level, difficultyIn, reason, spawnDataIn);

double offsetX = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
double offsetZ = level.getRandom().nextGaussian() * (1 + level.getRandom().nextInt(4));
entity.absMoveTo(this.getBlockX() + offsetX, this.getBlockY() + 1.5, this.getBlockZ() + offsetZ,
level.getRandom().nextInt(360), 0);
entity.setCustomName(Component.literal(TextUtil.generateName()));
entity.setSize(8,true); //Haha bigger slimes
level.addFreshEntity(entity);
}

return super.finalizeSpawn(level, difficultyIn, reason, spawnDataIn);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@

import com.klikli_dev.occultism.common.entity.spirit.WildHuntSkeletonEntity;
import com.klikli_dev.occultism.registry.OccultismEntities;
import com.klikli_dev.occultism.registry.OccultismTags;
import com.klikli_dev.occultism.util.TextUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnGroupData;
Expand Down Expand Up @@ -93,6 +97,21 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstanc
return super.finalizeSpawn(level, difficultyIn, reason, spawnDataIn);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand All @@ -39,16 +43,31 @@ public WildBoggedEntity(EntityType<? extends Bogged> type,
//region Static Methods
public static AttributeSupplier.Builder createAttributes() {
return Bogged.createAttributes()
.add(Attributes.MAX_HEALTH, 45.0)
.add(Attributes.ARMOR,10)
.add(Attributes.KNOCKBACK_RESISTANCE,0.5);
.add(Attributes.MAX_HEALTH, 60.0)
.add(Attributes.ARMOR,15)
.add(Attributes.KNOCKBACK_RESISTANCE,0.75);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
}
//endregion Static Methods

@Override
protected boolean isSunBurnTick() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand All @@ -38,9 +42,24 @@ public WildCaveSpiderEntity(EntityType<? extends CaveSpider> type,
//region Static Methods
public static AttributeSupplier.Builder createAttributes() {
return CaveSpider.createAttributes()
.add(Attributes.MAX_HEALTH, 60.0)
.add(Attributes.ARMOR,15)
.add(Attributes.KNOCKBACK_RESISTANCE,0.75);
.add(Attributes.MAX_HEALTH, 45.0)
.add(Attributes.ARMOR,10)
.add(Attributes.KNOCKBACK_RESISTANCE,0.5);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package com.klikli_dev.occultism.common.entity.possessed.horde;

import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand All @@ -43,6 +45,12 @@ public static AttributeSupplier.Builder createAttributes() {
.add(Attributes.KNOCKBACK_RESISTANCE, 1.0);
}

public boolean isInvulnerableTo(DamageSource source) {
if (source.is(DamageTypeTags.IS_EXPLOSION))
return true;
return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand All @@ -43,6 +47,21 @@ public static AttributeSupplier.Builder createAttributes() {
.add(Attributes.KNOCKBACK_RESISTANCE,0.75);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

package com.klikli_dev.occultism.common.entity.possessed.horde;

import com.klikli_dev.occultism.registry.OccultismTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand All @@ -43,6 +47,21 @@ public static AttributeSupplier.Builder createAttributes() {
.add(Attributes.KNOCKBACK_RESISTANCE,0.25);
}

@Override
public boolean isInvulnerableTo(DamageSource source) {
TagKey<EntityType<?>> wildTrialTag = OccultismTags.Entities.WILD_TRIAL;

Entity trueSource = source.getEntity();
if (trueSource != null && trueSource.getType().is(wildTrialTag))
return true;

Entity immediateSource = source.getDirectEntity();
if (immediateSource != null && immediateSource.getType().is(wildTrialTag))
return true;

return super.isInvulnerableTo(source);
}

@Override
protected boolean shouldDespawnInPeaceful() {
return false;
Expand Down
Loading

0 comments on commit fca50c5

Please sign in to comment.