Skip to content

Commit

Permalink
Sizeable commit
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed May 14, 2023
1 parent 2448283 commit 6b56959
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// 1.19.4 2023-05-13T15:45:29.3455678 Omni-Hopper/Tags for minecraft:block
// 1.19 2023-05-14T12:21:52.9004451 Tags for minecraft:block
ff81d82d656cfc039ebfcb6aecc7664c6ecf13e3 data\minecraft\tags\blocks\mineable\axe.json
30c02540c68c2f27f8b13a1aa9db5b33cfecc0b3 data\minecraft\tags\blocks\mineable\pickaxe.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.19.4 2023-05-13T15:45:29.3475642 Omni-Hopper/Block Loot Tables
// 1.19 2023-05-14T12:21:52.8984468 Block Loot Tables
5e1b7414e97ffd18526b521b2f668f2ff33a0081 data\omnihopper\loot_tables\blocks\weathered_fluid_omnihopper.json
4699e00ce71ee93c705d090c8214db233522dbd3 data\omnihopper\loot_tables\blocks\waxed_weathered_fluid_hopper.json
5309be1241244c97d8cbe053a55a08e8344e870d data\omnihopper\loot_tables\blocks\oxidized_fluid_omnihopper.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.19.4 2023-05-13T15:45:29.3495627 Omni-Hopper/Model Definitions
// 1.19 2023-05-14T12:21:52.8904479 Models
95f93723e1cb32f615234c52d121c3216e6836f7 assets\omnihopper\blockstates\exposed_fluid_hopper.json
0dad0f40b8c90d882230d431cdd522f6abfaf090 assets\omnihopper\models\block\waxed_oxidized_fluid_hopper_east.json
5757f300faf72762c4f41c8715bca1c267b6b8a5 assets\omnihopper\models\block\exposed_fluid_omnihopper_west.json
Expand Down Expand Up @@ -87,8 +87,8 @@ d3a9ee28f7b69327e867c9f1834e8fc74eb1412b assets\omnihopper\models\block\waxed_fl
f156ff47769487617520d3a24134e8e40804fa62 assets\omnihopper\blockstates\oxidized_fluid_hopper.json
704d08e81496cc39145807c93f6261d142b469f9 assets\omnihopper\models\block\wooden_omnihopper_east.json
6a9c29f72582051ec7ec4a550b736aa94204e721 assets\omnihopper\models\block\waxed_fluid_omnihopper_down.json
a518b959fe177b4149daba17136dfdb5cc39c42e assets\omnihopper\blockstates\fluid_omnihopper.json
0fae4612c17b86ba19c6df9f54a501ca7f9cd49e assets\omnihopper\blockstates\waxed_weathered_fluid_hopper.json
a518b959fe177b4149daba17136dfdb5cc39c42e assets\omnihopper\blockstates\fluid_omnihopper.json
db3953011021d444ab7d1f165911a99ef4c3eee0 assets\omnihopper\blockstates\fluid_hopper.json
faf2923502921a28898c8b9393cc4b3a3d4504b5 assets\omnihopper\models\block\fluid_omnihopper_south.json
0dad0f40b8c90d882230d431cdd522f6abfaf090 assets\omnihopper\models\block\oxidized_fluid_hopper_east.json
Expand All @@ -112,8 +112,8 @@ fc16ef4cc8906cf077bb7f00894b665880c1fbfa assets\omnihopper\blockstates\waxed_flu
b631c1755274c54d60c297e369e676839c4165c7 assets\omnihopper\models\block\weathered_fluid_hopper_up.json
3958402ecf1a36814e14405c7b52c4ba9699dcf8 assets\omnihopper\models\block\weathered_fluid_omnihopper_west.json
0fd34ff9f03769331006fa6d142fb106e5bb614f assets\omnihopper\models\block\waxed_exposed_fluid_hopper_down.json
2c2a9b0e67ec65a3fb031b9f4745686de0c0e0ab assets\omnihopper\models\block\fluid_omnihopper_up.json
b887fb9e822b4215fe063634d1b01f29e44d4213 assets\omnihopper\models\block\oxidized_fluid_omnihopper_down.json
2c2a9b0e67ec65a3fb031b9f4745686de0c0e0ab assets\omnihopper\models\block\fluid_omnihopper_up.json
0fd34ff9f03769331006fa6d142fb106e5bb614f assets\omnihopper\models\block\waxed_exposed_fluid_omnihopper_down.json
2c2a9b0e67ec65a3fb031b9f4745686de0c0e0ab assets\omnihopper\models\block\waxed_fluid_hopper_up.json
5cd16a3bdfa37147d3260153e29f83fd6c7ede7c assets\omnihopper\models\item\omnihopper.json
Expand Down
Empty file.
1 change: 0 additions & 1 deletion src/main/java/nl/enjarai/omnihopper/blocks/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.block.Material;
import net.minecraft.block.Oxidizable;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.registry.Registry;
import nl.enjarai.omnihopper.OmniHopper;
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/nl/enjarai/omnihopper/blocks/OpenBoxBlock.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package nl.enjarai.omnihopper.blocks;

