Class ConnectableLightTechBlock
java.lang.Object
net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.Block
etithespirit.orimod.common.block.light.connection.ConnectableLightTechBlock
- All Implemented Interfaces:
IBlockItemPropertiesProvider
,net.minecraft.world.level.block.EntityBlock
,net.minecraft.world.level.ItemLike
,net.minecraftforge.common.extensions.IForgeBlock
- Direct Known Subclasses:
LightCapacitorBlock
,LightConduitBlock
,SolidLightConduitBlock
public abstract class ConnectableLightTechBlock
extends net.minecraft.world.level.block.Block
implements net.minecraft.world.level.block.EntityBlock, IBlockItemPropertiesProvider
Defines a block that serves as a non-complex means of handling Light energy. This should strictly be
used when energy numbers are not a part of this block's function. It should instead be used when
this block provides a means of allowing
Blocks extending this class should always have a
ILightEnergyStorage
implementors
to communicate with one-another, for instance, by allowing two storage devices to transfer power through a pipeline.Blocks extending this class should always have a
TileEntity
associated with them, where
said tile extends AbstractLightEnergyLink
or AbstractLightEnergyHub
- Author:
- Eti
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.level.block.Block
net.minecraft.world.level.block.Block.BlockStatePairKey
Nested classes/interfaces inherited from class net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.state.BlockBehaviour.BlockStateBase, net.minecraft.world.level.block.state.BlockBehaviour.OffsetType, net.minecraft.world.level.block.state.BlockBehaviour.Properties, net.minecraft.world.level.block.state.BlockBehaviour.StateArgumentPredicate<A extends Object>, net.minecraft.world.level.block.state.BlockBehaviour.StatePredicate
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.world.level.block.state.properties.BooleanProperty
Whether or not this should automatically connect to neighboring instances ofConnectableLightTechBlock
static final net.minecraft.world.level.block.state.properties.BooleanProperty
Whether or not this is energized, which is not valid for use on Tile Entity providers implementingILightEnergyStorage
.Fields inherited from class net.minecraft.world.level.block.Block
BLOCK_STATE_REGISTRY, INDESTRUCTIBLE, INSTANT, stateDefinition, UPDATE_ALL, UPDATE_ALL_IMMEDIATE, UPDATE_CLIENTS, UPDATE_IMMEDIATE, UPDATE_INVISIBLE, UPDATE_KNOWN_SHAPE, UPDATE_LIMIT, UPDATE_MOVE_BY_PISTON, UPDATE_NEIGHBORS, UPDATE_NONE, UPDATE_SUPPRESS_DROPS, UPDATE_SUPPRESS_LIGHT
Fields inherited from class net.minecraft.world.level.block.state.BlockBehaviour
drops, dynamicShape, explosionResistance, friction, hasCollision, isRandomlyTicking, jumpFactor, material, properties, soundType, speedFactor, UPDATE_SHAPE_ORDER
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ConnectableLightTechBlock
(net.minecraft.world.level.block.state.BlockBehaviour.Properties props) Redirects to Block's ctor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if this block is set to always connect to any neighbor that is accepting connections in the appropriate direction.static boolean
alwaysConnectsWhenPossible
(net.minecraft.world.level.block.Block block) static boolean
alwaysConnectsWhenPossible
(net.minecraft.world.level.block.state.BlockState state) static void
autoRegisterDefaultState
(Consumer<net.minecraft.world.level.block.state.BlockState> initializer, net.minecraft.world.level.block.state.StateDefinition<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> stateContainer) Should be called in the block's constructorregisterDefaultState(this::registerDefaultState, this.stateDefinition)
.static void
autoRegisterDefaultState
(Consumer<net.minecraft.world.level.block.state.BlockState> initializer, net.minecraft.world.level.block.state.StateDefinition<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> stateContainer, Consumer<net.minecraft.world.level.block.state.BlockState> addAdditionalStates) Should be called in the block's constructorregisterDefaultState(this::registerDefaultState, this.stateDefinition)
.abstract void
connectionStateChanged
(net.minecraft.world.level.block.state.BlockState originalState, net.minecraft.world.level.block.state.BlockState newState) Executes when the connection state of this block changes, like when connecting to or disconnecting from a neighboringConnectableLightTechBlock
.static boolean
connectsAutomatically
(net.minecraft.world.level.block.state.BlockState state) void
createBlockStateDefinition
(net.minecraft.world.level.block.state.StateDefinition.Builder builder) When overriding, call super FIRST, then run your own code.static ConnectableLightTechBlock
from
(net.minecraft.world.level.block.Block block) If the givenBlock
is an instance ofConnectableLightTechBlock
, this will return Block as that type.static ConnectableLightTechBlock
from
(net.minecraft.world.level.block.state.BlockState state) If the givenBlockState
'sBlock
is an instance ofConnectableLightTechBlock
, this will return Block as that type.net.minecraft.world.item.Item.Properties
Returns the properties for this ItemBlock for use in forge registries.<T extends net.minecraft.world.level.block.entity.BlockEntity>
@Nullable net.minecraft.world.level.block.entity.BlockEntityTicker<T>getTicker
(net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.entity.BlockEntityType<T> type) static boolean
isConnectableBlock
(net.minecraft.world.level.block.Block block) static boolean
isConnectableBlock
(net.minecraft.world.level.block.state.BlockState state) static boolean
isConnectedTo
(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos from, net.minecraft.core.BlockPos to) Given the two block positions, which must be adjacent, this returns whether or not the two blocks are connected.void
neighborChanged
(net.minecraft.world.level.block.state.BlockState thisState, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos thisLocation, net.minecraft.world.level.block.Block replacedBlock, net.minecraft.core.BlockPos changedAt, boolean isMoving) static boolean
shouldBeUpdatedToConnectTo
(net.minecraft.world.level.BlockGetter world, net.minecraft.world.level.block.state.BlockState existingState, net.minecraft.world.level.block.state.BlockState newState, net.minecraft.core.Direction inDirection) Assuming thatnewState
was just placed in the world, and relative toexistingState
it is one block in the given direction, this method will observe the two states and determine if the existing state should be updated to connect to the new state.
The following are important to note: This assumes that the newly placed state has, prior to being placed (i.e.Methods inherited from class net.minecraft.world.level.block.Block
animateTick, appendHoverText, asBlock, asItem, box, builtInRegistryHolder, byItem, canSupportCenter, canSupportRigidBlock, canSustainPlant, defaultBlockState, destroy, dropFromExplosion, dropResources, dropResources, dropResources, dropResources, fallOn, fillItemCategory, getCloneItemStack, getDescriptionId, getDrops, getDrops, getExplosionResistance, getFriction, getId, getJumpFactor, getName, getRenderPropertiesInternal, getShapeForEachState, getSoundType, getSpeedFactor, getStateDefinition, getStateForPlacement, handlePrecipitation, hasDynamicShape, initializeClient, isExceptionForConnection, isFaceFull, isPossibleToRespawnInThis, isRandomlyTicking, isShapeFullBlock, playerDestroy, playerWillDestroy, popExperience, popResource, popResourceFromFace, propagatesSkylightDown, pushEntitiesUp, registerDefaultState, setPlacedBy, shouldRenderFace, spawnDestroyParticles, stateById, stepOn, toString, tryDropExperience, updateEntityAfterFallOn, updateFromNeighbourShapes, updateOrDestroy, updateOrDestroy, wasExploded, withPropertiesOf
Methods inherited from class net.minecraft.world.level.block.state.BlockBehaviour
attack, canBeReplaced, canBeReplaced, canSurvive, defaultDestroyTime, defaultMaterialColor, entityInside, getAnalogOutputSignal, getBlockSupportShape, getCollisionShape, getDestroyProgress, getDirectSignal, getDrops, getFluidState, getInteractionShape, getLightBlock, getLootTable, getMaxHorizontalOffset, getMaxVerticalOffset, getMenuProvider, getOcclusionShape, getPistonPushReaction, getRenderShape, getSeed, getShadeBrightness, getShape, getSignal, getVisualShape, hasAnalogOutputSignal, isAir, isCollisionShapeFullBlock, isOcclusionShapeFullBlock, isPathfindable, isSignalSource, mirror, onPlace, onProjectileHit, onRemove, randomTick, rotate, skipRendering, spawnAfterBreak, tick, triggerEvent, updateIndirectNeighbourShapes, updateShape, use, useShapeForLightOcclusion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.world.level.block.EntityBlock
getListener, newBlockEntity
Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlock
addLandingEffects, addRunningEffects, canBeHydrated, canConnectRedstone, canDropFromExplosion, canEntityDestroy, canHarvestBlock, canStickTo, collisionExtendsVertically, getAdjacentBlockPathType, getBeaconColorMultiplier, getBedDirection, getBlockPathType, getCloneItemStack, getEnchantPowerBonus, getExpDrop, getExplosionResistance, getFireSpreadSpeed, getFlammability, getFriction, getLightEmission, getMapColor, getRespawnPosition, getSoundType, getStateAtViewpoint, getToolModifiedState, getWeakChanges, hidesNeighborFace, isBed, isBurning, isConduitFrame, isFertile, isFireSource, isFlammable, isLadder, isPortalFrame, isScaffolding, isSlimeBlock, isStickyBlock, isValidSpawn, makesOpenTrapdoorAboveClimbable, onBlockExploded, onBlockStateChange, onCaughtFire, onDestroyedByPlayer, onNeighborChange, rotate, setBedOccupied, shouldCheckWeakPower, shouldDisplayFluidOverlay, supportsExternalFaceHiding
-
Field Details
-
AUTO
public static final net.minecraft.world.level.block.state.properties.BooleanProperty AUTOWhether or not this should automatically connect to neighboring instances ofConnectableLightTechBlock
-
ENERGIZED
public static final net.minecraft.world.level.block.state.properties.BooleanProperty ENERGIZEDWhether or not this is energized, which is not valid for use on Tile Entity providers implementingILightEnergyStorage
. Instead, this represents whether or not a passive Light-based block is handling Energy indirectly in some way, for instance, if a conduit is permitting transfer between two power sources.
-
-
Constructor Details
-
ConnectableLightTechBlock
protected ConnectableLightTechBlock(net.minecraft.world.level.block.state.BlockBehaviour.Properties props) Redirects to Block's ctor.- Parameters:
props
- The properties of this block.
-
-
Method Details
-
from
If the givenBlock
is an instance ofConnectableLightTechBlock
, this will return Block as that type. Otherwise, this returns null. This is comparable to the "as" keyword in C#.- Parameters:
block
- The block to test.- Returns:
- The given block as a
ConnectableLightTechBlock
if it is an instance, or null if it is not.
-
from
public static ConnectableLightTechBlock from(net.minecraft.world.level.block.state.BlockState state) If the givenBlockState
'sBlock
is an instance ofConnectableLightTechBlock
, this will return Block as that type. Otherwise, this returns null. This is comparable to the "as" keyword in C#.- Parameters:
state
- The block to test.- Returns:
- The given block as a
ConnectableLightTechBlock
if it is an instance, or null if it is not.
-
autoRegisterDefaultState
public static void autoRegisterDefaultState(Consumer<net.minecraft.world.level.block.state.BlockState> initializer, net.minecraft.world.level.block.state.StateDefinition<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> stateContainer) Should be called in the block's constructorregisterDefaultState(this::registerDefaultState, this.stateDefinition)
. This will automatically populate the default states.- Parameters:
initializer
- The method that initializes the validBlockState
sstateContainer
- TheStateDefinition
that houses the possibleBlockState
s.
-
autoRegisterDefaultState
public static void autoRegisterDefaultState(Consumer<net.minecraft.world.level.block.state.BlockState> initializer, net.minecraft.world.level.block.state.StateDefinition<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> stateContainer, Consumer<net.minecraft.world.level.block.state.BlockState> addAdditionalStates) Should be called in the block's constructorregisterDefaultState(this::registerDefaultState, this.stateDefinition)
. This will automatically populate the default states.- Parameters:
initializer
- The method that initializes the validBlockState
sstateContainer
- TheStateDefinition
that houses the possibleBlockState
s.addAdditionalStates
- A callback that can be used to add extra states on top of the defaults.
-
isConnectableBlock
public static boolean isConnectableBlock(net.minecraft.world.level.block.state.BlockState state) - Parameters:
state
- The state of a block to test.- Returns:
- whether or not the given
BlockState
is an instance ofConnectableLightTechBlock
-
isConnectableBlock
public static boolean isConnectableBlock(net.minecraft.world.level.block.Block block) - Parameters:
block
- The block to test.- Returns:
- whether or not the given
Block
is an instance ofConnectableLightTechBlock
-
createBlockStateDefinition
public void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder builder) When overriding, call super FIRST, then run your own code.- Overrides:
createBlockStateDefinition
in classnet.minecraft.world.level.block.Block
- Parameters:
builder
- The builder that assembles the validBlockState
s
-
neighborChanged
public void neighborChanged(net.minecraft.world.level.block.state.BlockState thisState, net.minecraft.world.level.Level world, net.minecraft.core.BlockPos thisLocation, net.minecraft.world.level.block.Block replacedBlock, net.minecraft.core.BlockPos changedAt, boolean isMoving) - Overrides:
neighborChanged
in classnet.minecraft.world.level.block.state.BlockBehaviour
-
connectionStateChanged
public abstract void connectionStateChanged(net.minecraft.world.level.block.state.BlockState originalState, net.minecraft.world.level.block.state.BlockState newState) Executes when the connection state of this block changes, like when connecting to or disconnecting from a neighboringConnectableLightTechBlock
.- Parameters:
originalState
- The original state of this block prior to the connection changing.newState
- The new state of this block after the connection changed.
-
alwaysConnectsWhenPossible
public boolean alwaysConnectsWhenPossible()Tests if this block is set to always connect to any neighbor that is accepting connections in the appropriate direction. This is used for blocks like the Light Capacitor, which cannot have any given face turned on or off - under all circumstances, if something is connected to the face of a capacitor, then that connection is live.
To name an example, if a conduit and a capacitor are next to eachother, then whether or not they are connected is only dependent on the conduit - the capacitor always connects, so the conduit is the only remaining thing that would be conditional.
Note: When this is true, all six cardinal states as well as the automatic connection state are not meaningful, that is, it should be treated as if all seven of those states are true no matter what.- Returns:
- Whether or not this block can auto-connect to neighbors regardless of the cardinal
BooleanProperty
values / automatic state this block has.
-
alwaysConnectsWhenPossible
public static boolean alwaysConnectsWhenPossible(net.minecraft.world.level.block.Block block) - Parameters:
block
- TheBlock
to test.- Returns:
- The result of
alwaysConnectsWhenPossible()
when called on the given block. If the block is not an instance ofConnectableLightTechBlock
then this will return false.
-
alwaysConnectsWhenPossible
public static boolean alwaysConnectsWhenPossible(net.minecraft.world.level.block.state.BlockState state) - Parameters:
state
- TheBlockState
containing theBlock
to test.- Returns:
- Whether or not the given block can auto-connect to neighbors regardless of the cardinal
BooleanProperty
values it has.
-
connectsAutomatically
public static boolean connectsAutomatically(net.minecraft.world.level.block.state.BlockState state) - Parameters:
state
- TheBlockState
to test.- Returns:
- Whether or not the given state has its value for
AUTO
set.
-
isConnectedTo
public static boolean isConnectedTo(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos from, net.minecraft.core.BlockPos to) throws IllegalArgumentException Given the two block positions, which must be adjacent, this returns whether or not the two blocks are connected.- Parameters:
world
- The world to read from.from
- The origin block's position.to
- The destination block's position.- Returns:
- True if the two blocks are both adjacent, and if both blocks either have the applicable cardinal states set and/or always connect in the given direction.
- Throws:
IllegalArgumentException
- If the two positions do not represent the positions ofConnectableLightTechBlock
s.
-
shouldBeUpdatedToConnectTo
public static boolean shouldBeUpdatedToConnectTo(net.minecraft.world.level.BlockGetter world, net.minecraft.world.level.block.state.BlockState existingState, net.minecraft.world.level.block.state.BlockState newState, net.minecraft.core.Direction inDirection) throws IllegalArgumentException Assuming thatnewState
was just placed in the world, and relative toexistingState
it is one block in the given direction, this method will observe the two states and determine if the existing state should be updated to connect to the new state.
The following are important to note:- This assumes that the newly placed state has, prior to being placed (i.e. in
Block.getStateForPlacement(BlockPlaceContext)
), set its state to connect to this existing block. - This returns false if the existing state is already connected in the given direction (and thus, no update is necessary).
- Parameters:
world
- The world this change occurred in.existingState
- The connectable tech block that was already in the world.newState
- The connectable tech block that was just placed in the world (and resulted in this method being called)inDirection
- The new state exists in this direction one block away from the existing state.- Returns:
- Whether or not the existing state should be updated to connect to the new state.
- Throws:
IllegalArgumentException
- If the either one or both of the two states are not instances ofConnectableLightTechBlock
.
- This assumes that the newly placed state has, prior to being placed (i.e. in
-
getTicker
@Nullable public <T extends net.minecraft.world.level.block.entity.BlockEntity> @Nullable net.minecraft.world.level.block.entity.BlockEntityTicker<T> getTicker(net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.block.entity.BlockEntityType<T> type) - Specified by:
getTicker
in interfacenet.minecraft.world.level.block.EntityBlock
-
getPropertiesOfItem
public net.minecraft.world.item.Item.Properties getPropertiesOfItem()Description copied from interface:IBlockItemPropertiesProvider
Returns the properties for this ItemBlock for use in forge registries.- Specified by:
getPropertiesOfItem
in interfaceIBlockItemPropertiesProvider
- Returns:
- The properties for this ItemBlock.
-