Backportat latest changes from master
This commit is contained in:
parent
9183293329
commit
53911dfe91
63 changed files with 1002 additions and 351 deletions
|
@ -40,7 +40,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
|
|||
public IntegerProperty durability;
|
||||
|
||||
public BaseAnvilBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.ANVIL).mapColor(color));
|
||||
super(FabricBlockSettings.copyOf(Blocks.ANVIL).color(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Optional;
|
|||
|
||||
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, RenderLayerProvider {
|
||||
public BaseChainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color));
|
||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).color(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.Optional;
|
|||
|
||||
public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider, RenderLayerProvider {
|
||||
public BaseFurnaceBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(LIT) ? 13 : 0));
|
||||
super(FabricBlockSettings.copyOf(source).lightLevel(state -> state.getValue(LIT) ? 13 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,13 +29,13 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
|||
|
||||
private static FabricBlockSettings makeLeaves(MaterialColor color) {
|
||||
return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||
.mapColor(color)
|
||||
.color(color)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.allowsSpawning((state, world, pos, type) -> false)
|
||||
.suffocates((state, world, pos) -> false)
|
||||
.blockVision((state, world, pos) -> false);
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false);
|
||||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) {
|
||||
|
@ -54,7 +54,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
|||
}
|
||||
|
||||
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
|
||||
super(makeLeaves(color).luminance(light));
|
||||
super(makeLeaves(color).lightLevel(light));
|
||||
this.sapling = sapling;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
|||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
||||
this(drop, minCount, maxCount, experience, FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||
.hardness(3F)
|
||||
.resistance(9F)
|
||||
.destroyTime(3F)
|
||||
.explosionResistance(9F)
|
||||
.requiresCorrectToolForDrops()
|
||||
.sound(SoundType.STONE));
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
|
|||
@Override
|
||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (state.getValue(WATERLOGGED)) {
|
||||
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
world.getFluidTicks().schedule(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||
}
|
||||
if (!canSurvive(state, world, pos)) {
|
||||
return state.getValue(WATERLOGGED) ? state.getFluidState()
|
||||
|
@ -191,6 +191,6 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
|
|||
|
||||
@Override
|
||||
public BlockItem getCustomItem(ResourceLocation blockID, FabricItemSettings settings) {
|
||||
return new BlockItem(this, settings.maxCount(16));
|
||||
return new BlockItem(this, settings.stacksTo(16));
|
||||
}
|
||||
}
|
|
@ -36,7 +36,8 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
|
|||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
int count = state.getValue(TYPE) == SlabType.DOUBLE ? 2 : 1;
|
||||
return Collections.singletonList(new ItemStack(this, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,7 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
|
|||
private final Block striped;
|
||||
|
||||
public BaseStripableLogBlock(MaterialColor color, Block striped) {
|
||||
super(FabricBlockSettings.copyOf(striped).mapColor(color));
|
||||
super(FabricBlockSettings.copyOf(striped).color(color));
|
||||
this.striped = striped;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr
|
|||
public SimpleLeavesBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.mapColor(color)
|
||||
.color(color)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
|
@ -25,7 +25,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr
|
|||
public SimpleLeavesBlock(MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.luminance(light)
|
||||
.mapColor(color)
|
||||
.color(color)
|
||||
.strength(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
|
|
|
@ -20,7 +20,7 @@ public class StripableBarkBlock extends BaseBarkBlock {
|
|||
private final Block striped;
|
||||
|
||||
public StripableBarkBlock(MaterialColor color, Block striped) {
|
||||
super(FabricBlockSettings.copyOf(striped).mapColor(color));
|
||||
super(FabricBlockSettings.copyOf(striped).color(color));
|
||||
this.striped = striped;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public abstract class WallMushroomBlock extends BaseWallPlantBlock {
|
|||
.breakByTool(FabricToolTags.AXES)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.hardness(0.2F)
|
||||
.destroyTime(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.sound(SoundType.WOOD)
|
||||
.noCollission());
|
||||
|
|
61
src/main/java/ru/bclib/blocks/properties/StringProperty.java
Normal file
61
src/main/java/ru/bclib/blocks/properties/StringProperty.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package ru.bclib.blocks.properties;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public class StringProperty extends Property<String> {
|
||||
private final Set<String> values;
|
||||
|
||||
public static StringProperty create(String name, String... values) {
|
||||
return new StringProperty(name, values);
|
||||
}
|
||||
|
||||
protected StringProperty(String string, String... values) {
|
||||
super(string, String.class);
|
||||
this.values = Sets.newHashSet(values);
|
||||
}
|
||||
|
||||
public void addValue(String name) {
|
||||
values.add(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getPossibleValues() {
|
||||
return Collections.unmodifiableSet(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(String comparable) {
|
||||
return comparable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getValue(String string) {
|
||||
if (values.contains(string)) {
|
||||
return Optional.of(string);
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int generateHashCode() {
|
||||
return super.generateHashCode() + Objects.hashCode(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof StringProperty that)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
return values.equals(that.values);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue