Skip to content

Commit

Permalink
Changed Multiblocks to accept redstone-ignoring conveyors as well as …
Browse files Browse the repository at this point in the history
…default ones.

They will revert to normal ones when the multiblock is broken.
  • Loading branch information
BluSunrize committed Dec 25, 2018
1 parent 5639af7 commit fe10198
Show file tree
Hide file tree
Showing 3 changed files with 1,246 additions and 1,224 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#####Version 0.12-88
- Fix crashes when opening a toolbox or a revolver GUI (Malte)
- Changed Multiblocks to accept redstone-ignoring conveyors as well as default ones. They will revert to normal ones when the multiblock is broken. (BluSunrize)
- Fixed crashes when opening a toolbox or a revolver GUI (Malte)
- Fixed side solidity on conveyors, prevents snow on places it shouldn't be (BluSunrize)

#####Version 0.12-87 - BUILT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import java.util.*;
Expand All @@ -44,6 +45,7 @@
public class ConveyorHandler
{
public static HashMap<ResourceLocation, Class<? extends IConveyorBelt>> classRegistry = new LinkedHashMap<ResourceLocation, Class<? extends IConveyorBelt>>();
public static HashMap<ResourceLocation, Set<ResourceLocation>> substituteRegistry = new HashMap<>();
public static HashMap<ResourceLocation, Function<TileEntity, ? extends IConveyorBelt>> functionRegistry = new LinkedHashMap<ResourceLocation, Function<TileEntity, ? extends IConveyorBelt>>();
public static HashMap<Class<? extends IConveyorBelt>, ResourceLocation> reverseClassRegistry = new LinkedHashMap<Class<? extends IConveyorBelt>, ResourceLocation>();
public static Set<BiConsumer<Entity, IConveyorTile>> magnetSupressionFunctions = new HashSet<BiConsumer<Entity, IConveyorTile>>();
Expand All @@ -67,6 +69,17 @@ public static <T extends IConveyorBelt> boolean registerConveyorHandler(Resource
return true;
}

/**
* Registers a valid substitute for the given key conveyor. This substitute is allowed in the construction of multiblocks in place of the key
* @param key A unique ResourceLocation to identify the conveyor by
* @param substitute A unique ResourceLocation to identify the substitute
*/
public static void registerSubstitute(ResourceLocation key, ResourceLocation substitute)
{
Set<ResourceLocation> registeredSubstitutes = substituteRegistry.computeIfAbsent(key, k -> new HashSet<>());
registeredSubstitutes.add(substitute);
}

/**
* @return a new instance of the given conveyor type
*/
Expand All @@ -92,7 +105,7 @@ public static ItemStack getConveyorStack(String key)
/**
* @return whether the given subtype key can be found at the location. Useful for multiblocks
*/
public static boolean isConveyor(World world, BlockPos pos, String key, @Nullable EnumFacing facing)
public static boolean isConveyor(World world, BlockPos pos, @Nonnull String key, @Nullable EnumFacing facing)
{
TileEntity tile = world.getTileEntity(pos);
if(!(tile instanceof IConveyorTile))
Expand All @@ -103,7 +116,14 @@ public static boolean isConveyor(World world, BlockPos pos, String key, @Nullabl
if(conveyor==null)
return false;
ResourceLocation rl = reverseClassRegistry.get(conveyor.getClass());
return !(rl==null||!key.equalsIgnoreCase(rl.toString()));
if(rl==null)
return false;
ResourceLocation rlKey = new ResourceLocation(key);
if(key.equalsIgnoreCase(rl.toString()))
return true;
else if(substituteRegistry.containsKey(rlKey))
return substituteRegistry.get(rlKey).contains(rl);
return false;
}

/**
Expand Down
Loading

0 comments on commit fe10198

Please sign in to comment.