-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix loader metadata
- Loading branch information
Showing
11 changed files
with
50 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
platform/forge/src/main/java/mcp/mobius/waila/forge/ForgeServerCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mcp.mobius.waila.forge; | ||
|
||
import mcp.mobius.waila.command.ServerCommand; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraftforge.common.capabilities.ForgeCapabilities; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ForgeServerCommand extends ServerCommand { | ||
|
||
@Override | ||
protected @Nullable String fillContainer(ServerLevel world, BlockPos pos, ServerPlayer player) { | ||
var be = world.getBlockEntity(pos); | ||
if (be == null) return "No BlockEntity at " + pos.toShortString(); | ||
var handler = be.getCapability(ForgeCapabilities.ITEM_HANDLER, null).resolve().orElse(null); | ||
if (handler == null) return "No storage at " + pos.toShortString(); | ||
var offHandStack = player.getOffhandItem(); | ||
|
||
var size = handler.getSlots(); | ||
for (var i = 0; i < size; i++) { | ||
var item = !offHandStack.isEmpty() | ||
? offHandStack.getItem() | ||
: BuiltInRegistries.ITEM.getRandom(world.random).orElseThrow().value(); | ||
|
||
handler.insertItem(i, new ItemStack(item, item.getDefaultMaxStackSize()), false); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters