Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advancements! #3160

Merged
merged 8 commits into from Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/main/java/appeng/bootstrap/ICriterionTriggerRegistry.java
@@ -0,0 +1,30 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.bootstrap;


import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;


@FunctionalInterface
public interface ICriterionTriggerRegistry
{
void register( ICriterionTrigger<? extends ICriterionInstance> trigger );
}
Expand Up @@ -319,7 +319,7 @@ public void initGui()
final Enum searchModeSetting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );

final boolean isAutoFocus = SearchBoxMode.AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting;
final boolean isManualFocus = SearchBoxMode.MANUAL_SEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isManualFocus = SearchBoxMode.MANUAL_SEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting;

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/appeng/core/AppEng.java
Expand Up @@ -51,6 +51,7 @@
import appeng.core.crash.IntegrationCrashEnhancement;
import appeng.core.crash.ModCrashEnhancement;
import appeng.core.features.AEFeature;
import appeng.core.stats.AdvancementTriggers;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.worlddata.WorldData;
Expand Down Expand Up @@ -141,6 +142,11 @@ public int getStorageDimensionID()
return this.registration.storageDimensionID;
}

public AdvancementTriggers getAdvancementTriggers()
{
return this.registration.advancementTriggers;
}

@EventHandler
private void preInit( final FMLPreInitializationEvent event )
{
Expand Down
43 changes: 39 additions & 4 deletions src/main/java/appeng/core/Registration.java
Expand Up @@ -20,13 +20,18 @@


import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;

import javax.annotation.Nonnull;

import com.google.common.base.Preconditions;

import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
Expand All @@ -49,6 +54,7 @@
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry;
Expand All @@ -72,6 +78,7 @@
import appeng.api.networking.ticking.ITickManager;
import appeng.api.parts.IPartHelper;
import appeng.api.recipes.IRecipeHandler;
import appeng.bootstrap.ICriterionTriggerRegistry;
import appeng.bootstrap.IModelRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IInitComponent;
Expand All @@ -88,7 +95,9 @@
import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.stats.PlayerStatsRegistration;
import appeng.core.stats.AdvancementTriggers;
import appeng.core.stats.PartItemPredicate;
import appeng.core.stats.Stats;
import appeng.core.worlddata.SpatialDimensionManager;
import appeng.hooks.TickHandler;
import appeng.items.materials.ItemMaterial;
Expand Down Expand Up @@ -131,6 +140,7 @@ final class Registration
DimensionType storageDimensionType;
int storageDimensionID;
Biome storageBiome;
AdvancementTriggers advancementTriggers;

private File recipeDirectory;
private CustomRecipeConfig customRecipeConfig;
Expand Down Expand Up @@ -286,9 +296,9 @@ public void initialize( @Nonnull final FMLInitializationEvent event, @Nonnull fi
registries.matterCannon().registerAmmo( ammoStack, weight );
} );

final PlayerStatsRegistration registration = new PlayerStatsRegistration( MinecraftForge.EVENT_BUS, AEConfig.instance() );
registration.registerAchievementHandlers();
registration.registerAchievements();
PartItemPredicate.register();
Stats.register();
this.advancementTriggers = new AdvancementTriggers( new CriterionTrigggerRegistry() );
}

@SubscribeEvent
Expand Down Expand Up @@ -581,4 +591,29 @@ public void setCustomStateMapper( Block block, IStateMapper mapper )
}
}

private static class CriterionTrigggerRegistry implements ICriterionTriggerRegistry
{
private Method method;

CriterionTrigggerRegistry()
{
this.method = ReflectionHelper.findMethod( CriteriaTriggers.class, "register", "func_192118_a", ICriterionTrigger.class );
method.setAccessible( true );
}

@Override
public void register( ICriterionTrigger<? extends ICriterionInstance> trigger )
{
try
{
method.invoke( null, trigger );
}
catch( IllegalAccessException | IllegalArgumentException | InvocationTargetException e )
{
AELog.debug( e );
}
}

}

}
73 changes: 0 additions & 73 deletions src/main/java/appeng/core/stats/AchievementCraftingHandler.java

This file was deleted.

61 changes: 0 additions & 61 deletions src/main/java/appeng/core/stats/AchievementHierarchy.java

This file was deleted.

64 changes: 0 additions & 64 deletions src/main/java/appeng/core/stats/AchievementPickupHandler.java

This file was deleted.