-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,819 changed files
with
47,080 additions
and
4,334 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "src\\main\\resources" | ||
} | ||
] | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "src\\main\\resources" | ||
}, | ||
{ | ||
"path": "C:\\Users\\hugeblank\\AppData\\Roaming\\CraftOS-PC\\computer\\3" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
798 changes: 569 additions & 229 deletions
798
src/main/java/dev/elexi/hugeblank/bagels_baking/Baking.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 71 additions & 4 deletions
75
src/main/java/dev/elexi/hugeblank/bagels_baking/block/BasicCakeBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,78 @@ | ||
package dev.elexi.hugeblank.bagels_baking.block; | ||
|
||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.CakeBlock; | ||
import net.minecraft.block.CandleBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.tag.ItemTags; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldAccess; | ||
import net.minecraft.world.event.GameEvent; | ||
|
||
public class BasicCakeBlock extends CakeBlock { | ||
public BasicCakeBlock() { | ||
super(FabricBlockSettings.copy(Blocks.CAKE)); | ||
public BasicCakeBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
// Mojang bad, hugeblank good. | ||
public static ActionResult tryEat(WorldAccess world, BlockPos pos, BlockState state, PlayerEntity player) { | ||
if (!player.canConsume(false)) { | ||
return ActionResult.PASS; | ||
} else { | ||
player.incrementStat(Stats.EAT_CAKE_SLICE); | ||
player.getHungerManager().add(2, 0.1F); | ||
int i = state.get(BITES); | ||
world.emitGameEvent(player, GameEvent.EAT, pos); | ||
if (i < 6) { | ||
world.setBlockState(pos, state.with(BITES, i + 1), 3); | ||
} else { | ||
world.removeBlock(pos, false); | ||
world.emitGameEvent(player, GameEvent.BLOCK_DESTROY, pos); | ||
} | ||
|
||
return ActionResult.SUCCESS; | ||
} | ||
} | ||
|
||
@Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
ItemStack itemStack = player.getStackInHand(hand); | ||
Item item = itemStack.getItem(); | ||
if (itemStack.isIn(ItemTags.CANDLES) && state.get(BITES) == 0) { | ||
Block block = Block.getBlockFromItem(item); | ||
if (block instanceof CandleBlock) { | ||
if (!player.isCreative()) { | ||
itemStack.decrement(1); | ||
} | ||
|
||
world.playSound(null, pos, SoundEvents.BLOCK_CAKE_ADD_CANDLE, SoundCategory.BLOCKS, 1.0F, 1.0F); | ||
world.setBlockState(pos, BasicCandleCakeBlock.getCandleCakeFromCandle(this, (CandleBlock) block)); | ||
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos); | ||
player.incrementStat(Stats.USED.getOrCreateStat(item)); | ||
return ActionResult.SUCCESS; | ||
} | ||
} | ||
|
||
if (world.isClient) { | ||
if (tryEat(world, pos, state, player).isAccepted()) { | ||
return ActionResult.SUCCESS; | ||
} | ||
|
||
if (itemStack.isEmpty()) { | ||
return ActionResult.CONSUME; | ||
} | ||
} | ||
|
||
return tryEat(world, pos, state, player); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/dev/elexi/hugeblank/bagels_baking/block/BasicCandleCakeBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package dev.elexi.hugeblank.bagels_baking.block; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.CandleBlock; | ||
import net.minecraft.block.CandleCakeBlock; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class BasicCandleCakeBlock extends CandleCakeBlock { | ||
private final BasicCakeBlock cake; | ||
private static final Map<BasicCakeBlock, Map<CandleBlock, BasicCandleCakeBlock>> COMBINER = new HashMap<>(); | ||
|
||
public BasicCandleCakeBlock(Block candle, BasicCakeBlock cake, Settings settings) { | ||
super(candle, settings); | ||
this.cake = cake; | ||
if (COMBINER.containsKey(cake)) { | ||
COMBINER.get(cake).put((CandleBlock) candle, this); | ||
} else { | ||
Map<CandleBlock, BasicCandleCakeBlock> candleCakeBlockMap = new HashMap<>(); | ||
candleCakeBlockMap.put((CandleBlock) candle, this); | ||
COMBINER.put(cake, candleCakeBlockMap); | ||
} | ||
|
||
} | ||
|
||
public static BlockState getCandleCakeFromCandle(BasicCakeBlock cake, CandleBlock candle) { | ||
return COMBINER.get(cake).get(candle).getDefaultState(); | ||
} | ||
|
||
@Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
ItemStack itemStack = player.getStackInHand(hand); | ||
if (!itemStack.isOf(Items.FLINT_AND_STEEL) && !itemStack.isOf(Items.FIRE_CHARGE)) { | ||
if (isHittingCandle(hit) && player.getStackInHand(hand).isEmpty() && state.get(LIT)) { | ||
extinguish(player, state, world, pos); | ||
return ActionResult.success(world.isClient); | ||
} else { | ||
ActionResult actionResult = BasicCakeBlock.tryEat(world, pos, cake.getDefaultState(), player); | ||
if (actionResult.isAccepted()) { | ||
dropStacks(state, world, pos); | ||
} | ||
|
||
return actionResult; | ||
} | ||
} else { | ||
return ActionResult.PASS; | ||
} | ||
} | ||
|
||
@Override | ||
public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { | ||
return new ItemStack(cake); | ||
} | ||
|
||
protected static boolean isHittingCandle(BlockHitResult hitResult) { | ||
return hitResult.getPos().y - (double)hitResult.getBlockPos().getY() > 0.5D; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/dev/elexi/hugeblank/bagels_baking/block/BasicDoorBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.elexi.hugeblank.bagels_baking.block; | ||
|
||
import net.minecraft.block.DoorBlock; | ||
|
||
public class BasicDoorBlock extends DoorBlock { | ||
|
||
public BasicDoorBlock(Settings settings) { | ||
super(settings); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/dev/elexi/hugeblank/bagels_baking/block/BasicLayerBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.elexi.hugeblank.bagels_baking.block; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.SnowBlock; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
import java.util.Random; | ||
|
||
public class BasicLayerBlock extends SnowBlock { | ||
|
||
public BasicLayerBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {} | ||
} |
Oops, something went wrong.