Skip to content

Commit

Permalink
1.20.1
Browse files Browse the repository at this point in the history
3.1
Regions Unexplored support
New Creative tab graphic
  • Loading branch information
xanthian committed Jan 28, 2024
1 parent 597e886 commit ee1e912
Show file tree
Hide file tree
Showing 446 changed files with 7,616 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mixingradle_version = 0.7-SNAPSHOT
mod_id=variantbarrels
mod_name=Variant Barrels
mod_license=MIT
mod_version=3.0
mod_version=3.1
mod_group_id=net.xanthian.variantbarrels
mod_authors=Xanthian
mod_description=Barrels for all wood types.
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/xanthian/variantbarrels/Initialise.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import net.xanthian.variantbarrels.block.Vanilla;
import net.xanthian.variantbarrels.block.compat.RegionsUnexplored;
import net.xanthian.variantbarrels.item.ModItems;
import net.xanthian.variantbarrels.util.ModCreativeTabs;
import net.xanthian.variantbarrels.util.ModPOITypes;
Expand All @@ -28,5 +29,8 @@ public Initialise() {
ModItems.ITEMS.register(modEventBus);

MinecraftForge.EVENT_BUS.register(this);

ModList.get().getModContainerById("regions_unexplored").ifPresent(modContainer
-> RegionsUnexplored.BLOCKS.register(modEventBus));
}
}
22 changes: 10 additions & 12 deletions src/main/java/net/xanthian/variantbarrels/block/Vanilla.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.BarrelBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;

