-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Added Villager Trades and basic movement #1263
Conversation
Fixed OutOfBound error in
Cool ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Problem is that Profession.class does not exist.
Also, please format your code:
- Remove the unused imports
- There should be space between expression tokens, e.g.
tick % (10 * 10) == 0
- There should be space between if/for/while, conditions and code blocks
- No empty lines at the start and the end of methods.
Anyway, thank you very much for your contribution to PNX!
pom.xml
Outdated
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.22</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to roll back the version from 1.18.24
to 1.18.22
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ did that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You dont
), | ||
Set.of( | ||
new Behavior(new FlatRandomRoamExecutor(0.4f, 12, 40, true, 100, true, 10), new PassByTimeEvaluator(CoreMemoryTypes.LAST_BE_ATTACKED_TIME, 0, 100), 4, 1), | ||
new Behavior(new EntityBreedingExecutor<>(EntityPig.class, 16, 100, 0.5f), entity -> entity.getMemoryStorage().get(CoreMemoryTypes.IS_IN_LOVE), 3, 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need EntityBreedingExecutor
with EntityPig.class
? Can we feed the villagers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh. I focused on the functionality. I probably missed that
new Behavior(new LookAtTargetExecutor(CoreMemoryTypes.NEAREST_PLAYER, 100), new ProbabilityEvaluator(4, 10), 1, 1, 100), | ||
new Behavior(new FlatRandomRoamExecutor(0.2f, 12, 100, false, -1, true, 10), (entity -> true), 1, 1) | ||
), | ||
Set.of(new NearestFeedingPlayerSensor(8, 0), new NearestPlayerSensor(8, 0, 20)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use NearestFeedingPlayerSensor, the Entity must extends EntityAnimal. However it's not the case for villager now.
this.setTradeSeed(new Random().nextInt(Integer.MAX_VALUE)); | ||
this.setProfession(profession.getIndex()); | ||
this.applyProfession(profession); | ||
BlockVector3 blockVector = block.getLocation().asBlockVector3(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using block.getFloorX/Y/Z instead.
if (id == profession.getBlockid()) { | ||
professionFound = true; | ||
if (this.profession != profession.getIndex()) { | ||
this.setTradeSeed(new Random().nextInt(Integer.MAX_VALUE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ThreadLocalRandom or NukkitRandom from the level of this villager instead, Random is globally synchronized and may block PNX, thereby affecting performance.
|
||
public static final int NETWORK_ID = 115; | ||
/** | ||
* 代表交易配方 | ||
*/ | ||
public final ListTag<Tag> recipes = new ListTag<>("Recipes"); | ||
@Getter | ||
public ListTag<Tag> recipes = new ListTag<>("Recipes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to protected
return new BehaviorGroup( | ||
this.tickSpread, | ||
Set.of( | ||
//用于刷新InLove状态的核心行为 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These behaviors do not match the villagers, please remove them
//todo:Growth rate | ||
all( | ||
new PassByTimeEvaluator(CoreMemoryTypes.ENTITY_SPAWN_TIME, 20 * 60 * 20, Integer.MAX_VALUE), | ||
entity -> entity instanceof EntityAnimal animal && animal.isBaby() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this
), | ||
Set.of( | ||
new Behavior(new FlatRandomRoamExecutor(0.4f, 12, 40, true, 100, true, 10), new PassByTimeEvaluator(CoreMemoryTypes.LAST_BE_ATTACKED_TIME, 0, 100), 4, 1), | ||
new Behavior(new EntityBreedingExecutor<>(EntityPig.class, 16, 100, 0.5f), entity -> entity.getMemoryStorage().get(CoreMemoryTypes.IS_IN_LOVE), 3, 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this
@@ -300,6 +306,24 @@ public void handle(@NotNull PlayerHandle playerHandle, @NotNull InventoryTransac | |||
} | |||
if (playerHandle.getTradingTransaction().canExecute()) { | |||
playerHandle.getTradingTransaction().execute(); | |||
|
|||
for(Inventory inventory : playerHandle.getTradingTransaction().getInventories()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest moving to TradeTransaction#execute
@Buddelbubi You did not commit cn.nukkit.entity.data.profession.Profession |
May I ask if you have time to resolve the problems in this PR recently? |
I already did. Did I miss some? |
thank you for your PR |
@@ -18,7 +18,7 @@ public interface ProtocolInfo { | |||
/** | |||
* Actual Minecraft: PE protocol version | |||
*/ | |||
int CURRENT_PROTOCOL = dynamic(589); | |||
int CURRENT_PROTOCOL = dynamic(594); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please wait #1312
Other than that, there are no issue |
Done |
No description provided.