-
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.
Crashes on NeoForge, but other then that its up and running. more work is needed.
- Loading branch information
1 parent
1364cb7
commit 0c950ac
Showing
97 changed files
with
1,120 additions
and
379 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
common/src/main/java/net/x_j0nnay_x/simpeladd/blocks/SimpelFarmLand.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,91 @@ | ||
package net.x_j0nnay_x.simpeladd.blocks; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.LevelReader; | ||
import net.minecraft.world.level.block.*; | ||
import net.minecraft.world.level.block.piston.MovingPistonBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.x_j0nnay_x.simpeladd.core.ModTags; | ||
|
||
import java.util.Random; | ||
|
||
import static net.minecraft.world.level.block.SweetBerryBushBlock.AGE; | ||
|
||
public class SimpelFarmLand extends FarmBlock { | ||
|
||
public SimpelFarmLand() { | ||
super(Properties.of() | ||
.sound(SoundType.GRASS) | ||
.strength(3.0f) | ||
.randomTicks() | ||
); | ||
|
||
} | ||
|
||
@Override | ||
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) { | ||
super.canSurvive(blockState, levelReader, blockPos); | ||
BlockState blockstate = levelReader.getBlockState(blockPos.above()); | ||
if (blockstate.is(ModTags.Blocks.PLANTABLECROPS)) | ||
return true; | ||
return !blockstate.isSolid() || blockstate.getBlock() instanceof FenceGateBlock || blockstate.getBlock() instanceof MovingPistonBlock; | ||
} | ||
|
||
@Override | ||
public void fallOn(Level $$0, BlockState $$1, BlockPos $$2, Entity $$3, float $$4) { | ||
$$3.causeFallDamage($$4, 1.0F, $$3.damageSources().fall()); | ||
} | ||
|
||
@Override | ||
public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) { | ||
super.tick(pState, pLevel, pPos, pRandom); | ||
} | ||
|
||
@Override | ||
public void randomTick(BlockState blockState, ServerLevel level, BlockPos blockPos, RandomSource randomSource) { | ||
super.randomTick(blockState, level, blockPos, randomSource); | ||
for (int i = 0; i < 3; i++) { | ||
growBlocks(level, blockPos); | ||
// turnToFarmLand(level, blockPos); | ||
} | ||
} | ||
|
||
public void turnToFarmLand(Level level, BlockPos blockPos){ | ||
int blockValue = level.getBlockState(blockPos).getValue(MOISTURE); | ||
Random rand = new Random(); | ||
int outOfChance = 75; | ||
int chance = rand.nextInt(outOfChance); | ||
if(chance == 0) { | ||
level.setBlockAndUpdate(blockPos, Blocks.FARMLAND.defaultBlockState().setValue(FarmBlock.MOISTURE, blockValue)); | ||
} | ||
} | ||
|
||
public void growBlocks(ServerLevel level, BlockPos blockPos){ | ||
BlockState blockState = level.getBlockState(blockPos); | ||
if (blockState.getBlock() instanceof SimpelFarmLand) { | ||
BlockPos cropPos = blockPos.above(); | ||
BlockState crop = level.getBlockState(cropPos); | ||
BlockState crop1 = null; | ||
if (crop.getBlock() instanceof CropBlock cropblock) { | ||
if (!cropblock.isMaxAge(crop)) { | ||
this.turnToFarmLand(level, blockPos); | ||
crop1 = cropblock.getStateForAge(cropblock.getAge(crop) + 1); | ||
} | ||
} else if (crop.is(Blocks.SWEET_BERRY_BUSH) || crop.is(Blocks.NETHER_WART)) { | ||
int bushBlock = crop.getValue(AGE); | ||
if (bushBlock < 3) { | ||
this.turnToFarmLand(level, blockPos); | ||
crop1 = crop.setValue(AGE, bushBlock + 1); | ||
} | ||
} | ||
if (crop1 != null) { | ||
level.setBlockAndUpdate(cropPos, crop1); | ||
} | ||
} | ||
} | ||
|
||
} |
44 changes: 0 additions & 44 deletions
44
common/src/main/java/net/x_j0nnay_x/simpeladd/compat/jei/JEI_PluginSimpeladd_ABST.java
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
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
82 changes: 82 additions & 0 deletions
82
common/src/main/java/net/x_j0nnay_x/simpeladd/item/GrowStaff.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,82 @@ | ||
package net.x_j0nnay_x.simpeladd.item; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.context.UseOnContext; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.CropBlock; | ||
import net.minecraft.world.level.block.FarmBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.x_j0nnay_x.simpeladd.blocks.SimpelFarmLand; | ||
import net.x_j0nnay_x.simpeladd.core.ModBlocks; | ||
import java.util.Map; | ||
|
||
|
||
public class GrowStaff extends Item { | ||
|
||
|
||
private static final Map<Block, Block> FARMLAND_MAP = | ||
Map.of( | ||
Blocks.FARMLAND, ModBlocks.SIMPELFARMLAND | ||
); | ||
|
||
public GrowStaff(int maxuses){ | ||
super(new Item.Properties() | ||
.stacksTo(1) | ||
.durability(maxuses) | ||
); | ||
} | ||
public static ItemStack damageItem(ItemStack itemstack) { | ||
ItemStack growstaf = itemstack.copy(); | ||
if(growstaf.getDamageValue() > growstaf.getMaxDamage()){ | ||
return itemstack; | ||
}else { | ||
growstaf.setDamageValue(growstaf.getDamageValue() + 1); | ||
return growstaf; | ||
} | ||
} | ||
|
||
@Override | ||
public InteractionResult useOn(UseOnContext context) { | ||
int blockValue; | ||
Level level = context.getLevel(); | ||
if (!level.isClientSide) { | ||
ItemStack staf = context.getItemInHand(); | ||
BlockPos blockPos = context.getClickedPos(); | ||
BlockState blockState = context.getLevel().getBlockState(blockPos); | ||
Block block = blockState.getBlock(); | ||
if(staf.getDamageValue() > staf.getMaxDamage()){ | ||
return InteractionResult.FAIL; | ||
} | ||
if (block instanceof CropBlock) { | ||
CropBlock cropBlock = (CropBlock) block; | ||
if (cropBlock.isMaxAge(blockState)) { | ||
return InteractionResult.FAIL; | ||
} | ||
cropBlock.growCrops((ServerLevel) context.getLevel(), blockPos, blockState); | ||
level.playSound(context.getPlayer(), blockPos, SoundEvents.BONE_MEAL_USE, SoundSource.PLAYERS, 1.0f, 1.0f); | ||
staf.setDamageValue(staf.getDamageValue() + 1); | ||
return InteractionResult.SUCCESS; | ||
} | ||
|
||
if(block instanceof FarmBlock && block != ModBlocks.SIMPELFARMLAND){ | ||
blockValue = blockState.getValue(FarmBlock.MOISTURE); | ||
level.setBlockAndUpdate(blockPos, FARMLAND_MAP.get(block).defaultBlockState().setValue(SimpelFarmLand.MOISTURE, blockValue)); | ||
level.playSound(context.getPlayer(), blockPos, SoundEvents.HOE_TILL, SoundSource.PLAYERS, 1.0f, 1.0f); | ||
staf.setDamageValue(staf.getDamageValue() + 3); | ||
return InteractionResult.SUCCESS; | ||
} | ||
|
||
} | ||
return InteractionResult.PASS; | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
common/src/main/java/net/x_j0nnay_x/simpeladd/mixin/CropBlockMixin.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,50 @@ | ||
package net.x_j0nnay_x.simpeladd.mixin; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.CropBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.x_j0nnay_x.simpeladd.blocks.SimpelFarmLand; | ||
import net.x_j0nnay_x.simpeladd.core.ModBlocks; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(CropBlock.class) | ||
public class CropBlockMixin { | ||
|
||
@Inject(method = "mayPlaceOn", at = @At("HEAD"), cancellable = true) | ||
protected void mayPlaceOn(BlockState $$0, BlockGetter $$1, BlockPos $$2, CallbackInfoReturnable<Boolean> cir) { | ||
// if ($$0.is(ModBlocks.SIMPELFARMLAND)) { | ||
// cir.setReturnValue(true); | ||
// } | ||
if ($$0.getBlock() instanceof SimpelFarmLand){ | ||
cir.setReturnValue(true); | ||
} | ||
} | ||
|
||
@Inject(method = "getGrowthSpeed", at = @At("HEAD"), cancellable = true) | ||
private static void getGrowthSpeed(Block $$0, BlockGetter $$1, BlockPos $$2, CallbackInfoReturnable<Float> cir) { | ||
float flot1 = 1.0F; | ||
BlockPos blockPos = $$2.below(); | ||
for (int i1 = -1; i1 <= 1; ++i1) { | ||
for (int i2 = -1; i2 <= 1; ++i2) { | ||
float flot2 = 0.0F; | ||
BlockState $$8 = $$1.getBlockState(blockPos.offset(i1, 0, i2)); | ||
if ($$8.is(ModBlocks.SIMPELFARMLAND)) { | ||
flot2 = 3.0F; | ||
} | ||
|
||
if (i1 != 0 || i2 != 0) { | ||
flot2 /= 4.0F; | ||
} | ||
|
||
flot1 += flot2; | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
common/src/main/java/net/x_j0nnay_x/simpeladd/mixin/NetherWartMixin.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,28 @@ | ||
package net.x_j0nnay_x.simpeladd.mixin; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.NetherWartBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.x_j0nnay_x.simpeladd.blocks.SimpelFarmLand; | ||
import net.x_j0nnay_x.simpeladd.core.ModBlocks; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(NetherWartBlock.class) | ||
public class NetherWartMixin { | ||
|
||
@Inject(method = "mayPlaceOn", at = @At("HEAD"), cancellable = true) | ||
protected void mayPlaceOn(BlockState $$0, BlockGetter $$1, BlockPos $$2, CallbackInfoReturnable<Boolean> cir) { | ||
// if($$0.is(ModBlocks.SIMPELFARMLAND)){ | ||
// cir.setReturnValue(true); | ||
// } | ||
if ($$0.getBlock() instanceof SimpelFarmLand){ | ||
cir.setReturnValue(true); | ||
} | ||
} | ||
|
||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
common/src/main/resources/assets/simpeladdmod/blockstates/simpel_farmland.json
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,28 @@ | ||
{ | ||
"variants": { | ||
"moisture=0": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=1": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=2": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=3": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=4": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=5": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=6": { | ||
"model": "simpeladdmod:block/simpel_farmland" | ||
}, | ||
"moisture=7": { | ||
"model": "simpeladdmod:block/simpel_farmland_moist" | ||
} | ||
} | ||
} |
Oops, something went wrong.