Flower pot drop

This commit is contained in:
paulevsGitch 2021-07-12 19:13:13 +03:00
parent f072f22605
commit b49dfb45b0
3 changed files with 21 additions and 2 deletions

View file

@ -1,5 +1,6 @@
package ru.betterend.blocks; package ru.betterend.blocks;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -33,6 +34,7 @@ import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.storage.loot.LootContext.Builder;
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.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
@ -56,6 +58,8 @@ import ru.betterend.interfaces.PottableTerrain;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.io.File; import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -79,6 +83,20 @@ public class FlowerPotBlock extends BaseBlockNotFull implements IRenderTyped, IP
builder.add(PLANT_ID, SOIL_ID, POT_LIGHT); builder.add(PLANT_ID, SOIL_ID, POT_LIGHT);
} }
@Override
public List<ItemStack> getDrops(BlockState state, Builder builder) {
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
int id = state.getValue(SOIL_ID) - 1;
if (id >= 0 && id < soils.length && soils[id] != null) {
drop.add(new ItemStack(soils[id]));
}
id = state.getValue(PLANT_ID) - 1;
if (id >= 0 && id < plants.length && plants[id] != null) {
drop.add(new ItemStack(plants[id]));
}
return drop;
}
@Override @Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
int plantID = state.getValue(PLANT_ID); int plantID = state.getValue(PLANT_ID);

View file

@ -50,6 +50,7 @@
"suggests": { "suggests": {
"byg": ">=1.1.3", "byg": ">=1.1.3",
"blockus": ">=2.0.2", "blockus": ">=2.0.2",
"nourish": ">=1.2.0" "nourish": ">=1.2.0",
"colored_lights": ">=1.0.3"
} }
} }