made the water bowl spill

Closes #785
This commit is contained in:
Ellpeck 2017-05-28 01:49:57 +02:00
parent d84a1b7ba2
commit 348086dc62
3 changed files with 32 additions and 4 deletions

View file

@ -48,6 +48,7 @@ public enum ConfigBoolValues{
GEN_LUSH_CAVES("Generate Lush Caves", ConfigCategories.WORLD_GEN, true, "Should caves with trees and grass randomly generate underground?"),
WATER_BOWL("Water Bowl", ConfigCategories.OTHER, true, "Should right-clicking a bowl on water blocks create a water bowl?"),
WATER_BOWL_LOSS("Water Bowl Spilling", ConfigCategories.OTHER, true, "Should the water bowl spill if you don't sneak while using it?"),
TINY_COAL_STUFF("Tiny Coal", ConfigCategories.OTHER, true, "Should Tiny Coal and Tiny Charcoal be craftable"),
LASER_RELAY_LOSS("Laser Relay Energy Loss", ConfigCategories.MACHINE_VALUES, true, "If Energy Laser Relays should have energy loss"),

View file

@ -18,6 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -107,7 +108,7 @@ public class ItemWaterBowl extends ItemBase{
if(!player.canPlayerEdit(pos1, trace.sideHit, stack)){
return new ActionResult(EnumActionResult.FAIL, stack);
}
else if(this.tryPlaceContainedLiquid(player, world, pos1)){
else if(this.tryPlaceContainedLiquid(player, world, pos1, false)){
return !player.capabilities.isCreativeMode ? new ActionResult(EnumActionResult.SUCCESS, new ItemStack(Items.BOWL)) : new ActionResult(EnumActionResult.SUCCESS, stack);
}
else{
@ -117,7 +118,25 @@ public class ItemWaterBowl extends ItemBase{
}
}
public boolean tryPlaceContainedLiquid(EntityPlayer player, World world, BlockPos pos){
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){
if(!world.isRemote){
if(ConfigBoolValues.WATER_BOWL_LOSS.isEnabled()){
if(!entity.isSneaking()){
if(world.getTotalWorldTime()%10 == 0 && world.rand.nextFloat() >= 0.8F){
if(entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)entity;
if(this.tryPlaceContainedLiquid(player, world, player.getPosition(), true)){
player.inventory.setInventorySlotContents(itemSlot, new ItemStack(Items.BOWL));
}
}
}
}
}
}
}
public boolean tryPlaceContainedLiquid(EntityPlayer player, World world, BlockPos pos, boolean finite){
IBlockState state = world.getBlockState(pos);
Material material = state.getMaterial();
boolean nonSolid = !material.isSolid();
@ -140,7 +159,15 @@ public class ItemWaterBowl extends ItemBase{
}
world.playSound(player, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState(), 3);
IBlockState placeState;
if(finite){
placeState = Blocks.FLOWING_WATER.getDefaultState();
}
else{
placeState = Blocks.FLOWING_WATER.getDefaultState();
}
world.setBlockState(pos, placeState, 3);
}
return true;

View file

@ -1147,7 +1147,7 @@ booklet.actuallyadditions.chapter.lushCaves.name=Lush Caves
booklet.actuallyadditions.chapter.lushCaves.text.1=If you have ever done any <imp>Cave exploration<r>, you will have probably noticed some <imp>caves<r> that have <imp>trees and grass<r> inside of them. <n>These can be found at any height underground all over the world, and they can be very valuable when needing wood for torches and tools at some point. Sometimes, there might also be some <imp>treasure hidden in the trees<r>! <n><n>If you didn't ever see one before, look on the <imp>next page<r> for a <imp>picture<r>!
booklet.actuallyadditions.chapter.waterBowl.name=Bowl of Water
booklet.actuallyadditions.chapter.waterBowl.text.1=The <item>Bowl of Water<r> can be obtained by <imp>right-cliking a bowl on water<r> anywhere in the world. When the <item>Bowl of Water<r> is then right-clicked onto a block, the water will be placed, much like a <item>Bucket<r>. <n><n>This can be used, for example, for early game farms.
booklet.actuallyadditions.chapter.waterBowl.text.1=The <item>Bowl of Water<r> can be obtained by <imp>right-cliking a bowl on water<r> anywhere in the world. When the <item>Bowl of Water<r> is then right-clicked onto a block, the water will be placed, much like a <item>Bucket<r>. <n><n>This can be used, for example, for early game farms. <n><n>If you don't move around <imp>carefully enough<r>, however, the water might <imp>spill out of it<r>!
booklet.actuallyadditions.chapter.playerInterface.name=Player Interface
booklet.actuallyadditions.chapter.playerInterface.text.1=The <item>Player Interface<r> works in a similar way to the <item>Phantomface<r>, except it is <imp>connected to a player<r> instead of a block, and the connection is established by <imp>placing it down<r>. <n>When <imp>inputting items<r>, they will <imp>move to the player's inventory<r>. Also, when <imp>inputting CF<r>, it will <imp>charge the items<r> in the player's inventory. <n>It has a default range of <range> blocks, however, it can be expanded by placing up to 3 <item>Phantom Boosters<r> on top of it.