Clean Up API

This commit is contained in:
Nedelosk committed 2018-01-20 21:29:07 +01:00
1 parent c00fa15f0e
commit 533c9d0b2a
11 files changed
+37 -39

No files matched your search

@@ -64,7 +64,7 @@ public interface IFarmLogic {
}
/**
* Use {@link IFarmRegistry#getFarm(String)} to get the soil container for the farm logic and register the soil
* Use {@link IFarmRegistry#getProperties(String)} to get the {@link IFarmProperties} for the farm logic and register the soil
* with {@link IFarmProperties#registerSoil(ItemStack, IBlockState, boolean)}.
*/
@Deprecated
@@ -78,7 +78,6 @@ public interface IFarmLogic {
String getName();
/* GUI ONLY */
/**
* @deprecated No longer needed because mc always uses the same map for blocks and items.
* TODO remove this method in 1.13
@@ -10,23 +10,39 @@ import net.minecraft.item.ItemStack;
*/
public interface IFarmProperties {
/**
* Can be used to register a {@link IBlockState} as a valid soil.
*/
default void registerSoil(ItemStack resource, IBlockState soilState){
registerSoil(resource, soilState, false);
}
void registerFarmables(String identifier);
/**
* Can be used to register a {@link IBlockState} as a valid soil.
*/
void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData);
/**
* Adds the {@link IFarmable}s that where registered with the given identifier.
*/
void registerFarmables(String identifier);
/**
* @return true if the given block state is a valid soil state.
*/
boolean isAcceptedSoil(IBlockState blockState);
/**
* @return true if the given stack is the {@link ItemStack} of a soil.
*/
boolean isAcceptedResource(ItemStack itemStack);
String getIdentifier();
Collection<ISoil> getSoils();
Collection<IFarmable> getFarmables();
/**
* Returns the instance of the manual or managed {@link IFarmLogic}.
*/
IFarmLogic getLogic(boolean manuel);
}
@@ -19,7 +19,7 @@ public interface IFarmRegistry {
* @param logic corresponding instance of logic
*
* @deprecated Since Forestry 5.8. Use {@link #registerLogic(String, BiFunction, String...)} or
* {@link #registerLogic(IFarmProperties)}.
* {@link #registerLogic(String, IFarmProperties)}.
*/
@Deprecated
void registerLogic(String identifier, IFarmLogic logic);
@@ -28,7 +28,7 @@ public interface IFarmRegistry {
* Registers farming logic in registry
* @since Forestry 5.8
*/
IFarmProperties registerLogic(IFarmProperties farmInstance);
IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance);
/**
* Registers farming logic in registry under given identifier
@@ -91,13 +91,9 @@ public interface IFarmRegistry {
IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic);
/**
*
* @param identifier
* @return
*
* @since Forestry 5.8
*/
@Nullable
IFarmProperties getFarm(String identifier);
IFarmProperties getProperties(String identifier);
}
@@ -88,7 +88,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
public void setManual(boolean manual) {
isManual = manual;
logic = FarmRegistry.getInstance().getFarm(identifier).getLogic(manual);
logic = FarmRegistry.getInstance().getProperties(identifier).getLogic(manual);
}
protected TilePlanter(String identifier) {
@@ -33,8 +33,7 @@ public class DummyFarmRegistry implements IFarmRegistry {
}
@Override
public IFarmProperties registerLogic(IFarmProperties farmInstance) {
//Dummy-Implementation
public IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance) {
return null;
}
@@ -69,7 +68,7 @@ public class DummyFarmRegistry implements IFarmRegistry {
@Nullable
@Override
public IFarmProperties getFarm(String identifier) {
public IFarmProperties getProperties(String identifier) {
//Dummy-Implementation
return null;
}
@@ -88,23 +88,23 @@ public final class FarmRegistry implements IFarmRegistry {
}
@Override
public IFarmProperties registerLogic(IFarmProperties farmInstance) {
farmInstances.put(farmInstance.getIdentifier(), farmInstance);
public IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance) {
farmInstances.put(identifier, farmInstance);
return farmInstance;
}
@Override
public IFarmProperties registerLogic(String identifier, BiFunction<IFarmProperties, Boolean, IFarmLogic> logicFactory, String... farmablesIdentifiers) {
Set<String> fIdentifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers));
fIdentifiers.add(identifier);
IFarmProperties instance = new FarmProperties(identifier, logicFactory, fIdentifiers);
Set<String> identifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers));
identifiers.add(identifier);
IFarmProperties instance = new FarmProperties(logicFactory, identifiers);
farmInstances.put(identifier, instance);
return instance;
}
@Override
@Nullable
public IFarmProperties getFarm(String identifier) {
public IFarmProperties getProperties(String identifier) {
return farmInstances.get(identifier);
}
@@ -36,11 +36,6 @@ public class FakeFarmProperties implements IFarmProperties {
return false;
}
@Override
public String getIdentifier() {
return "farmFake";
}
@Override
public Collection<ISoil> getSoils() {
return Collections.emptySet();
@@ -22,13 +22,11 @@ public final class FarmProperties implements IFarmProperties {
private final Set<String> farmablesIdentifiers;
private final IFarmLogic manualLogic;
private final IFarmLogic managedLogic;
private final String identifier;
@Nullable
private Collection<IFarmable> farmables;
public FarmProperties(String identifier, BiFunction<IFarmProperties, Boolean, IFarmLogic> logicFactory, Set<String> farmablesIdentifiers) {
this.identifier = identifier;
public FarmProperties(BiFunction<IFarmProperties, Boolean, IFarmLogic> logicFactory, Set<String> farmablesIdentifiers) {
this.farmablesIdentifiers = farmablesIdentifiers;
this.manualLogic = logicFactory.apply(this, true);
this.managedLogic = logicFactory.apply(this, false);
@@ -86,9 +84,4 @@ public final class FarmProperties implements IFarmProperties {
public Collection<ISoil> getSoils() {
return soils;
}
@Override
public String getIdentifier() {
return identifier;
}
}
@@ -87,7 +87,7 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
@Override
public IFarmLogic getFarmLogic(FarmDirection direction) {
return FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false);
return FarmRegistry.getInstance().getProperties("farmArboreal").getLogic(false);
}
@Override
@@ -630,7 +630,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
@Override
public void resetFarmLogic(FarmDirection direction) {
setFarmLogic(direction, FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false));
setFarmLogic(direction, FarmRegistry.getInstance().getProperties("farmArboreal").getLogic(false));
}
@Override
@@ -266,7 +266,7 @@ public class PluginNatura extends BlankForestryModule {
*/
@Override
public void postInit() {
IFarmProperties farmArboreal = FarmRegistry.getInstance().getFarm("managedArboreal");
IFarmProperties farmArboreal = FarmRegistry.getInstance().getProperties("managedArboreal");
if(farmArboreal != null) {
farmArboreal.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false);
}