forked from Anvil-Dev/AnvilCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Anvil-Dev#742 from dmzz-yyhyy/reinforced_concrete
添加钢筋混凝土
- Loading branch information
Showing
1,335 changed files
with
38,873 additions
and
25 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
common/src/main/java/dev/dubhe/anvilcraft/block/CementCauldronBlock.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,59 @@ | ||
package dev.dubhe.anvilcraft.block; | ||
|
||
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; | ||
import dev.dubhe.anvilcraft.block.state.Color; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.cauldron.CauldronInteraction; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.AbstractCauldronBlock; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.EnumProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CementCauldronBlock extends AbstractCauldronBlock implements IHammerRemovable { | ||
public static final EnumProperty<Color> COLOR = | ||
EnumProperty.create("color", Color.class); | ||
|
||
/** | ||
* @param properties 方块属性 | ||
*/ | ||
public CementCauldronBlock(Properties properties) { | ||
super(properties, CauldronInteraction.EMPTY); | ||
this.registerDefaultState( | ||
this.stateDefinition.any() | ||
.setValue(COLOR, Color.GRAY)); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition( | ||
@NotNull StateDefinition.Builder<Block, BlockState> builder) { | ||
builder.add(COLOR); | ||
} | ||
|
||
@Override | ||
protected double getContentHeight(@NotNull BlockState state) { | ||
return 0.9375; | ||
} | ||
|
||
@Override | ||
public boolean isFull(@NotNull BlockState state) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getAnalogOutputSignal(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos) { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public @NotNull ItemStack getCloneItemStack( | ||
@NotNull BlockGetter level, @NotNull BlockPos pos, @NotNull BlockState state | ||
) { | ||
return new ItemStack(Items.CAULDRON); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
common/src/main/java/dev/dubhe/anvilcraft/block/ReinforcedConcreteBlock.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,77 @@ | ||
package dev.dubhe.anvilcraft.block; | ||
|
||
import dev.dubhe.anvilcraft.block.state.Half; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.EnumProperty; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ReinforcedConcreteBlock extends Block { | ||
public static final EnumProperty<Half> HALF = EnumProperty.create("half", Half.class); | ||
|
||
/** | ||
* @param properties 方块属性 | ||
*/ | ||
public ReinforcedConcreteBlock(Properties properties) { | ||
super(properties); | ||
this.registerDefaultState( | ||
this.stateDefinition.any() | ||
.setValue(HALF, Half.MID)); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition( | ||
@NotNull StateDefinition.Builder<Block, BlockState> builder) { | ||
builder.add(HALF); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public void neighborChanged( | ||
@NotNull BlockState state, | ||
@NotNull Level level, | ||
@NotNull BlockPos pos, | ||
@NotNull Block neighborBlock, | ||
@NotNull BlockPos neighborPos, | ||
boolean movedByPiston | ||
) { | ||
if (level.isClientSide) return; | ||
if (neighborPos.getY() == pos.getY()) return; | ||
Half half = state.getValue(HALF); | ||
if (half != Half.MID) { | ||
if (half == Half.TOP && !level.getBlockState(pos.below()).is(this)) { | ||
level.setBlock(pos, state.setValue(HALF, Half.MID), 2); | ||
return; | ||
} | ||
if (half == Half.BOTTOM && !level.getBlockState(pos.above()).is(this)) { | ||
level.setBlock(pos, state.setValue(HALF, Half.MID), 2); | ||
} | ||
} else { | ||
if (level.getBlockState(pos.above()).is(this) | ||
&& level.getBlockState(pos.above()).getValue(HALF) == Half.MID) { | ||
level.setBlock(pos, state.setValue(HALF, Half.BOTTOM), 2); | ||
level.setBlock(pos.above(), state.setValue(HALF, Half.TOP), 2); | ||
return; | ||
} | ||
if (level.getBlockState(pos.below()).is(this) | ||
&& level.getBlockState(pos.below()).getValue(HALF) == Half.MID) { | ||
level.setBlock(pos, state.setValue(HALF, Half.TOP), 2); | ||
level.setBlock(pos.below(), state.setValue(HALF, Half.BOTTOM), 2); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void tick( | ||
@NotNull BlockState state, | ||
@NotNull ServerLevel level, | ||
@NotNull BlockPos pos, | ||
@NotNull RandomSource random) { | ||
super.tick(state, level, pos, random); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
common/src/main/java/dev/dubhe/anvilcraft/block/state/Color.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,38 @@ | ||
package dev.dubhe.anvilcraft.block.state; | ||
|
||
import net.minecraft.util.StringRepresentable; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public enum Color implements StringRepresentable { | ||
BLACK("black"), | ||
BLUE("blue"), | ||
BROWN("brown"), | ||
CYAN("cyan"), | ||
GRAY("gray"), | ||
GREEN("green"), | ||
LIGHT_BLUE("light_blue"), | ||
LIGHT_GRAY("light_gray"), | ||
LIME("lime"), | ||
MAGENTA("magenta"), | ||
ORANGE("orange"), | ||
PINK("pink"), | ||
PURPLE("purple"), | ||
RED("red"), | ||
WHITE("white"), | ||
YELLOW("yellow"); | ||
|
||
private final String name; | ||
|
||
Color(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String toString() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public @NotNull String getSerializedName() { | ||
return this.name; | ||
} | ||
} |
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.