Skip to content

Commit

Permalink
修正所有问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Dec 18, 2023
1 parent a48205e commit 75d9521
Show file tree
Hide file tree
Showing 36 changed files with 489 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityBookshelf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.pathfinding.PathType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
Expand Down Expand Up @@ -41,4 +42,9 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) {
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}

@Override
public boolean isPathfindable(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathType;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
Expand Down Expand Up @@ -335,4 +336,9 @@ public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos,
return CENTER;
}
}

@Override
public boolean isPathfindable(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityKeyboard;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.pathfinding.PathType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
Expand Down Expand Up @@ -41,4 +42,9 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) {
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}

@Override
public boolean isPathfindable(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public BlockShrine() {
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
}

@Override
public boolean hasTileEntity(BlockState state) {
return true;
}

@Override
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
builder.add(FACING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void addEffectButton(int start, int spacing, int y) {
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(matrixStack);
getMinecraft().textureManager.bind(BG);
blit(matrixStack, leftPos, topPos, 0, 0, imageWidth, imageHeight);
blit(matrixStack, leftPos, topPos, 0, 0, 142, 111);
blit(matrixStack, leftPos, topPos + 2, 0, 0, 142, 111);
blit(matrixStack, leftPos + 118, topPos + 1, 44, 111, 154, 15);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GomokuModel() {
main.texOffs(0, 0).addBox(-16.0F, -2.0F, -16.0F, 32.0F, 2.0F, 32.0F, 0.0F, false);

blackBox = new ModelRenderer(this);
blackBox.setPos(0.0F, 24.0F, 0.0F);
blackBox.setPos(0.0F, 24.0F, -21.0F);
blackBox.texOffs(69, 11).addBox(-22.0F, -1.0F, 8.0F, 5.0F, 1.0F, 5.0F, 0.0F, false);
blackBox.texOffs(12, 99).addBox(-21.5F, -2.95F, 8.5F, 4.0F, 1.0F, 4.0F, 0.0F, false);
blackBox.texOffs(12, 99).addBox(-20.25F, -3.85F, 8.9F, 2.0F, 1.0F, 2.0F, -0.25F, false);
Expand All @@ -40,7 +40,7 @@ public GomokuModel() {
bone2.texOffs(12, 99).addBox(-1.0F, -0.5F, -1.0F, 2.0F, 1.0F, 2.0F, -0.25F, false);

whiteBox = new ModelRenderer(this);
whiteBox.setPos(0.0F, 24.0F, 0.0F);
whiteBox.setPos(0.0F, 24.0F, 21.0F);
whiteBox.texOffs(69, 11).addBox(17.0F, -1.0F, -13.0F, 5.0F, 1.0F, 5.0F, 0.0F, true);
whiteBox.texOffs(44, 96).addBox(17.5F, -2.95F, -12.5F, 4.0F, 1.0F, 4.0F, 0.0F, true);
whiteBox.texOffs(44, 96).addBox(18.25F, -3.85F, -10.9F, 2.0F, 1.0F, 2.0F, -0.25F, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public PieceModel() {

main = new ModelRenderer(this);
main.setPos(0.0F, 24.0F, 0.0F);
main.texOffs(0, 0).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 1.0F, 2.0F, 0.0F, false);
main.texOffs(0, 0).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 1.0F, 2.0F, -0.25F, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityGomoku;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
Expand All @@ -31,11 +30,9 @@ public class TileEntityGomokuRenderer extends TileEntityRenderer<TileEntityGomok
private static final int PIECE_RENDER_DISTANCE = 24;
private final GomokuModel CHECKER_BOARD_MODEL = new GomokuModel();
private final PieceModel PIECE_MODEL = new PieceModel();
private final FontRenderer font;

public TileEntityGomokuRenderer(TileEntityRendererDispatcher context) {
super(context);
this.font = context.getFont();
}

@Override
Expand All @@ -55,8 +52,8 @@ private void renderLatestChessTips(TileEntityGomoku gomoku, MatrixStack poseStac
poseStack.translate(point.x * 0.1316, 0, point.y * 0.1316);
poseStack.mulPose(Vector3f.YN.rotationDegrees(180 + camera.getYRot()));
poseStack.scale(0.015625F, -0.015625F, 0.015625F);
float width = (float) (-this.font.width("▼") / 2) + 0.5f;
this.font.drawInBatch("▼", width, -1.5f, 0xFF0000, false, poseStack.last().pose(), bufferIn, true, 0, combinedLightIn);
float width = (float) (-renderer.font.width("▼") / 2) + 0.5f;
renderer.font.drawInBatch("▼", width, -1.5f, 0xFF0000, false, poseStack.last().pose(), bufferIn, true, 0, combinedLightIn);
poseStack.popPose();
}
}
Expand All @@ -66,7 +63,7 @@ private void renderChessboard(TileEntityGomoku gomoku, MatrixStack poseStack, IR
poseStack.pushPose();
poseStack.translate(0.5, 1.5, 0.5);
poseStack.mulPose(Vector3f.ZN.rotationDegrees(180));
poseStack.mulPose(Vector3f.YN.rotationDegrees(facing.get2DDataValue() * 90));
poseStack.mulPose(Vector3f.YP.rotationDegrees(facing.get2DDataValue() * 90));
IVertexBuilder checkerBoardBuff = bufferIn.getBuffer(RenderType.entityTranslucent(CHECKER_BOARD_TEXTURE));
CHECKER_BOARD_MODEL.renderToBuffer(poseStack, checkerBoardBuff, combinedLightIn, combinedOverlayIn, 1.0F, 1.0F, 1.0F, 1.0F);
poseStack.popPose();
Expand Down Expand Up @@ -111,18 +108,18 @@ private void renderTipsText(TileEntityGomoku gomoku, MatrixStack poseStack, IRen
} else {
loseTips = new TranslationTextComponent("message.touhou_little_maid.gomoku.lose").withStyle(TextFormatting.BOLD).withStyle(TextFormatting.DARK_PURPLE);
}
float loseTipsWidth = (float) (-this.font.width(loseTips) / 2);
float resetTipsWidth = (float) (-this.font.width(resetTips) / 2);
float roundTipsWidth = (float) (-this.font.width(roundTips) / 2);
float loseTipsWidth = (float) (-renderer.font.width(loseTips) / 2);
float resetTipsWidth = (float) (-renderer.font.width(resetTips) / 2);
float roundTipsWidth = (float) (-renderer.font.width(roundTips) / 2);
poseStack.pushPose();
poseStack.translate(0.5, 0.75, 0.5);
poseStack.mulPose(Vector3f.YN.rotationDegrees(180 + camera.getYRot()));
poseStack.mulPose(Vector3f.XN.rotationDegrees(camera.getXRot()));
poseStack.scale(0.03F, -0.03F, 0.03F);
this.font.drawInBatch(loseTips, loseTipsWidth, -10, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, true, 0, combinedLightIn);
renderer.font.drawInBatch(loseTips, loseTipsWidth, -10, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, false, 0, combinedLightIn);
poseStack.scale(0.5F, 0.5F, 0.5F);
this.font.drawInBatch(roundTips, roundTipsWidth, -30, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, true, 0, combinedLightIn);
this.font.drawInBatch(resetTips, resetTipsWidth, 0, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, true, 0, combinedLightIn);
renderer.font.drawInBatch(roundTips, roundTipsWidth, -30, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, false, 0, combinedLightIn);
renderer.font.drawInBatch(resetTips, resetTipsWidth, 0, 0xFFFFFF, true, poseStack.last().pose(), bufferIn, false, 0, combinedLightIn);
poseStack.popPose();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.github.tartaricacid.touhoulittlemaid.network.message.SendEffectMessage;
import com.github.tartaricacid.touhoulittlemaid.util.BiomeCacheUtil;
import com.github.tartaricacid.touhoulittlemaid.util.ParseI18n;
import com.github.tartaricacid.touhoulittlemaid.util.TeleportHelper;
import com.github.tartaricacid.touhoulittlemaid.world.data.MaidWorldData;
import com.google.common.collect.Lists;
import com.mojang.serialization.Dynamic;
Expand Down Expand Up @@ -72,6 +73,8 @@
import net.minecraft.pathfinding.GroundPathNavigator;
import net.minecraft.pathfinding.Path;
import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.stats.Stats;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
Expand All @@ -94,6 +97,7 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ITeleporter;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.network.NetworkHooks;
Expand Down Expand Up @@ -584,6 +588,42 @@ protected void actuallyHurt(DamageSource damageSrc, float damageAmount) {
}
}

@Nullable
@Override
public Entity changeDimension(ServerWorld pServer, ITeleporter teleporter) {
final int MAX_RETRY = 16;
if (this.level instanceof ServerWorld && this.isAlive()) {
for (int i = 0; i < MAX_RETRY; ++i) {
if (TeleportHelper.teleport(this)) {
this.addEffect(new EffectInstance(Effects.GLOWING, 200, 1, true, false));
}
}
}
return null;
}

@Override
public void onAddedToWorld() {
super.onAddedToWorld();
if (this.getOwnerUUID() != null) {
MaidWorldData data = MaidWorldData.get(this.level);
if (data != null) {
data.removeInfo(this);
}
}
}

@Override
public void onRemovedFromWorld() {
super.onRemovedFromWorld();
if (!this.level.isClientSide && this.getOwnerUUID() != null) {
MaidWorldData data = MaidWorldData.get(this.level);
if (data != null) {
data.addInfo(this);
}
}
}

@Override
public void die(DamageSource cause) {
if (!MinecraftForge.EVENT_BUS.post(new MaidDeathEvent(this, cause))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean isSeed(ItemStack stack) {

@Override
public boolean canHarvest(EntityMaid maid, BlockPos cropPos, BlockState cropState) {
return cropState.is(BlockTags.JUNGLE_LOGS) && cropState.getValue(CocoaBlock.AGE) >= 2;
return cropState.is(Blocks.COCOA) && cropState.getValue(CocoaBlock.AGE) >= 2;
}

@Override
Expand All @@ -74,7 +74,7 @@ public void harvest(EntityMaid maid, BlockPos cropPos, BlockState cropState) {
public boolean canPlant(EntityMaid maid, BlockPos basePos, BlockState baseState, ItemStack seed) {
basePos = basePos.above();
baseState = maid.level.getBlockState(basePos);
if (baseState.is(Blocks.JUNGLE_LOG) && seed.getItem() == Items.COCOA_BEANS) {
if (baseState.is(BlockTags.JUNGLE_LOGS) && seed.getItem() == Items.COCOA_BEANS) {
for (Direction direction : Direction.Plane.HORIZONTAL) {
BlockState state = maid.level.getBlockState(basePos.relative(direction));
if (state.getMaterial().isReplaceable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
import net.minecraft.entity.ai.goal.TemptGoal;
import net.minecraft.entity.monster.CreeperEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class EntityJoinWorldEvent {
public class ChangeEntityAiEvent {
@SubscribeEvent
public static void onCreeperJoinWorld(net.minecraftforge.event.entity.EntityJoinWorldEvent event) {
public static void onCreeperJoinWorld(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof CreeperEntity) {
CreeperEntity creeper = (CreeperEntity) event.getEntity();
creeper.goalSelector.addGoal(1, new AvoidEntityGoal<>(creeper, EntityMaid.class, 6, 1, 1.2));
}
}

@SubscribeEvent
public static void onAnimalJoinWorld(net.minecraftforge.event.entity.EntityJoinWorldEvent event) {
public static void onAnimalJoinWorld(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof AnimalEntity) {
AnimalEntity animal = (AnimalEntity) event.getEntity();
animal.goalSelector.availableGoals.stream().filter(goal -> goal.getGoal() instanceof TemptGoal).findFirst().ifPresent(g -> {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public final class InitItems {
public static RegistryObject<Item> MAID_BACKPACK_SMALL = ITEMS.register("maid_backpack_small", ItemMaidBackpack::new);
public static RegistryObject<Item> MAID_BACKPACK_MIDDLE = ITEMS.register("maid_backpack_middle", ItemMaidBackpack::new);
public static RegistryObject<Item> MAID_BACKPACK_BIG = ITEMS.register("maid_backpack_big", ItemMaidBackpack::new);
public static RegistryObject<Item> CRAFTING_TABLE_BACKPACK = ITEMS.register("crafting_table_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> ENDER_CHEST_BACKPACK = ITEMS.register("ender_chest_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> FURNACE_BACKPACK = ITEMS.register("furnace_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> CHAIR = ITEMS.register("chair", ItemChair::new);
public static RegistryObject<Item> HAKUREI_GOHEI = ITEMS.register("hakurei_gohei", ItemHakureiGohei::new);
public static RegistryObject<Item> MAID_BED = ITEMS.register("maid_bed", ItemMaidBed::new);
Expand Down Expand Up @@ -49,12 +52,9 @@ public final class InitItems {
public static RegistryObject<Item> MAID_BEACON = ITEMS.register("maid_beacon", ItemMaidBeacon::new);
public static RegistryObject<Item> MODEL_SWITCHER = ITEMS.register("model_switcher", ItemModelSwitcher::new);
public static RegistryObject<Item> CHAIR_SHOW = ITEMS.register("chair_show", ItemChairShow::new);
public static RegistryObject<Item> GOMOKU = ITEMS.register("gomoku", () -> new BlockItem(InitBlocks.GOMOKU.get(), new Item.Properties().tab(MAIN_TAB)));
public static RegistryObject<Item> RED_FOX_SCROLL = ITEMS.register("red_fox_scroll", ItemFoxScroll::new);
public static RegistryObject<Item> WHITE_FOX_SCROLL = ITEMS.register("white_fox_scroll", ItemFoxScroll::new);
public static RegistryObject<Item> CRAFTING_TABLE_BACKPACK = ITEMS.register("crafting_table_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> ENDER_CHEST_BACKPACK = ITEMS.register("ender_chest_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> FURNACE_BACKPACK = ITEMS.register("furnace_backpack", ItemMaidBackpack::new);
public static RegistryObject<Item> GOMOKU = ITEMS.register("gomoku", () -> new BlockItem(InitBlocks.GOMOKU.get(), new Item.Properties().tab(MAIN_TAB)));
public static RegistryObject<Item> KEYBOARD = ITEMS.register("keyboard", () -> new BlockItem(InitBlocks.KEYBOARD.get(), new Item.Properties().tab(MAIN_TAB)));
public static RegistryObject<Item> BOOKSHELF = ITEMS.register("bookshelf", () -> new BlockItem(InitBlocks.BOOKSHELF.get(), new Item.Properties().tab(MAIN_TAB)));
public static RegistryObject<Item> COMPUTER = ITEMS.register("computer", () -> new BlockItem(InitBlocks.COMPUTER.get(), new Item.Properties().tab(MAIN_TAB)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public MaidMainContainer(ContainerType<?> type, int id, PlayerInventory inventor
this.addMaidBauble();
this.addMaidHandInv();
this.addMainDefaultInv();
this.addMainDefaultInv();
this.addBackpackInv(inventory);
}
}
Expand Down
Loading

0 comments on commit 75d9521

Please sign in to comment.