import java.util.Set;

import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.enums.SlabType;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import nl.enjarai.omnihopper.blocks.entity.OpenBoxBlockEntity;
import nl.enjarai.omnihopper.util.DatagenBlock;

import nl.enjarai.omnihopper.util.HasTooltip;
import org.jetbrains.annotations.Nullable;

import java.util.Set;

@SuppressWarnings("deprecation")
public class OpenBoxBlock extends BlockWithEntity implements DatagenBlock, HasTooltip, Waterloggable {
public static final DirectionProperty FACING = Properties.FACING;
Expand Down Expand Up @@ -110,7 +108,7 @@ public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state,
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) {
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected void handleEntry(ItemVariant resource, long amount) {

var direction = state.get(OpenBoxBlock.FACING);
var vOffset = new Vec3d(0, -0.125, 0);
var dOffset = new Vec3d(direction.getUnitVector().mul(0.25f));
var pos = getPos().toCenterPos().add(dOffset).add(vOffset);
var dOffset = new Vec3d(direction.getUnitVector()).multiply(0.25f);
var pos = Vec3d.of(getPos()).add(0.5, 0.5, 0.5).add(dOffset).add(vOffset);

while (amount > 0) {
var stackSize = Math.min(amount, resource.getItem().getMaxCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidDrainable;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.stat.Stats;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package nl.enjarai.omnihopper.blocks.hopper;

import java.util.Set;

import org.jetbrains.annotations.Nullable;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.data.client.TextureMap;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nl.enjarai.omnihopper.blocks.entity.hopper.behaviour.WoodenHopperBehaviour;
import nl.enjarai.omnihopper.blocks.entity.hopper.WoodenHopperBlockEntity;
import nl.enjarai.omnihopper.blocks.entity.hopper.behaviour.WoodenHopperBehaviour;
import nl.enjarai.omnihopper.util.TextureMapProvider;
import org.jetbrains.annotations.Nullable;

import java.util.Set;

public class WoodenHopperBlock extends BasicHopperBlock {
public WoodenHopperBlock(Settings settings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package nl.enjarai.omnihopper.blocks.hopper;

import java.util.Set;

import org.jetbrains.annotations.Nullable;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.data.client.TextureMap;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nl.enjarai.omnihopper.blocks.entity.hopper.WoodenOmniHopperBlockEntity;
import nl.enjarai.omnihopper.blocks.entity.hopper.behaviour.WoodenHopperBehaviour;
import nl.enjarai.omnihopper.util.TextureMapProvider;
import org.jetbrains.annotations.Nullable;

import java.util.Set;

public class WoodenOmniHopperBlock extends OmniHopperBlock {
public WoodenOmniHopperBlock(Settings settings) {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/nl/enjarai/omnihopper/datagen/ModDatagen.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
public class ModDatagen implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
var pack = fabricDataGenerator.createPack();

pack.addProvider(ModLootTables::new);
pack.addProvider(ModTags::new);
pack.addProvider(ModModels::new);
fabricDataGenerator.addProvider(ModLootTables::new);
fabricDataGenerator.addProvider(ModTags::new);
fabricDataGenerator.addProvider(ModModels::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package nl.enjarai.omnihopper.datagen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.minecraft.data.server.BlockLootTableGenerator;
import nl.enjarai.omnihopper.blocks.ModBlocks;

public class ModLootTables extends FabricBlockLootTableProvider {
protected ModLootTables(FabricDataOutput dataOutput) {
protected ModLootTables(FabricDataGenerator dataOutput) {
super(dataOutput);
}

@Override
public void generate() {
ModBlocks.ALL.forEach(block -> addDrop(block, this::nameableContainerDrops));
protected void generateBlockLootTables() {
ModBlocks.ALL.forEach(block -> addDrop(block, BlockLootTableGenerator::nameableContainerDrops));
}
}
5 changes: 2 additions & 3 deletions src/main/java/nl/enjarai/omnihopper/datagen/ModModels.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package nl.enjarai.omnihopper.datagen;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Models;
import net.minecraft.item.BlockItem;
import nl.enjarai.omnihopper.blocks.ModBlocks;
import nl.enjarai.omnihopper.items.ModItems;
import nl.enjarai.omnihopper.util.DatagenBlock;

public class ModModels extends FabricModelProvider {
public ModModels(FabricDataOutput output) {
public ModModels(FabricDataGenerator output) {
super(output);
}

Expand Down
14 changes: 5 additions & 9 deletions src/main/java/nl/enjarai/omnihopper/datagen/ModTags.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package nl.enjarai.omnihopper.datagen;

import java.util.concurrent.CompletableFuture;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.registry.Registry;
import nl.enjarai.omnihopper.blocks.ModBlocks;
import nl.enjarai.omnihopper.util.DatagenBlock;

public class ModTags extends FabricTagProvider<Block> {
public ModTags(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, Registries.BLOCK.getKey(), registriesFuture);
public ModTags(FabricDataGenerator output) {
super(output, Registry.BLOCK);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup arg) {
protected void generateTags() {
for (var block : ModBlocks.ALL) {
if (block instanceof DatagenBlock datagen) {
for (var tagKey : datagen.getConfiguredTags()) {
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/nl/enjarai/omnihopper/items/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
package nl.enjarai.omnihopper.items;

import java.util.ArrayList;
import java.util.List;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.block.Block;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.registry.Registry;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import nl.enjarai.omnihopper.blocks.ModBlocks;
import nl.enjarai.omnihopper.util.HasTooltip;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class ModItems {
public static final List<Item> ALL = new ArrayList<>();
public static final List<BlockItem> HOPPERS = ModBlocks.ALL.stream().map(ModItems::registerBlockItem).toList();
Expand All @@ -30,7 +26,7 @@ public static void register() {}

private static BlockItem registerBlockItem(Block block) {
Identifier id = Registry.BLOCK.getId(block);
var item = Registry.register(Registry.ITEM, id, new BlockItem(block, new FabricItemSettings()) {
var item = Registry.register(Registry.ITEM, id, new BlockItem(block, new FabricItemSettings().group(ItemGroup.REDSTONE)) {
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
if (block instanceof HasTooltip hasTooltip) {
Expand All @@ -42,7 +38,6 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too
});

ALL.add(item);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.REDSTONE).register((entries) -> entries.add(item));

return item;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package nl.enjarai.omnihopper.screen;

import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.registry.Registry;
import nl.enjarai.omnihopper.OmniHopper;

public class ModScreenHandlers {
public static final ScreenHandlerType<OneSlotHopperScreenHandler> ONE_SLOT_HOPPER =
new ScreenHandlerType<>(OneSlotHopperScreenHandler::new, FeatureFlags.VANILLA_FEATURES);
new ScreenHandlerType<>(OneSlotHopperScreenHandler::new);

public static void register() {
Registry.register(Registries.SCREEN_HANDLER, OmniHopper.id("one_slot_hopper"), ONE_SLOT_HOPPER);
Registry.register(Registry.SCREEN_HANDLER, OmniHopper.id("one_slot_hopper"), ONE_SLOT_HOPPER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean canUse(PlayerEntity player) {
}

@Override
public ItemStack quickMove(PlayerEntity player, int slot) {
public ItemStack transferSlot(PlayerEntity player, int slot) {
ItemStack itemStack = ItemStack.EMPTY;
Slot slot2 = slots.get(slot);
if (slot2.hasStack()) {
Expand All @@ -59,8 +59,8 @@ public ItemStack quickMove(PlayerEntity player, int slot) {
}

@Override
public void onClosed(PlayerEntity player) {
super.onClosed(player);
public void close(PlayerEntity player) {
super.close(player);
inventory.onClose(player);
}
}
16 changes: 8 additions & 8 deletions src/main/java/nl/enjarai/omnihopper/util/DatagenBlock.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package nl.enjarai.omnihopper.util;

import java.util.Optional;
import java.util.Set;

import net.minecraft.block.Block;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Model;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.Optional;
import java.util.Set;

public interface DatagenBlock {
default void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
Expand All @@ -21,7 +21,7 @@ default Set<TagKey<Block>> getConfiguredTags() {
}

default void generateItemModel(ItemModelGenerator itemModelGenerator, BlockItem item) {
var id = Registries.ITEM.getId(item);
itemModelGenerator.register(item, new Model(Optional.of(id.withPath(path -> "block/" + path)), Optional.empty()));
var id = Registry.ITEM.getId(item);
itemModelGenerator.register(item, new Model(Optional.of(new Identifier(id.getNamespace(), "block/" + id.getPath())), Optional.empty()));
}
}
Loading

0 comments on commit 6b56959

Please sign in to comment.