Fix serverside issues.
This commit is contained in:
@@ -5,6 +5,7 @@ import com.refinedmods.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.refinedmods.refinedstorage.block.BaseBlock;
|
||||
import com.refinedmods.refinedstorage.item.*;
|
||||
import com.refinedmods.refinedstorage.item.blockitem.*;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -143,8 +144,22 @@ public final class RSItems {
|
||||
registerBlockItemFor(RSBlocks.CONSTRUCTOR);
|
||||
registerBlockItemFor(RSBlocks.DESTRUCTOR);
|
||||
|
||||
CONTROLLER.put(ColorMap.DEFAULT_COLOR, ITEMS.register(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get(), ColorMap.DEFAULT_COLOR, RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getTranslatedName())));
|
||||
CREATIVE_CONTROLLER.put(ColorMap.DEFAULT_COLOR, ITEMS.register(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get(), ColorMap.DEFAULT_COLOR, RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getTranslatedName())));
|
||||
CONTROLLER.put(ColorMap.DEFAULT_COLOR, ITEMS.register(
|
||||
RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).getId().getPath(),
|
||||
() -> new ControllerBlockItem(
|
||||
RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get(),
|
||||
ColorMap.DEFAULT_COLOR,
|
||||
BlockUtils.getBlockTranslation(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get())
|
||||
)
|
||||
));
|
||||
CREATIVE_CONTROLLER.put(ColorMap.DEFAULT_COLOR, ITEMS.register(
|
||||
RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).getId().getPath(),
|
||||
() -> new ControllerBlockItem(
|
||||
RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get(),
|
||||
ColorMap.DEFAULT_COLOR,
|
||||
BlockUtils.getBlockTranslation(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get())
|
||||
)
|
||||
));
|
||||
|
||||
COLORED_ITEM_TAGS.put(ItemTags.createOptional(new ResourceLocation(RS.ID, CONTROLLER.get(ColorMap.DEFAULT_COLOR).getId().getPath())), CONTROLLER);
|
||||
|
||||
|
@@ -3,11 +3,15 @@ package com.refinedmods.refinedstorage.util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public class BlockUtils {
|
||||
public static final Block.Properties DEFAULT_ROCK_PROPERTIES = Block.Properties.create(Material.ROCK).hardnessAndResistance(1.9F).sound(SoundType.STONE);
|
||||
public static final Block.Properties DEFAULT_GLASS_PROPERTIES = Block.Properties.create(Material.GLASS).sound(SoundType.GLASS).hardnessAndResistance(0.35F);
|
||||
public static final DyeColor DEFAULT_COLOR = DyeColor.LIGHT_BLUE;
|
||||
|
||||
// Block#getTranslatedName is client only
|
||||
public static ITextComponent getBlockTranslation(Block block) {
|
||||
return new TranslationTextComponent(block.getTranslationKey());
|
||||
}
|
||||
}
|
||||
|
@@ -90,7 +90,15 @@ public class ColorMap<T extends IForgeRegistryEntry<? super T>> {
|
||||
}
|
||||
|
||||
private <S extends BaseBlock> RegistryObject<T> registerBlockItemFor(RegistryObject<S> block, DyeColor color, RegistryObject<S> translationBlock) {
|
||||
return (RegistryObject<T>) itemRegister.register(block.getId().getPath(), () -> new ColoredBlockItem(block.get(), new Item.Properties().group(RS.MAIN_GROUP), color, translationBlock.get().getTranslatedName()));
|
||||
return (RegistryObject<T>) itemRegister.register(
|
||||
block.getId().getPath(),
|
||||
() -> new ColoredBlockItem(
|
||||
block.get(),
|
||||
new Item.Properties().group(RS.MAIN_GROUP),
|
||||
color,
|
||||
BlockUtils.getBlockTranslation(translationBlock.get())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public <S extends BaseBlock> ActionResultType changeBlockColor(BlockState state, ItemStack heldItem, World world, BlockPos pos, PlayerEntity player) {
|
||||
|
Reference in New Issue
Block a user