commit so I don't loose progress

main
TheBlackfurGuy 2021-12-05 18:25:52 +01:00
parent 92352c2413
commit a62cbc74ba
3 changed files with 36 additions and 7 deletions

View File

@ -4,7 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="9d600e86-9aa6-49ee-bbc5-e23128c6a4d1" name="Changes" comment="so much fucking work!!!">
<list default="true" id="9d600e86-9aa6-49ee-bbc5-e23128c6a4d1" name="Changes" comment="I did a thing and nothing broke OMG">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/blackfur/tastytoasters/block/ToasterBlockEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/blackfur/tastytoasters/block/ToasterBlockEntity.java" afterDir="false" />
@ -241,7 +241,14 @@
<option name="project" value="LOCAL" />
<updated>1638638076796</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="I did a thing and nothing broke OMG">
<created>1638722000773</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1638722000773</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -261,6 +268,7 @@
<MESSAGE value="uhm what?" />
<MESSAGE value="added toaster block hardness and tool requirement" />
<MESSAGE value="so much fucking work!!!" />
<option name="LAST_COMMIT_MESSAGE" value="so much fucking work!!!" />
<MESSAGE value="I did a thing and nothing broke OMG" />
<option name="LAST_COMMIT_MESSAGE" value="I did a thing and nothing broke OMG" />
</component>
</project>

View File

@ -5,13 +5,17 @@ import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.function.BooleanBiFunction;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
@ -29,6 +33,18 @@ public class ToasterBlock extends BlockWithEntity implements BlockEntityProvider
this.setDefaultState(this.stateManager.getDefaultState().with(TOASTING, false));
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!player.isSneaking() && world.getBlockEntity(pos) instanceof ToasterBlockEntity toasterBlockEntity) {
if (player.getStackInHand(hand).getItem() == Tastytoasters.RAW_TOAST_ITEM) {
world.setBlockState(pos, state.with(TOASTING, true));
toasterBlockEntity.handleUse();
}
return ActionResult.success(world.isClient());
}
return super.onUse(state, world, pos, player, hand, hit);
}
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
}

View File

@ -11,18 +11,23 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ToasterBlockEntity extends BlockEntity {
private int cookTicks;
private static int cookTicks;
public ToasterBlockEntity(BlockPos pos, BlockState state) {
super(Tastytoasters.TOASTER_BLOCK_ENTITY, pos, state);
}
public static void tick(World world, BlockPos pos, BlockState state, ToasterBlockEntity be) {
if (state.get(ToasterBlock.TOASTING)) {
if (cookTicks <= 0) {
world.setBlockState(pos, state.with(ToasterBlock.TOASTING, false));
}
cookTicks--;
}
}
public void handleUse(PlayerEntity player, Hand hand, ItemStack itemStack) {
public void handleUse() {
cookTicks = 10*20;
}
@Override