added canola oil for the drills

This commit is contained in:
Jottyfan 2024-01-14 23:30:43 +01:00
parent 8dd50f73aa
commit efca60e5da
31 changed files with 250 additions and 24 deletions

View File

@ -9,7 +9,7 @@
loader_version=0.15.1
# Mod Properties
mod_version = 1.20.4.5
mod_version = 1.20.4.6
maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric

View File

@ -22,8 +22,9 @@ public class QuickieFabricClient implements ClientModInitializer {
public void onInitializeClient() {
HandledScreens.register(RegistryManager.BACKPACK_SCREEN_HANDLER, BackpackScreen::new);
HandledScreens.register(RegistryManager.BLOCKSTACKER_SCREEN_HANDLER, BlockStackerScreen::new);
// make cotton plant block and sulforpad transparent
// make plant blocks and sulforpad transparent
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.COTTONPLANT, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.CANOLAPLANT, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(QuickieBlocks.SULFORPAD, RenderLayer.getCutout());
}
}

View File

@ -0,0 +1,68 @@
package de.jottyfan.minecraft.quickiefabric.blocks;
import java.util.List;
import java.util.Random;
import de.jottyfan.minecraft.quickiefabric.items.QuickieItems;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContextParameterSet.Builder;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockCanolaplant extends CropBlock {
public BlockCanolaplant() {
super(FabricBlockSettings.copy(Blocks.WHEAT));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
DefaultedList<ItemStack> list = DefaultedList.of();
list.add(new ItemStack(getSeedsItem())); // the one from the seed
if (isMature(state)) {
list.add(new ItemStack(getSeedsItem(), new Random().nextInt(2)));
list.add(new ItemStack(QuickieItems.CANOLA, new Random().nextFloat() > 0.9f ? 2 : 1));
}
return list;
}
private void spawnHarvested(World world, BlockPos pos, BlockState state) {
DefaultedList<ItemStack> list = DefaultedList.of();
getDroppedStacks(state, null).forEach(itemStack -> {
list.add(itemStack);
});
ItemScatterer.spawn(world, pos, list);
}
@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
spawnHarvested(world, pos, state);
return super.onBreak(world, pos, state, player);
}
@Override
protected ItemConvertible getSeedsItem() {
return QuickieItems.CANOLASEED;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hitResult) {
if (!world.isClient && isMature(state)) {
spawnHarvested(world, pos, state);
world.setBlockState(pos, state.with(AGE, 0));
}
return ActionResult.PASS;
}
}

View File

@ -50,10 +50,7 @@ public abstract class DrillBlock extends FallingBlock {
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
Map<Item, Integer> loadings = new HashMap<>();
loadings.put(QuickieItems.SPEEDPOWDER, 8);
loadings.put(QuickieItems.QUICKIEPOWDER, 32);
loadings.put(Items.REDSTONE, 1);
loadings.put(Items.REDSTONE_BLOCK, 10);
loadings.put(QuickieItems.CANOLABOTTLE, 8);
ItemStack stack = player.getStackInHand(hand);
Item item = stack.getItem();
if (stack.isEmpty() || !loadings.containsKey(item) ) {
@ -67,9 +64,12 @@ public abstract class DrillBlock extends FallingBlock {
if (load < fuelWeight) {
Integer numberOfTooMuchLoad = fuelWeight - load;
fuelWeight = load;
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.REDSTONE, numberOfTooMuchLoad)));
// world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuickieItems.CANOLABOTTLE, numberOfTooMuchLoad)));
}
world.setBlockState(pos, state.with(FUEL, state.get(FUEL) + fuelWeight));
if (item.equals(QuickieItems.CANOLABOTTLE)) {
world.spawnEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.GLASS_BOTTLE, 1)));
}
stack.decrement(1);
}
}

View File

