-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fa1cb5
commit 35d38a7
Showing
52 changed files
with
1,401 additions
and
300 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
src/main/java/com/github/tartaricacid/touhoulittlemaid/api/backpack/IBackpackData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.api.backpack; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import net.minecraft.nbt.CompoundNBT; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.inventory.ContainerData; | ||
|
||
public interface IBackpackData { | ||
ContainerData getDataAccess(); | ||
|
||
void load(CompoundTag tag, EntityMaid maid); | ||
void load(CompoundNBT tag, EntityMaid maid); | ||
|
||
void save(CompoundTag tag, EntityMaid maid); | ||
void save(CompoundNBT tag, EntityMaid maid); | ||
|
||
void serverTick(EntityMaid maid); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ava/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidFindGomokuTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.block.BlockJoy; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityGomoku; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class MaidFindGomokuTask extends MaidMoveToBlockTask { | ||
public MaidFindGomokuTask(float movementSpeed, int searchLength) { | ||
super(movementSpeed, searchLength); | ||
} | ||
|
||
@Override | ||
protected boolean shouldMoveTo(ServerWorld worldIn, EntityMaid entityIn, BlockPos pos) { | ||
BlockState blockstate = worldIn.getBlockState(pos); | ||
return blockstate.getBlock() instanceof BlockJoy && !this.isOccupied(worldIn, pos); | ||
} | ||
|
||
@Override | ||
protected void start(ServerWorld worldIn, EntityMaid maid, long gameTimeIn) { | ||
if (maid.getVehicle() == null && !maid.isInSittingPose()) { | ||
this.searchForDestination(worldIn, maid); | ||
} | ||
} | ||
|
||
private boolean isOccupied(ServerWorld worldIn, BlockPos pos) { | ||
TileEntity te = worldIn.getBlockEntity(pos); | ||
if (te instanceof TileEntityGomoku) { | ||
TileEntityGomoku gomoku = (TileEntityGomoku) te; | ||
return worldIn.getEntity(gomoku.getSitId()) != null; | ||
} | ||
return true; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...n/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidFindJoyTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.block.BlockJoy; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityJoy; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class MaidFindJoyTask extends MaidMoveToBlockTask { | ||
public MaidFindJoyTask(float movementSpeed, int searchLength) { | ||
super(movementSpeed, searchLength); | ||
} | ||
|
||
@Override | ||
protected boolean shouldMoveTo(ServerWorld worldIn, EntityMaid entityIn, BlockPos pos) { | ||
BlockState blockstate = worldIn.getBlockState(pos); | ||
return blockstate.getBlock() instanceof BlockJoy && !this.isOccupied(worldIn, pos); | ||
} | ||
|
||
@Override | ||
protected void start(ServerWorld worldIn, EntityMaid maid, long gameTimeIn) { | ||
if (maid.getVehicle() == null && !maid.isInSittingPose()) { | ||
this.searchForDestination(worldIn, maid); | ||
} | ||
} | ||
|
||
private boolean isOccupied(ServerWorld worldIn, BlockPos pos) { | ||
TileEntity te = worldIn.getBlockEntity(pos); | ||
if (te instanceof TileEntityJoy) { | ||
TileEntityJoy joy = (TileEntityJoy) te; | ||
return worldIn.getEntity(joy.getSitId()) != null; | ||
} | ||
return true; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...in/java/com/github/tartaricacid/touhoulittlemaid/entity/ai/brain/task/MaidSitJoyTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.block.BlockJoy; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities; | ||
import com.github.tartaricacid.touhoulittlemaid.tileentity.TileEntityJoy; | ||
import com.google.common.collect.ImmutableMap; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.ai.brain.Brain; | ||
import net.minecraft.entity.ai.brain.memory.MemoryModuleStatus; | ||
import net.minecraft.entity.ai.brain.memory.MemoryModuleType; | ||
import net.minecraft.entity.ai.brain.memory.WalkTarget; | ||
import net.minecraft.entity.ai.brain.task.Task; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
import java.util.Optional; | ||
|
||
public class MaidSitJoyTask extends Task<EntityMaid> { | ||
private static final int CLOSED_DISTANCE = 2; | ||
|
||
public MaidSitJoyTask() { | ||
super(ImmutableMap.of(InitEntities.TARGET_POS.get(), MemoryModuleStatus.VALUE_PRESENT)); | ||
} | ||
|
||
@Override | ||
protected boolean checkExtraStartConditions(ServerWorld worldIn, EntityMaid owner) { | ||
Brain<EntityMaid> brain = owner.getBrain(); | ||
if (owner.getVehicle() != null && owner.isInSittingPose()) { | ||
brain.eraseMemory(MemoryModuleType.PATH); | ||
brain.eraseMemory(MemoryModuleType.WALK_TARGET); | ||
brain.eraseMemory(MemoryModuleType.LOOK_TARGET); | ||
return false; | ||
} | ||
return brain.getMemory(InitEntities.TARGET_POS.get()).map(targetPos -> { | ||
BlockPos blockPos = targetPos.currentBlockPosition(); | ||
if (!blockPos.closerThan(owner.blockPosition(), CLOSED_DISTANCE)) { | ||
Optional<WalkTarget> walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET); | ||
if (!walkTarget.isPresent() || !walkTarget.get().getTarget().currentBlockPosition().equals(blockPos)) { | ||
brain.eraseMemory(InitEntities.TARGET_POS.get()); | ||
} | ||
return false; | ||
} | ||
BlockState blockstate = worldIn.getBlockState(blockPos); | ||
return blockstate.getBlock() instanceof BlockJoy && !this.isOccupied(worldIn, blockPos); | ||
}).orElse(false); | ||
} | ||
|
||
@Override | ||
protected void start(ServerWorld worldIn, EntityMaid maid, long gameTimeIn) { | ||
maid.getBrain().getMemory(InitEntities.TARGET_POS.get()).ifPresent((targetPos) -> { | ||
BlockPos pos = targetPos.currentBlockPosition(); | ||
BlockState blockState = worldIn.getBlockState(pos); | ||
if (blockState.getBlock() instanceof BlockJoy) { | ||
BlockJoy blockJoy = (BlockJoy) blockState.getBlock(); | ||
blockJoy.startMaidSit(maid, blockState, worldIn, pos); | ||
maid.getBrain().eraseMemory(InitEntities.TARGET_POS.get()); | ||
maid.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET); | ||
maid.getBrain().eraseMemory(MemoryModuleType.LOOK_TARGET); | ||
} | ||
}); | ||
} | ||
|
||
private boolean isOccupied(ServerWorld worldIn, BlockPos pos) { | ||
TileEntity te = worldIn.getBlockEntity(pos); | ||
if (te instanceof TileEntityJoy) { | ||
TileEntityJoy joy = (TileEntityJoy) te; | ||
return worldIn.getEntity(joy.getSitId()) != null; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.