Tags and LootTable test, added drops
This commit is contained in:
parent
839313bde4
commit
e8665ddde2
@ -69,7 +69,6 @@ public class OverdriveThatMatters {
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event) {
|
||||
// some preinit code
|
||||
LOGGER.info("setup called");
|
||||
}
|
||||
|
||||
private void enqueueIMC(final InterModEnqueueEvent event) {
|
||||
@ -88,7 +87,6 @@ public class OverdriveThatMatters {
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(FMLServerStartingEvent event) {
|
||||
// do something when the server starts
|
||||
LOGGER.info("server starting called");
|
||||
}
|
||||
|
||||
private final ResourceLocation android_cap_location = new ResourceLocation(OverdriveThatMatters.MOD_ID, "android_capability");
|
||||
@ -122,23 +120,16 @@ public class OverdriveThatMatters {
|
||||
public static class RegistryEvents {
|
||||
@SubscribeEvent
|
||||
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
||||
// регистрация блоков
|
||||
LOGGER.info("Register Block called");
|
||||
blockRegistryEvent.getRegistry().register(ANDROID_STATION);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onItemRegistry(final RegistryEvent.Register<Item> blockRegistryEvent) {
|
||||
// регистрация предметов
|
||||
LOGGER.info("Register Item called");
|
||||
blockRegistryEvent.getRegistry().register(ANDROID_STATION_ITEM);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockEntityRegistry(final RegistryEvent.Register<BlockEntityType<?>> blockRegistryEvent) {
|
||||
// регистрация tile entity
|
||||
LOGGER.info("Register BlockEntity called");
|
||||
// build(data_fixer)
|
||||
ANDROID_STATION_FACTORY = ANDROID_STATION_BUILDER.build(null);
|
||||
ANDROID_STATION_FACTORY.setRegistryName(BlockAndroidStation.REGISTRY_NAME);
|
||||
blockRegistryEvent.getRegistry().register(ANDROID_STATION_FACTORY);
|
||||
@ -146,8 +137,6 @@ public class OverdriveThatMatters {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onMenuTypeRegistry(final RegistryEvent.Register<MenuType<?>> blockRegistryEvent) {
|
||||
// регистрация tile entity
|
||||
LOGGER.info("Register MenuType called");
|
||||
blockRegistryEvent.getRegistry().register(ANDROID_STATION_MENU_TYPE);
|
||||
MenuScreens.register(ANDROID_STATION_MENU_TYPE, AndroidStationScreen::new);
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
package ru.dbotthepony.mc.otm.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@ -16,6 +20,9 @@ import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParam;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
@ -24,16 +31,26 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters;
|
||||
import ru.dbotthepony.mc.otm.block.entity.BlockEntityAndroidStation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockAndroidStation extends Block implements EntityBlock {
|
||||
public static final ResourceLocation REGISTRY_NAME = new ResourceLocation(OverdriveThatMatters.MOD_ID, "android_station");
|
||||
private final VoxelShape SHAPE = Shapes.box(0, 0, 0, 1, 0.5, 1);
|
||||
|
||||
public BlockAndroidStation() {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(3F, 6.0F));
|
||||
super(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(1.5F, 6.0F));
|
||||
this.setRegistryName(REGISTRY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) {
|
||||
if (p_49851_.hasCustomHoverName() && !p_49847_.isClientSide && p_49847_.getBlockEntity(p_49848_) instanceof BlockEntityAndroidStation tile) {
|
||||
tile.setDisplayName(p_49851_.getDisplayName());
|
||||
}
|
||||
super.setPlacedBy(p_49847_, p_49848_, p_49849_, p_49850_, p_49851_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState p_151964_, BlockGetter p_151965_, BlockPos p_151966_, CollisionContext p_151967_) {
|
||||
return SHAPE;
|
||||
|
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.block.entity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
@ -29,9 +30,15 @@ import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockEntityAndroidStation extends BlockEntity implements MenuProvider {
|
||||
private Component display_name;
|
||||
|
||||
public void setDisplayName(Component text) {
|
||||
display_name = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return new TranslatableComponent("container.otm.android_station");
|
||||
return display_name != null ? display_name : new TranslatableComponent("container.otm.android_station");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -57,7 +64,12 @@ public class BlockEntityAndroidStation extends BlockEntity implements MenuProvid
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt) {
|
||||
nbt.put("energy_cap", energy.serializeNBT());
|
||||
nbt.put("energy_cap", energy.serializeNBT());
|
||||
|
||||
if (display_name != null) {
|
||||
nbt.putString("Name", Component.Serializer.toJson(display_name));
|
||||
}
|
||||
|
||||
return super.save(nbt);
|
||||
}
|
||||
|
||||
@ -66,6 +78,9 @@ public class BlockEntityAndroidStation extends BlockEntity implements MenuProvid
|
||||
|
||||
if (nbt.contains("energy_cap") && nbt.get("energy_cap") instanceof CompoundTag tag)
|
||||
energy.deserializeNBT(tag);
|
||||
|
||||
if (nbt.contains("Name") && nbt.get("Name") instanceof StringTag tag)
|
||||
display_name = Component.Serializer.fromJson(tag.getAsString());
|
||||
}
|
||||
|
||||
void tick() {
|
||||
|
@ -60,6 +60,6 @@ public class AndroidStationScreen extends AbstractContainerScreen<AndroidStation
|
||||
}
|
||||
|
||||
if (level > 0.01)
|
||||
this.blit(pose, i + 13, j + 15 + 46 - (int) (level * 45d), 176, 0, 7, (int) (level * 45d));
|
||||
this.blit(pose, i + 13, j + 15 + 46 - (int) (level * 45d), 176, 0, 7, (int) (level * 46d));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"overdrive_that_matters:android_station"
|
||||
]
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1.0,
|
||||
"bonus_rolls": 0.0,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_name",
|
||||
"source": "block_entity"
|
||||
},
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
"ops": [
|
||||
{
|
||||
"source": "energy_cap",
|
||||
"target": "BlockEntityTag.energy_cap",
|
||||
"op": "replace"
|
||||
},
|
||||
{
|
||||
"source": "Name",
|
||||
"target": "BlockEntityTag.Name",
|
||||
"op": "replace"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"name": "overdrive_that_matters:android_station"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user