Push some experimental new features
This commit is contained in:
parent
620207a49c
commit
1ce264862e
44 changed files with 720 additions and 2 deletions
|
@ -1,30 +1,65 @@
|
|||
package dev.zontreck.shapedaionresources;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import dev.zontreck.shapedaionresources.blocks.ModBlocks;
|
||||
import dev.zontreck.shapedaionresources.configs.SARServerConfig;
|
||||
import dev.zontreck.shapedaionresources.items.ModItems;
|
||||
import dev.zontreck.shapedaionresources.ore.OreGenerator;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod("shapedaionresources")
|
||||
public class ShapedAionResources
|
||||
{
|
||||
// Directly reference a slf4j logger
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String FIRST_JOIN_TAG = "dev.zontreck.shapedaionresources.firstjoin";
|
||||
public static final String MOD_ID = "shapedaionresources";
|
||||
|
||||
|
||||
public ShapedAionResources()
|
||||
{
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
// Register the setup method for modloading
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
bus.addListener(this::setup);
|
||||
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SARServerConfig.SPEC, "aion-rss-server.toml");
|
||||
|
||||
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
|
||||
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
|
||||
ModBlocks.register(bus);
|
||||
ModItems.register(bus);
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
|
@ -39,5 +74,49 @@ public class ShapedAionResources
|
|||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void biomeLoadingEvent(final BiomeLoadingEvent ev){
|
||||
//OreGenerator.generateOres(ev);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSpawn(EntityJoinWorldEvent ev){
|
||||
Level w = ev.getWorld();
|
||||
if(w.isClientSide){
|
||||
return;
|
||||
}
|
||||
|
||||
Entity e = ev.getEntity();
|
||||
if(!(e instanceof Player))return;
|
||||
|
||||
Player p = (Player)e;
|
||||
|
||||
if(firstJoin(p)){
|
||||
// Do first join actions here
|
||||
|
||||
/*for (Entry<String,Integer> ent : SARServerConfig.INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN.get().entrySet()) {
|
||||
|
||||
Inventory i = p.getInventory();
|
||||
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean firstJoin(Player p){
|
||||
|
||||
Set<String> tags = p.getTags();
|
||||
|
||||
if(tags.contains(ShapedAionResources.FIRST_JOIN_TAG)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//p.addTag(ShapedAionResources.FIRST_JOIN_TAG);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package dev.zontreck.shapedaionresources.blocks;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import dev.zontreck.shapedaionresources.ShapedAionResources;
|
||||
import dev.zontreck.shapedaionresources.items.ModItems;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.OreBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ShapedAionResources.MOD_ID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ShapedAionResources.MOD_ID);
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
ShapedAionResources.LOGGER.info("Registering all blocks...");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> AION_ORE_BLOCK = BLOCKS.register("aion_ore_block", () -> new OreBlock(BlockBehaviour.Properties.of(Material.METAL)));
|
||||
|
||||
public static final RegistryObject<Item> AION_ORE_BLOCK_I = ITEMS.register("aion_ore_block", () -> new BlockItem(AION_ORE_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
public static final RegistryObject<Block> AION_BLOCK = BLOCKS.register("aion_block", () -> new Block(BlockBehaviour.Properties.of(Material.HEAVY_METAL).explosionResistance(10000).requiresCorrectToolForDrops().strength(9f)));
|
||||
|
||||
public static final RegistryObject<Item> AION_BLOCK_I = ITEMS.register("aion_block", () -> new BlockItem(AION_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package dev.zontreck.shapedaionresources.configs;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
|
||||
public class SARServerConfig {
|
||||
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<List<ItemStack>> INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN;
|
||||
|
||||
|
||||
static {
|
||||
List<ItemStack> defaults = new ArrayList<ItemStack>();
|
||||
|
||||
BUILDER.push("Configuration for Shaped Aion Cubes Resources");
|
||||
INITIAL_ITEMS_TO_GIVE_ON_FIRST_JOIN = BUILDER.comment("What items, identified by modid:item, to give to a brand new user on the server").define("New Player Gear", defaults);
|
||||
|
||||
BUILDER.pop();
|
||||
SPEC=BUILDER.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package dev.zontreck.shapedaionresources.items;
|
||||
|
||||
import dev.zontreck.shapedaionresources.ShapedAionResources;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ShapedAionResources.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Item> AION_FRAGMENT = ITEMS.register("aion_fragment", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
public static final RegistryObject<Item> AION_CRYSTAL = ITEMS.register("aion_crystal", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
|
||||
public static final RegistryObject<Item> AION_RAW_ORE = ITEMS.register("aion_ore", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
ITEMS.register(bus);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package dev.zontreck.shapedaionresources.ore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
|
||||
import net.minecraft.world.level.levelgen.placement.CountPlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
||||
import net.minecraft.world.level.levelgen.placement.RarityFilter;
|
||||
|
||||
public class ModdedOrePlacement {
|
||||
public static List<PlacementModifier> orePlacement(PlacementModifier p_195347_, PlacementModifier p_195348_) {
|
||||
return List.of(p_195347_, InSquarePlacement.spread(), p_195348_, BiomeFilter.biome());
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> commonOrePlacement(int p_195344_, PlacementModifier p_195345_) {
|
||||
return orePlacement(CountPlacement.of(p_195344_), p_195345_);
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> rareOrePlacement(int p_195350_, PlacementModifier p_195351_) {
|
||||
return orePlacement(RarityFilter.onAverageOnceEvery(p_195350_), p_195351_);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package dev.zontreck.shapedaionresources.ore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.zontreck.shapedaionresources.blocks.ModBlocks;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
||||
import net.minecraft.data.worldgen.features.OreFeatures;
|
||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||
import net.minecraft.data.worldgen.placement.VegetationPlacements;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.VerticalAnchor;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.OreFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraftforge.event.world.BiomeLoadingEvent;
|
||||
|
||||
public class OreGenerator {
|
||||
public static final List<ConfiguredFeature<OreConfiguration, OreFeature>> OVERWORLD_ORES = new ArrayList();
|
||||
|
||||
|
||||
public static final List<OreConfiguration.TargetBlockState> OVERWORLD_AION_ORE = List.of(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.AION_ORE_BLOCK.get().defaultBlockState()), OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.AION_ORE_BLOCK.get().defaultBlockState()));
|
||||
|
||||
public static final Holder<ConfiguredFeature<OreConfiguration, ?>> AION_ORE = FeatureUtils.register("aion_ore_block", Feature.ORE, new OreConfiguration(OVERWORLD_AION_ORE, 9));
|
||||
|
||||
|
||||
//public static final Holder<PlacedFeature> EBONY_PLACED = PlacementUtils.register("ebony_placed",
|
||||
//ModConfiguredFeatures.EBONY_SPAWN, VegetationPlacements.treePlacement(
|
||||
//PlacementUtils.countExtra(3, 0.1f, 2)));
|
||||
|
||||
//public static final Holder<PlacedFeature> PINK_ROSE_PLACED = PlacementUtils.register("pink_rose_placed",
|
||||
//ModConfiguredFeatures.PINK_ROSE, RarityFilter.onAverageOnceEvery(16),
|
||||
//InSquarePlacement.spread(), PlacementUtils.HEIGHTMAP, BiomeFilter.biome());
|
||||
|
||||
public static final Holder<PlacedFeature> AION_ORE_PLACED = PlacementUtils.register("aion_ore_placed",
|
||||
AION_ORE, ModdedOrePlacement.commonOrePlacement(6, // VeinsPerChunk
|
||||
HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-40), VerticalAnchor.aboveBottom(40))));
|
||||
|
||||
public static void generateOres(final BiomeLoadingEvent ev){
|
||||
List<Holder<PlacedFeature>> base = ev.getGeneration().getFeatures(GenerationStep.Decoration.UNDERGROUND_ORES);
|
||||
|
||||
base.add(AION_ORE_PLACED);
|
||||
}
|
||||
}
|
Reference in a new issue