Message when using reach upgrades in creative.
Sound when placing blocks far away.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user