commit so I don't loose progress

This commit is contained in:
TheBlackfurGuy 2021-12-05 18:25:52 +01:00
parent 6aeb203dd3
commit 3dc4fa4cb7
3 changed files with 36 additions and 7 deletions

View file

@ -4,7 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <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$/.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/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" /> <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" /> <option name="project" value="LOCAL" />
<updated>1638638076796</updated> <updated>1638638076796</updated>
</task> </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 /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -261,6 +268,7 @@
<MESSAGE value="uhm what?" /> <MESSAGE value="uhm what?" />
<MESSAGE value="added toaster block hardness and tool requirement" /> <MESSAGE value="added toaster block hardness and tool requirement" />
<MESSAGE value="so much fucking work!!!" /> <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> </component>
</project> </project>

View file

@ -5,13 +5,17 @@ import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation; import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.function.BooleanBiFunction; import net.minecraft.util.function.BooleanBiFunction;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape; 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)); 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) { public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite()); 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; import net.minecraft.world.World;
public class ToasterBlockEntity extends BlockEntity { public class ToasterBlockEntity extends BlockEntity {
private int cookTicks; private static int cookTicks;
public ToasterBlockEntity(BlockPos pos, BlockState state) { public ToasterBlockEntity(BlockPos pos, BlockState state) {
super(Tastytoasters.TOASTER_BLOCK_ENTITY, pos, state); super(Tastytoasters.TOASTER_BLOCK_ENTITY, pos, state);
} }
public static void tick(World world, BlockPos pos, BlockState state, ToasterBlockEntity be) { 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 @Override