-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add desert bonuses to pickaxe and effect texture
- Loading branch information
1 parent
04ff78b
commit b442783
Showing
12 changed files
with
319 additions
and
52 deletions.
There are no files selected for viewing
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,129 @@ | ||
# Rafael's Useful Cactus Mod Changelog | ||
|
||
## Important Keypoints 🌵 | ||
- **Correct Method Names**: | ||
- Use `getMiningSpeed` not `getMiningSpeedMultiplier` | ||
- Use `postMine` for durability modifications | ||
- Use `getEnchantability` for enchantment bonuses | ||
|
||
- **Biome Tags**: | ||
- Use `BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE` not `BiomeTags.IS_DESERT` | ||
- Always check world and player for null before biome checks | ||
|
||
- **Time Constants**: | ||
- Day cycle: 24000 ticks total | ||
- Daytime: 0-13000 ticks | ||
- Noon: 6000-6500 ticks | ||
|
||
## Features Implementation | ||
|
||
### CactusPickaxeItem Features | ||
- ⛏️ Mining speed boost in desert (25% faster) | ||
- 🛡️ Durability preservation in desert (20% chance) | ||
- ✨ Fortune bonus in desert biomes | ||
- ☀️ Time-based bonuses: | ||
- Daytime: Additional speed boost | ||
- Noon: Extra fortune chance | ||
|
||
### Code Structure | ||
```java | ||
// Important method signatures | ||
public float getMiningSpeed(ItemStack stack, BlockState state) | ||
public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) | ||
public int getEnchantability() | ||
``` | ||
|
||
### Technical Implementation | ||
- **World Access**: | ||
```java | ||
World world = MinecraftClient.getInstance().world; | ||
PlayerEntity player = MinecraftClient.getInstance().player; | ||
``` | ||
- **Biome Checks**: | ||
```java | ||
world.getBiome(player.getBlockPos()).isIn(BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE) | ||
``` | ||
- **Time Checks**: | ||
```java | ||
long timeOfDay = world.getTimeOfDay() % 24000; | ||
if (timeOfDay >= 0 && timeOfDay < 13000) { // Daytime | ||
if (timeOfDay >= 6000 && timeOfDay <= 6500) { // Noon | ||
// Noon-specific code | ||
} | ||
} | ||
``` | ||
|
||
## Development Notes | ||
|
||
### Current Implementation | ||
- ✅ Basic desert speed boost | ||
- ✅ Durability preservation system | ||
- ✅ Fortune bonus implementation | ||
- ✅ Time-based mechanics | ||
|
||
### Known Issues | ||
- ⚠️ Resource management with MinecraftClient singleton | ||
- ⚠️ Need for comprehensive testing | ||
- ⚠️ Performance optimization needed for frequent biome checks | ||
|
||
### Development Environment | ||
- 🎮 Minecraft Version: 1.21 | ||
- 🧰 Fabric API | ||
- ☕ Java 21 | ||
|
||
### File Structure | ||
``` | ||
src/main/java/net/rafael/usefulcactus/ | ||
├── item/custom/ | ||
│ └── CactusPickaxeItem.java | ||
└── mixin/ | ||
└── CactusPickaxeMixin.java | ||
``` | ||
|
||
## Future Considerations | ||
- 🎯 Performance optimization for biome checks | ||
- 🎯 Additional desert-themed mechanics | ||
- 🎯 Comprehensive testing suite | ||
- 🎯 Better resource management | ||
|
||
## Common Mistakes to Avoid | ||
1. ❌ Using wrong method names (getMiningSpeedMultiplier) | ||
2. ❌ Using incorrect BiomeTags (IS_DESERT) | ||
3. ❌ Forgetting null checks for world and player | ||
4. ❌ Not handling resource cleanup | ||
|
||
## Gradle Command Guidelines | ||
### Common Mistakes and Corrections | ||
- ❌ Using `gradlew` directly on Windows | ||
- ❌ Using `./gradlew` on Windows | ||
- ❌ Running `gradlew.bat` without proper path | ||
|
||
### Correct Usage on Windows | ||
```batch | ||
# Correct way to build the project | ||
cmd /c gradlew.bat build | ||
# Other useful commands | ||
cmd /c gradlew.bat runClient # Run the client with mod | ||
cmd /c gradlew.bat genSources # Generate sources | ||
``` | ||
|
||
### Important Notes | ||
- Always use `cmd /c gradlew.bat` on Windows systems | ||
- Run commands from the project root directory | ||
- Ensure Gradle wrapper files exist: | ||
- gradlew.bat | ||
- gradle/wrapper/gradle-wrapper.jar | ||
- gradle/wrapper/gradle-wrapper.properties | ||
|
||
## Useful Commands | ||
```bash | ||
# Gradle commands | ||
./gradlew build | ||
./gradlew runClient | ||
./gradlew genSources | ||
``` | ||
|
||
--- | ||
Last Updated: [Current Date] | ||
Remember to update this file when making significant changes! |
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
20 changes: 19 additions & 1 deletion
20
src/main/java/net/rafael/usefulcactus/block/custom/StrippedCactusBlock.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,4 +1,22 @@ | ||
package net.rafael.usefulcactus.block.custom; | ||
|
||
public class StrippedCactusBlock { | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.PillarBlock; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.random.Random; | ||
import net.rafael.usefulcactus.block.ModBlocks; | ||
|
||
public class StrippedCactusBlock extends PillarBlock { | ||
public StrippedCactusBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { | ||
world.setBlockState(pos, ModBlocks.DRIED_CACTUS.getDefaultState()); | ||
world.playSound(null, pos, SoundEvents.BLOCK_WOOD_BREAK, SoundCategory.BLOCKS, 0.3F, 1.5F); | ||
} | ||
} |
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
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
85 changes: 85 additions & 0 deletions
85
src/main/java/net/rafael/usefulcactus/item/custom/CactusPickaxeItem.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,85 @@ | ||
package net.rafael.usefulcactus.item.custom; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.PickaxeItem; | ||
import net.minecraft.item.ToolMaterial; | ||
import net.minecraft.item.tooltip.TooltipType; | ||
import net.minecraft.registry.tag.BiomeTags; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class CactusPickaxeItem extends PickaxeItem { | ||
public CactusPickaxeItem(ToolMaterial material, Item.Settings settings) { | ||
super(material, settings); | ||
} | ||
|
||
|
||
@Override | ||
public float getMiningSpeed(ItemStack stack, BlockState state) { | ||
World world = MinecraftClient.getInstance().world; | ||
PlayerEntity player = MinecraftClient.getInstance().player; | ||
|
||
if (world != null && player != null) { | ||
if (world.getBiome(player.getBlockPos()).isIn(BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE)) { | ||
return super.getMiningSpeed(stack, state) * 1.25F; // 25% faster in deserts | ||
} | ||
} | ||
|
||
return super.getMiningSpeed(stack, state); | ||
} | ||
|
||
@Override | ||
public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) { | ||
if (miner instanceof PlayerEntity player) { | ||
if (world.getBiome(player.getBlockPos()).isIn(BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE)) { | ||
// 20% chance to not consume durability | ||
if (world.random.nextFloat() < 0.20f) { | ||
return false; | ||
} | ||
} | ||
} | ||
return super.postMine(stack, world, state, pos, miner); | ||
} | ||
|
||
@Override | ||
public int getEnchantability() { | ||
World world = MinecraftClient.getInstance().world; | ||
PlayerEntity player = MinecraftClient.getInstance().player; | ||
|
||
if (world != null && player != null) { | ||
if (world.getBiome(player.getBlockPos()).isIn(BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE)) { | ||
return super.getEnchantability() + 1; | ||
} | ||
} | ||
return super.getEnchantability(); | ||
} | ||
|
||
@Override | ||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
World world = client.world; | ||
|
||
if (world != null && world.getBiome(client.player.getBlockPos()).isIn(BiomeTags.VILLAGE_DESERT_HAS_STRUCTURE)) { | ||
tooltip.add(Text.translatable("item.rafaels-useful-cactus.cactus_pickaxe.tooltip.desert")); | ||
tooltip.add(Text.translatable("item.rafaels-useful-cactus.cactus_pickaxe.tooltip.durability")); | ||
|
||
long timeOfDay = world.getTimeOfDay() % 24000; | ||
if (timeOfDay >= 6000 && timeOfDay <= 6500) { | ||
tooltip.add(Text.translatable("item.rafaels-useful-cactus.cactus_pickaxe.tooltip.noon")); | ||
} else if (timeOfDay >= 0 && timeOfDay < 13000) { | ||
tooltip.add(Text.translatable("item.rafaels-useful-cactus.cactus_pickaxe.tooltip.daytime")); | ||
} | ||
} | ||
|
||
super.appendTooltip(stack, context, tooltip, type); | ||
} | ||
} |
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
Oops, something went wrong.