Added ability to change the block type of the JumpVader. Also fixed the "enabled" config option.

This commit is contained in:
VenomCodeDev 2022-10-18 12:05:27 -05:00
parent 626aff5b52
commit 8678e47211
2 changed files with 20 additions and 6 deletions

@ -20,12 +20,16 @@ public class JumpVaderConfig
{
return rootNode.node(MAX_VERTICAL_BLOCKS_TAG).getInt(128);
}
public String getAlternativeBlock()
{
return rootNode.node(USE_ALTERNATIVE_BLOCK_TAG).getString("default");
}
public void setupConfig() throws SerializationException
{
rootNode.node(ENABLED_TAG).comment(ENABLED_TAG_COMMENT).set(getEnabled());
rootNode.node(MAX_VERTICAL_BLOCKS_TAG).comment(MAX_VERTICAL_BLOCKS_TAG_COMMENT).set(getMaxVerticalBlocks());
rootNode.node(USE_ALTERNATIVE_BLOCK_TAG).comment(USE_ALTERNATIVE_BLOCK_TAG_COMMENT).set(getAlternativeBlock());
save();
}
@ -35,6 +39,8 @@ public class JumpVaderConfig
private static final String ENABLED_TAG_COMMENT = "Toggles this entire mod on and off.";
private static final String MAX_VERTICAL_BLOCKS_TAG = "max_blocks_vertical";
private static final String MAX_VERTICAL_BLOCKS_TAG_COMMENT = "The maximum amount of vertical blocks to travel when using the jump vader block.";
private static final String USE_ALTERNATIVE_BLOCK_TAG = "use_alternative_block";
private static final String USE_ALTERNATIVE_BLOCK_TAG_COMMENT = "Block to use for clients. Allowed Values: default, stained_glass, white_wool";
public JumpVaderConfig()

@ -18,7 +18,6 @@ import net.minecraft.util.math.BlockPos;
public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderListener
{
public JumpVaderBlock(Settings settings, Block virtualBlock)
{
super(settings, virtualBlock);
@ -27,11 +26,13 @@ public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderList
@Override
public boolean onJump(BlockPos pos , ServerPlayerEntity player )
{
if(!JumpVaderMod.getConfig().getEnabled())
return false;
pos = pos.up();
ServerWorld w = player.getWorld();
int count = 0;
while(count < JumpVaderMod.getConfig().getMaxVerticalBlocks() && pos.getY() < 318)
while(count < JumpVaderMod.getConfig().getMaxVerticalBlocks() && pos.getY() < 316)
{
Block blk = w.getBlockState( pos ).getBlock();
@ -44,7 +45,7 @@ public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderList
player.networkHandler.requestTeleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, player.getHeadYaw(), 0f );
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
w.spawnParticles( ParticleTypes.END_ROD, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 10, 0, 0, 0, 0.25f );
w.spawnParticles( ParticleTypes.POOF, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 5, 0, 0, 0, 0.25f );
return true;
}
@ -58,6 +59,9 @@ public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderList
@Override
public void onCrouch( BlockPos pos , ServerPlayerEntity player )
{
if(!JumpVaderMod.getConfig().getEnabled())
return;
pos = pos.down();
ServerWorld w = player.getWorld();
int count = 0;
@ -75,7 +79,7 @@ public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderList
player.networkHandler.requestTeleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, player.getHeadYaw(), 0f );
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
w.spawnParticles( ParticleTypes.END_ROD, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 10, 0, 0, 0, 0.25f );
w.spawnParticles( ParticleTypes.POOF, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 5, 0, 0, 0, 0.25f );
return;
}
@ -89,7 +93,11 @@ public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderList
@Override
public Block getPolymerBlock(BlockState state)
{
return Blocks.ORANGE_STAINED_GLASS;
return switch (JumpVaderMod.getConfig().getAlternativeBlock()) {
case "tinted_glass" -> Blocks.TINTED_GLASS;
case "white_wool" -> Blocks.WHITE_WOOL;
default -> Blocks.ORANGE_STAINED_GLASS;
};
}
private static final Identifier _identifier = new Identifier( JumpVaderMod.MODID, "jumpvader_block" );