Skip to content

Commit

Permalink
添加树脂块和强化树脂块及其相关制品的注册、方块模型、贴图、物品和掉落。但未添加合成表!
Browse files Browse the repository at this point in the history
修复了冶矿台和制冰机不能shift快速转移的bug
  • Loading branch information
Viola-Siemens committed Feb 14, 2023
1 parent 38a7e71 commit 4eca8b6
Show file tree
Hide file tree
Showing 57 changed files with 820 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.hexagram2021.emeraldcraft.common.register.ECBlocks;
import com.hexagram2021.emeraldcraft.common.register.ECItems;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.level.block.FireBlock;
import net.minecraft.world.level.block.*;

import java.util.Map;
import java.util.function.Supplier;

import static com.hexagram2021.emeraldcraft.common.util.RegistryHelper.getRegistryName;

public class ModVanillaCompat {
public static void setup() {
Expand Down Expand Up @@ -78,11 +78,25 @@ public static void setup() {
registerFlammable(ECBlocks.TO_STAIRS.get(ECBlocks.Plant.PEACH_PLANKS.getId()).get(), 5, 20);
registerFlammable(ECBlocks.TO_FENCE.get(ECBlocks.Plant.PEACH_PLANKS.getId()).get(), 5, 20);
registerFlammable(ECBlocks.TO_FENCE_GATE.get(ECBlocks.Plant.PEACH_PLANKS.getId()).get(), 5, 20);
registerFlammable(ECBlocks.Decoration.RESIN_BLOCK.get(), 5, 20);

registerFlowerPot(ECBlocks.Plant.CYAN_PETUNIA.get(), ECBlocks.Plant.POTTED_CYAN_PETUNIA::get);
registerFlowerPot(ECBlocks.Plant.MAGENTA_PETUNIA.get(), ECBlocks.Plant.POTTED_MAGENTA_PETUNIA::get);
registerFlowerPot(ECBlocks.Plant.HIGAN_BANA.get(), ECBlocks.Plant.POTTED_HIGAN_BANA::get);
registerFlowerPot(ECBlocks.Plant.GINKGO_SAPLING.get(), ECBlocks.Plant.POTTED_GINKGO_SAPLING::get);
registerFlowerPot(ECBlocks.Plant.PALM_SAPLING.get(), ECBlocks.Plant.POTTED_PALM_SAPLING::get);
registerFlowerPot(ECBlocks.Plant.PEACH_SAPLING.get(), ECBlocks.Plant.POTTED_PEACH_SAPLING::get);
registerFlowerPot(ECBlocks.Plant.PURPURACEUS_FUNGUS.get(), ECBlocks.Plant.POTTED_PURPURACEUS_FUNGUS::get);
registerFlowerPot(ECBlocks.Plant.PURPURACEUS_ROOTS.get(), ECBlocks.Plant.POTTED_PURPURACEUS_ROOTS::get);
}

private static final FireBlock fireblock = (FireBlock)Blocks.FIRE;

public static void registerFlammable(Block blockIn, int encouragement, int flammability) {
fireblock.setFlammable(blockIn, encouragement, flammability);
}

private static final FlowerPotBlock flowerpotblock = (FlowerPotBlock)Blocks.FLOWER_POT;
public static void registerFlowerPot(Block flower, Supplier<Block> pot) {
flowerpotblock.addPlant(getRegistryName(flower), pot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public IceMakerMenu(int id, Inventory inventory, Container container, ContainerD
checkContainerDataCount(data, DATA_COUNT);
this.iceMaker = container;
this.iceMakerData = data;
this.addSlot(new IceMakerMenu.IceMakerResultSlot(inventory.player, container, RESULT_SLOT, 134, 35));
this.ingredientInputSlot = this.addSlot(new Slot(container, INGREDIENT_INPUT_SLOT, 50, 18) {
@Override
public boolean mayPlace(@NotNull ItemStack itemStack) {
Expand Down Expand Up @@ -76,6 +75,7 @@ public int getMaxStackSize() {
return 1;
}
});
this.addSlot(new IceMakerMenu.IceMakerResultSlot(inventory.player, container, RESULT_SLOT, 134, 35));
this.addDataSlots(data);

for(int i = 0; i < 3; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public MineralTableMenu(int id, Inventory inventory, Container container, Contai
this.mineralTable = container;
this.mineralTableData = data;
this.level = inventory.player.level;
this.addSlot(new MineralTableMenu.MineralResultSlot(inventory.player, container, RESULT_SLOT, 79, 58));
this.ingredientSlot = this.addSlot(new MineralTableMenu.IngredientSlot(this, container, INGREDIENT_SLOT, 79, 17));
this.addSlot(new MineralTableMenu.FuelSlot(container, FUEL_SLOT, 17, 17));
this.addSlot(new MineralTableMenu.MineralResultSlot(inventory.player, container, RESULT_SLOT, 79, 58));
this.addDataSlots(data);

for(int i = 0; i < 3; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.hexagram2021.emeraldcraft.EmeraldCraft.MODID;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -238,6 +239,38 @@ private static <T extends Block> void registerSign(BlockEntry<T> fullBlock, Wood
)));
}

private static <T extends Block> void addColoredBlockToList(List<BlockEntry<?>> list, DyeColor color, BlockEntry<T> colorlessBlock,
Function<DyeColor, Supplier<BlockBehaviour.Properties>> properties,
Function<BlockBehaviour.Properties, T> factory) {
list.add(new BlockEntry<>(color.getName() + "_" + colorlessBlock.getId().getPath(), properties.apply(color), factory));
}

@SuppressWarnings("SameParameterValue")
private static <T extends Block> List<BlockEntry<?>> registerAllColors(BlockEntry<T> colorlessBlock,
Function<DyeColor, Supplier<BlockBehaviour.Properties>> properties,
Function<BlockBehaviour.Properties, T> factory) {
List<BlockEntry<?>> list = new ArrayList<>();
/* 不会吧,不会真有mod会添加或修改原版DyeColor吧,我怕了还不行吗 */
addColoredBlockToList(list, DyeColor.WHITE, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.ORANGE, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.MAGENTA, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.LIGHT_BLUE, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.YELLOW, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.LIME, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.PINK, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.GRAY, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.LIGHT_GRAY, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.CYAN, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.PURPLE, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.BLUE, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.BROWN, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.GREEN, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.RED, colorlessBlock, properties, factory);
addColoredBlockToList(list, DyeColor.BLACK, colorlessBlock, properties, factory);
TO_COLORS.put(colorlessBlock.getId(), list);
return list;
}

public static void init(IEventBus bus) {
REGISTER.register(bus);

Expand Down Expand Up @@ -290,6 +323,11 @@ public static void init(IEventBus bus) {
blockSign.getValue().getA().get(),
blockSign.getValue().getB().get()));
}
for(Map.Entry<ResourceLocation, List<BlockEntry<?>>> colorBlock: ECBlocks.TO_COLORS.entrySet()) {
for(BlockEntry<?> blockEntry: colorBlock.getValue()) {
ECItems.REGISTER.register(blockEntry.getId().getPath(), () -> new BlockItem(blockEntry.get(), new Item.Properties().tab(EmeraldCraft.ITEM_GROUP)));
}
}
}

public static final class MineralDecoration {
Expand Down Expand Up @@ -618,6 +656,17 @@ public static final class Decoration {
BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE)
.requiresCorrectToolForDrops().strength(1.5F, 6.0F);

public static final Supplier<BlockBehaviour.Properties> RESIN_PROPERTIES = () ->
BlockBehaviour.Properties.of(Material.DECORATION, MaterialColor.TERRACOTTA_YELLOW)
.strength(0.5F).sound(SoundType.FROGLIGHT);
public static final Supplier<BlockBehaviour.Properties> REINFORCED_RESIN_PROPERTIES = () ->
BlockBehaviour.Properties.of(Material.DECORATION, MaterialColor.TERRACOTTA_ORANGE)
.requiresCorrectToolForDrops().strength(30.0F, 600.0F).sound(SoundType.FROGLIGHT);

public static final Function<DyeColor, Supplier<BlockBehaviour.Properties>> COLORED_REINFORCED_RESIN_PROPERTIES = (color) ->
() -> BlockBehaviour.Properties.of(Material.DECORATION, color)
.requiresCorrectToolForDrops().strength(30.0F, 600.0F).sound(SoundType.FROGLIGHT);

public static final BlockEntry<Block> VITRIFIED_SAND = new BlockEntry<>(
"vitrified_sand", SANDSTONE_PROPERTIES, Block::new
);
Expand Down Expand Up @@ -710,6 +759,13 @@ public static final class Decoration {
"mossy_stone", STONE_PROPERTIES, Block::new
);

public static final BlockEntry<Block> RESIN_BLOCK = new BlockEntry<>(
"resin_block", RESIN_PROPERTIES, Block::new
);
public static final BlockEntry<Block> REINFORCED_RESIN_BLOCK = new BlockEntry<>(
"reinforced_resin_block", REINFORCED_RESIN_PROPERTIES, Block::new
);

private static void init() {
ECItems.REGISTER.register(VITRIFIED_SAND.getId().getPath(), () -> new BlockItem(VITRIFIED_SAND.get(), new Item.Properties().tab(EmeraldCraft.ITEM_GROUP)));

Expand Down Expand Up @@ -747,6 +803,8 @@ private static void init() {

ECItems.REGISTER.register(MOSSY_STONE.getId().getPath(), () -> new BlockItem(MOSSY_STONE.get(), new Item.Properties().tab(EmeraldCraft.ITEM_GROUP)));

ECItems.REGISTER.register(RESIN_BLOCK.getId().getPath(), () -> new BlockItem(RESIN_BLOCK.get(), new Item.Properties().tab(EmeraldCraft.ITEM_GROUP)));
ECItems.REGISTER.register(REINFORCED_RESIN_BLOCK.getId().getPath(), () -> new BlockItem(REINFORCED_RESIN_BLOCK.get(), new Item.Properties().tab(EmeraldCraft.ITEM_GROUP)));

registerStairs(Decoration.AZURE_SANDSTONE);
registerStairs(Decoration.QUARTZ_SANDSTONE);
Expand All @@ -765,6 +823,7 @@ private static void init() {
registerStairs(Decoration.WARPED_STONE);
registerStairs(Decoration.WARPED_COBBLESTONE);
registerStairs(Decoration.MOSSY_STONE);
registerStairs(Decoration.REINFORCED_RESIN_BLOCK);

registerSlab(Decoration.AZURE_SANDSTONE);
registerSlab(Decoration.QUARTZ_SANDSTONE);
Expand All @@ -788,6 +847,7 @@ private static void init() {
registerSlab(Decoration.WARPED_STONE);
registerSlab(Decoration.WARPED_COBBLESTONE);
registerSlab(Decoration.MOSSY_STONE);
registerSlab(Decoration.REINFORCED_RESIN_BLOCK);

registerWall(Decoration.AZURE_SANDSTONE);
registerWall(Decoration.QUARTZ_SANDSTONE);
Expand All @@ -800,6 +860,12 @@ private static void init() {
registerWall(Decoration.CRIMSON_COBBLESTONE);
registerWall(Decoration.WARPED_STONE);
registerWall(Decoration.WARPED_COBBLESTONE);
registerWall(Decoration.REINFORCED_RESIN_BLOCK);

List<ECBlocks.BlockEntry<?>> list = registerAllColors(Decoration.REINFORCED_RESIN_BLOCK, COLORED_REINFORCED_RESIN_PROPERTIES, Block::new);
list.forEach(ECBlocks::registerStairs);
list.forEach(ECBlocks::registerSlab);
list.forEach(ECBlocks::registerWall);
}
}

Expand Down Expand Up @@ -900,29 +966,25 @@ public static final class Plant {
"higan_bana", HIGAN_BANA_PROPERTIES, (props) -> new HiganBanaFlowerBlock(() -> MobEffects.LEVITATION, 12, props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_CYAN_PETUNIA = new BlockEntry<>(
"potted_cyan_petunia", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, CYAN_PETUNIA, props
)
"potted_cyan_petunia", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, CYAN_PETUNIA, props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_MAGENTA_PETUNIA = new BlockEntry<>(
"potted_magenta_petunia", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, MAGENTA_PETUNIA, props
)
"potted_magenta_petunia", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, MAGENTA_PETUNIA, props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_HIGAN_BANA = new BlockEntry<>(
"potted_higan_bana", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, HIGAN_BANA, props
)
"potted_higan_bana", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, HIGAN_BANA, props)
);

//GINKGO
public static final BlockEntry<SaplingBlock> GINKGO_SAPLING = new BlockEntry<>(
"ginkgo_sapling", SAPLING_PROPERTIES, (props) -> new SaplingBlock(new GinkgoTreeGrower(), props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_GINKGO_SAPLING = new BlockEntry<>(
"potted_ginkgo_sapling", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, GINKGO_SAPLING, props
)
"potted_ginkgo_sapling", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, GINKGO_SAPLING, props)
);
public static final BlockEntry<RotatedPillarBlock> GINKGO_LOG = new BlockEntry<>(
"ginkgo_log", GINKGO_LOG_PROPERTIES, RotatedPillarBlock::new
Expand All @@ -949,9 +1011,8 @@ public static final class Plant {
"palm_sapling", SAPLING_PROPERTIES, (props) -> new SaplingBlock(new PalmTreeGrower(), props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_PALM_SAPLING = new BlockEntry<>(
"potted_palm_sapling", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, PALM_SAPLING, props
)
"potted_palm_sapling", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, PALM_SAPLING, props)
);
public static final BlockEntry<RotatedPillarBlock> PALM_LOG = new BlockEntry<>(
"palm_log", PALM_LOG_PROPERTIES, RotatedPillarBlock::new
Expand All @@ -978,9 +1039,8 @@ public static final class Plant {
"peach_sapling", SAPLING_PROPERTIES, (props) -> new SaplingBlock(new PeachTreeGrower(), props)
);
public static final BlockEntry<FlowerPotBlock> POTTED_PEACH_SAPLING = new BlockEntry<>(
"potted_peach_sapling", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, PEACH_SAPLING, props
)
"potted_peach_sapling", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, PEACH_SAPLING, props)
);
public static final BlockEntry<RotatedPillarBlock> PEACH_LOG = new BlockEntry<>(
"peach_log", PEACH_LOG_PROPERTIES, RotatedPillarBlock::new
Expand Down Expand Up @@ -1009,9 +1069,8 @@ public static final class Plant {
(props) -> new FungusBlock(props, () -> ECConfiguredFeatures.TreeConfiguredFeatures.PURPURACEUS_FUNGUS_PLANTED)
);
public static final BlockEntry<FlowerPotBlock> POTTED_PURPURACEUS_FUNGUS = new BlockEntry<>(
"potted_purpuraceus_fungus", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, PURPURACEUS_FUNGUS, props
)
"potted_purpuraceus_fungus", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, PURPURACEUS_FUNGUS, props)
);
public static final BlockEntry<RotatedPillarBlock> PURPURACEUS_STEM = new BlockEntry<>(
"purpuraceus_stem", PURPURACEUS_STEM_PROPERTIES, RotatedPillarBlock::new
Expand Down Expand Up @@ -1047,9 +1106,8 @@ public static final class Plant {
RootsBlock::new
);
public static final BlockEntry<FlowerPotBlock> POTTED_PURPURACEUS_ROOTS = new BlockEntry<>(
"potted_purpuraceus_roots", POTTED_FLOWER_PROPERTIES, (props) -> new FlowerPotBlock(
null, PURPURACEUS_ROOTS, props
)
"potted_purpuraceus_roots", POTTED_FLOWER_PROPERTIES,
(props) -> new FlowerPotBlock(() -> (FlowerPotBlock)Blocks.FLOWER_POT, PURPURACEUS_ROOTS, props)
);


Expand Down Expand Up @@ -1138,6 +1196,7 @@ private static void init() {
public static final Map<ResourceLocation, BlockEntry<PressurePlateBlock>> TO_PRESSURE_PLATE = new HashMap<>();
public static final Map<ResourceLocation, BlockEntry<ButtonBlock>> TO_BUTTON = new HashMap<>();
public static final Map<ResourceLocation, Tuple<BlockEntry<StandingSignBlock>, BlockEntry<WallSignBlock>>> TO_SIGN = new HashMap<>();
public static final Map<ResourceLocation, List<BlockEntry<?>>> TO_COLORS = new HashMap<>();

public static final class BlockEntry<T extends Block> implements Supplier<T>, ItemLike {
private final RegistryObject<T> regObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
{
"variants": {
"": {
"model": "emeraldcraft:block/mossy_stone"
}
"": [
{
"model": "emeraldcraft:block/mossy_stone"
},
{
"model": "emeraldcraft:block/mossy_stone",
"y": 90
},
{
"model": "emeraldcraft:block/mossy_stone",
"y": 180
},
{
"model": "emeraldcraft:block/mossy_stone",
"y": 270
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "emeraldcraft:block/reinforced_resin_block"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"variants": {
"type=bottom": {
"model": "emeraldcraft:block/reinforced_resin_slab"
},
"type=double": {
"model": "emeraldcraft:block/reinforced_resin_slab_double"
},
"type=top": {
"model": "emeraldcraft:block/reinforced_resin_slab_top"
}
}
}
Loading

0 comments on commit 4eca8b6

Please sign in to comment.