import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
Expand All @@ -24,26 +22,26 @@ public class Vanilla {
DeferredRegister.create(ForgeRegistries.BLOCKS, Initialise.MOD_ID);

public static final RegistryObject<Block> ACACIA_BARREL = register("acacia_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.ACACIA_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.ACACIA_PLANKS)), 300);
public static final RegistryObject<Block> BAMBOO_BARREL = register("bamboo_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.BAMBOO_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.BAMBOO_PLANKS)), 300);
public static final RegistryObject<Block> BIRCH_BARREL = register("birch_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.BIRCH_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.BIRCH_PLANKS)), 300);
public static final RegistryObject<Block> CHERRY_BARREL = register("cherry_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.CHERRY_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.CHERRY_PLANKS)), 300);
public static final RegistryObject<Block> CRIMSON_BARREL = register("crimson_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.CRIMSON_PLANKS)), 0);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.CRIMSON_PLANKS)), 0);
public static final RegistryObject<Block> DARK_OAK_BARREL = register("dark_oak_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.DARK_OAK_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.DARK_OAK_PLANKS)), 300);
public static final RegistryObject<Block> JUNGLE_BARREL = register("jungle_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.JUNGLE_PLANKS)), 300);
public static final RegistryObject<Block> MANGROVE_BARREL = register("mangrove_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.MANGROVE_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.MANGROVE_PLANKS)), 300);
public static final RegistryObject<Block> OAK_BARREL = register("oak_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);

public static final RegistryObject<Block> WARPED_BARREL = register("warped_barrel",
() -> new BarrelBlock(BlockBehaviour.Properties.copy(Blocks.WARPED_PLANKS)), 0);
() -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.WARPED_PLANKS)), 0);


private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, int burnTime) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.xanthian.variantbarrels.block;

import net.minecraft.world.level.block.BarrelBlock;

public class VariantBarrelBlock extends BarrelBlock {
public VariantBarrelBlock(Properties pProperties) {
super(pProperties);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package net.xanthian.variantbarrels.block.compat;

import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.xanthian.variantbarrels.Initialise;
import net.xanthian.variantbarrels.block.VariantBarrelBlock;
import net.xanthian.variantbarrels.item.ModItems;
import org.jetbrains.annotations.Nullable;

import java.util.function.Supplier;

public class RegionsUnexplored {

public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Initialise.MOD_ID);

public static final RegistryObject<Block> RU_ALPHA_BARREL = register("ru_alpha_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BAOBAB_BARREL = register("ru_baobab_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BLACK_PAINTED_BARREL = register("ru_black_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BLACKWOOD_BARREL = register("ru_blackwood_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BLUE_PAINTED_BARREL = register("ru_blue_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BROWN_PAINTED_BARREL = register("ru_brown_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_CYAN_PAINTED_BARREL = register("ru_cyan_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_CYPRESS_BARREL = register("ru_cypress_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_DEAD_BARREL = register("ru_dead_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 0);
public static final RegistryObject<Block> RU_EUCALYPTUS_BARREL = register("ru_eucalyptus_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_GREEN_PAINTED_BARREL = register("ru_green_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_GRAY_PAINTED_BARREL = register("ru_gray_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_JOSHUA_BARREL = register("ru_joshua_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_LARCH_BARREL = register("ru_larch_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_LIGHT_BLUE_PAINTED_BARREL = register("ru_light_blue_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_LIGHT_GRAY_PAINTED_BARREL = register("ru_light_gray_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_LIME_PAINTED_BARREL = register("ru_lime_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_MAGENTA_PAINTED_BARREL = register("ru_magenta_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_MAPLE_BARREL = register("ru_maple_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_MAUVE_BARREL = register("ru_mauve_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_ORANGE_PAINTED_BARREL = register("ru_orange_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_PALM_BARREL = register("ru_palm_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_PINE_BARREL = register("ru_pine_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_PINK_PAINTED_BARREL = register("ru_pink_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_PURPLE_PAINTED_BARREL = register("ru_purple_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_RED_PAINTED_BARREL = register("ru_red_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_REDWOOD_BARREL = register("ru_redwood_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_WHITE_PAINTED_BARREL = register("ru_white_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_WILLOW_BARREL = register("ru_willow_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_YELLOW_PAINTED_BARREL = register("ru_yellow_painted_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BLUE_BIOSHROOM_BARREL = register("ru_blue_bioshroom_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_BRIMWOOD_BARREL = register("ru_brimwood_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 0);
public static final RegistryObject<Block> RU_COBALT_BARREL = register("ru_cobalt_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 0);
public static final RegistryObject<Block> RU_GREEN_BIOSHROOM_BARREL = register("ru_green_bioshroom_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_KAPOK_BARREL = register("ru_kapok_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_MAGNOLIA_BARREL = register("ru_magnolia_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_PINK_BIOSHROOM_BARREL = register("ru_pink_bioshroom_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_SOCOTRA_BARREL = register("ru_socotra_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 300);
public static final RegistryObject<Block> RU_YELLOW_BIOSHROOM_BARREL = register("ru_yellow_bioshroom_barrel", () -> new VariantBarrelBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS)), 0);

private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, int burnTime) {
RegistryObject<T> toReturn = BLOCKS.register(name, block);
registerBlockItem(name, toReturn, burnTime);
return toReturn;
}

private static <T extends Block> RegistryObject<BlockItem> registerBlockItem(String name, RegistryObject<T> block, int burnTime) {
return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()) {
@Override
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
return burnTime;
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package net.xanthian.variantbarrels.util;

import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;

import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import net.xanthian.variantbarrels.Initialise;
import net.xanthian.variantbarrels.block.Vanilla;
import net.xanthian.variantbarrels.block.compat.RegionsUnexplored;


public class ModCreativeTabs {
Expand All @@ -19,7 +20,8 @@ public class ModCreativeTabs {

public static final RegistryObject<CreativeModeTab> VCB_TAB = CREATIVE_MODE_TABS.register("variantbarrels",
() -> CreativeModeTab.builder().icon(() -> new ItemStack(Vanilla.MANGROVE_BARREL.get()))
.title(Component.literal("Variant Barrels"))
.hideTitle()
.withBackgroundLocation(new ResourceLocation(Initialise.MOD_ID, "textures/gui/container/creative_inventory/tab_variantbarrels.png"))
.displayItems((pParameters, pOutput) -> {
pOutput.accept(Vanilla.ACACIA_BARREL.get());
pOutput.accept(Vanilla.BAMBOO_BARREL.get());
Expand All @@ -32,6 +34,11 @@ public class ModCreativeTabs {
pOutput.accept(Vanilla.OAK_BARREL.get());
pOutput.accept(Blocks.BARREL); // Spruce
pOutput.accept(Vanilla.WARPED_BARREL.get());
ModList.get().getModContainerById("regions_unexplored").ifPresent(modContainer ->
RegionsUnexplored.BLOCKS.getEntries()
.stream()
.map(RegistryObject::get)
.forEach(pOutput::accept));
})
.build());
}
40 changes: 24 additions & 16 deletions src/main/java/net/xanthian/variantbarrels/util/ModPOITypes.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
package net.xanthian.variantbarrels.util;

import com.google.common.collect.ImmutableSet;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.entity.ai.village.poi.PoiTypes;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.xanthian.variantbarrels.block.Vanilla;
import net.xanthian.variantbarrels.block.VariantBarrelBlock;
import org.jetbrains.annotations.NotNull;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

public class ModPOITypes {

public static DeferredRegister<PoiType> POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, "minecraft");
public static RegistryObject<PoiType> FISHERMAN = POI_TYPES.register("fisherman", () ->
new PoiType(ImmutableSet.copyOf(getPOIBlockStates()), 1, 1));

// Credit to cech12 & BrickFurnace mod

public static RegistryObject<PoiType> FISHERMAN = POI_TYPES.register("fisherman", () -> {
HashSet<BlockState> states = new HashSet<>(ForgeRegistries.POI_TYPES.getDelegateOrThrow(PoiTypes.FISHERMAN).get().matchingStates());
RegistryObject<Block>[] barrelRegistryObjects = new RegistryObject[]{
Vanilla.ACACIA_BARREL, Vanilla.BAMBOO_BARREL, Vanilla.CHERRY_BARREL,
Vanilla.CRIMSON_BARREL, Vanilla.DARK_OAK_BARREL, Vanilla.JUNGLE_BARREL,
Vanilla.MANGROVE_BARREL, Vanilla.OAK_BARREL, Vanilla.WARPED_BARREL
};
for (RegistryObject<Block> barrelRegistryObject : barrelRegistryObjects) {
states.addAll(barrelRegistryObject.get().getStateDefinition().getPossibleStates());
}
return new PoiType(states, 1, 1);
});
private static Set<BlockState> getPOIBlockStates() {
Set<BlockState> states = new HashSet<>();

ForgeRegistries.BLOCKS.getValues().stream()
.filter(ModPOITypes::isVariantBarrel)
.forEach(addAllBlockStates(states));
return states;
}

@NotNull
private static Consumer<Block> addAllBlockStates(Set<BlockState> states) {
return block -> states.addAll(block.getStateDefinition().getPossibleStates());
}

private static boolean isVariantBarrel(Block block) {
return block instanceof VariantBarrelBlock;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"variants": {
"facing=down,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel",
"x": 180
},
"facing=down,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open",
"x": 180
},
"facing=east,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel",
"x": 90,
"y": 90
},
"facing=east,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open",
"x": 90,
"y": 90
},
"facing=north,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel",
"x": 90
},
"facing=north,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open",
"x": 90
},
"facing=south,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel",
"x": 90,
"y": 180
},
"facing=south,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open",
"x": 90,
"y": 180
},
"facing=up,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel"
},
"facing=up,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open"
},
"facing=west,open=false": {
"model": "variantbarrels:block/ru_alpha_barrel",
"x": 90,
"y": 270
},
"facing=west,open=true": {
"model": "variantbarrels:block/ru_alpha_barrel_open",
"x": 90,
"y": 270
}
}
}
Loading

0 comments on commit ee1e912

Please sign in to comment.