Skip to content

Commit

Permalink
Merge pull request #626 from zyxkad/dev/1.20.1
Browse files Browse the repository at this point in the history
Merge dev/1.19.2 into dev/1.20.1
  • Loading branch information
SirEndii authored Jun 3, 2024
2 parents 741ee23 + b28b7b4 commit e6ea969
Show file tree
Hide file tree
Showing 26 changed files with 504 additions and 158 deletions.
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ body:
multiple: false
options:
- Own compiled build.
- 1.20.1-0.7.39r (Latest 1.20.1)
- 1.20.1-0.7.39r (Latest 1.20.1)
- 1.20.1-0.7.38r
- 1.20.1-0.7.37r
- 1.20.1-0.7.36r
- 1.19.2-0.7.35r (Latest 1.19.2)
- 1.20.1-0.7.36r

- 1.19.2-0.7.35r (Latest 1.19.2)
- 1.19.2-0.7.34r
- 1.19.2-0.7.33r
- 1.19.2-0.7.32r
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ will close pull requests related to translations.
<!----------------------------------------------------------------------------->

[Documentation]: https://advancedperipherals.madefor.cc/
[Contributors]: https://github.com/Seniorendi/AdvancedPeripherals/graphs/contributors
[Contributors]: https://github.com/IntelligenceModding/AdvancedPeripherals/graphs/contributors
[CurseForge]: https://www.curseforge.com/minecraft/mc-mods/advanced-peripherals
[Actions]: https://github.com/Seniorendi/AdvancedPeripherals/actions
[Actions]: https://github.com/IntelligenceModding/AdvancedPeripherals/actions
[Crowdin]: https://crowdin.com/project/advanced-peripherals
[Discord]: https://discord.intelligence-modding.de
[Banner]: https://www.bisecthosting.com/images/CF/Advanced_Peripherals/BH_AP_Header.png 'Advanced Peripherals'
Expand All @@ -77,7 +77,7 @@ will close pull requests related to translations.

[@FatalMerlin]: https://github.com/FatalMerlin
[@SirEdvin]: https://github.com/SirEdvin
[@Srendi]: https://github.com/Seniorendi
[@Srendi]: https://github.com/IntelligenceModding
[@Olfi01]: https://github.com/Olfi01