@ -19,6 +19,7 @@ public class QuickieBlocks {
public static final BlockMonsterhoarder MONSTERHOARDER = new BlockMonsterhoarder();
public static final BlockKelpstack KELPSTACK = new BlockKelpstack();
public static final BlockCottonplant COTTONPLANT = new BlockCottonplant();
public static final BlockCanolaplant CANOLAPLANT = new BlockCanolaplant();
public static final BlockSulphor BLOCKSULPHOR = new BlockSulphor();
public static final BlockSalpeter BLOCKSALPETER = new BlockSalpeter();
public static final BlockDrillDown DRILL_DOWN = new BlockDrillDown();

View File

@ -86,6 +86,9 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieItems.CARROTSTACK));
stacks.add(new ItemStack(QuickieItems.COTTON));
stacks.add(new ItemStack(QuickieItems.COTTONSEED));
stacks.add(new ItemStack(QuickieItems.CANOLA));
stacks.add(new ItemStack(QuickieItems.CANOLASEED));
stacks.add(new ItemStack(QuickieItems.CANOLABOTTLE));
stacks.add(new ItemStack(QuickieItems.BACKPACK_BROWN));
stacks.add(new ItemStack(QuickieItems.BACKPACK_WHITE));
stacks.add(new ItemStack(QuickieItems.BACKPACK_BLACK));
@ -145,7 +148,7 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieBlocks.BLOCKSTACKERSOUTH));
stacks.add(new ItemStack(QuickieBlocks.BLOCKSPREADER));
stacks.add(new ItemStack(QuickieBlocks.SULFORPAD));
}).build());
}).build());
}
private static final void registerBlock(Block block, String name) {
@ -209,6 +212,7 @@ public class RegistryManager {
registerBlock(QuickieBlocks.MONSTERHOARDER, "monsterhoarder");
registerBlock(QuickieBlocks.KELPSTACK, "kelpstack");
registerBlock(QuickieBlocks.COTTONPLANT, "cottonplant");
registerBlock(QuickieBlocks.CANOLAPLANT, "canolaplant");
registerBlock(QuickieBlocks.BLOCKSULPHOR, "blocksulphor");
registerBlock(QuickieBlocks.BLOCKSALPETER, "blocksalpeter");
registerBlock(QuickieBlocks.BLOCKSPEEDPOWDER, "blockspeedpowder");
@ -241,6 +245,9 @@ public class RegistryManager {
registerItem(QuickieItems.CARROTSTACK, "carrotstack");
registerItem(QuickieItems.COTTON, "cotton");
registerItem(QuickieItems.COTTONSEED, "cottonseed");
registerItem(QuickieItems.CANOLA, "canola");
registerItem(QuickieItems.CANOLASEED, "canolaseed");
registerItem(QuickieItems.CANOLABOTTLE, "canolabottle");
registerItem(QuickieItems.BACKPACK_BROWN, "backpack_brown");
registerItem(QuickieItems.BACKPACK_WHITE, "backpack_white");
registerItem(QuickieItems.BACKPACK_BLACK, "backpack_black");
@ -265,6 +272,8 @@ public class RegistryManager {
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTONSEED, 0.5f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.COTTON, 0.75f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLASEED, 0.5f);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(QuickieItems.CANOLA, 0.75f);
FuelRegistry.INSTANCE.add(QuickieItems.SULPHOR, 200);
FuelRegistry.INSTANCE.add(QuickieBlocks.BLOCKSULPHOR, 2000);
@ -307,25 +316,13 @@ public class RegistryManager {
// Nether features
BiomeModifications.create(new Identifier(QUICKIEFABRIC, "nether_features")).add(ModificationPhase.ADDITIONS,
BiomeSelectors.foundInTheNether(), FeaturesManager.netherOres());
// // Sulforpad feature
// Identifier SULFORPAD_FEATURE_ID = new Identifier(QUICKIEFABRIC, "sulforpad");
// Feature<SulforpadFeatureConfig> SULFORPAD_FEATURE = new SulforpadFeature(SulforpadFeatureConfig.CODEC);
// ConfiguredFeature<SulforpadFeatureConfig, SulforpadFeature> SULFORPAD_FEATURE_CONFIGURED = new ConfiguredFeature<>(
// (SulforpadFeature) SULFORPAD_FEATURE,
// new SulforpadFeatureConfig(new Identifier(QUICKIEFABRIC, "sulforpad")));
// PlacedFeature SULFORPAD_FEATURE_PLACED = new PlacedFeature(RegistryEntry.of(SULFORPAD_FEATURE_CONFIGURED), List.of(SquarePlacementModifier.of()));
// Registry.register(Registries.FEATURE, new Identifier(QUICKIEFABRIC, "sulforpad"), new SulforpadFeature(SulforpadFeatureConfig.CODEC));
// Registry.register(Registries.CONFIGURED_FEATURE, SULFORPAD_FEATURE_ID, SULFORPAD_FEATURE_CONFIGURED);
// Registry.register(RegistryKeys.PLACED_FEATURE, SULFORPAD_FEATURE_ID, SULFORPAD_FEATURE_PLACED);
// BiomeModifications.addFeature(BiomeSelectors.foundInTheNether(),GenerationStep.Feature.VEGETAL_DECORATION,
// RegistryKey.of(RegistryKeys.PLACED_FEATURE, SULFORPAD_FEATURE_ID));
}
public static final void registerLootings() {
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (isGrass(id)) {
tableBuilder.pool(LootHelper.build(1, QuickieItems.COTTONSEED, 0.125f));
tableBuilder.pool(LootHelper.build(1, QuickieItems.COTTONSEED, 0.025f));
tableBuilder.pool(LootHelper.build(1, QuickieItems.CANOLASEED, 0.05f));
tableBuilder.pool(LootHelper.build(2, QuickieItems.SALPETER, 0.012f));
}
});

View File

@ -0,0 +1,16 @@
package de.jottyfan.minecraft.quickiefabric.items;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCanola extends Item {
public ItemCanola() {
super(new FabricItemSettings().maxCount(64));
}
}

View File

@ -0,0 +1,16 @@
package de.jottyfan.minecraft.quickiefabric.items;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
/**
*
* @author jotty
*
*/
public class ItemCanolabottle extends Item {
public ItemCanolabottle() {
super(new FabricItemSettings().maxCount(64));
}
}

View File

@ -0,0 +1,37 @@
package de.jottyfan.minecraft.quickiefabric.items;
import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class ItemCanolaseed extends Item {
public ItemCanolaseed() {
super(new FabricItemSettings().maxCount(64));
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
BlockPos pos = context.getBlockPos();
World world = context.getWorld();
if (QuickieItems.CANOLASEED.equals(context.getStack().getItem())) {
BlockState state = world.getBlockState(pos);
if (Blocks.FARMLAND.equals(state.getBlock()) && world.getBlockState(pos.up()).isAir()) {
world.setBlockState(pos.up(), QuickieBlocks.CANOLAPLANT.getDefaultState());
context.getStack().decrement(1);
}
}
return super.useOnBlock(context);
}
}

View File

@ -33,8 +33,11 @@ public class QuickieItems {
public static final ItemCarrotstack CARROTSTACK = new ItemCarrotstack();
public static final ItemCotton COTTON = new ItemCotton();
public static final ItemCottonseed COTTONSEED = new ItemCottonseed();
public static final ItemCanola CANOLA = new ItemCanola();
public static final ItemCanolaseed CANOLASEED = new ItemCanolaseed();
public static final ItemStub STUB = new ItemStub();
public static final ItemOxidizedcopperpowder OXIDIZEDCOPPERPOWDER = new ItemOxidizedcopperpowder();
public static final ItemSpeedingot SPEEDINGOT = new ItemSpeedingot();
public static final ItemQuickieingot QUICKIEINGOT = new ItemQuickieingot();
public static final ItemCanolabottle CANOLABOTTLE = new ItemCanolabottle();
}

View File

@ -0,0 +1,12 @@
{
"variants": {
"age=0": { "model": "quickiefabric:block/canolaplant0" },
"age=1": { "model": "quickiefabric:block/canolaplant1" },
"age=2": { "model": "quickiefabric:block/canolaplant1" },
"age=3": { "model": "quickiefabric:block/canolaplant2" },
"age=4": { "model": "quickiefabric:block/canolaplant2" },
"age=5": { "model": "quickiefabric:block/canolaplant2" },
"age=6": { "model": "quickiefabric:block/canolaplant3" },
"age=7": { "model": "quickiefabric:block/canolaplant4" }
}
}

View File

@ -40,6 +40,9 @@
"item.quickiefabric.carrotstack": "Karottenbündel",
"item.quickiefabric.cotton": "Baumwolle",
"item.quickiefabric.cottonseed": "Baumwollsaat",
"item.quickiefabric.canola": "Raps",
"item.quickiefabric.canolaseed": "Rapssaat",
"item.quickiefabric.canolabottle": "Rapsöl",
"item.quickiefabric.stub": "Stummel",
"item.quickiefabric.oxidizedcopperpowder": "oxidiertes Kupferpulver",
"item.quickiefabric.speedingot": "Fluchtpulverbarren",
@ -101,6 +104,6 @@
"msg.backpack.transfer.filled": "Der Rucksack wurde befüllt.",
"msg.backpack.transfer.cleared": "Der Rucksackinhalt wurde soweit möglich geleert.",
"msg.backpack.transfer.cancel": "Entweder der Rucksack oder die Kiste sind nicht komplett leer.",
"msg.drill.fuelinfo": "Der Bohrer hat noch eine Ladung für den Abbau von %s Blöcken. Er kann mit Redstone, Flucht- oder Eilpulver aufgeladen werden.",
"msg.drill.fuelinfo": "Der Bohrer hat noch eine Ladung für den Abbau von %s Blöcken. Er kann mit Rapsöl aufgeladen werden.",
"error.unleveling.inventory.full": "Es ist kein Platz mehr frei, um die Aufwertungen abzulegen."
}

View File

@ -40,6 +40,9 @@
"item.quickiefabric.carrotstack": "a bundle of carrots",
"item.quickiefabric.cotton": "cotton",
"item.quickiefabric.cottonseed": "cotton seed",
"item.quickiefabric.canola": "canola",
"item.quickiefabric.canolaseed": "canola seed",
"item.quickiefabric.canolabottle": "canola oil",
"item.quickiefabric.stub": "stub",
"item.quickiefabric.oxidizedcopperpowder": "oxidized copper powder",
"item.quickiefabric.speedingot": "Speedpowderingot",
@ -101,6 +104,6 @@
"msg.backpack.transfer.filled": "Filled the backpack.",
"msg.backpack.transfer.cleared": "Cleared the backpack as much as possible.",
"msg.backpack.transfer.cancel": "Eigther backpack or chest are not completely empty.",
"msg.drill.fuelinfo": "The drill still has a charge for mining %s blocks. It can be charged with redstone, speed or hurry powder.",
"msg.drill.fuelinfo": "The drill still has a charge for mining %s blocks. It can be charged with canola oil.",
"error.unleveling.inventory.full": "There is no free stack in your inventory for the level ups."
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiefabric:block/canolaplant0"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiefabric:block/canolaplant1"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiefabric:block/canolaplant2"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiefabric:block/canolaplant3"
}
}

View File

@ -0,0 +1,6 @@
{
"parent":"block/cross",
"textures":{
"cross":"quickiefabric:block/canolaplant4"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/canola"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/canolabottle"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/canolaseed"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "quickiefabric:item/canolaseed"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:glass_bottle"
},
{
"item": "quickiefabric:canola"
}
],
"result": {
"item": "quickiefabric:canolabottle",
"count": 1
}
}