Skip to content

Commit

Permalink
Version Bump for new config setup
Browse files Browse the repository at this point in the history
Items only combine within half a block of eachother
Items only combine if they will not be above their maximum stack size
Zombie and Skeleton's visually pick up items now
  • Loading branch information
jasonw4331 committed May 26, 2019
1 parent e434e4b commit 634cdf8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: VanillaEntityAI
main: jasonwynn10\VanillaEntityAI\EntityAI
version: 0.0.1
version: 1.0.0
api:
- 3.0.0
description: "A plugin for vanilla-like mob AI"
author: "jasonwynn10"
load: STARTUP
softdepend:
- PureEntitiesX
- PureEntitiesX
2 changes: 1 addition & 1 deletion src/jasonwynn10/VanillaEntityAI/EntityAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function getRegionalDifficulty(Level $level, Chunk $chunk): float {
}
$phaseTime = $level->getTime() / Level::TIME_FULL;
while($phaseTime > 5)
$phaseTime -= 5; // TODO: better method
$phaseTime -= 5; // TODO: find better method
$moonPhase = 1.0;
switch($phaseTime) {
case 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ protected function checkNearEntities() {
continue;
}
$entity->scheduleUpdate();
if($entity instanceof Collidable) {
if($entity instanceof Collidable and $this instanceof Collidable) {
if($this->getBoundingBox()->intersectsWith($entity->getBoundingBox())) {
$entity->push($this->getBoundingBox());
}
$entity->onCollideWithEntity($this);
$this->onCollideWithEntity($entity);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/jasonwynn10/VanillaEntityAI/entity/hostile/Skeleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public static function spawnFromSpawner(Position $spawnPos, ?CompoundTag $spawnD
}

public function onCollideWithEntity(Entity $entity) : void {
// TODO: Implement onCollideWithEntity() method.
if($entity instanceof \jasonwynn10\VanillaEntityAI\entity\neutral\Item) {
if($entity->getPickupDelay() > 0 or !$this instanceof InventoryHolder or $this->level->getDifficulty() <= Level::DIFFICULTY_EASY) {
return;
Expand All @@ -222,7 +221,7 @@ public function onCollideWithEntity(Entity $entity) : void {
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->target = $this->getId();
$pk->target = $entity->getId();
$this->server->broadcastPacket($this->getViewers(), $pk);
$this->setDropAll();
$this->setPersistence(true);
Expand Down
2 changes: 1 addition & 1 deletion src/jasonwynn10/VanillaEntityAI/entity/hostile/Zombie.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function onCollideWithEntity(Entity $entity) : void {
}
$pk = new TakeItemEntityPacket();
$pk->eid = $this->getId();
$pk->target = $this->getId();
$pk->target = $entity->getId();
$this->server->broadcastPacket($this->getViewers(), $pk);
$this->setDropAll();
$this->setPersistence(true);
Expand Down
6 changes: 3 additions & 3 deletions src/jasonwynn10/VanillaEntityAI/entity/neutral/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Item extends ItemEntity implements Collidable {
use CollisionCheckingTrait;

public function entityBaseTick(int $tickDiff = 1) : bool {
foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(1.5,1.5,1.5), $this) as $entity) {
if($this->pickupDelay === 0 and $entity instanceof Item and $entity->onGround and $this->motion->equals($entity->getMotion()) and $this->item->equals($entity->getItem())) {
$this->item->setCount($this->item->getCount() + $entity->getItem()->getCount());
foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(0.5,0.5,0.5), $this) as $entity) {
if($this->pickupDelay === 0 and $entity instanceof Item and $entity->onGround and $this->motion->equals($entity->getMotion()) and $this->item->equals($entity->getItem()) and ($count = $this->item->getCount() + $entity->getItem()->getCount()) <= $this->item->getMaxStackSize()) {
$this->item->setCount($count);
$entity->flagForDespawn();
foreach($this->getViewers() as $player)
$this->sendSpawnPacket($player);
Expand Down

0 comments on commit 634cdf8

Please sign in to comment.