Skip to content
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.19.2-0.7.37r] - 2024-10-06

### Added
- Wandering Trader config

### Changed
- Safe the owner of the memory card to the inventory manager after a player places the card into the manager and clear the card after. Resolves a security issue where players could eventually steal memory cards from other players

### Fixed
- [#660] Fixed that the inventory manager's `getItemInHand` function adds a blank nbt tag to the item
- [#636] Fixed that the automata's `useOnBlock` function will return PASS in some specific case
- [#645] Fixed that the inventory functions for the powah integration would always return nil
- Fixed that some entity operations don't have enough range

## [1.19.2-0.7.36r] - 2024-06-11

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ public static List<Object> listCells(IGridNode node) {
if (!iterator.hasNext()) return items;
while (iterator.hasNext()) {
IStorageProvider entity = iterator.next().getService(IStorageProvider.class);
if (entity == null || !(entity instanceof DriveBlockEntity drive))
if (!(entity instanceof DriveBlockEntity drive))
continue;

InternalInventory inventory = drive.getInternalInventory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public final MethodResult useOnAnimal(@NotNull IArguments arguments) throws LuaE
if (automataCore.hasAttribute(AutomataCorePeripheral.ATTR_STORING_TOOL_DURABILITY))
selectedTool.setDamageValue(previousDamageValue);

return MethodResult.of(true, result.toString());
return MethodResult.of(result.consumesAction(), result.toString());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final MethodResult feedSoul() {

InteractionResult result = owner.withPlayer(APFakePlayer::useOnEntity);
automataCore.addRotationCycle(3);
return MethodResult.of(true, result.toString());
return MethodResult.of(result.consumesAction(), result.toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn

@Override
public void setItem(int index, @NotNull ItemStack stack) {
if (stack.getItem() instanceof MemoryCardItem && stack.hasTag() && stack.getTag().contains("ownerId")) {
UUID owner = stack.getTag().getUUID("ownerId");
this.owner = owner;
stack.getTag().remove("ownerId");
stack.getTag().remove("owner");
if (stack.getItem() instanceof MemoryCardItem) {
if (stack.hasTag() && stack.getTag().contains("ownerId")) {
UUID owner = stack.getTag().getUUID("ownerId");
this.owner = owner;
stack.getTag().remove("ownerId");
stack.getTag().remove("owner");
} else if (stack != this.getItem(index)) {
// Only clear owner when the new card item is not the current item
this.owner = null;
}
} else {
this.owner = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Function;
import java.util.function.Predicate;
Expand Down Expand Up @@ -92,7 +91,6 @@ public boolean canAttack(@NotNull LivingEntity livingEntity) {
public void openTextEdit(@NotNull SignBlockEntity sign) {
}


@Override
public boolean isSilent() {
return true;
Expand Down Expand Up @@ -318,46 +316,59 @@ public HitResult findHit(boolean skipEntity, boolean skipBlock, @Nullable Predic
if (skipEntity)
return blockHit;

List<Entity> entities = level.getEntities(this, getBoundingBox().expandTowards(look.x * range, look.y * range, look.z * range).inflate(1, 1, 1), collidablePredicate);
List<Entity> entities = level.getEntities(this, getBoundingBox().expandTowards(look.x * range, look.y * range, look.z * range).inflate(1), collidablePredicate);

LivingEntity closestEntity = null;
Vec3 closestVec = null;
double closestDistance = range;
double closestDistance = blockHit.getType() == HitResult.Type.MISS ? range * range : distanceToSqr(blockHit.getLocation());
for (Entity entityHit : entities) {
if (!(entityHit instanceof LivingEntity) || entityFilter != null && !entityFilter.test(entityHit))
if (!(entityHit instanceof LivingEntity entity)) {
continue;
}
// TODO: maybe let entityFilter returns the priority of the entity, instead of only returns the closest one.
if (entityFilter != null && !entityFilter.test(entity)) {
continue;
}

// Removed a lot logic here to make Automata cores interact like a player.
// However, the results for some edge cases may change. Need more review and tests.

// Hit vehicle before passenger
if (entity.isPassenger()) {
continue;
// Add litter bigger that just pick radius
AABB box = entityHit.getBoundingBox().inflate(entityHit.getPickRadius() + 0.5);
Optional<Vec3> clipResult = box.clip(origin, target);
}

AABB box = entity.getBoundingBox();
Vec3 clipVec;
if (box.contains(origin)) {
if (closestDistance >= 0.0D) {
closestEntity = (LivingEntity) entityHit;
closestVec = clipResult.orElse(origin);
closestDistance = 0.0D;
clipVec = origin;
} else {
clipVec = box.clip(origin, target).orElse(null);
if (clipVec == null) {
continue;
}
} else if (clipResult.isPresent()) {
Vec3 clipVec = clipResult.get();
double distance = origin.distanceTo(clipVec);

if (distance < closestDistance || closestDistance == 0.0D) {
if (entityHit == entityHit.getRootVehicle() && !entityHit.canRiderInteract()) {
if (closestDistance == 0.0D) {
closestEntity = (LivingEntity) entityHit;
closestVec = clipVec;
}
} else {
closestEntity = (LivingEntity) entityHit;
closestVec = clipVec;
closestDistance = distance;
}
}
double distance = origin.distanceToSqr(clipVec);
// Ignore small enough distance
if (distance <= 1e-6) {
distance = 0;
}
if (distance > closestDistance) {
continue;
}
if (distance == closestDistance && closestEntity != null) {
// Hit larger entity before smaller
if (closestEntity.getBoundingBox().getSize() >= box.getSize()) {
continue;
}
}
closestEntity = entity;
closestVec = clipVec;
closestDistance = distance;
}
if (closestEntity != null && closestDistance <= range && (blockHit.getType() == HitResult.Type.MISS || distanceToSqr(blockHit.getLocation()) > closestDistance * closestDistance)) {
if (closestEntity != null) {
return new EntityHitResult(closestEntity, closestVec);
} else {
return blockHit;
}
return blockHit;
}
}
Loading