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

Mca reborn #1

Open
wants to merge 3 commits into
base: 1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ configurations {
sourceSets{
main {
java{
exclude '**/mca/*'
exclude '**/abyssalcraft/*'
exclude '**/toroquest/*'
}
Expand Down
11 changes: 4 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ main_version=1
major_version=7
minor_version=0
minecraft_version=1.16.5
forge_version=36.2.4
forge_version=36.2.26
mcp_mappings=1.16.5
mcp_channel=official
vampirism_mcversion=1.16.5
vampirism_version=1.8.3
vampirism_version=1.8.9
bop_fileid=3360574
bop_api_fileid=3360577
hywla_fileid=3033593
Expand All @@ -24,7 +24,7 @@ structurize_version=0.13.177-ALPHA
evilcraft_fileid=3525654
cyclopscore_fileid=3517568
tough_as_nails_fileid=3430873
survive_fileid=3416821
survive_fileid=3655901
unionlib_fileid=3405963
diet_fileid=3525299
tconstruct_version=3.2.1.296
Expand All @@ -33,9 +33,6 @@ crafttweaker_version=1.16.5:7.1.2.442
mantle_version=1.6.124
guideapi_version=1.16.3-2.2.0
jei_version=1.16.5:7.7.0.104
#Not currently used
mca_version=6.1.0
abyssalcraft_version=1.9.12
ancient_warfare2_version=2.7.0.575
mca_fileid=3650709
betteranimalsplus_fileid=3286395
betteranimals_fileid=3231449
16 changes: 8 additions & 8 deletions gradle/forge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ repositories {
name = "LocalForge"
url = "../../MinecraftForge/repo/"
}
maven {
name = "Local2"
url = "../../../.m2/repository"
}
mavenLocal()

maven {
url = 'https://maven.blamejared.com'
Expand Down Expand Up @@ -162,21 +159,24 @@ dependencies {
runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-"+project.mantle_version)

// Survive - https://www.curseforge.com/minecraft/mc-mods/survive
implementation fg.deobf("curse.maven:survive-367337:"+project.survive_fileid)
compileOnly fg.deobf("curse.maven:survive-367337:"+project.survive_fileid)
// UnionLib - https://www.curseforge.com/minecraft/mc-mods/unionlib
runtimeOnly fg.deobf("curse.maven:unionlib-367806:"+project.unionlib_fileid)

// Diet - https://www.curseforge.com/minecraft/mc-mods/diet
implementation fg.deobf("curse.maven:diet-443570:"+project.diet_fileid)
implementation fg.deobf("curse.maven:diet-443570:" + project.diet_fileid)

implementation fg.deobf("curse.maven:betteranimalsplus-303557:"+project.betteranimalsplus_fileid)
implementation fg.deobf("curse.maven:betteranimalsplus-303557:" + project.betteranimalsplus_fileid)

implementation fg.deobf("curse.maven:betteranimals-287443:"+project.betteranimals_fileid)
implementation fg.deobf("curse.maven:betteranimals-287443:" + project.betteranimals_fileid)

// CraftTweaker
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-${project.crafttweaker_version}")
//runtimeOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-${project.crafttweaker_version}") // For testing

//MCA
implementation fg.deobf("curse.maven:minecraft-comes-alive-reborn-535291:" + project.mca_fileid)

//Optional
runtimeOnly fg.deobf("de.maxanier.guideapi:Guide-API-VP:${project.guideapi_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${project.jei_version}") //Full for runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import de.teamlapen.vampirism_integrations.crafttweaker.CrafttweakerCompat;
import de.teamlapen.vampirism_integrations.diet.DietCompat;
import de.teamlapen.vampirism_integrations.evilcraft.EvilCraftCompat;
import de.teamlapen.vampirism_integrations.mca.MCACompat;
import de.teamlapen.vampirism_integrations.survive.SurviveCompat;
import de.teamlapen.vampirism_integrations.tan.TANCompat;
import de.teamlapen.vampirism_integrations.tconstruct.TConstructCompat;
Expand Down Expand Up @@ -73,6 +74,7 @@ public VampirismIntegrationsMod() {
compatLoader.addModCompat(new BetterAnimalsPlusCompat());
compatLoader.addModCompat(new BetterAnimalsCompat());
compatLoader.addModCompat(new CrafttweakerCompat());
compatLoader.addModCompat(new MCACompat());
FMLJavaModLoadingContext.get().getModEventBus().register(this);
MinecraftForge.EVENT_BUS.addListener(this::onCommandRegister);
MinecraftForge.EVENT_BUS.register(new EventHandler());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
package de.teamlapen.vampirism_integrations.mca;

import de.teamlapen.lib.lib.util.UtilLib;
import de.teamlapen.vampirism.api.VReference;
import de.teamlapen.vampirism.api.VampirismAPI;
import de.teamlapen.vampirism.api.entity.IAggressiveVillager;
import de.teamlapen.vampirism.api.entity.factions.IFaction;
import de.teamlapen.vampirism.api.world.IVampirismVillage;
import de.teamlapen.vampirism.entity.ai.EntityAIDefendVillage;
import de.teamlapen.vampirism.entity.ai.EntityAIMoveThroughVillageCustom;
import mca.core.minecraft.ProfessionsMCA;
import mca.entity.EntityVillagerMCA;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.player.EntityPlayer;
import de.teamlapen.vampirism.api.world.ICaptureAttributes;
import de.teamlapen.vampirism.core.ModItems;
import de.teamlapen.vampirism.entity.goals.DefendVillageGoal;
import mca.entity.VillagerEntityMCA;
import mca.entity.ai.ProfessionsMCA;
import mca.entity.ai.relationship.Gender;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.goal.HurtByTargetGoal;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.ai.goal.MoveThroughVillageGoal;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.IServerWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.registries.ObjectHolder;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
Expand All @@ -29,64 +39,59 @@
*/
public class EntityAngryVillagerMCA extends EntityVillagerVampirismMCA implements IAggressiveVillager {

private ItemStack pitchforkStack;
private AxisAlignedBB area;


public EntityAngryVillagerMCA(World world) {
super(world);
pitchforkStack = new ItemStack(MCACompatREFERENCE.pitchfork);
}

@Override
public boolean attackEntityAsMob(Entity entity) {
this.swingArm(getActiveHand());
return super.attackEntityAsMob(entity);
}
@ObjectHolder("vampirism_integrations:mca_angry_villager_male")
public static final EntityType<EntityAngryVillagerMCA> angry_villager_male = UtilLib.getNull();
@ObjectHolder("vampirism_integrations:mca_angry_villager_female")
public static final EntityType<EntityAngryVillagerMCA> angry_villager_female = UtilLib.getNull();

@Nullable
public static EntityAngryVillagerMCA makeAngry(EntityVillagerMCA villager) {
if (villager.getProfessionForge() == ProfessionsMCA.guard || villager.getProfessionForge() == ProfessionsMCA.bandit || villager.get(EntityVillagerMCA.IS_INFECTED)) {
public static EntityAngryVillagerMCA makeAngry(VillagerEntityMCA villager) {
if (villager.getProfession() == ProfessionsMCA.GUARD || villager.getProfession() == ProfessionsMCA.OUTLAW || villager.isInfected()) {
return null;//Don't make guards or infected villagers angry
}
EntityAngryVillagerMCA angry = new EntityAngryVillagerMCA(villager.getEntityWorld());
NBTTagCompound tag = new NBTTagCompound();
villager.writeToNBT(tag);
angry.readFromNBT(tag);
angry.setUniqueId(MathHelper.getRandomUUID(villager.getRNG()));
EntityAngryVillagerMCA angry = new EntityAngryVillagerMCA(villager.getGenetics().getGender() == Gender.FEMALE ? angry_villager_female : angry_villager_male, villager.level, villager.getGenetics().getGender());
CompoundNBT tag = new CompoundNBT();
villager.saveWithoutId(tag);
angry.load(tag);
angry.setUUID(MathHelper.createInsecureUUID(villager.getRandom()));
return angry;

}

@Override
public ItemStack getHeldItem(EnumHand hand) {
return pitchforkStack;
@Nullable
private ICaptureAttributes villageAttributes;


public EntityAngryVillagerMCA(EntityType<? extends EntityAngryVillagerMCA> type, World w, Gender gender) {
super(type, w, gender);
}

@Override
public void attackVillage(AxisAlignedBB area) {
public void attackVillage(ICaptureAttributes villageAttributes) {
this.villageAttributes = villageAttributes;
}

@Override
public ItemStack getHeldItemMainhand() {
return pitchforkStack;
public void defendVillage(ICaptureAttributes villageAttributes) {
this.villageAttributes = villageAttributes;
}

@Override
public void defendVillage(AxisAlignedBB area) {
this.area = area;
public ILivingEntityData finalizeSpawn(@Nonnull IServerWorld worldIn, @Nonnull DifficultyInstance difficultyIn, @Nonnull SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
ILivingEntityData data = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
this.setItemSlot(EquipmentSlotType.MAINHAND, new ItemStack(ModItems.pitchfork));
return data;
}

@Nullable
@Override
public IVampirismVillage getCurrentFriendlyVillage() {
return this.vampirismVillage != null ? this.vampirismVillage.getControllingFaction() == VReference.HUNTER_FACTION ? this.vampirismVillage : null : null;
public ICaptureAttributes getCaptureInfo() {
return villageAttributes;
}

@Nullable
@Override
public AxisAlignedBB getTargetVillageArea() {
return area;
public IFaction getFaction() {
return VReference.HUNTER_FACTION;
}

@Override
Expand All @@ -95,59 +100,59 @@ public boolean isAttackingVillage() {
}

@Override
public void stopVillageAttackDefense() {
EntityVillagerMCA mca = new EntityVillagerMCA(this.getEntityWorld());
NBTTagCompound nbt = new NBTTagCompound();
this.writeToNBT(nbt);
mca.readFromNBT(nbt);
this.world.spawnEntity(mca);
this.setDead();
public LivingEntity getRepresentingEntity() {
return this;
}

@Nullable
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
applySpecialAITasks();
public AxisAlignedBB getTargetVillageArea() {
return villageAttributes == null ? null : villageAttributes.getVillageArea();
}

protected void applySpecialAITasks() {
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, 10, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), true, false, false, false, null)));
this.targetTasks.addTask(3, new EntityAIDefendVillage<>(this));
this.targetTasks.addTask(4, new EntityAINearestAttackableTarget<EntityCreature>(this, EntityCreature.class, 5, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), false, true, false, false, null)) {

@Override
protected double getTargetDistance() {
return super.getTargetDistance() / 2;
}
});
@Override
public boolean isDefendingVillage() {
return villageAttributes != null;
}


@Override
public IFaction getFaction() {
return VReference.HUNTER_FACTION;
public void refreshBrain(@Nonnull ServerWorld serverWorldIn) {
}

@Override
public EntityLivingBase getRepresentingEntity() {
return this;
public void stopVillageAttackDefense() {
VillagerEntityMCA villager = this.getGenetics().getGender().getVillagerType().create(this.level);
assert villager != null;
this.setItemInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
CompoundNBT nbt = new CompoundNBT();
this.saveWithoutId(nbt);
villager.load(nbt);
villager.setUUID(MathHelper.createInsecureUUID(this.random));
UtilLib.replaceEntity(this, villager);
}

@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
protected ITextComponent getTypeName() {
return this.getType().getDescription(); //Don't use profession as part of the translation key
}

@Override
protected void initEntityAI() {
super.initEntityAI();
this.tasks.taskEntries.removeIf(entry -> entry.action instanceof EntityAITradePlayer || entry.action instanceof EntityAILookAtTradePlayer || entry.action instanceof EntityAIVillagerMate || entry.action instanceof EntityAIFollowGolem);
this.tasks.addTask(6, new EntityAIAttackMelee(this, 0.6, false));
this.tasks.addTask(8, new EntityAIMoveThroughVillageCustom(this, 0.55, false, 400));
protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 0.6, false));
this.goalSelector.addGoal(8, new MoveThroughVillageGoal(this, 0.55, false, 400, () -> true));

applySpecialAITasks();
this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, 5, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), true, false, false, false, null)));
this.targetSelector.addGoal(3, new DefendVillageGoal<>(this));
this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<CreatureEntity>(this, CreatureEntity.class, 5, true, false, VampirismAPI.factionRegistry().getPredicate(getFaction(), false, true, false, false, null)) {

@Override
protected double getFollowDistance() {
return super.getFollowDistance() / 2;
}
});
}


}
Loading