reformatted all src files (#141)
This commit is contained in:
@@ -22,15 +22,14 @@ package appeng.recipes.ores;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public interface IOreListener
|
||||
{
|
||||
public interface IOreListener {
|
||||
|
||||
/**
|
||||
* Called with various items registered in the dictionary.
|
||||
* AppEng.oreDictionary.observe(...) to register them.
|
||||
*
|
||||
* @param name name of ore
|
||||
* @param item item with name
|
||||
*/
|
||||
void oreRegistered( String name, ItemStack item );
|
||||
/**
|
||||
* Called with various items registered in the dictionary.
|
||||
* AppEng.oreDictionary.observe(...) to register them.
|
||||
*
|
||||
* @param name name of ore
|
||||
* @param item item with name
|
||||
*/
|
||||
void oreRegistered(String name, ItemStack item);
|
||||
}
|
||||
|
||||
@@ -19,73 +19,61 @@
|
||||
package appeng.recipes.ores;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OreDictionaryHandler
|
||||
{
|
||||
|
||||
public static final OreDictionaryHandler INSTANCE = new OreDictionaryHandler();
|
||||
public class OreDictionaryHandler {
|
||||
|
||||
private final List<IOreListener> oreListeners = new ArrayList<>();
|
||||
public static final OreDictionaryHandler INSTANCE = new OreDictionaryHandler();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOreDictionaryRegister( final OreDictionary.OreRegisterEvent event )
|
||||
{
|
||||
if( event.getName() == null || event.getOre().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
private final List<IOreListener> oreListeners = new ArrayList<>();
|
||||
|
||||
if( this.shouldCare( event.getName() ) )
|
||||
{
|
||||
for( final IOreListener v : this.oreListeners )
|
||||
{
|
||||
v.oreRegistered( event.getName(), event.getOre() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void onOreDictionaryRegister(final OreDictionary.OreRegisterEvent event) {
|
||||
if (event.getName() == null || event.getOre().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Just limit what items are sent to the final listeners, I got sick of strange items showing up...
|
||||
*
|
||||
* @param name name about cared item
|
||||
*
|
||||
* @return true if it should care
|
||||
*/
|
||||
private boolean shouldCare( final String name )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (this.shouldCare(event.getName())) {
|
||||
for (final IOreListener v : this.oreListeners) {
|
||||
v.oreRegistered(event.getName(), event.getOre());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new IOreListener and immediately notifies it of any previous ores, any ores added latter will be added at
|
||||
* that point.
|
||||
*
|
||||
* @param n to be added ore listener
|
||||
*/
|
||||
public void observe( final IOreListener n )
|
||||
{
|
||||
this.oreListeners.add( n );
|
||||
/**
|
||||
* Just limit what items are sent to the final listeners, I got sick of strange items showing up...
|
||||
*
|
||||
* @param name name about cared item
|
||||
* @return true if it should care
|
||||
*/
|
||||
private boolean shouldCare(final String name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// notify the listener of any ore already in existence.
|
||||
for( final String name : OreDictionary.getOreNames() )
|
||||
{
|
||||
if( name != null && this.shouldCare( name ) )
|
||||
{
|
||||
for( final ItemStack item : OreDictionary.getOres( name ) )
|
||||
{
|
||||
if( !item.isEmpty() )
|
||||
{
|
||||
n.oreRegistered( name, item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds a new IOreListener and immediately notifies it of any previous ores, any ores added latter will be added at
|
||||
* that point.
|
||||
*
|
||||
* @param n to be added ore listener
|
||||
*/
|
||||
public void observe(final IOreListener n) {
|
||||
this.oreListeners.add(n);
|
||||
|
||||
// notify the listener of any ore already in existence.
|
||||
for (final String name : OreDictionary.getOreNames()) {
|
||||
if (name != null && this.shouldCare(name)) {
|
||||
for (final ItemStack item : OreDictionary.getOres(name)) {
|
||||
if (!item.isEmpty()) {
|
||||
n.oreRegistered(name, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user