fixes the cutout bug, see #2
This commit is contained in:
@@ -12,7 +12,7 @@ loader_version=0.18.4
|
|||||||
loom_version=1.14-SNAPSHOT
|
loom_version=1.14-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=26.1.2
|
mod_version=26.1.3
|
||||||
maven_group=de.jottyfan.minecraft
|
maven_group=de.jottyfan.minecraft
|
||||||
archives_base_name=quickly
|
archives_base_name=quickly
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,15 @@ import net.minecraft.world.Containers;
|
|||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.CropBlock;
|
import net.minecraft.world.level.block.CropBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -24,11 +28,26 @@ public class BlockPlant extends CropBlock {
|
|||||||
private Identifier fruitName;
|
private Identifier fruitName;
|
||||||
|
|
||||||
public BlockPlant(Properties properties, Identifier seedName, Identifier fruitName) {
|
public BlockPlant(Properties properties, Identifier seedName, Identifier fruitName) {
|
||||||
super(properties);
|
super(properties.noOcclusion().dynamicShape());
|
||||||
this.seedName = seedName;
|
this.seedName = seedName;
|
||||||
this.fruitName = fruitName;
|
this.fruitName = fruitName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||||
|
return Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) {
|
||||||
|
return 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean propagatesSkylightDown(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemLike getSeed() {
|
public ItemLike getSeed() {
|
||||||
return QuicklyItems.of(seedName);
|
return QuicklyItems.of(seedName);
|
||||||
}
|
}
|
||||||
@@ -42,7 +61,7 @@ public class BlockPlant extends CropBlock {
|
|||||||
BlockHitResult hitResult) {
|
BlockHitResult hitResult) {
|
||||||
if (!level.isClientSide() && isMaxAge(state)) {
|
if (!level.isClientSide() && isMaxAge(state)) {
|
||||||
int fruitAmount = (level.getRandom().nextFloat() > 0.9f) ? 2 : 1;
|
int fruitAmount = (level.getRandom().nextFloat() > 0.9f) ? 2 : 1;
|
||||||
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getFruit(), fruitAmount));
|
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getFruit(), fruitAmount));
|
||||||
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getSeed()));
|
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getSeed()));
|
||||||
level.setBlock(pos, state.setValue(AGE, 0), 2);
|
level.setBlock(pos, state.setValue(AGE, 0), 2);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|||||||
@@ -1,20 +1,34 @@
|
|||||||
package de.jottyfan.minecraft.mixin;
|
package de.jottyfan.minecraft.mixin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import de.jottyfan.minecraft.block.QuicklyBlocks;
|
||||||
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
|
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jotty
|
* @author jotty
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Mixin(MinecraftServer.class)
|
@Mixin(ItemBlockRenderTypes.class)
|
||||||
public class QuicklyMixin {
|
public class QuicklyMixin {
|
||||||
@Inject(at = @At("HEAD"), method = "loadLevel")
|
@Shadow
|
||||||
private void init(CallbackInfo info) {
|
@Final
|
||||||
|
private static Map<Block, ChunkSectionLayer> TYPE_BY_BLOCK;
|
||||||
|
|
||||||
|
@Inject(method = "<clinit>", at = @At("RETURN"))
|
||||||
|
private static void onStaticInit(CallbackInfo info) {
|
||||||
|
ChunkSectionLayer cutout = ChunkSectionLayer.CUTOUT;
|
||||||
|
TYPE_BY_BLOCK.put(QuicklyBlocks.CANOLAPLANT, cutout);
|
||||||
|
TYPE_BY_BLOCK.put(QuicklyBlocks.COTTONPLANT, cutout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user