@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* handles the achievement when an {@link net.minecraft.item.Item} is crafted by a player.
|
||||
* The achievement is only added if its a real {@link net.minecraft.entity.player.EntityPlayer}.
|
||||
*
|
||||
* @author thatsIch
|
||||
* @since rv2
|
||||
*/
|
||||
public class AchievementCraftingHandler
|
||||
{
|
||||
private final PlayerDifferentiator differentiator;
|
||||
|
||||
public AchievementCraftingHandler( final PlayerDifferentiator differentiator )
|
||||
{
|
||||
this.differentiator = differentiator;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerCraftingEvent( final PlayerEvent.ItemCraftedEvent event )
|
||||
{
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.crafting.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( final Achievements achievement : Achievements.values() )
|
||||
{
|
||||
switch( achievement.getType() )
|
||||
{
|
||||
case Craft:
|
||||
if( Platform.itemComparisons().isSameItem( achievement.getStack(), event.crafting ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CraftItem:
|
||||
if( achievement.getStack() != null && achievement.getStack().getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
/**
|
||||
* Hierarchy of the AE2 achievements
|
||||
*
|
||||
* @author thatsIch
|
||||
* @since rv2
|
||||
*/
|
||||
public class AchievementHierarchy
|
||||
{
|
||||
/**
|
||||
* Setup hierarchy through assigning parents.
|
||||
*/
|
||||
void registerAchievementHierarchy()
|
||||
{
|
||||
// Achievements.Presses.setParent( Achievements.Compass );
|
||||
//
|
||||
// Achievements.Fluix.setParent( Achievements.ChargedQuartz );
|
||||
//
|
||||
// Achievements.Charger.setParent( Achievements.Fluix );
|
||||
//
|
||||
// Achievements.CrystalGrowthAccelerator.setParent( Achievements.Charger );
|
||||
//
|
||||
// Achievements.GlassCable.setParent( Achievements.Charger );
|
||||
//
|
||||
// Achievements.SpatialIOExplorer.setParent( Achievements.SpatialIO );
|
||||
//
|
||||
// Achievements.IOPort.setParent( Achievements.StorageCell );
|
||||
//
|
||||
// Achievements.PatternTerminal.setParent( Achievements.CraftingTerminal );
|
||||
//
|
||||
// Achievements.Controller.setParent( Achievements.Networking1 );
|
||||
//
|
||||
// Achievements.Networking2.setParent( Achievements.Controller );
|
||||
//
|
||||
// Achievements.Networking3.setParent( Achievements.Networking2 );
|
||||
//
|
||||
// Achievements.P2P.setParent( Achievements.Controller );
|
||||
//
|
||||
// Achievements.Recursive.setParent( Achievements.Controller );
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* handles the achievement when an {@link net.minecraft.item.Item} is picked up by a player.
|
||||
* The achievement is only added if its a real {@link net.minecraft.entity.player.EntityPlayer}.
|
||||
*
|
||||
* @author thatsIch
|
||||
* @since rv2
|
||||
*/
|
||||
public class AchievementPickupHandler
|
||||
{
|
||||
private final PlayerDifferentiator differentiator;
|
||||
|
||||
public AchievementPickupHandler( final PlayerDifferentiator differentiator )
|
||||
{
|
||||
this.differentiator = differentiator;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemPickUp( final PlayerEvent.ItemPickupEvent event )
|
||||
{
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getItem().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack is = event.pickedUp.getItem();
|
||||
|
||||
for( final Achievements achievement : Achievements.values() )
|
||||
{
|
||||
if( achievement.getType() == AchievementType.Pickup && Platform.itemComparisons().isSameItem( achievement.getStack(), is ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
|
||||
public enum Achievements
|
||||
{
|
||||
// done
|
||||
Compass( -2, -4, AEApi.instance().definitions().blocks().skyCompass(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
Presses( -2, -2, AEApi.instance().definitions().materials().logicProcessorPress(), AchievementType.Custom ),
|
||||
|
||||
// done
|
||||
SpatialIO( -4, -4, AEApi.instance().definitions().blocks().spatialIOPort(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
SpatialIOExplorer( -4, -2, AEApi.instance().definitions().items().spatialCell128(), AchievementType.Custom ),
|
||||
|
||||
// done
|
||||
StorageCell( -6, -4, AEApi.instance().definitions().items().cell64k(), AchievementType.CraftItem ),
|
||||
|
||||
// done
|
||||
IOPort( -6, -2, AEApi.instance().definitions().blocks().iOPort(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
CraftingTerminal( -8, -4, AEApi.instance().definitions().parts().craftingTerminal(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
PatternTerminal( -8, -2, AEApi.instance().definitions().parts().patternTerminal(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
ChargedQuartz( 0, -4, AEApi.instance().definitions().materials().certusQuartzCrystalCharged(), AchievementType.Pickup ),
|
||||
|
||||
// done
|
||||
Fluix( 0, -2, AEApi.instance().definitions().materials().fluixCrystal(), AchievementType.Pickup ),
|
||||
|
||||
// done
|
||||
Charger( 0, 0, AEApi.instance().definitions().blocks().charger(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
CrystalGrowthAccelerator( -2, 0, AEApi.instance().definitions().blocks().quartzGrowthAccelerator(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
GlassCable( 2, 0, AEApi.instance().definitions().parts().cableGlass(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
Networking1( 4, -6, AEApi.instance().definitions().parts().cableCovered(), AchievementType.Custom ),
|
||||
|
||||
// done
|
||||
Controller( 4, -4, AEApi.instance().definitions().blocks().controller(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
Networking2( 4, 0, AEApi.instance().definitions().parts().cableSmart(), AchievementType.Custom ),
|
||||
|
||||
// done
|
||||
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDenseSmart(), AchievementType.Custom ),
|
||||
|
||||
// done
|
||||
P2P( 2, -2, AEApi.instance().definitions().parts().p2PTunnelME(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
Recursive( 6, -2, AEApi.instance().definitions().blocks().iface(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
CraftingCPU( 6, 0, AEApi.instance().definitions().blocks().craftingStorage64k(), AchievementType.CraftItem ),
|
||||
|
||||
// done
|
||||
Facade( 6, 2, AEApi.instance().definitions().items().facade(), AchievementType.CraftItem ),
|
||||
|
||||
// done
|
||||
NetworkTool( 8, 0, AEApi.instance().definitions().items().networkTool(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
PortableCell( 8, 2, AEApi.instance().definitions().items().portableCell(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
StorageBus( 10, 0, AEApi.instance().definitions().parts().storageBus(), AchievementType.Craft ),
|
||||
|
||||
// done
|
||||
QNB( 10, 2, AEApi.instance().definitions().blocks().quantumLink(), AchievementType.Craft );
|
||||
|
||||
private final ItemStack stack;
|
||||
private final AchievementType type;
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
private Advancement parent;
|
||||
private Advancement stat;
|
||||
|
||||
Achievements( final int x, final int y, final AEColoredItemDefinition which, final AchievementType type )
|
||||
{
|
||||
this.stack = ( which != null ) ? which.stack( AEColor.TRANSPARENT, 1 ) : ItemStack.EMPTY;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
Achievements( final int x, final int y, final IItemDefinition which, final AchievementType type )
|
||||
{
|
||||
this.stack = which.maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
Achievements( final int x, final int y, final ItemStack which, final AchievementType type )
|
||||
{
|
||||
this.stack = which;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
void setParent( final Achievements parent )
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Advancement getAchievement()
|
||||
{
|
||||
// if( this.stat == null && !this.getStack().isEmpty() )
|
||||
// {
|
||||
// this.stat = new Advancement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y,
|
||||
// this.getStack(), this.parent );
|
||||
// this.stat.registerStat();
|
||||
// }
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
public void addToPlayer( final EntityPlayer player )
|
||||
{
|
||||
// player.addStat( this.getAchievement(), 1 );
|
||||
}
|
||||
|
||||
AchievementType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
ItemStack getStack()
|
||||
{
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.core.stats;
|
||||
|
||||
|
||||
import appeng.bootstrap.ICriterionTriggerRegistry;
|
||||
|
||||
|
||||
public class AdvancementTriggers
|
||||
{
|
||||
private AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger( "network_apprentice" );
|
||||
private AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger( "network_engineer" );
|
||||
private AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger( "network_admin" );
|
||||
private AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger( "spatial_explorer" );
|
||||
|
||||
public AdvancementTriggers( ICriterionTriggerRegistry registry )
|
||||
{
|
||||
registry.register( networkApprentice );
|
||||
registry.register( networkEngineer );
|
||||
registry.register( networkAdmin );
|
||||
registry.register( spatialExplorer );
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkApprentice()
|
||||
{
|
||||
return this.networkApprentice;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkEngineer()
|
||||
{
|
||||
return this.networkEngineer;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkAdmin()
|
||||
{
|
||||
return this.networkAdmin;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getSpatialExplorer()
|
||||
{
|
||||
return this.spatialExplorer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* 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.core.stats;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.AbstractCriterionInstance;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class AppEngAdvancementTrigger implements ICriterionTrigger<AppEngAdvancementTrigger.Instance>, IAdvancementTrigger
|
||||
{
|
||||
private final ResourceLocation ID;
|
||||
private final Map<PlayerAdvancements, AppEngAdvancementTrigger.Listeners> listeners = new HashMap<>();
|
||||
|
||||
public AppEngAdvancementTrigger( String parString )
|
||||
{
|
||||
super();
|
||||
ID = new ResourceLocation( AppEng.MOD_ID, parString );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn );
|
||||
|
||||
if( l == null )
|
||||
{
|
||||
l = new AppEngAdvancementTrigger.Listeners( playerAdvancementsIn );
|
||||
this.listeners.put( playerAdvancementsIn, l );
|
||||
}
|
||||
|
||||
l.add( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn );
|
||||
|
||||
if( l != null )
|
||||
{
|
||||
l.remove( listener );
|
||||
|
||||
if( l.isEmpty() )
|
||||
{
|
||||
this.listeners.remove( playerAdvancementsIn );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners( PlayerAdvancements playerAdvancementsIn )
|
||||
{
|
||||
this.listeners.remove( playerAdvancementsIn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngAdvancementTrigger.Instance deserializeInstance( JsonObject json, JsonDeserializationContext context )
|
||||
{
|
||||
return new AppEngAdvancementTrigger.Instance( this.getId() );
|
||||
}
|
||||
|
||||
public void trigger( EntityPlayerMP parPlayer )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() );
|
||||
|
||||
if( l != null )
|
||||
{
|
||||
l.trigger( parPlayer );
|
||||
}
|
||||
}
|
||||
|
||||
public static class Instance extends AbstractCriterionInstance
|
||||
{
|
||||
public Instance( ResourceLocation parID )
|
||||
{
|
||||
super( parID );
|
||||
}
|
||||
|
||||
public boolean test()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static class Listeners
|
||||
{
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
private final Set<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> listeners = new HashSet<>();
|
||||
|
||||
Listeners( PlayerAdvancements playerAdvancementsIn )
|
||||
{
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.listeners.isEmpty();
|
||||
}
|
||||
|
||||
public void add( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
|
||||
public void remove( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
this.listeners.remove( listener );
|
||||
}
|
||||
|
||||
public void trigger( EntityPlayerMP player )
|
||||
{
|
||||
List<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> list = null;
|
||||
|
||||
for( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener : this.listeners )
|
||||
{
|
||||
if( listener.getCriterionInstance().test() )
|
||||
{
|
||||
if( list == null )
|
||||
{
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
list.add( listener );
|
||||
}
|
||||
}
|
||||
|
||||
if( list != null )
|
||||
{
|
||||
for( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> l : list )
|
||||
{
|
||||
l.grantCriterion( this.playerAdvancements );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
* 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
|
||||
@@ -19,9 +19,11 @@
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
public enum AchievementType
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IAdvancementTrigger
|
||||
{
|
||||
|
||||
Craft, CraftItem, Pickup, Custom
|
||||
|
||||
void trigger( EntityPlayerMP parPlayer );
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.core.stats;
|
||||
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.advancements.critereon.ItemPredicates;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.parts.ItemPart;
|
||||
import appeng.items.parts.PartType;
|
||||
|
||||
|
||||
public class PartItemPredicate extends ItemPredicate
|
||||
{
|
||||
private final PartType partType;
|
||||
|
||||
public PartItemPredicate( String partName )
|
||||
{
|
||||
this.partType = PartType.valueOf( partName.toUpperCase() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test( ItemStack item )
|
||||
{
|
||||
if( ItemPart.instance != null && item.getItem() == ItemPart.instance )
|
||||
{
|
||||
return ItemPart.instance.getTypeByStack( item ) == this.partType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemPredicate deserialize( JsonObject jsonobject )
|
||||
{
|
||||
if( jsonobject.has( "part" ) )
|
||||
{
|
||||
return new PartItemPredicate( JsonUtils.getString( jsonobject, "part" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemPredicate.ANY;
|
||||
}
|
||||
}
|
||||
|
||||
public static void register()
|
||||
{
|
||||
ItemPredicates.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize );
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
|
||||
/**
|
||||
* Can differentiate if a {@link net.minecraft.entity.player.EntityPlayer} is a real player or not
|
||||
*
|
||||
* @author thatsIch
|
||||
* @since rv2
|
||||
*/
|
||||
public class PlayerDifferentiator
|
||||
{
|
||||
/**
|
||||
* Can determine if an {@link net.minecraft.entity.player.EntityPlayer} is not a real player.
|
||||
* This is based on if the
|
||||
*
|
||||
* @param player is:
|
||||
* - null
|
||||
* - dead
|
||||
* - fake
|
||||
*
|
||||
* @param player to be checked player
|
||||
*
|
||||
* @return true if
|
||||
* @param player is not a real player
|
||||
*/
|
||||
boolean isNoPlayer( final EntityPlayer player )
|
||||
{
|
||||
return player == null || player.isDead || player instanceof FakePlayer;
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.stats;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
/**
|
||||
* Registers any items a player is picking up or is crafting.
|
||||
* Registered items are added to the player stats.
|
||||
* This will only happen if the {@link AEFeature#ACHIEVEMENTS} feature is enabled.
|
||||
*/
|
||||
public class PlayerStatsRegistration
|
||||
{
|
||||
/**
|
||||
* {@link net.minecraftforge.fml.common.eventhandler.EventBus} to which the handlers might get posted to depending
|
||||
* if the feature is enabled
|
||||
*/
|
||||
private final EventBus bus;
|
||||
|
||||
/**
|
||||
* is true if the {@link appeng.core.features.AEFeature#ACHIEVEMENTS} is enabled in the
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
private final boolean isAchievementFeatureEnabled;
|
||||
|
||||
/**
|
||||
* Constructs this with an {@link net.minecraftforge.fml.common.eventhandler.EventBus} and
|
||||
* {@link appeng.core.AEConfig}.
|
||||
*
|
||||
* @param bus {@see #bus}
|
||||
* @param config {@link appeng.core.AEConfig} which is used to determine if the
|
||||
* {@link appeng.core.features.AEFeature#ACHIEVEMENTS} is enabled
|
||||
*/
|
||||
public PlayerStatsRegistration( final EventBus bus, final AEConfig config )
|
||||
{
|
||||
this.bus = bus;
|
||||
this.isAchievementFeatureEnabled = config.isFeatureEnabled( AEFeature.ACHIEVEMENTS );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the {@link appeng.core.stats.AchievementCraftingHandler} and
|
||||
* {@link appeng.core.stats.AchievementPickupHandler} to the {@link #bus} if {@link #isAchievementFeatureEnabled} is
|
||||
* true.
|
||||
*/
|
||||
public void registerAchievementHandlers()
|
||||
{
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final PlayerDifferentiator differentiator = new PlayerDifferentiator();
|
||||
final AchievementCraftingHandler craftingHandler = new AchievementCraftingHandler( differentiator );
|
||||
final AchievementPickupHandler pickupHandler = new AchievementPickupHandler( differentiator );
|
||||
|
||||
this.bus.register( craftingHandler );
|
||||
this.bus.register( pickupHandler );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the {@link appeng.core.stats.AchievementHierarchy} and adds all {@link appeng.core.stats.Achievements}
|
||||
* to a new {@link net.minecraft.advancements.Advancement}.
|
||||
*/
|
||||
public void registerAchievements()
|
||||
{
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final AchievementHierarchy hierarchy = new AchievementHierarchy();
|
||||
hierarchy.registerAchievementHierarchy();
|
||||
|
||||
for( final Stats s : Stats.values() )
|
||||
{
|
||||
s.getStat();
|
||||
}
|
||||
|
||||
/**
|
||||
* register
|
||||
*/
|
||||
// final ArrayList<Achievement> list = new ArrayList<Achievement>();
|
||||
//
|
||||
// for( final Achievements a : Achievements.values() )
|
||||
// {
|
||||
// final Achievement ach = a.getAchievement();
|
||||
// if( ach != null )
|
||||
// {
|
||||
// list.add( ach );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final AchievementPage ae2AchievementPage = new AchievementPage( "Applied Energistics 2", list.toArray(
|
||||
// new Achievement[list.size()] ) );
|
||||
// AchievementPage.registerAchievementPage( ae2AchievementPage );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,18 +44,18 @@ public enum Stats
|
||||
|
||||
public void addToPlayer( final EntityPlayer player, final int howMany )
|
||||
{
|
||||
player.addStat( this.getStat(), howMany );
|
||||
player.addStat( this.stat, howMany );
|
||||
}
|
||||
|
||||
StatBasic getStat()
|
||||
public static void register()
|
||||
{
|
||||
if( this.stat == null )
|
||||
for( final Stats s : Stats.values() )
|
||||
{
|
||||
this.stat = new StatBasic( "stat.ae2." + this.name(), new TextComponentTranslation( "stat.ae2." + this.name() ) );
|
||||
this.stat.registerStat();
|
||||
if( s.stat == null )
|
||||
{
|
||||
s.stat = new StatBasic( "stat.ae2." + s.name(), new TextComponentTranslation( "stat.ae2." + s.name() ) );
|
||||
s.stat.registerStat();
|
||||
}
|
||||
}
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user