Class CraftingHandler
java.lang.Object
com.hammy275.immersivemc.common.immersive.handler.ItemWorldStorageHandler<CraftingTableStorage>
com.hammy275.immersivemc.common.immersive.handler.CraftingHandler
- All Implemented Interfaces:
ImmersiveHandler<CraftingTableStorage>, WorldStorageHandler<CraftingTableStorage>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanenabledInConfig(net.minecraft.world.entity.player.Player player) net.minecraft.resources.IdentifiergetID()Class<? extends WorldStorage> static booleanisCraftingTableBlock(net.minecraft.world.level.block.Block block) booleanisValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) makeInventoryContents(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos) Creates inventory contents on the server to send to clients.voidswap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer player, ItemSwapAmount amount) Swaps an item from a player's hand into this immersive (and/or vice-versa).voidupdateStorageOutputAfterItemReturn(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, ItemStorage storage) Methods inherited from class ItemWorldStorageHandler
isDirtyForClientSync, onStopTrackingMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WorldStorageHandler
clientAuthoritative
-
Constructor Details
-
CraftingHandler
public CraftingHandler()
-
-
Method Details
-
makeInventoryContents
public CraftingTableStorage makeInventoryContents(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos) Description copied from interface:ImmersiveHandlerCreates inventory contents on the server to send to clients.- Parameters:
player- Player being sent to.pos- Position of the block being sent about.- Returns:
- A NetworkStorage to be sent over the network.
-
getEmptyNetworkStorage
- Returns:
- A new instance of the same type of NetworkStorage as made with makeInventoryContents(), but in an empty state for purposes such as being decoded into by the client.
-
swap
public void swap(int slot, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.server.level.ServerPlayer player, ItemSwapAmount amount) Description copied from interface:ImmersiveHandlerSwaps an item from a player's hand into this immersive (and/or vice-versa).- Parameters:
slot- Slot being swapped with in this immersive.hand- Player's hand being swapped with.pos- Position of block being swapped with.player- Player who is swapping.amount- An object representing the amount of items to swap. UseItemSwapAmount.getNumItemsToSwap(), passing in the item stack size of the item in the player's hand to get the amount of items to swap.
-
isValidBlock
public boolean isValidBlock(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level level) - Parameters:
pos- Position to check.level- The level being checked in.- Returns:
- Whether the supplied block matches what this handler handles.
-
enabledInConfig
public boolean enabledInConfig(net.minecraft.world.entity.player.Player player) - Parameters:
player- The player we're checking the config of.- Returns:
- Whether the immersive this handler handles is enabled. If you do not have a configuration system, this should always return true.
-
getID
public net.minecraft.resources.Identifier getID()- Returns:
- A unique ID to identify this handler. The same value should always be returned by this method.
-
getEmptyWorldStorage
- Returns:
- An empty WorldStorage to load from NBT in.
-
getWorldStorageClass
- Returns:
- The class this handler's world storage uses.
-
updateStorageOutputAfterItemReturn
public void updateStorageOutputAfterItemReturn(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, ItemStorage storage) - Overrides:
updateStorageOutputAfterItemReturnin classItemWorldStorageHandler<CraftingTableStorage>
-
isCraftingTableBlock
public static boolean isCraftingTableBlock(net.minecraft.world.level.block.Block block)
-