Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make swimming in oil a lot harder #2377

Merged
merged 1 commit into from Jan 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/buildcraft/BuildCraftEnergy.java
Expand Up @@ -103,6 +103,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
public static Item fuel;

public static boolean canOilBurn;
public static boolean isOilDense;
public static boolean canEnginesExplode;
public static double oilWellScalar = 1.0;
public static ITriggerExternal triggerBlueEngineHeat = new TriggerEngineHeat(EnergyStage.BLUE);
Expand All @@ -121,6 +122,7 @@ public void preInit(FMLPreInitializationEvent evt) {
int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT);
int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN);
canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true);
isOilDense = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "denseOil", true, "Should it be hard to swim in oil?").getBoolean(true);
oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0);
canEnginesExplode = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "enginesExplode", false, "Do engines explode upon overheat?").getBoolean(false);

Expand Down Expand Up @@ -192,7 +194,7 @@ public void preInit(FMLPreInitializationEvent evt) {
fluidRedPlasma = FluidRegistry.getFluid("redplasma");

if (fluidOil.getBlock() == null) {
blockOil = new BlockBuildcraftFluid(fluidOil, Material.water, MapColor.blackColor).setFlammable(canOilBurn).setFlammability(0);
blockOil = new BlockBuildcraftFluid(fluidOil, Material.water, MapColor.blackColor).setFlammable(canOilBurn).setFlammability(0).setDense(isOilDense);
blockOil.setBlockName("blockOil").setLightOpacity(8);
CoreProxy.proxy.registerBlock(blockOil);
fluidOil.setBlock(blockOil);
Expand Down
23 changes: 23 additions & 0 deletions common/buildcraft/energy/BlockBuildcraftFluid.java
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand All @@ -37,6 +38,7 @@ public class BlockBuildcraftFluid extends BlockFluidClassic {
@SideOnly(Side.CLIENT)
protected IIcon[] theIcon;
protected boolean flammable;
protected boolean dense = false;
protected int flammability = 0;
private MapColor mapColor;

Expand Down Expand Up @@ -67,6 +69,27 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
}
}

@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {

if(!dense || entity == null) return;

entity.motionY = Math.min(0.0, entity.motionY);

if (entity.motionY < -0.05) {
entity.motionY *= 0.05;
}

entity.motionX = Math.max(-0.05, Math.min(0.05, entity.motionX * 0.05));
entity.motionY -= 0.05;
entity.motionZ = Math.max(-0.05, Math.min(0.05, entity.motionZ * 0.05));
}

public BlockBuildcraftFluid setDense(boolean dense) {
this.dense = dense;
return this;
}

public BlockBuildcraftFluid setFlammable(boolean flammable) {
this.flammable = flammable;
return this;
Expand Down