Finished CraftingManager.

This commit is contained in:
zangamj 2016-08-05 10:49:05 -04:00
parent 1ee1583a06
commit 23e57a9cca
2 changed files with 35 additions and 79 deletions

View file

@ -16,8 +16,7 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
public class ConnectionHandler
{
public class ConnectionHandler {
@SubscribeEvent
public void serverConnectionFromClientEvent(FMLNetworkEvent.ServerConnectionFromClientEvent event) {
if (FMLCommonHandler.instance().getSide() == Side.SERVER) {
@ -25,10 +24,10 @@ public class ConnectionHandler
FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
for (NewDimData data : PocketManager.getDimensions()) {
try {
if (data.isPocketDimension() || data.id() == DDProperties.instance().LimboDimensionID) {
channel.writeOutbound(new ForgeMessage.DimensionRegisterMessage(data.id(), DimensionManager.getProviderType(data.id())));
}
int id = data.id();
if (data.isPocketDimension() || id == DDProperties.instance().LimboDimensionID)
channel.writeOutbound(new ForgeMessage.DimensionRegisterMessage(id,
DimensionManager.getProviderType(id)));
} catch (Exception ex) {
ex.printStackTrace();
}
@ -37,16 +36,11 @@ public class ConnectionHandler
}
@SubscribeEvent
public void connectionClosed(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
PocketManager.tryUnload();
}
public void connectionClosed(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {PocketManager.tryUnload();}
@SubscribeEvent
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
// Hax... please don't do this! >_<
DimDoorsNetwork.sendToPlayer(new ClientJoinPacket(), event.player);
}
}

View file

@ -14,16 +14,10 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
import com.zixiken.dimdoors.items.ItemDDKey;
public class CraftingManager
{
CraftingManager() { }
public static void registerRecipes(DDProperties properties)
{
public class CraftingManager {
public static void registerRecipes(DDProperties properties) {
if (properties.CraftingStableFabricAllowed)
{
switch (properties.WorldThreadRequirementLevel)
{
switch (properties.WorldThreadRequirementLevel) {
case 1:
GameRegistry.addShapelessRecipe(new ItemStack(DimDoors.itemStableFabric, 1),
Items.ender_pearl, DimDoors.itemWorldThread);
@ -39,79 +33,57 @@ public class CraftingManager
default:
GameRegistry.addRecipe(new ItemStack(DimDoors.itemStableFabric, 1),
"yyy", "yxy", "yyy", 'x', Items.ender_pearl, 'y', DimDoors.itemWorldThread);
break;
}
}
if (properties.CraftingDimensionalDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemDimensionalDoor, 1),
"yxy", 'x', DimDoors.itemStableFabric, 'y', Items.iron_door);
}
if (properties.CraftingUnstableDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemUnstableDoor, 1),
"yxy", 'x', Items.ender_eye, 'y', DimDoors.itemDimensionalDoor);
}
if (properties.CraftingWarpDoorAllowed)
{
if (properties.CraftingWarpDoorAllowed)
GameRegistry.addRecipe(new ItemStack(DimDoors.itemWarpDoor, 1),
"yxy", 'x', Items.ender_pearl, 'y', Items.oak_door);
}
if (properties.CraftingTransTrapdoorAllowed)
{
if (properties.CraftingTransTrapdoorAllowed)
GameRegistry.addRecipe(new ItemStack(DimDoors.transTrapdoor, 1),
"y", "x", "y", 'x', Items.ender_pearl, 'y', Blocks.trapdoor);
}
if (properties.CraftingRiftSignatureAllowed)
{
if (properties.CraftingRiftSignatureAllowed)
GameRegistry.addRecipe(new ItemStack(DimDoors.itemRiftSignature, 1),
" y ", "yxy", " y ", 'x', Items.ender_pearl, 'y', Items.iron_ingot);
}
if (properties.CraftingRiftRemoverAllowed)
{
if (properties.CraftingRiftRemoverAllowed)
GameRegistry.addRecipe(new ItemStack(DimDoors.itemRiftRemover, 1),
"yyy", "yxy", "yyy", 'x', Items.ender_pearl, 'y', Items.gold_ingot);
}
if (properties.CraftingRiftBladeAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemRiftBlade, 1),
"x", "x", "y", 'x', DimDoors.itemStableFabric, 'y', Items.blaze_rod);
}
if (properties.CraftingStabilizedRiftSignatureAllowed)
{
if (properties.CraftingStabilizedRiftSignatureAllowed)
GameRegistry.addRecipe(new ItemStack(DimDoors.itemStabilizedRiftSignature, 1),
" y ", "yxy", " y ", 'x', DimDoors.itemStableFabric, 'y', Items.iron_ingot);
}
if (properties.CraftingGoldenDimensionalDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemGoldenDimensionalDoor, 1),
"yxy", 'x', DimDoors.itemStableFabric, 'y', DimDoors.itemGoldenDoor);
}
if (properties.CraftingGoldenDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemGoldenDoor, 1),
"yy", "yy", "yy", 'y', Items.gold_ingot);
}
if (properties.CraftingPersonalDimDoorAllowed)
{
GameRegistry.addRecipe(new ItemStack(DimDoors.itemPersonalDoor,1),
"yxy", 'y', DimDoors.itemQuartzDoor, 'x', DimDoors.itemStableFabric);
}
if (properties.CraftingQuartzDoorAllowed)
{
GameRegistry.addRecipe(new ShapedOreRecipe(DimDoors.itemQuartzDoor, new Object[]{
"yy", "yy", "yy", Character.valueOf('y'), "oreQuartz"}));
}
if (properties.CraftingDDKeysAllowed)
{
GameRegistry.addRecipe(new ShapedOreRecipe(DimDoors.itemQuartzDoor,
"yy", "yy", "yy", 'y', "oreQuartz"));
if (properties.CraftingDDKeysAllowed) {
GameRegistry.addRecipe(new ItemStack(DimDoors.itemDDKey, 1),
" z", " y ", "y ", 'y', Items.gold_ingot, 'z', Items.ender_pearl);
GameRegistry.addRecipe(new ItemStack(DimDoors.itemDDKey, 1),
@ -121,42 +93,32 @@ public class CraftingManager
}
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event)
{
if(event.crafting.getItem() instanceof ItemDDKey)
{
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
if(event.crafting.getItem() instanceof ItemDDKey) {
ItemDDKey keyItem = (ItemDDKey) event.crafting.getItem();
ItemStack topKey = null;
ItemStack bottomKey = null;
int topKeySlot = 0;
for(int i = 0; i<event.craftMatrix.getSizeInventory();i++)
{
for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
ItemStack slot = event.craftMatrix.getStackInSlot(i);
if(slot!=null)
{
if(topKey==null)
{
topKey = slot;
topKeySlot = i;
}
else
{
if(slot != null) {
if(topKey == null) topKey = slot;
else {
bottomKey = slot;
break;
}
}
}
DDLock.addKeys(bottomKey, DDLock.getKeys(topKey));
event.crafting.setTagCompound(bottomKey.getTagCompound());
event.player.inventory.addItemStackToInventory(topKey);
}
}
public static void registerDispenserBehaviors()
{
public static void registerDispenserBehaviors() {
// Register the dispenser behaviors for certain DD items
BlockDispenser.dispenseBehaviorRegistry.putObject(DimDoors.itemStabilizedRiftSignature, new DispenserBehaviorStabilizedRS());
BlockDispenser.dispenseBehaviorRegistry.putObject(
DimDoors.itemStabilizedRiftSignature, new DispenserBehaviorStabilizedRS());
}
}