[License]: LICENSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ public static long getTotalItemStorage(IGridNode node) {
net.minecraft.world.level.Level level = bus.getLevel();
BlockPos connectedInventoryPos = bus.getHost().getBlockEntity().getBlockPos().relative(bus.getSide());
BlockEntity connectedInventoryEntity = level.getBlockEntity(connectedInventoryPos);
if (connectedInventoryEntity == null)
continue;

LazyOptional<IItemHandler> itemHandler = connectedInventoryEntity.getCapability(ForgeCapabilities.ITEM_HANDLER);
if (itemHandler.isPresent()) {
Expand Down Expand Up @@ -410,6 +412,8 @@ public static long getTotalFluidStorage(IGridNode node) {
net.minecraft.world.level.Level level = bus.getLevel();
BlockPos connectedInventoryPos = bus.getHost().getBlockEntity().getBlockPos().relative(bus.getSide());
BlockEntity connectedInventoryEntity = level.getBlockEntity(connectedInventoryPos);
if (connectedInventoryEntity == null)
continue;

LazyOptional<IFluidHandler> fluidHandler = connectedInventoryEntity.getCapability(ForgeCapabilities.FLUID_HANDLER);
if (fluidHandler.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dan200.computercraft.api.lua.LuaFunction;
import de.srendi.advancedperipherals.lib.peripherals.APGenericPeripheral;
import vazkii.botania.api.block_entity.GeneratingFlowerBlockEntity;
import vazkii.botania.common.block.BotaniaBlocks;

public class ManaFlowerIntegration implements APGenericPeripheral {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.NoteBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import org.jetbrains.annotations.NotNull;

public class NoteBlockIntegration extends BlockIntegrationPeripheral<NoteBlock> {
Expand Down Expand Up @@ -50,6 +51,7 @@ public final int getNote() {
public final void playNote() {
if (world.isEmptyBlock(pos.above())) {
world.blockEvent(pos, getBlock(), 0, 0);
world.gameEvent(null, GameEvent.NOTE_BLOCK_PLAY, pos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum SingleOperation implements IPeripheralOperation<SingleOperationConte
SUCK(1000, 1),
USE_ON_ANIMAL(2500, 10),
CAPTURE_ANIMAL(50_000, 100),
WARP(1000, DistancePolicy.IGNORED, CountPolicy.MULTIPLY, 1, DistancePolicy.SQRT, CountPolicy.MULTIPLY);
WARP(1000, DistancePolicy.IGNORED, CountPolicy.MULTIPLY, 1, DistancePolicy.SQRT, CountPolicy.MULTIPLY),
ACCURE_PLACE(1000, DistancePolicy.IGNORED, CountPolicy.MULTIPLY, 1, DistancePolicy.LINEAR, CountPolicy.MULTIPLY);

private final int defaultCooldown;
private final DistancePolicy distanceCooldownPolicy;
Expand Down Expand Up @@ -74,6 +75,7 @@ public void addToConfig(ForgeConfigSpec.Builder builder) {

public enum DistancePolicy {
IGNORED(d -> 1),
LINEAR(d -> d),
SQRT(d -> (int) Math.sqrt(d));

private final Function<Integer, Integer> factorFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ public Direction getFacing() {
return turtle.getDirection();
}

/**
* Not used for turtles
*/
@NotNull
@Override
public FrontAndTop getOrientation() {
return FrontAndTop.NORTH_UP;
return FrontAndTop.fromFrontAndTop(getFacing(), Direction.UP);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import de.srendi.advancedperipherals.common.configuration.APConfig;
import de.srendi.advancedperipherals.common.events.Events;
import de.srendi.advancedperipherals.common.util.CoordUtil;
import de.srendi.advancedperipherals.common.util.StringUtil;
import de.srendi.advancedperipherals.lib.peripherals.BasePeripheral;
import de.srendi.advancedperipherals.lib.peripherals.IPeripheralFunction;
import de.srendi.advancedperipherals.network.APNetworking;
Expand Down Expand Up @@ -110,8 +111,7 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th
return withChatOperation(ignored -> {
String message = arguments.getString(0);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(4, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(4, -1);
ResourceKey<Level> dimension = getLevel().dimension();
MutableComponent component = Component.Serializer.fromJson(message);
if (component == null)
Expand All @@ -121,14 +121,14 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(2, "[]"),
arguments.optString(3, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(3, ""))
).append(component);
for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) {
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
}
return MethodResult.of(true);
Expand All @@ -140,21 +140,20 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE
return withChatOperation(ignored -> {
String message = arguments.getString(0);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(4, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(4, -1);
ResourceKey<Level> dimension = getLevel().dimension();
if (checkBrackets(arguments.optString(2)))
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(1, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(2, "[]"),
arguments.optString(3, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(3, ""))
).append(message);
for (ServerPlayer player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) {
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
}
return MethodResult.of(true);
Expand All @@ -167,8 +166,7 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum
String message = arguments.getString(0);
String playerName = arguments.getString(1);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(5, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(5, -1);
ResourceKey<Level> dimension = getLevel().dimension();
ServerPlayer player = getPlayer(playerName);
if (player == null)
Expand All @@ -182,14 +180,14 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(3, "[]"),
arguments.optString(4, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(4, ""))
).append(component);
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage);
return MethodResult.of(true);
});
Expand All @@ -203,8 +201,7 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen
String title = arguments.getString(1);
String playerName = arguments.getString(2);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(6, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(6, -1);
ResourceKey<Level> dimension = getLevel().dimension();
ServerPlayer player = getPlayer(playerName);
if (player == null)
Expand All @@ -222,15 +219,15 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ,,,)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(4, "[]"),
arguments.optString(5, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(5, ""))
).append(messageComponent);

if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
ToastToClientPacket packet = new ToastToClientPacket(titleComponent, preparedMessage);
APNetworking.sendTo(packet, player);
}
Expand All @@ -245,8 +242,7 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr
String message = arguments.getString(0);
String playerName = arguments.getString(1);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(5, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(5, -1);
ResourceKey<Level> dimension = getLevel().dimension();
ServerPlayer player = getPlayer(playerName);
if (player == null)
Expand All @@ -256,14 +252,14 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(2, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(3, "[]"),
arguments.optString(4, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(4, ""))
).append(message);
if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange))
player.sendSystemMessage(preparedMessage, false);
return MethodResult.of(true);
});
Expand All @@ -276,8 +272,7 @@ public final MethodResult sendToastToPlayer(@NotNull IArguments arguments) throw
String title = arguments.getString(1);
String playerName = arguments.getString(2);
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
int range = arguments.optInt(6, maxRange);
range = maxRange == -1 ? range : Math.min(range, APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get());
int range = arguments.optInt(6, -1);
ResourceKey<Level> dimension = getLevel().dimension();
ServerPlayer player = getPlayer(playerName);
if (player == null)
Expand All @@ -287,15 +282,15 @@ public final MethodResult sendToastToPlayer(@NotNull IArguments arguments) throw
return MethodResult.of(null, "incorrect bracket string (e.g. [], {}, <>, ...)");

MutableComponent preparedMessage = appendPrefix(
arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get()).replaceAll("&", "\u00a7"),
StringUtil.convertAndToSectionMark(arguments.optString(3, APConfig.PERIPHERALS_CONFIG.defaultChatBoxPrefix.get())),
arguments.optString(4, "[]"),
arguments.optString(5, "").replaceAll("&", "\u00a7")
StringUtil.convertAndToSectionMark(arguments.optString(5, ""))
).append(message);

if (!APConfig.PERIPHERALS_CONFIG.chatBoxMultiDimensional.get() && player.level().dimension() != dimension)
return MethodResult.of(false, "NOT_SAME_DIMENSION");

if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, maxRange)) {
ToastToClientPacket packet = new ToastToClientPacket(Component.literal(title), preparedMessage);
APNetworking.sendTo(packet, player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ public class CompassPeripheral extends BasePeripheral<TurtlePeripheralOwner> {

public static final String PERIPHERAL_TYPE = "compass";

protected CompassPeripheral(TurtlePeripheralOwner owner) {
super(PERIPHERAL_TYPE, owner);
}

public CompassPeripheral(ITurtleAccess turtle, TurtleSide side) {
super(PERIPHERAL_TYPE, new TurtlePeripheralOwner(turtle, side));
this(new TurtlePeripheralOwner(turtle, side));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final List<String> getPlayersInRange(int range) {
for (ServerPlayer player : getPlayers()) {
if (!isAllowedMultiDimensional() && player.level().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE))
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE))
playersName.add(player.getName().getString());
}
return playersName;
Expand Down Expand Up @@ -142,7 +142,7 @@ public final boolean isPlayersInRange(int range) {
for (ServerPlayer player : getPlayers()) {
if (!isAllowedMultiDimensional() && player.level().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) return true;
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) return true;
}
return false;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public final boolean isPlayerInRange(int range, String username) {
for (Player player : getPlayers()) {
if (!isAllowedMultiDimensional() && player.level().dimension() != dimension)
continue;
if (range == -1 || CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) {
if (CoordUtil.isInRange(getPos(), getLevel(), player, range, MAX_RANGE)) {
if(player.getName().getString().equals(username))
return true;
}
Expand Down
Loading

0 comments on commit e6ea969

Please sign in to comment.