mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fix slime block rendering
This commit is contained in:
parent
c795af04ab
commit
12208b147c
4 changed files with 39 additions and 38 deletions
|
@ -8,8 +8,6 @@ import com.minelittlepony.unicopia.ducks.Climbable;
|
||||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
import com.minelittlepony.unicopia.util.PosHelper;
|
import com.minelittlepony.unicopia.util.PosHelper;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
|
||||||
import net.fabricmc.fabric.api.tools.FabricToolTags;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -22,7 +20,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtHelper;
|
import net.minecraft.nbt.NbtHelper;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
|
@ -55,27 +52,13 @@ public class SlimeDropBlock extends Block implements Climbable {
|
||||||
Block.createCuboidShape(2, 0, 2, 14, 12, 14),
|
Block.createCuboidShape(2, 0, 2, 14, 12, 14),
|
||||||
};
|
};
|
||||||
|
|
||||||
public SlimeDropBlock() {
|
public SlimeDropBlock(Settings settings) {
|
||||||
super(FabricBlockSettings.of(UMaterials.HIVE)
|
super(settings);
|
||||||
.ticksRandomly()
|
|
||||||
.breakInstantly()
|
|
||||||
.lightLevel(9)
|
|
||||||
.slipperiness(0.5F)
|
|
||||||
.sounds(BlockSoundGroup.SLIME)
|
|
||||||
.breakByTool(FabricToolTags.SHOVELS, 2)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
setDefaultState(stateManager.getDefaultState()
|
setDefaultState(stateManager.getDefaultState()
|
||||||
.with(AGE, 0)
|
.with(AGE, 0)
|
||||||
.with(SHAPE, Shape.BULB));
|
.with(SHAPE, Shape.BULB));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTranslucent(BlockState state, BlockView view, BlockPos pos) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block.OffsetType getOffsetType() {
|
public Block.OffsetType getOffsetType() {
|
||||||
return Block.OffsetType.XZ;
|
return Block.OffsetType.XZ;
|
||||||
|
|
|
@ -1,33 +1,36 @@
|
||||||
package com.minelittlepony.unicopia.block;
|
package com.minelittlepony.unicopia.block;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.block.MaterialColor;
|
|
||||||
import net.minecraft.block.SnowBlock;
|
import net.minecraft.block.SnowBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class SlimeLayerBlock extends SnowBlock {
|
public class SlimeLayerBlock extends SnowBlock {
|
||||||
|
|
||||||
public SlimeLayerBlock() {
|
public SlimeLayerBlock(Settings settings) {
|
||||||
super(FabricBlockSettings.of(Material.CLAY)
|
super(settings);
|
||||||
.sounds(BlockSoundGroup.SLIME)
|
}
|
||||||
.materialColor(MaterialColor.GRASS)
|
|
||||||
.build()
|
@Override
|
||||||
);
|
public void onLandedUpon(World world, BlockPos pos, Entity entity, float distance) {
|
||||||
|
Blocks.SLIME_BLOCK.onLandedUpon(world, pos, entity, distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityLand(BlockView world, Entity entity) {
|
||||||
|
Blocks.SLIME_BLOCK.onEntityLand(world, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSteppedOn(World world, BlockPos pos, Entity entity) {
|
public void onSteppedOn(World world, BlockPos pos, Entity entity) {
|
||||||
float factor = getMotionFactor(world.getBlockState(pos));
|
double velocity = Math.abs(entity.getVelocity().y);
|
||||||
|
|
||||||
entity.setVelocity(entity.getVelocity().multiply(factor));
|
if (velocity < 0.1 && !entity.bypassesSteppingEffects()) {
|
||||||
}
|
double factor = 0.4D + velocity * (0.2D * 8/world.getBlockState(pos).get(LAYERS));
|
||||||
|
|
||||||
protected float getMotionFactor(BlockState state) {
|
entity.setVelocity(entity.getVelocity().multiply(factor, 1, factor));
|
||||||
return 1/state.get(LAYERS);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,11 @@ import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.structure.CustomSaplingGenerator;
|
import com.minelittlepony.unicopia.structure.CustomSaplingGenerator;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||||
|
import net.fabricmc.fabric.api.tools.FabricToolTags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.block.MaterialColor;
|
||||||
import net.minecraft.block.SaplingBlock;
|
import net.minecraft.block.SaplingBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.sound.BlockSoundGroup;
|
import net.minecraft.sound.BlockSoundGroup;
|
||||||
|
@ -63,8 +65,19 @@ public interface UBlocks {
|
||||||
ChitinBlock CHITIN_SHELL_BLOCK = register(new ChitinBlock(), "chitin_shell_block");
|
ChitinBlock CHITIN_SHELL_BLOCK = register(new ChitinBlock(), "chitin_shell_block");
|
||||||
Block CHISELED_CHITIN_SHELL_BLOCK = register(new ChiselledChitinBlock(), "chiseled_chitin_shell_block");
|
Block CHISELED_CHITIN_SHELL_BLOCK = register(new ChiselledChitinBlock(), "chiseled_chitin_shell_block");
|
||||||
|
|
||||||
SlimeDropBlock SLIME_DROP = register(new SlimeDropBlock(), "slime_drop");
|
SlimeDropBlock SLIME_DROP = register(new SlimeDropBlock(FabricBlockSettings.of(UMaterials.HIVE)
|
||||||
SlimeLayerBlock SLIME_LAYER = register(new SlimeLayerBlock(), "slime_layer");
|
.ticksRandomly()
|
||||||
|
.breakInstantly()
|
||||||
|
.lightLevel(9)
|
||||||
|
.slipperiness(0.5F)
|
||||||
|
.sounds(BlockSoundGroup.SLIME)
|
||||||
|
.breakByTool(FabricToolTags.SHOVELS, 2)
|
||||||
|
.build()), "slime_drop");
|
||||||
|
SlimeLayerBlock SLIME_LAYER = register(new SlimeLayerBlock(FabricBlockSettings.of(Material.CLAY, MaterialColor.GRASS)
|
||||||
|
.sounds(BlockSoundGroup.SLIME)
|
||||||
|
.slipperiness(0.8F)
|
||||||
|
.nonOpaque()
|
||||||
|
.build()), "slime_layer");
|
||||||
|
|
||||||
Block SUGAR_BLOCK = register(new SugarBlock(), "sugar_block");
|
Block SUGAR_BLOCK = register(new SugarBlock(), "sugar_block");
|
||||||
Block APPLE_LEAVES = register(new FruitLeavesBlock()
|
Block APPLE_LEAVES = register(new FruitLeavesBlock()
|
||||||
|
|
|
@ -47,7 +47,9 @@ public interface URenderers {
|
||||||
UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND,
|
UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND,
|
||||||
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.CLOUD_FENCE,
|
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.CLOUD_FENCE,
|
||||||
UBlocks.DENSE_CLOUD_BLOCK, UBlocks.DENSE_CLOUD_SLAB,
|
UBlocks.DENSE_CLOUD_BLOCK, UBlocks.DENSE_CLOUD_SLAB,
|
||||||
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB
|
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB,
|
||||||
|
|
||||||
|
UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue