Skip to content

Commit

Permalink
Support 1.17.*
Browse files Browse the repository at this point in the history
A new bug in Main.java: Line 83 to 110
  • Loading branch information
crazy-piggy committed Jul 15, 2021
1 parent bdae854 commit ff8537b
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 4 deletions.
39 changes: 38 additions & 1 deletion src/main/java/io/github/chemiscraft/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.item.*;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;

import static net.minecraft.block.FacingBlock.FACING;

public class Main implements ModInitializer {
public static final String MODID = "chemiscraft";
Expand Down Expand Up @@ -38,8 +47,8 @@ public class Main implements ModInitializer {
public static final Item HELIUM_9 = new Item (new Item.Settings().group(ELEMENT));
public static final Item HELIUM_10 = new Item (new Item.Settings().group(ELEMENT));
/*Block*/
public static final Block IRON_STAND = new Block(FabricBlockSettings.of(Material.METAL).hardness(0.0f));
public static final Block IRON_TRIVET = new Block(FabricBlockSettings.of(Material.METAL).hardness(0.0f));
private static final IronStand IRON_STAND = new IronStand(FabricBlockSettings.of(Material.METAL).hardness(0.0f));
@Override
public void onInitialize() {
/*Block*/
Expand Down Expand Up @@ -71,4 +80,32 @@ public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier(MODID, "helium_9"), HELIUM_9);
Registry.register(Registry.ITEM, new Identifier(MODID, "helium_10"), HELIUM_10);
}
//这里会崩
//我也不知道为啥
public static class IronStand extends Block {
public IronStand(Settings settings){
super(settings);
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(Properties.HORIZONTAL_FACING);
}

public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos) {
Direction dir = state.get(FACING);
return switch (dir) {
case NORTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
case SOUTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f);
case EAST -> VoxelShapes.cuboid(0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
case WEST -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 0.5f, 1.0f, 1.0f);
default -> VoxelShapes.fullCube();
};
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
return (BlockState)this.getDefaultState().with(FACING, ctx.getPlayerFacing());
}
}
//
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"variants": {
"": {
"model": "chemiscraft:block/iron_stand"
}
"facing=north": { "model": "chemiscraft:block/iron_stand" },
"facing=east": { "model": "chemiscraft:block/iron_stand", "y": 90},
"facing=south": { "model": "chemiscraft:block/iron_stand", "y": 180 },
"facing=west": { "model": "chemiscraft:block/iron_stand", "y": 270 }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "chemiscraft:block/iron_trivet"
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/chemiscraft/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"block.chemiscraft.iron_stand": "铁架台",
"block.chemiscraft.iron_trivet": "铁三脚架",

"item.chemiscraft.iron_stand_ring": "铁架台-铁圈",
"item.chemiscraft.iron_stand_base": "铁架台-底座",
Expand Down
Loading

0 comments on commit ff8537b

Please sign in to comment.