-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e6f57e
commit df46013
Showing
23 changed files
with
457 additions
and
11 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
51 changes: 51 additions & 0 deletions
51
src/main/java/net/zepalesque/redux/block/dungeon/DoorwayPillarBlock.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,51 @@ | ||
package net.zepalesque.redux.block.dungeon; | ||
|
||
import com.aetherteam.aether.block.dungeon.DoorwayBlock; | ||
import com.aetherteam.aether.block.dungeon.TrappedBlock; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Rotation; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.EnumProperty; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class DoorwayPillarBlock extends DoorwayBlock { | ||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS; | ||
|
||
public DoorwayPillarBlock(Supplier<EntityType<?>> blockedEntityTypeSupplier, Properties properties) { | ||
super(blockedEntityTypeSupplier, properties); | ||
this.registerDefaultState(this.defaultBlockState().setValue(AXIS, Direction.Axis.Y)); | ||
} | ||
|
||
@Override | ||
public BlockState rotate(BlockState state, Rotation rot) { | ||
return rotatePillar(state, rot); | ||
} | ||
|
||
public static BlockState rotatePillar(BlockState state, Rotation rotation) { | ||
return switch (rotation) { | ||
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.getValue(AXIS)) { | ||
case X -> state.setValue(AXIS, Direction.Axis.Z); | ||
case Z -> state.setValue(AXIS, Direction.Axis.X); | ||
default -> state; | ||
}; | ||
default -> state; | ||
}; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
super.createBlockStateDefinition(builder); | ||
builder.add(AXIS); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext context) { | ||
return this.defaultBlockState().setValue(AXIS, context.getClickedFace().getAxis()); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/net/zepalesque/redux/block/dungeon/TrappedPillarBlock.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,50 @@ | ||
package net.zepalesque.redux.block.dungeon; | ||
|
||
import com.aetherteam.aether.block.dungeon.TrappedBlock; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Rotation; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.EnumProperty; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class TrappedPillarBlock extends TrappedBlock { | ||
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS; | ||
|
||
public TrappedPillarBlock(Supplier<EntityType<?>> spawnableEntityTypeSupplier, Supplier<? extends BlockState> defaultStateSupplier, Properties properties) { | ||
super(spawnableEntityTypeSupplier, defaultStateSupplier, properties); | ||
this.registerDefaultState(this.getStateDefinition().any().setValue(AXIS, Direction.Axis.Y)); | ||
} | ||
|
||
@Override | ||
public BlockState rotate(BlockState state, Rotation rot) { | ||
return rotatePillar(state, rot); | ||
} | ||
|
||
public static BlockState rotatePillar(BlockState state, Rotation rotation) { | ||
return switch (rotation) { | ||
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.getValue(AXIS)) { | ||
case X -> state.setValue(AXIS, Direction.Axis.Z); | ||
case Z -> state.setValue(AXIS, Direction.Axis.X); | ||
default -> state; | ||
}; | ||
default -> state; | ||
}; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
super.createBlockStateDefinition(builder); | ||
builder.add(AXIS); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext context) { | ||
return this.defaultBlockState().setValue(AXIS, context.getClickedFace().getAxis()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/net/zepalesque/redux/block/state/ReduxBlockBuilders.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,25 @@ | ||
package net.zepalesque.redux.block.state; | ||
|
||
import com.google.common.base.Supplier; | ||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.neoforged.neoforge.registries.DeferredBlock; | ||
import net.zepalesque.redux.block.ReduxBlocks; | ||
import net.zepalesque.redux.item.ReduxItems; | ||
|
||
import java.util.function.Function; | ||
|
||
public class ReduxBlockBuilders { | ||
|
||
|
||
protected static <T extends Block> DeferredBlock<T> register(final String name, final Supplier<? extends T> block, Function<DeferredBlock<T>, Supplier<? extends Item>> item) { | ||
DeferredBlock<T> obj = ReduxBlocks.BLOCKS.register(name, block); | ||
ReduxItems.ITEMS.register(name, item.apply(obj)); | ||
return obj; | ||
} | ||
|
||
public static <T extends Block> DeferredBlock<T> register(final String name, final Supplier<? extends T> block) { | ||
return register(name, block, object -> () -> new BlockItem(object.get(), new Item.Properties())); | ||
} | ||
} |
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
Oops, something went wrong.