fixed energy usage in creative and stone/gravel requirements, fix #1558
This commit is contained in:
parent
2cd973caab
commit
fea765d875
4 changed files with 101 additions and 15 deletions
|
@ -64,6 +64,7 @@ import buildcraft.builders.schematics.SchematicDoor;
|
|||
import buildcraft.builders.schematics.SchematicFarmland;
|
||||
import buildcraft.builders.schematics.SchematicFire;
|
||||
import buildcraft.builders.schematics.SchematicFluid;
|
||||
import buildcraft.builders.schematics.SchematicGravel;
|
||||
import buildcraft.builders.schematics.SchematicHanging;
|
||||
import buildcraft.builders.schematics.SchematicIgnore;
|
||||
import buildcraft.builders.schematics.SchematicIgnoreMeta;
|
||||
|
@ -78,6 +79,7 @@ import buildcraft.builders.schematics.SchematicRotateMeta;
|
|||
import buildcraft.builders.schematics.SchematicSeeds;
|
||||
import buildcraft.builders.schematics.SchematicSign;
|
||||
import buildcraft.builders.schematics.SchematicStairs;
|
||||
import buildcraft.builders.schematics.SchematicStone;
|
||||
import buildcraft.builders.schematics.SchematicWallSide;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
import buildcraft.builders.triggers.BuildersActionProvider;
|
||||
|
@ -191,7 +193,18 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
SchematicRegistry.registerSchematicBlock(Blocks.stone_button, SchematicLever.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.lever, SchematicLever.class);
|
||||
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.stone, SchematicCustomStack.class, new ItemStack(Blocks.stone));
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.stone, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.gold_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.iron_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.coal_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.lapis_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.diamond_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.redstone_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.lit_redstone_ore, SchematicStone.class);
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.emerald_ore, SchematicStone.class);
|
||||
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.gravel, SchematicGravel.class);
|
||||
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.redstone_wire, SchematicCustomStack.class, new ItemStack(Items.redstone));
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.cake, SchematicCustomStack.class, new ItemStack(Items.cake));
|
||||
SchematicRegistry.registerSchematicBlock(Blocks.pumpkin_stem, SchematicCustomStack.class, new ItemStack(Items.pumpkin_seeds));
|
||||
|
|
37
common/buildcraft/builders/schematics/SchematicGravel.java
Executable file
37
common/buildcraft/builders/schematics/SchematicGravel.java
Executable file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.builders.schematics;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
|
||||
public class SchematicGravel extends SchematicBlock {
|
||||
|
||||
@Override
|
||||
public void addRequirements(IBuilderContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Blocks.gravel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList <ItemStack> stacks) {
|
||||
context.world().setBlock(x, y, z, Blocks.gravel, 0, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(IBuilderContext context, int x, int y, int z) {
|
||||
Block block = context.world().getBlock(x, y, z);
|
||||
|
||||
return block == Blocks.gravel;
|
||||
}
|
||||
}
|
37
common/buildcraft/builders/schematics/SchematicStone.java
Executable file
37
common/buildcraft/builders/schematics/SchematicStone.java
Executable file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.builders.schematics;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
|
||||
public class SchematicStone extends SchematicBlock {
|
||||
|
||||
@Override
|
||||
public void addRequirements(IBuilderContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Blocks.stone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList <ItemStack> stacks) {
|
||||
context.world().setBlock(x, y, z, Blocks.stone, 0, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(IBuilderContext context, int x, int y, int z) {
|
||||
Block block = context.world().getBlock(x, y, z);
|
||||
|
||||
return block == Blocks.stone;
|
||||
}
|
||||
}
|
|
@ -183,20 +183,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (world.getWorldInfo().getGameType() == GameType.CREATIVE) {
|
||||
|
||||
// In creative, we don't use blocks or energy from the
|
||||
// builder
|
||||
|
||||
for (ItemStack s : slot.getRequirements(context)) {
|
||||
slot.addStackConsumed(s);
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
postProcessing.add(slot);
|
||||
return slot;
|
||||
} else if (checkRequirements(builder,
|
||||
(SchematicBlock) slot.schematic)) {
|
||||
if (checkRequirements(builder, (SchematicBlock) slot.schematic)) {
|
||||
useRequirements(builder, slot);
|
||||
|
||||
iterator.remove();
|
||||
|
@ -239,6 +226,10 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (context.world().getWorldInfo().getGameType() == GameType.CREATIVE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int size = builder.getSizeInventory();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (!builder.isBuildingMaterialSlot(i)) {
|
||||
|
@ -296,6 +287,14 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
|
||||
builder.consumeEnergy(energyRequired);
|
||||
|
||||
if (context.world ().getWorldInfo().getGameType() == GameType.CREATIVE) {
|
||||
for (ItemStack s : slot.getRequirements(context)) {
|
||||
slot.addStackConsumed(s);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ListIterator<ItemStack> itr = tmpReq.listIterator();
|
||||
|
||||
while (itr.hasNext()) {
|
||||
|
|
Loading…
Reference in a new issue