Skip to content

Commit

Permalink
Preliminary 1.12.x update (ASM not updated or tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysteryem committed Oct 16, 2017
1 parent 985911c commit 36795a4
Show file tree
Hide file tree
Showing 107 changed files with 2,187 additions and 693 deletions.
82 changes: 82 additions & 0 deletions src/main/java/uk/co/mysterymayhem/gravitymod/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
package uk.co.mysterymayhem.gravitymod;

import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionType;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import uk.co.mysterymayhem.gravitymod.client.listeners.*;
Expand Down Expand Up @@ -50,4 +62,74 @@ public void registerListeners() {
public Collection<?> createSidedEventListeners() {
return Lists.newArrayList(new FallOutOfWorldUpwardsListenerClient());
}

@Override
@SubscribeEvent
public void onRegisterBlocks(RegistryEvent.Register<Block> event) {
super.onRegisterBlocks(event);
this.doRegister(registry -> registry.onRegisterBlocksClient(event));
}

@Override
@SubscribeEvent
public void onRegisterItems(RegistryEvent.Register<Item> event) {
super.onRegisterItems(event);
this.doRegister(col -> col.onRegisterItemsClient(event));
}

@Override
@SubscribeEvent
public void onRegisterPotions(RegistryEvent.Register<Potion> event) {
super.onRegisterPotions(event);
this.doRegister(registry -> registry.onRegisterPotionsClient(event));
}

@Override
@SubscribeEvent
public void onRegisterBiomes(RegistryEvent.Register<Biome> event) {
super.onRegisterBiomes(event);
this.doRegister(registry -> registry.onRegisterBiomesClient(event));
}

@Override
@SubscribeEvent
public void onRegisterSoundEvents(RegistryEvent.Register<SoundEvent> event) {
super.onRegisterSoundEvents(event);
this.doRegister(registry -> registry.onRegisterSoundEventsClient(event));
}

@Override
@SubscribeEvent
public void onRegisterPotionTypes(RegistryEvent.Register<PotionType> event) {
super.onRegisterPotionTypes(event);
this.doRegister(registry -> registry.onRegisterPotionTypesClient(event));
}

@Override
@SubscribeEvent
public void onRegisterEnchantments(RegistryEvent.Register<Enchantment> event) {
super.onRegisterEnchantments(event);
this.doRegister(registry -> registry.onRegisterEnchantmentsClient(event));
}

@Override
@SubscribeEvent
public void onRegisterIRecipes(RegistryEvent.Register<IRecipe> event) {
super.onRegisterIRecipes(event);
this.doRegister(registry -> registry.onRegisterIRecipesClient(event));
}

@Override
@SubscribeEvent
public void onRegisterVillagerProfessions(RegistryEvent.Register<VillagerRegistry.VillagerProfession> event) {
super.onRegisterVillagerProfessions(event);
this.doRegister(registry -> registry.onRegisterVillagerProfessionsClient(event));
}

@Override
@SubscribeEvent
public void onRegisterEntityEntries(RegistryEvent.Register<EntityEntry> event) {
super.onRegisterEntityEntries(event);
this.doRegister(registry -> registry.onRegisterEntityEntriesClient(event));
}
}
79 changes: 76 additions & 3 deletions src/main/java/uk/co/mysterymayhem/gravitymod/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
package uk.co.mysterymayhem.gravitymod;

import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionType;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import uk.co.mysterymayhem.gravitymod.common.capabilities.gravitydirection.GravityDirectionCapability;
import uk.co.mysterymayhem.gravitymod.common.config.ConfigHandler;
import uk.co.mysterymayhem.gravitymod.common.entities.EntityFloatingItem;
Expand All @@ -14,16 +26,18 @@
import uk.co.mysterymayhem.gravitymod.common.packets.PacketHandler;
import uk.co.mysterymayhem.gravitymod.common.registries.*;
import uk.co.mysterymayhem.gravitymod.common.world.generation.ore.Generator;
import uk.co.mysterymayhem.mystlib.setup.IFMLStaged;
import uk.co.mysterymayhem.mystlib.setup.registries.AbstractIFMLStagedRegistry;
import uk.co.mysterymayhem.mystlib.setup.registries.AbstractModObjectRegistry;
import uk.co.mysterymayhem.mystlib.setup.registries.AbstractRegistrableModObjectRegistry;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;

/**
* Created by Mysteryem on 2016-08-04.
*/
public class CommonProxy extends AbstractIFMLStagedRegistry<IFMLStaged, ArrayList<IFMLStaged>> {
public class CommonProxy extends AbstractIFMLStagedRegistry<AbstractModObjectRegistry<?,?>, ArrayList<AbstractModObjectRegistry<?,?>>> {

public GravityManagerCommon gravityManagerCommon;

Expand All @@ -33,6 +47,7 @@ public CommonProxy() {

@Override
public void preInit() {
MinecraftForge.EVENT_BUS.register(this);
GravityDirectionCapability.registerCapability();
this.registerGravityManager();
PacketHandler.registerMessages();
Expand Down Expand Up @@ -71,12 +86,70 @@ public Collection<?> createSidedEventListeners() {
}

@Override
protected void addToCollection(ArrayList<IFMLStaged> modObjects) {
protected void addToCollection(ArrayList<AbstractModObjectRegistry<?,?>> modObjects) {
modObjects.add(new ModItems());
modObjects.add(new ModBlocks());
modObjects.add(new ModEntities());
modObjects.add(new ModTileEntities());
modObjects.add(new ModGUIs());
modObjects.add(new ModPotions());
}

@SubscribeEvent
public void onRegisterBlocks(RegistryEvent.Register<Block> event) {
this.doRegister(registry -> registry.onRegisterBlocks(event));
}

@SubscribeEvent
public void onRegisterItems(RegistryEvent.Register<Item> event) {
this.doRegister(registry -> registry.onRegisterItems(event));
}

@SubscribeEvent
public void onRegisterPotions(RegistryEvent.Register<Potion> event) {
this.doRegister(registry -> registry.onRegisterPotions(event));
}

@SubscribeEvent
public void onRegisterBiomes(RegistryEvent.Register<Biome> event) {
this.doRegister(registry -> registry.onRegisterBiomes(event));
}

@SubscribeEvent
public void onRegisterSoundEvents(RegistryEvent.Register<SoundEvent> event) {
this.doRegister(registry -> registry.onRegisterSoundEvents(event));
}

@SubscribeEvent
public void onRegisterPotionTypes(RegistryEvent.Register<PotionType> event) {
this.doRegister(registry -> registry.onRegisterPotionTypes(event));
}

@SubscribeEvent
public void onRegisterEnchantments(RegistryEvent.Register<Enchantment> event) {
this.doRegister(registry -> registry.onRegisterEnchantments(event));
}

@SubscribeEvent
public void onRegisterIRecipes(RegistryEvent.Register<IRecipe> event) {
this.doRegister(registry -> registry.onRegisterIRecipes(event));
}

@SubscribeEvent
public void onRegisterVillagerProfessions(RegistryEvent.Register<VillagerRegistry.VillagerProfession> event) {
this.doRegister(registry -> registry.onRegisterVillagerProfessions(event));
}

@SubscribeEvent
public void onRegisterEntityEntries(RegistryEvent.Register<EntityEntry> event) {
this.doRegister(registry -> registry.onRegisterEntityEntries(event));
}

protected void doRegister(Consumer<AbstractRegistrableModObjectRegistry<?,?>> consumer) {
this.getCollection().forEach(registry -> {
if (registry instanceof AbstractRegistrableModObjectRegistry) {
consumer.accept((AbstractRegistrableModObjectRegistry<?,?>)registry);
}
});
}
}
3 changes: 3 additions & 0 deletions src/main/java/uk/co/mysterymayhem/gravitymod/GravityMod.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.co.mysterymayhem.gravitymod;

import net.minecraft.item.EnumRarity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidRegistry;
Expand Down Expand Up @@ -98,6 +99,8 @@ public static void logInfo(String formattableString, Object... objects) {
logger.info(formattableString, objects);
}

public static ResourceLocation resource(String path) {return new ResourceLocation(GravityMod.MOD_ID, path);}

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
//TODO: config stuff instead of hardcoding for just the Botania rod (or just for the air sigil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;
import uk.co.mysterymayhem.gravitymod.common.config.ConfigHandler;
import uk.co.mysterymayhem.gravitymod.common.registries.IGravityModCommon;
import uk.co.mysterymayhem.gravitymod.common.registries.ModItems;
import uk.co.mysterymayhem.gravitymod.common.registries.StaticItems;
import uk.co.mysterymayhem.mystlib.setup.singletons.AbstractModBlockWithItem;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Random;

Expand All @@ -51,8 +52,8 @@ public GenericItemBlock<BlockGravityOre> createItem(BlockGravityOre block) {
}

@Override
public void preInit() {
super.preInit();
public void registerItem(IForgeRegistry<Item> registry) {
super.registerItem(registry);
OreDictionary.registerOre("oreGravity", new ItemStack(this, 1, OreDictionary.WILDCARD_VALUE));
}

Expand Down Expand Up @@ -100,7 +101,7 @@ else if (placedAgainstBlock == Blocks.STONE) {

@SideOnly(Side.CLIENT)
@Override
public void preInitClient() {
public void registerItemClient(IForgeRegistry<Item> registry) {
for (Type blockType : Type.values()) {
int meta = this.getMetaFromState(this.getDefaultState().withProperty(TYPE, blockType));
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(this.getRegistryName(),
Expand All @@ -110,16 +111,19 @@ public void preInitClient() {
}
}

@Nonnull
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this, 1, this.getMetaFromState(state));
}

@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
for (Type blockType : Type.values()) {
list.add(new ItemStack(this, 1, this.getMetaFromState(this.getDefaultState().withProperty(TYPE, blockType))));
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> items) {
if (tab == ModItems.UP_AND_DOWN_CREATIVE_TAB) {
for (Type blockType : Type.values()) {
items.add(new ItemStack(this, 1, this.getMetaFromState(this.getDefaultState().withProperty(TYPE, blockType))));
}
}
}

Expand All @@ -134,7 +138,7 @@ public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, Enti
// return false;
}

@Nullable
@Nonnull
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return StaticItems.GRAVITY_DUST;
Expand All @@ -143,7 +147,7 @@ public Item getItemDropped(IBlockState state, Random rand, int fortune) {
//TODO: Re-test, these values are no longer correct
// ~7.2526 drops with no fortune (1.7M trials), ~15.1809 drops with fortune 3 (1.9M trials)
@Override
public int quantityDropped(IBlockState state, int fortune, Random random) {
public int quantityDropped(IBlockState state, int fortune, @Nonnull Random random) {
int baseAmount = this.quantityDropped(random);

// From BlockOre
Expand Down Expand Up @@ -175,7 +179,7 @@ public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.SOLID;
}

@Nullable
@Nonnull
@Override
protected ItemStack getSilkTouchDrop(IBlockState state) {
return new ItemStack(this);
Expand Down
Loading

0 comments on commit 36795a4

Please sign in to comment.