Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-nuclearcrackhead239 committed Dec 18, 2024
2 parents 75d0243 + d043b1d commit 3f30e38
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.nuclearcrackhead.serverboss;

import com.nuclearcrackhead.serverboss.registry.ModBlockRenderMap;
import com.nuclearcrackhead.serverboss.registry.ModBlocks;
import com.nuclearcrackhead.serverboss.registry.ModBlockEntityTypes;
import com.nuclearcrackhead.serverboss.registry.ModEntityRenderers;
import com.nuclearcrackhead.serverboss.registry.ModItemGroups;
import com.nuclearcrackhead.serverboss.registry.*;
import com.nuclearcrackhead.serverboss.content.block.SpikeBlockEntityRenderer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
Expand Down Expand Up @@ -40,6 +36,7 @@ public void onInitializeClient() {
ModItemGroups.init();
ModBlockRenderMap.init();
ModEntityRenderers.init();
ModColorProviders.init();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nuclearcrackhead.serverboss.registry;

import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.block.BlockState;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.item.BlockItem;
import net.minecraft.registry.Registries;

public class ModColorProviders {

public static void init() {
//blocks
ColorProviderRegistry.BLOCK.register(
(state, view, pos, tintIndex) -> view != null && pos != null ? -14647248 : -9321636,
ModBlocks.WATER_SILK
);

//items
ColorProviderRegistry.ITEM.register(
(stack, tintIndex) -> {
BlockState blockState = ((BlockItem)stack.getItem()).getBlock().getDefaultState();
BlockColorProvider blockColorProvider = (BlockColorProvider) ColorProviderRegistry.BLOCK.get(blockState.getBlock());
return blockColorProvider == null ? -1 : blockColorProvider.getColor(blockState, null, null, tintIndex);
},
ModItems.WATER_SILK
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class ModItemGroups {
entries.add(ModBlocks.PORTAL_GLASS_TRANSPARENT);
entries.add(ModBlocks.VOID_LAMP);
entries.add(ModBlocks.SMOOTH_STONE_STAIRS);
entries.add(ModItems.WATER_SILK);
})
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ public WaterSilk(AbstractBlock.Settings settings) {
super(settings);
}

protected void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
if (world instanceof ServerWorld && entity instanceof AbstractBoatEntity) {
world.breakBlock(new BlockPos(pos), true, entity);
}

}

protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ public static void init() {}
public static final Block VOID_LAMP = register("void_lamp", Block::new,
AbstractBlock.Settings.create().emissiveLighting(ModBlocks::always).luminance(value -> 15).sounds(BlockSoundGroup.STONE)
);
public static final Block WATER_SILK = register("water_silk", WaterSilk::new, AbstractBlock.Settings.create().replaceable().noCollision().mapColor(MapColor.DARK_GREEN).breakInstantly().sounds(BlockSoundGroup.LILY_PAD).nonOpaque().pistonBehavior(PistonBehavior.DESTROY));
public static final Block WATER_SILK = registerBlock("water_silk", WaterSilk::new, AbstractBlock.Settings.create().replaceable().noCollision().mapColor(MapColor.DARK_GREEN).breakInstantly().sounds(BlockSoundGroup.LILY_PAD).nonOpaque().pistonBehavior(PistonBehavior.DESTROY));

public static final Block SMOOTH_STONE_STAIRS = register("smooth_stone_stairs", settings -> new StairsBlock(Blocks.SMOOTH_STONE.getDefaultState(), settings),
AbstractBlock.Settings.copy(Blocks.SMOOTH_STONE)
);

public static Block register(String path, Function<AbstractBlock.Settings, Block> function, AbstractBlock.Settings settings) {
Identifier id = SVBCR.of(path);
RegistryKey<Block> blockKey = RegistryKey.of(RegistryKeys.BLOCK, id);
settings.registryKey(blockKey);
Block block = Registry.register(Registries.BLOCK, blockKey, function.apply(settings));
Block block = registerBlock(path, function, settings);

Identifier id = SVBCR.of(path);
RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, id);
Item.Settings itemSettings = new Item.Settings()
.useBlockPrefixedTranslationKey()
Expand All @@ -80,6 +78,15 @@ public static Block register(String path, Function<AbstractBlock.Settings, Block
return block;
}

// registers ONLY the block. because ice was having trouble with water silk -mikii/adenator
public static Block registerBlock(String path, Function<AbstractBlock.Settings, Block> function, AbstractBlock.Settings settings) {
Identifier id = SVBCR.of(path);
RegistryKey<Block> blockKey = RegistryKey.of(RegistryKeys.BLOCK, id);
settings.registryKey(blockKey);
Block block = Registry.register(Registries.BLOCK, blockKey, function.apply(settings));
return block;
}

protected static boolean always(BlockState state, BlockView world, BlockPos pos){
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nuclearcrackhead.serverboss.registry;

import com.nuclearcrackhead.serverboss.SVBCR;
import com.nuclearcrackhead.serverboss.content.block.WaterSilk;
import com.nuclearcrackhead.serverboss.registry.ModBlocks;
import com.nuclearcrackhead.serverboss.content.item.ExampleItem;
import com.nuclearcrackhead.serverboss.content.item.GcpDotTestingItem;
import net.fabricmc.fabric.api.item.v1.FabricItem;
Expand Down Expand Up @@ -30,7 +30,7 @@ public static void init() {
public static final Item GCP_DOT_TESTING_ITEM = register("gcp_dot_testing_item", GcpDotTestingItem::new,
new Item.Settings()
);
public static Item RADIOACTIVE_BUCKET = register("radioactive_bucket",
public static final Item RADIOACTIVE_BUCKET = register("radioactive_bucket",
settings -> new BucketItem(RADIOACTIVE_STILL, settings),
new Item.Settings().recipeRemainder(Items.BUCKET).maxCount(1)
);
Expand All @@ -44,6 +44,9 @@ public static void init() {
settings -> new SpawnEggItem(ModEntities.BATTERY, 0xFFFFFF, 0xFF00FF, settings), new Item.Settings()
);

//blocks that don't already have an associated item
public static final Item WATER_SILK = register("water_silk", settings -> new PlaceableOnWaterItem(ModBlocks.WATER_SILK, settings), new Item.Settings());

public static Item register(String path, Function<Item.Settings, Item> function, Item.Settings settings) {
Identifier id = SVBCR.of(path);
RegistryKey<Item> key = RegistryKey.of(RegistryKeys.ITEM, id);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/svbcr/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"item.svbcr.axemachine_spawn_egg": "Axemachine Spawn Egg",
"item.svbcr.example_item": "Example Item",
"item.svbcr.radioactive_bucket": "Radioactive Waste Barrel",
"item.svbcr.water_silk": "Water Silk",

"itemGroup.svbcr.decorational_blocks": "Serverboss Decoration Blocks",
"itemGroup.svbcr.functional_blocks": "Serverboss Functional Blocks",
Expand Down

0 comments on commit 3f30e38

Please sign in to comment.