Message when using reach upgrades in creative.

Sound when placing blocks far away.
This commit is contained in:
Christian Knaapen
2019-01-02 17:05:51 +01:00
parent 36a698cd95
commit 3d3a90e76f
5 changed files with 48 additions and 10 deletions

View File

@@ -17,7 +17,8 @@ public class BuildConfig {
"If disabled, reach is set to level 3 for survival players."})
public boolean enableReachUpgrades = true;
@Comment("Maximum reach in creative")
@Comment({"Maximum reach in creative",
"Keep in mind that chunks need to be loaded to be able to place blocks inside."})
public int maxReachCreative = 200;
@Comment({"Maximum reach in survival without upgrades",

View File

@@ -30,6 +30,12 @@ public class ItemReachUpgrade1 extends Item {
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
int currentLevel = buildSettings.getReachUpgrade();
if (currentLevel == 0) {

View File

@@ -28,6 +28,12 @@ public class ItemReachUpgrade2 extends Item {
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
int currentLevel = buildSettings.getReachUpgrade();
if (currentLevel == 1) {

View File

@@ -28,6 +28,12 @@ public class ItemReachUpgrade3 extends Item {
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if (player.isCreative()) {
if (world.isRemote) EffortlessBuilding.log(player, "Reach upgrades are not necessary in creative.");
if (world.isRemote) EffortlessBuilding.log(player, "Still want increased reach? Use the config.");
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
BuildSettingsManager.BuildSettings buildSettings = BuildSettingsManager.getBuildSettings(player);
int currentLevel = buildSettings.getReachUpgrade();
if (currentLevel == 2) {

View File

@@ -52,6 +52,7 @@ public class ClientProxy implements IProxy {
public static KeyBinding[] keyBindings;
public static RayTraceResult previousLookAt;
public static RayTraceResult currentLookAt;
private static int breakCooldown = 0;
@Override
public void preInit(FMLPreInitializationEvent event) {
@@ -127,6 +128,16 @@ public class ClientProxy implements IProxy {
RayTraceResult lookingAt = getLookingAt(player);
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
EffortlessBuilding.packetHandler.sendToServer(new BlockPlacedMessage(lookingAt));
//play sound if further than normal
if ((lookingAt.hitVec.subtract(player.getPositionEyes(1f))).lengthSquared() > 25f) {
BlockPos blockPos = lookingAt.getBlockPos();
IBlockState state = player.world.getBlockState(blockPos);
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
player.world.playSound(player, blockPos, soundtype.getPlaceSound(), SoundCategory.BLOCKS,
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
player.swingArm(EnumHand.MAIN_HAND);
}
}
}
}
@@ -136,6 +147,8 @@ public class ClientProxy implements IProxy {
//Break block in distance in creative (or survival if enabled in config)
if (ReachHelper.canBreakFar(player)) {
if (breakCooldown <= 0) {
breakCooldown = 6;
RayTraceResult lookingAt = getLookingAt(player);
if (lookingAt != null && lookingAt.typeOfHit == RayTraceResult.Type.BLOCK) {
EffortlessBuilding.packetHandler.sendToServer(new BlockBrokenMessage(lookingAt));
@@ -144,11 +157,17 @@ public class ClientProxy implements IProxy {
BlockPos blockPos = lookingAt.getBlockPos();
IBlockState state = player.world.getBlockState(blockPos);
SoundType soundtype = state.getBlock().getSoundType(state, player.world, blockPos, player);
player.world.playSound(player, blockPos, soundtype.getBreakSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
player.world.playSound(player, blockPos, soundtype.getBreakSound(), SoundCategory.BLOCKS,
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
player.swingArm(EnumHand.MAIN_HAND);
}
} else {
breakCooldown--;
}
}
} else {
breakCooldown = 0;
}
event.setResult(Event.Result.ALLOW);
}