Mob Grinding Utils

Mob Grinding Utils

57M Downloads

XP Tap crash when activated on a block's "disabled" face (Industrial Foregoing)

andrewsf opened this issue ยท 0 comments

commented

Description

XP Tap causes a crash when it is turned on while attached to a liquid-holding block that has a "disabled" face. I tested with:

  • Pity Black Hole Tank
  • Mob Crusher

Mod version

0.4.44

Minecraft version

1.18.2

Steps to reproduce

  • Place a Pity Black Hole Tank
  • In the block's configuration, mark all faces as "Disabled"
  • Attach an XP Tap to the side
  • Activate the XP Tap

image
image

(Putting fluid into the tank, as in the screenshots, is optional.)

Problem

The offending code is here:

if (handler.getFluidInTank(0).getAmount() >= 20 && handler.getFluidInTank(0).getFluid().is(MobGrindingUtils.EXPERIENCE) && world.getGameTime() % 3 == 0) {

Solution

You need to check handler.isEmpty() or handler.getTanks() > 0 before calling handler.getFluidInTank(0).

Crash stack trace

Description: Ticking block entity

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100) ~[?:?] {}
	at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) ~[?:?] {}
	at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) ~[?:?] {}
	at java.util.Objects.checkIndex(Objects.java:359) ~[?:?] {re:mixin}
	at java.util.ArrayList.get(ArrayList.java:427) ~[?:?] {re:mixin}
	at com.hrznstudio.titanium.component.fluid.MultiTankComponent$MultiTankCapabilityHandler.getFluidInTank(MultiTankComponent.java:149) ~[titanium-1.18.2-3.5.6-38.jar%23249!/:3.5.6] {re:classloading}
	at mob_grinding_utils.tile.TileEntityXPTap.lambda$serverTick$0(TileEntityXPTap.java:35) ~[mob_grinding_utils-1.18.2-0.4.44.jar%23184!/:1.18.2-0.4.44] {re:classloading}
	at net.minecraftforge.common.util.LazyOptional.ifPresent(LazyOptional.java:150) ~[forge-1.18.2-40.1.74-universal.jar%23266!/:?] {re:mixin,re:classloading}
	at mob_grinding_utils.tile.TileEntityXPTap.serverTick(TileEntityXPTap.java:34) ~[mob_grinding_utils-1.18.2-0.4.44.jar%23184!/:1.18.2-0.4.44] {re:classloading}
	at net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity.m_142224_(LevelChunk.java:673) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper.m_142224_(LevelChunk.java:766) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.Level.redirect$zmf000$redirectTick(Level.java:1600) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:LevelMixin,pl:mixin:APP:observable.common.json:LevelMixin,pl:mixin:A}
	at net.minecraft.world.level.Level.m_46463_(Level.java:476) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:kubejs-common.mixins.json:LevelMixin,pl:mixin:APP:observable.common.json:LevelMixin,pl:mixin:A}
	at net.minecraft.server.level.ServerLevel.m_8793_(ServerLevel.java:327) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:botania_xplat.mixins.json:MixinServerLevel,pl:mixin:APP:immersiveengineering.mixins.json:coremods.ServerWorldMixin,pl:mixin:APP:observable.common.json:ServerLevelMixin,pl:mixin:APP:create.mixins.json:accessor.ServerLevelAccessor,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_5703_(MinecraftServer.java:902) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:842) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.client.server.IntegratedServer.m_5705_(IntegratedServer.java:84) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:685) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:261) ~[client-1.18.2-20220404.173914-srg.jar%23261!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin}