Skip to content

Commit

Permalink
完成一部分迁移内容
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Dec 13, 2023
1 parent c54368f commit eecb6cd
Show file tree
Hide file tree
Showing 119 changed files with 4,640 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false
mod_version=1.1.4
mod_version=1.1.5
forge_version=1.16.5-36.2.0
jei_version=7.6.1.75
top_version=1.16-3.1.3-21
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.tartaricacid.touhoulittlemaid;

import com.github.tartaricacid.touhoulittlemaid.api.ILittleMaid;
import com.github.tartaricacid.touhoulittlemaid.api.gomoku.AIService;
import com.github.tartaricacid.touhoulittlemaid.api.gomoku.ZhiZhangAIService;
import com.github.tartaricacid.touhoulittlemaid.block.multiblock.MultiBlockManager;
import com.github.tartaricacid.touhoulittlemaid.compat.cloth.MenuIntegration;
import com.github.tartaricacid.touhoulittlemaid.config.GeneralConfig;
Expand Down Expand Up @@ -30,6 +32,7 @@ public final class TouhouLittleMaid {
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
private static final String CLOTH_CONFIG = "cloth-config";
public static List<ILittleMaid> EXTENSIONS = Lists.newArrayList();
public static AIService SERVICE = new ZhiZhangAIService(new AIService.AIConfig(4, 10, false, 0, 6));

public TouhouLittleMaid() {
InitEntities.ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ default void bindMaidBauble(BaubleManager manager) {
default void addMaidTask(TaskManager manager) {
}

/**
* 添加女仆的背包
*
* @param manager 注册器
*/
default void addMaidBackpack(BackpackManager manager) {
}

/**
* 添加多方块结构
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.tartaricacid.touhoulittlemaid.api.backpack;

import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.inventory.ContainerData;

public interface IBackpackData {
ContainerData getDataAccess();

void load(CompoundTag tag, EntityMaid maid);

void save(CompoundTag tag, EntityMaid maid);

void serverTick(EntityMaid maid);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.github.tartaricacid.touhoulittlemaid.api.backpack;

import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityTombstone;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.item.BackpackLevel;
import com.github.tartaricacid.touhoulittlemaid.util.ItemsUtil;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import javax.annotation.Nullable;


public abstract class IMaidBackpack {
public abstract ResourceLocation getId();

public abstract Item getItem();

public abstract void onPutOn(ItemStack stack, Player player, EntityMaid maid);

public ItemStack getTakeOffItemStack(ItemStack stack, @Nullable Player player, EntityMaid maid) {
return this.getItem().getDefaultInstance();
}

public abstract void onTakeOff(ItemStack stack, Player player, EntityMaid maid);

public abstract void onSpawnTombstone(EntityMaid maid, EntityTombstone tombstone);

public abstract MenuProvider getGuiProvider(int entityId);

public boolean hasBackpackData() {
return false;
}

@Nullable
public IBackpackData getBackpackData(EntityMaid maid) {
return null;
}

public abstract int getAvailableMaxContainerIndex();

@OnlyIn(Dist.CLIENT)
public abstract void offsetBackpackItem(PoseStack poseStack);

@Nullable
@OnlyIn(Dist.CLIENT)
public abstract EntityModel<EntityMaid> getBackpackModel(EntityModelSet modelSet);

@Nullable
@OnlyIn(Dist.CLIENT)
public abstract ResourceLocation getBackpackTexture();

protected final void dropAllItems(EntityMaid maid) {
ItemsUtil.dropEntityItems(maid, maid.getMaidInv(), BackpackLevel.EMPTY_CAPACITY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* https://github.com/anlingyi/xechat-idea
*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*/
package com.github.tartaricacid.touhoulittlemaid.api.gomoku;

/**
* @author anlingyi
* @date 2021/11/1 3:26 下午
*/
public interface AIService {
/**
* 获取AI棋位
*
* @param chessData 已下棋子数据
* @param point 对手棋位
*/
Point getPoint(int[][] chessData, Point point);

/**
* 获取棋局状态
*
* @param chessData 已下棋子数据
* @param point 落子棋位
*/
Statue getStatue(int[][] chessData, Point point);

/**
* AI配置
*/
class AIConfig {
/**
* 搜索深度
*/
private final int depth;
/**
* 最大启发式节点数
*/
private final int maxNodes;
/**
* debug
*/
private final boolean debug;
/**
* 算杀 0.不开启 1.VCT 2.VCF
*/
private final int vcx;
/**
* 算杀深度
*/
private final int vcxDepth;

public AIConfig(int depth, int maxNodes, boolean debug, int vcx, int vcxDepth) {
this.depth = depth;
this.maxNodes = maxNodes;
this.debug = debug;
this.vcx = vcx;
this.vcxDepth = vcxDepth;
}

public int getDepth() {
return depth;
}

public int getMaxNodes() {
return maxNodes;
}

public boolean isDebug() {
return debug;
}

public int getVcx() {
return vcx;
}

public int getVcxDepth() {
return vcxDepth;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* https://github.com/anlingyi/xechat-idea
*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*/
package com.github.tartaricacid.touhoulittlemaid.api.gomoku;

import net.minecraft.nbt.CompoundNBT;

/**
* 棋子点位
*
* @author anlingyi
* @date 2021/11/7 5:59 下午
*/
public class Point {
public static final int EMPTY = 0;
public static final int BLACK = 1;
public static final int WHITE = 2;
public static final Point NULL = new Point(-1, -1, 0);
/**
* 横坐标
*/
public final int x;
/**
* 纵坐标
*/
public final int y;
/**
* 棋子类型 1.黑 2.白
*/
public int type;
/**
* 得分
*/
public int score;

public Point(int x, int y, int type) {
this.x = x;
this.y = y;
this.type = type;
}

public static CompoundNBT toTag(Point point) {
CompoundNBT tag = new CompoundNBT();
tag.putInt("x", point.x);
tag.putInt("y", point.y);
tag.putInt("type", point.type);
return tag;
}

public static Point fromTag(CompoundNBT tag) {
int x = tag.getInt("x");
int y = tag.getInt("y");
int type = tag.getInt("type");
return new Point(x, y, type);
}

@Override
public boolean equals(Object other) {
if (other == null) {
return false;
} else if (this == other) {
return true;
} else if (other instanceof Point) {
Point otherPoint = (Point) other;
return otherPoint.x == this.x && otherPoint.y == this.y && otherPoint.type == this.type;
} else {
return false;
}
}

@Override
public String toString() {
return (type == 1 ? "Black" : "White") + "[" + x + "," + y + ']';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.tartaricacid.touhoulittlemaid.api.gomoku;

public enum Statue {
WIN,
IN_PROGRESS
}
Loading

0 comments on commit eecb6cd

Please sign in to comment.