Class PartTypeBase<P extends IPartType<P,S>,S extends IPartState<P>>
java.lang.Object
org.cyclops.integrateddynamics.api.part.PartTypeAdapter<P,S>
org.cyclops.integrateddynamics.core.part.PartTypeBase<P,S>
- All Implemented Interfaces:
INetworkEventListener<IPartNetworkElement<P,,S>> IPartType<P,S>
- Direct Known Subclasses:
PartTypeConfigurable,PartTypeConnector,PartTypePanel
public abstract class PartTypeBase<P extends IPartType<P,S>,S extends IPartState<P>>
extends PartTypeAdapter<P,S>
An abstract
IPartType with a default implementation for creating
network elements.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacePartTypeBase.IEventAction<P extends IPartType<P,S>, S extends IPartState<P>, E extends INetworkEvent> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrops(PartTarget target, S state, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Add the itemstacks to drop when this element is removed.protected Map<Class<? extends INetworkEvent>,PartTypeBase.IEventAction> Override this to register your network event actions.protected net.minecraft.world.level.block.BlockcreateBlock(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig) Factory method for creating a block instance.protected net.minecraft.world.item.ItemcreateItem(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig, net.minecraft.world.level.block.Block block) Factory method for creating a item instance.createNetworkElement(IPartContainer partContainer, org.cyclops.cyclopscore.datastructure.DimPos pos, net.minecraft.core.Direction side) Create a network element for this part type.protected StringbooleanforceLightTransparency(S state) net.minecraft.world.level.block.state.BlockStatenet.minecraft.resources.ResourceLocationnet.minecraft.world.level.block.state.BlockStategetBlockState(IPartContainer partContainer, net.minecraft.core.Direction side) Get the base block state that will be rendered for this part.protected org.cyclops.cyclopscore.init.ModBasegetMod()protected StringgetModId()final Set<Class<? extends INetworkEvent>>net.minecraft.resources.ResourceLocationfinal booleanvoidloadTooltip(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.network.chat.Component> lines) Add tooltip lines for this aspect when this part's item is being hovered.voidloadTooltip(S state, List<net.minecraft.network.chat.Component> lines) Add tooltip lines for this aspect when this part is being hovered by a mod like WAILA.final voidonEvent(INetworkEvent event, IPartNetworkElement<P, S> networkElement) Can be called at any time by theINetworkEventBus.net.minecraft.world.InteractionResultonPartActivated(S partState, net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack heldItem, net.minecraft.world.phys.BlockHitResult hit) Called when a part is right-clicked.protected voidCreates and registers a block instance for this part type.voidwriteExtraGuiData(net.minecraft.network.FriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player) This method can be overridden for cases when additional data needs to be sent to clients when opening containers.Methods inherited from class org.cyclops.integrateddynamics.api.part.PartTypeAdapter
afterNetworkAlive, afterNetworkReAlive, beforeNetworkKill, constructDefaultState, defaultBlockState, fromNBT, getChannel, getCloneItemStack, getConsumptionRate, getItemStack, getMinimumUpdateInterval, getPriority, getState, getTarget, getTargetOffset, getTargetSideOverride, getTranslationKey, getUpdateInterval, hasOffsetVariables, isEnabled, isSolid, isUpdate, onBlockNeighborChange, onNetworkAddition, onNetworkRemoval, onOffsetVariablesChanged, onPostRemoved, onPreRemoved, postUpdate, setEnabled, setPriorityAndChannel, setTargetOffset, setTargetSideOverride, setUpdateInterval, shouldTriggerBlockRenderUpdate, toNBT, update, updateTickMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.integrateddynamics.api.part.IPartType
getContainerProvider, getContainerProviderOffsets, getContainerProviderSettings, getItem, getPartRenderPosition, supportsOffsets, writeExtraGuiDataOffsets, writeExtraGuiDataSettings
-
Constructor Details
-
PartTypeBase
-
-
Method Details
-
getUniqueName
public net.minecraft.resources.ResourceLocation getUniqueName()- Returns:
- The unique name for this part type.
-
getMod
protected org.cyclops.cyclopscore.init.ModBase getMod() -
getModId
-
registerBlock
protected void registerBlock()Creates and registers a block instance for this part type. This is mainly used for the block model. -
createBlock
protected net.minecraft.world.level.block.Block createBlock(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig) Factory method for creating a block instance.- Parameters:
blockConfig- The config to register the block for.- Returns:
- The block instance.
-
createItem
protected net.minecraft.world.item.Item createItem(org.cyclops.cyclopscore.config.extendedconfig.BlockConfig blockConfig, net.minecraft.world.level.block.Block block) Factory method for creating a item instance.- Parameters:
blockConfig- The block config to register the item for.block- The block corresponding to the item.- Returns:
- The item instance.
-
getBlockModelPath
public net.minecraft.resources.ResourceLocation getBlockModelPath()- Returns:
- JSON model path for the block representation of this part.
-
createTranslationKey
- Specified by:
createTranslationKeyin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>>
-
createNetworkElement
public INetworkElement createNetworkElement(IPartContainer partContainer, org.cyclops.cyclopscore.datastructure.DimPos pos, net.minecraft.core.Direction side) Description copied from interface:IPartTypeCreate a network element for this part type.- Parameters:
partContainer- The container this part is/will be part of.pos- The position this network element is/will be placed at.side- The side this network element is/will be placed at.- Returns:
- A new network element instance.
-
onPartActivated
public net.minecraft.world.InteractionResult onPartActivated(S partState, net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack heldItem, net.minecraft.world.phys.BlockHitResult hit) Description copied from interface:IPartTypeCalled when a part is right-clicked.- Specified by:
onPartActivatedin interfaceIPartType<P extends IPartType<P,S>, S extends IPartState<P>> - Overrides:
onPartActivatedin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Parameters:
partState- The state of this part.pos- The position of the block this part is part of.world- The world.player- The player activating the part.hand- The hand in use by the player.heldItem- The held item.hit- The ray trace hit result.- Returns:
- The action result.
-
addDrops
public void addDrops(PartTarget target, S state, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Description copied from interface:IPartTypeAdd the itemstacks to drop when this element is removed.- Specified by:
addDropsin interfaceIPartType<P extends IPartType<P,S>, S extends IPartState<P>> - Overrides:
addDropsin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Parameters:
target- The target.state- The stateitemStacks- The itemstack list to add to.dropMainElement- If the part itself should also be dropped.saveState- If the part state should be saved in the item.
-
getBlockState
public net.minecraft.world.level.block.state.BlockState getBlockState(IPartContainer partContainer, net.minecraft.core.Direction side) Description copied from interface:IPartTypeGet the base block state that will be rendered for this part. An appropriateIgnoredBlock.FACINGproperty will be set.- Parameters:
partContainer- The part entity.side- The position of the part.- Returns:
- The block state to render with.
-
getBaseBlockState
public net.minecraft.world.level.block.state.BlockState getBaseBlockState()- Returns:
- The default block state representation of this part.
-
loadTooltip
Description copied from interface:IPartTypeAdd tooltip lines for this aspect when this part is being hovered by a mod like WAILA.- Specified by:
loadTooltipin interfaceIPartType<P extends IPartType<P,S>, S extends IPartState<P>> - Overrides:
loadTooltipin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Parameters:
state- The state.lines- The list to add lines to.
-
loadTooltip
public void loadTooltip(net.minecraft.world.item.ItemStack itemStack, List<net.minecraft.network.chat.Component> lines) Description copied from interface:IPartTypeAdd tooltip lines for this aspect when this part's item is being hovered.- Specified by:
loadTooltipin interfaceIPartType<P extends IPartType<P,S>, S extends IPartState<P>> - Overrides:
loadTooltipin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Parameters:
itemStack- The itemstack.lines- The list to add lines to.
-
constructNetworkEventActions
protected Map<Class<? extends INetworkEvent>,PartTypeBase.IEventAction> constructNetworkEventActions()Override this to register your network event actions.- Returns:
- The event actions.
-
hasEventSubscriptions
public final boolean hasEventSubscriptions()- Specified by:
hasEventSubscriptionsin interfaceINetworkEventListener<P extends IPartType<P,S>> - Overrides:
hasEventSubscriptionsin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Returns:
- If this should be registered to the network event bus for listening to network events.
-
getSubscribedEvents
- Specified by:
getSubscribedEventsin interfaceINetworkEventListener<P extends IPartType<P,S>> - Overrides:
getSubscribedEventsin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Returns:
- The static set of events this listener should be subscribed to.
-
onEvent
Description copied from interface:INetworkEventListenerCan be called at any time by theINetworkEventBus. Only events in the set fromINetworkEventListener.getSubscribedEvents()will be received.- Specified by:
onEventin interfaceINetworkEventListener<P extends IPartType<P,S>> - Overrides:
onEventin classPartTypeAdapter<P extends IPartType<P,S>, S extends IPartState<P>> - Parameters:
event- The received event.networkElement- The network element.
-
forceLightTransparency
- Parameters:
state- The state.- Returns:
- If this part should force the block to be transparent to light.
-
writeExtraGuiData
public void writeExtraGuiData(net.minecraft.network.FriendlyByteBuf packetBuffer, PartPos pos, net.minecraft.server.level.ServerPlayer player) Description copied from interface:IPartTypeThis method can be overridden for cases when additional data needs to be sent to clients when opening containers.- Parameters:
packetBuffer- A packet buffer that can be written to.pos- A part position.player- The player opening the gui.
-