侧边栏壁纸
  • 累计撰写 793 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

目 录CONTENT

文章目录
MC

MineColonies

Dettan
2021-07-10 / 0 评论 / 0 点赞 / 143 阅读 / 1,298 字
温馨提示:
本文最后更新于 2022-07-23,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
Gradle项目编译报错: 编码 GBK 的不可映射字符_qssn的博客-CSDN博客
今天找出许久未看的JAVA项目进行操作,也不知道是什么原因,编码竟然是GBK的,然鹅我的Eclipse默认编码是UTF8,项目是可以运行的,但是中文各种错乱,把所有文件改成UTF8编码后发现报错"编码 GBK 的不可映射字符";最后通过 修改build.gradle文件编码 解决(改成utf-8,难道Gradle项目编译编码是根据这个文件的编码来的?) 如何上述方法没有解决,请在build.gradle中添加下面这段代码 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
https://blog.csdn.net/dKnightL/article/details/79950305?utm_medium=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_feed_404.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecas
https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20200606-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20200606-1.15.1.jar
https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20200606-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20200606-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201026-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201026-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201027-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201027-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201028-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201028-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201029-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201029-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201030-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201030-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201031-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201031-1.15.1.jar
        https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.15.2-31.2.33_mapped_snapshot_20201101-1.15.1/forge-1.15.2-31.2.33_mapped_snapshot_20201101-1.15.1.jar
对象能占多少内存? 多个对象对应的方法只占用一个空间才对?
C:\JAVA\MC\minecolonies\src\main\java


注册 ForgeRegistryEntry
ForgeRegistryEntry里有 BiFunction 这个是指定给的参数是什么参数和返回值的函数.
ForgeRegistryEntry是指定名字和 创建方法的 一个东西,有了这个forge就能在适合的时间初始化值.
entityCitizen (多例模式,每个市民创建一个,然后添加都world里)
this.goalSelector = new CustomGoalSelector(this.goalSelector);
this.targetSelector = new CustomGoalSelector(this.targetSelector);
this.citizenExperienceHandler = new CitizenExperienceHandler(this);
this.citizenChatHandler = new CitizenChatHandler(this);
this.citizenStatusHandler = new CitizenStatusHandler(this);
this.citizenItemHandler = new CitizenItemHandler(this);
this.citizenInventoryHandler = new CitizenInventoryHandler(this);
this.citizenColonyHandler = new CitizenColonyHandler(this);
this.citizenJobHandler = new CitizenJobHandler(this);
this.citizenSleepHandler = new CitizenSleepHandler(this);
this.citizenStuckHandler = new CitizenStuckHandler(this);
this.citizenDiseaseHandler = new CitizenDiseaseHandler(this);

	public class EntityCitizen extends AbstractEntityCitizen
	public abstract class AbstractEntityCitizen extends AgeableEntity implements INamedContainerProvider, INPC
package net.minecraft.entity;
	public abstract class AgeableEntity extends CreatureEntity 
	public abstract class CreatureEntity extends MobEntity 
	public abstract class MobEntity extends LivingEntity 
只有一个没有子类,剩下都是CitizenData,每个citizen出了工作和ai之外用享元模式就行了.
entity有很多,但是表示市民的就一个citizen
CitizenManager
保存管理所有市民数据, 每个colony一个
@NotNull
private ICitizenData spawnCitizenOnPosition( @Nullable final ICitizenData data, @NotNull final World world, final boolean force, final BlockPos spawnPoint)
{
    ICitizenData citizenData = data;
    if (citizenData == null)
    {
				//创建 citizenData 然后存入 map里保存
        citizenData = createAndRegisterNewCitizenData();

        if (getMaxCitizens() == getCitizens().size() && !force)
        {
            if (maxCitizensFromResearch() <= getCitizens().size())
            {
                LanguageHandler.sendPlayersMessage(
                  colony.getMessagePlayerEntities(),
                  "block.blockhuttownhall.messagemaxsize.research",
                  colony.getName());
            }
            else
            {
                LanguageHandler.sendPlayersMessage(
                  colony.getMessagePlayerEntities(),
                  "block.blockhuttownhall.messagemaxsize.config",
                  colony.getName());
            }
        }
    }
		//创建
    final EntityCitizen entity = (EntityCitizen) ModEntities.CITIZEN.create(world);
		//注册CitizenData到殖民地
    entity.getCitizenColonyHandler().registerWithColony(citizenData.getColony().getID(), citizenData.getId());

    entity.setPosition(spawnPoint.getX() + HALF_BLOCK, spawnPoint.getY() + SLIGHTLY_UP, spawnPoint.getZ() + HALF_BLOCK);
		//注册CitizenData到world
    world.addEntity(entity);
		//通知 进展,在对话框显示内容
    colony.getProgressManager()
      .progressCitizenSpawn(citizens.size(), citizens.values().stream().filter(tempDate -> tempDate.getJob() != null).collect(Collectors.toList()).size());
    markCitizensDirty();
    return citizenData;
}
ICitizenData(多例模式) citizen的拓展信息, 存了job workBuilding 等
每个里面都有一个对应的 CitizenHappinessHandler 和 CitizenSkillHandler 和 InventoryCitizen
colony
lastPosition
IdleAtJob
Ate
homeBuilding
workBuilding
job
name
bedPos
isChild
citizenEntity
InventoryCitizen
Job
存储AI和一些工作相关的东西,AI应该没有存储能力
AbstractJobCrafter
rsDataStoreToken 在DataStore 里标记这个job的数据
NBT
getTaskQueueFromDataStore
getAssignedTasksFromDataStore
public <R extends PublicCrafting> IRequest<R> getCurrentTask()
等一些和task和request的相关信息,没有制作过程. 只是放一些信息

AI

一个状态机 , 这个状态机是简版的, 只是几个状态,每一个状态对应着一个转换函数,返回值决定下一个状态是什么.
super.registerTargets(
  new AITarget(IDLE, START_WORKING, 100),
	在参数1状态执行参数2函数返回true就执行参数3进行状态转换
  new AITarget(START_WORKING, this::checkForWorkOrder, this::startWorkingAtOwnBuilding, 100),
  new AITarget(PICK_UP, this::pickUpMaterial, 5)
);

requestSystem


GUI



EntityCitizen 里有GoalSelecter ,这个是原版的ai逻辑,
EntityAIWorkStoneSmeltery 这里面是具体的ai,用的是自己状态机实现,状态机实现实现了原版的Goal接口,把其注册给entity的goalSelecter就会没tick调用一下
public abstract class AbstractAISkeleton<J extends IJob<?>> extends Goal

把goal注册给entity是在换工作的时候
0

评论区