fix #3341
This commit is contained in:
parent
cc9df443f7
commit
50f983bda3
3 changed files with 33 additions and 31 deletions
|
@ -14,6 +14,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
import buildcraft.api.blueprints.*;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -54,14 +55,6 @@ import net.minecraftforge.common.ForgeChunkManager;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import buildcraft.api.blueprints.BlueprintDeployer;
|
||||
import buildcraft.api.blueprints.BuilderAPI;
|
||||
import buildcraft.api.blueprints.ISchematicRegistry;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
import buildcraft.api.blueprints.SchematicEntity;
|
||||
import buildcraft.api.blueprints.SchematicFactory;
|
||||
import buildcraft.api.blueprints.SchematicMask;
|
||||
import buildcraft.api.blueprints.SchematicTile;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.library.LibraryAPI;
|
||||
import buildcraft.api.statements.StatementManager;
|
||||
|
@ -141,6 +134,8 @@ import buildcraft.core.builders.schematics.SchematicRotateMeta;
|
|||
import buildcraft.core.builders.schematics.SchematicRotateMetaSupported;
|
||||
import buildcraft.core.builders.schematics.SchematicTileCreative;
|
||||
import buildcraft.core.config.ConfigManager;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
public class BuildCraftBuilders extends BuildCraftMod {
|
||||
|
|
|
@ -2,14 +2,10 @@ package buildcraft.builders;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBasePressurePlate;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.BlockButton;
|
||||
import net.minecraft.block.BlockLever;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import buildcraft.api.blueprints.Schematic;
|
||||
import buildcraft.core.builders.schematics.SchematicIgnore;
|
||||
import buildcraft.core.lib.utils.FluidUtils;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
@ -41,18 +37,16 @@ public final class HeuristicBlockDetection {
|
|||
if (!SchematicRegistry.INSTANCE.isSupported(block, meta)) {
|
||||
try {
|
||||
if (block.hasTileEntity(meta)) {
|
||||
// All tiles are registered as creative only.
|
||||
// This is helpful for example for server admins.
|
||||
// All tiles not otherwise supported are registered
|
||||
// as creative only to prevent exploitation.
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicTileCreative.class);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (block instanceof IFluidBlock) {
|
||||
IFluidBlock fblock = (IFluidBlock) block;
|
||||
if (fblock.getFluid() != null) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicFluid.class, new FluidStack(fblock.getFluid(), 1000));
|
||||
}
|
||||
if (block instanceof BlockDynamicLiquid) {
|
||||
// Fixes #3341 - not recording flowing water
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicIgnore.class);
|
||||
} else {
|
||||
if (block instanceof BlockBush || block instanceof IPlantable || block instanceof IGrowable || block instanceof BlockBasePressurePlate) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockFloored.class);
|
||||
|
@ -60,10 +54,15 @@ public final class HeuristicBlockDetection {
|
|||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicWallSide.class);
|
||||
} else if (block instanceof BlockStairs) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicStairs.class);
|
||||
} else {
|
||||
FluidStack fstack = FluidUtils.getFluidStackFromBlock(block);
|
||||
if (fstack != null) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicFluid.class, fstack);
|
||||
} else {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,20 @@ public final class FluidUtils {
|
|||
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStackFromBlock(Block b) {
|
||||
if (b != null) {
|
||||
if (b instanceof IFluidBlock && ((IFluidBlock) b).getFluid() != null) {
|
||||
return new FluidStack(((IFluidBlock) b).getFluid(), 1000);
|
||||
} else if (b == Blocks.lava) {
|
||||
return new FluidStack(FluidRegistry.getFluid("lava"), 1000);
|
||||
} else if (b == Blocks.water) {
|
||||
return new FluidStack(FluidRegistry.getFluid("water"), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStackFromItemStack(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
|
@ -26,13 +40,7 @@ public final class FluidUtils {
|
|||
} else if (stack.getItem() instanceof ItemBlock) {
|
||||
Block b = Block.getBlockFromItem(stack.getItem());
|
||||
if (b != null) {
|
||||
if (b instanceof IFluidBlock && ((IFluidBlock) b).getFluid() != null) {
|
||||
return new FluidStack(((IFluidBlock) b).getFluid(), 1000);
|
||||
} else if (b == Blocks.lava) {
|
||||
return new FluidStack(FluidRegistry.getFluid("lava"), 1000);
|
||||
} else if (b == Blocks.water) {
|
||||
return new FluidStack(FluidRegistry.getFluid("water"), 1000);
|
||||
}
|
||||
return getFluidStackFromBlock(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue